     1                                  ; ****************************************************************************
     2                                  ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3
     3                                  ; ----------------------------------------------------------------------------
     4                                  ; Last Update: 27/02/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[FA6D]              	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[F66D]              	mov	[mem_1m_1k], cx
   210 00000017 8916[F86D]              	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[F86D]              	mov	si, [mem_16m_64k]
   247 00000076 8936[E10E]              	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[5409]                	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[2F43]                	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[E30E]              	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[F86D]              	mov	di, [mem_16m_64k]
   333 000000DD 893E[E10E]              	mov	[real_mem_16m_64k], di
   334                                  
   335 000000E1 39F7                    	cmp	di, si
   336 000000E3 7604                    	jna	short V1
   337                                  
   338 000000E5 8936[F86D]              	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
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.2 - diskinit.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/08/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.14 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskinit.inc (10/07/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKINIT.INC
    20                              <1> ; Last Modification: 10/07/2015
    21                              <1> 
    22                              <1> ; DISK I/O SYSTEM INITIALIZATION - Erdogan Tan (Retro UNIX 386 v1 project)
    23                              <1> 
    24                              <1> ; ///////// DISK I/O SYSTEM STRUCTURE INITIALIZATION ///////////////
    25                              <1> 
    26                              <1> 	; 29/08/2020
    27                              <1> 	; 17/07/2020
    28                              <1> 	; 14/07/2020 (TRDOS 386 v2.0.2)
    29                              <1> 	; 10/12/2014 - 02/02/2015 - dsectrm2.s
    30                              <1> ;L0:
    31                              <1> 	; 12/11/2014 (Retro UNIX 386 v1 - beginning)
    32                              <1> 	; Detecting disk drives... (by help of ROM-BIOS)
    33 000000EB BA7F00              <1> 	mov	dx, 7Fh
    34                              <1> L1:	
    35 000000EE FEC2                <1> 	inc	dl
    36 000000F0 B441                <1> 	mov	ah, 41h ; Check extensions present
    37                              <1> 			; Phoenix EDD v1.1 - EDD v3
    38 000000F2 BBAA55              <1> 	mov	bx, 55AAh
    39 000000F5 CD13                <1> 	int 	13h
    40 000000F7 721A                <1> 	jc	short L2
    41                              <1> 
    42 000000F9 81FB55AA            <1> 	cmp	bx, 0AA55h
    43 000000FD 7514                <1> 	jne	short L2
    44 000000FF FE06[FD6D]          <1> 	inc	byte [hdc]	; count of hard disks (EDD present)
    45 00000103 8816[FC6D]          <1>         mov     [last_drv], dl  ; last hard disk number
    46 00000107 BB[806D]            <1> 	mov	bx, hd0_type - 80h
    47 0000010A 01D3                <1> 	add	bx, dx	 
    48 0000010C 880F                <1> 	mov	[bx], cl ; Interface support bit map in CX
    49                              <1> 			 ; Bit 0 - 1, Fixed disk access subset ready
    50                              <1> 			 ; Bit 1 - 1, Drv locking and ejecting ready
    51                              <1> 			 ; Bit 2 - 1, Enhanced Disk Drive Support
    52                              <1>                          ;            (EDD) ready (DPTE ready)
    53                              <1> 			 ; Bit 3 - 1, 64bit extensions are present
    54                              <1>                          ;            (EDD-3)
    55                              <1> 			 ; Bit 4 to 15 - 0, Reserved
    56 0000010E 80FA83              <1> 	cmp	dl, 83h	 ; drive number < 83h
    57 00000111 72DB                <1> 	jb	short L1
    58                              <1> L2:
    59                              <1> 	; 23/11/2014
    60                              <1> 	; 19/11/2014
    61 00000113 30D2                <1> 	xor	dl, dl  ; 0
    62                              <1> 	; 04/02/2016 (esi -> si)
    63 00000115 BE[FE6D]            <1> 	mov	si, fd0_type
    64                              <1> L3:
    65                              <1> 	; 14/01/2015
    66 00000118 8816[FB6D]          <1> 	mov	[drv], dl
    67                              <1> 	;
    68 0000011C B408                <1> 	mov 	ah, 08h ; Return drive parameters
    69 0000011E CD13                <1> 	int	13h	
    70 00000120 7210                <1> 	jc	short L4
    71                              <1> 		; BL = drive type (for floppy drives)
    72                              <1> 		; DL = number of floppy drives
    73                              <1> 		;		
    74                              <1> 		; ES:DI = Address of DPT from BIOS
    75                              <1> 		;
    76 00000122 881C                <1> 	mov	[si], bl ;  Drive type
    77                              <1> 			; 4 = 1.44 MB, 80 track, 3 1/2"
    78                              <1> 	; 14/01/2015
    79 00000124 E8DE01              <1> 	call	set_disk_parms
    80                              <1> 	; 10/12/2014
    81 00000127 81FE[FE6D]          <1> 	cmp	si, fd0_type
    82 0000012B 7705                <1> 	ja	short L4
    83 0000012D 46                  <1> 	inc	si ; fd1_type
    84 0000012E B201                <1> 	mov	dl, 1
    85 00000130 EBE6                <1> 	jmp	short L3
    86                              <1> L4:
    87 00000132 B27F                <1> 	mov	dl, 7Fh
    88                              <1> 	; 24/12/2014
    89 00000134 803E[FD6D]00        <1> 	cmp	byte [hdc], 0 ; EDD present or not ?	
    90 00000139 0F878700            <1>         ja      L10       ; yes, all fixed disk operations
    91                              <1> 			  ; will be performed according to
    92                              <1> 			  ; present EDD specification
    93                              <1> 
    94                              <1> 	; 17/07/2020
    95                              <1> 	; Note: Virtual CPU will not come here while 
    96                              <1> 	; running in QEMU, Bochs, VirtualBox emulators !!!
    97                              <1> 	
    98                              <1> 	; 17/07/2020
    99                              <1> 	; Older BIOS (INT 13h, AH = 48h is not available)
   100                              <1> L6:
   101 0000013D FEC2                <1> 	inc 	dl
   102 0000013F 8816[FB6D]          <1>         mov     [drv], dl
   103 00000143 8816[FC6D]          <1>         mov     [last_drv], dl ; 14/01/2015
   104 00000147 B408                <1> 	mov 	ah, 08h ; Return drive parameters
   105 00000149 CD13                <1> 	int	13h	; (conventional function)
   106 0000014B 0F82A801            <1>         jc      L13	; fixed disk drive not ready
   107 0000014F 8816[FD6D]          <1>         mov     [hdc], dl ; number of drives
   108                              <1> 	;; 14/01/2013
   109                              <1> 	;;push	cx
   110 00000153 E8AF01              <1> 	call	set_disk_parms
   111                              <1> 	;;pop	cx
   112                              <1> 	;
   113                              <1> 	;;and	cl, 3Fh	 ; sectors per track (bits 0-6)
   114 00000156 8A16[FB6D]          <1>         mov     dl, [drv]
   115 0000015A BB0401              <1> 	mov	bx, 65*4 ; hd0 parameters table (INT 41h)	
   116 0000015D 80FA80              <1> 	cmp	dl, 80h
   117 00000160 7603                <1> 	jna	short L7
   118 00000162 83C314              <1> 	add	bx, 5*4	 ; hd1 parameters table (INT 46h)
   119                              <1> L7:	
   120 00000165 31C0                <1> 	xor	ax, ax
   121 00000167 8ED8                <1> 	mov	ds, ax
   122 00000169 8B37                <1>         mov     si, [bx]
   123 0000016B 8B4702              <1>         mov     ax, [bx+2] 
   124 0000016E 8ED8                <1> 	mov	ds, ax
   125 00000170 3A4C0E              <1>         cmp     cl, [si+FDPT_SPT] ; sectors per track 
   126 00000173 0F857C01            <1>         jne     L12 ; invalid FDPT
   127 00000177 BF0000              <1> 	mov	di, HD0_DPT
   128 0000017A 80FA80              <1> 	cmp	dl, 80h
   129 0000017D 7603                <1> 	jna	short L8
   130 0000017F BF2000              <1> 	mov	di, HD1_DPT 
   131                              <1> L8:
   132                              <1> 	; 30/12/2014
   133 00000182 B80090              <1> 	mov	ax, DPT_SEGM
   134 00000185 8EC0                <1> 	mov	es, ax
   135                              <1> 	; 24/12/2014
   136 00000187 B90800              <1> 	mov	cx, 8
   137 0000018A F3A5                <1> 	rep	movsw  ; copy 16 bytes to the kernel's DPT location
   138 0000018C 8CC8                <1> 	mov	ax, cs
   139 0000018E 8ED8                <1> 	mov	ds, ax
   140                              <1> 
   141                              <1> 	; 02/02/2015
   142                              <1> 	;mov	cl, [drv]
   143                              <1> 	;mov	bl, cl
   144                              <1> 	;mov	ax, 1F0h
   145                              <1> 	;and	bl, 1
   146                              <1> 	;jz	short L9
   147                              <1> 	;shl	bl, 4
   148                              <1> 	;sub	ax, 1F0h-170h
   149                              <1> 
   150                              <1> 	; 17/07/2020 
   151                              <1> 	; (Only 1F0h port address must be valid for old ROM BIOSes)
   152 00000190 B8F001              <1> 	mov	ax, 1F0h
   153 00000193 B3A0                <1> 	mov	bl, 0A0h
   154 00000195 80FA80              <1> 	cmp	dl, 80h
   155 00000198 7603                <1> 	jna	short L9
   156                              <1> 	; dl = 81h
   157 0000019A 80C310              <1> 	add	bl, 10h  ; slave disk
   158                              <1> 	;sub	ax, 1F0h-170h
   159                              <1> L9:
   160 0000019D AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   161 0000019E 050602              <1> 	add	ax, 206h
   162 000001A1 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   163 000001A2 88D8                <1> 	mov	al, bl  ; bit 4, master/slave disk bit
   164                              <1> 	;add	al, 0A0h ; 17/07/2020
   165 000001A4 AA                  <1> 	stosb	; Device/Head Register upper nibble
   166                              <1> 	;
   167 000001A5 FE06[FB6D]          <1> 	inc	byte [drv]
   168 000001A9 BB[806D]            <1> 	mov	bx, hd0_type - 80h
   169 000001AC 01CB                <1> 	add	bx, cx
   170 000001AE 800F80              <1>         or      byte [bx], 80h  ; present sign (when lower nibble is 0)
   171 000001B1 A0[FD6D]            <1> 	mov	al, [hdc]
   172 000001B4 FEC8                <1> 	dec	al
   173 000001B6 0F843D01            <1>         jz      L13
   174 000001BA 80FA80              <1> 	cmp	dl, 80h
   175 000001BD 0F867CFF            <1>         jna	L6 ; Max. 2 hard disks  ; 17/07/2020 
   176 000001C1 E93301              <1>         jmp     L13
   177                              <1> L10:
   178 000001C4 FEC2                <1> 	inc 	dl
   179                              <1> 	; 25/12/2014
   180 000001C6 8816[FB6D]          <1> 	mov	[drv], dl
   181 000001CA B408                <1> 	mov 	ah, 08h ; Return drive parameters
   182 000001CC CD13                <1> 	int	13h	; (conventional function)
   183 000001CE 0F822501            <1>         jc      L13
   184                              <1> 	; 14/01/2015
   185 000001D2 8A16[FB6D]          <1> 	mov	dl, [drv]
   186 000001D6 52                  <1> 	push	dx
   187 000001D7 51                  <1> 	push	cx
   188 000001D8 E82A01              <1> 	call	set_disk_parms
   189 000001DB 59                  <1> 	pop	cx
   190 000001DC 5A                  <1> 	pop	dx
   191                              <1> 	; 06/07/2016 (BugFix for >64K kernel files)
   192                              <1> 	; 04/02/2016 (esi -> si)
   193                              <1> 	;mov	si, _end ; 30 byte temporary buffer address 	
   194                              <1> 	;		 ; at the '_end' of kernel.
   195                              <1> 	;mov	word [si], 30
   196                              <1> 	; 06/07/2016
   197 000001DD BE[5000]            <1> 	mov	si, _int13h_48h_buffer
   198                              <1> 	; 09/07/2016
   199 000001E0 B81E00              <1> 	mov	ax, 001Eh
   200 000001E3 8824                <1> 	mov	[si], ah ; 0
   201 000001E5 46                  <1> 	inc	si
   202 000001E6 8904                <1> 	mov	word [si], ax
   203                              <1>  	; word [si] = 30
   204                              <1> 	;
   205 000001E8 B448                <1> 	mov	ah, 48h	 ; Get drive parameters (EDD function)
   206 000001EA CD13                <1> 	int	13h
   207 000001EC 0F820701            <1>         jc      L13
   208                              <1> 
   209                              <1> 	; 29/08/2020
   210                              <1> 	; 04/02/2016 (ebx -> bx)
   211                              <1> 	; 14/01/2015
   212 000001F0 28FF                <1> 	sub	bh, bh
   213 000001F2 88D3                <1> 	mov	bl, dl
   214                              <1> 	;sub	bl, 80h
   215                              <1> 	; 29/08/2020
   216 000001F4 81C3[806D]          <1> 	add	bx, (hd0_type - 80h)
   217                              <1> 	;mov 	al, [bx]
   218 000001F8 8A07                <1> 	mov	al, [bx]
   219 000001FA 0C80                <1> 	or	al, 80h
   220 000001FC 8807                <1> 	mov 	[bx], al	
   221 000001FE 81EB[FE6D]          <1> 	sub	bx, hd0_type - 2 ; 15/01/2015
   222                              <1> 	;add	bx, drv.status
   223                              <1> 	;mov	[bx], al
   224                              <1> 	; 29/08/2020
   225 00000202 8887[4A6E]          <1> 	mov	[bx+drv.status], al
   226                              <1> 	; 04/02/2016 (eax -> ax)
   227                              <1> 	;mov	ax, [si+16]
   228                              <1> 	; 14/07/2020
   229                              <1> 	;mov	di, [si+18] 
   230                              <1> 	;;test	ax, [si+18]
   231                              <1> 	;test	ax, di ; 14/07/2020
   232                              <1> 	;jz	short L10_A0h ; (!) ; 17/07/2020
   233                              <1> 			; 'CHS only' disks on EDD system 
   234                              <1> 			;  are reported with ZERO disk size
   235                              <1> 			; (if so, we must not overwrite
   236                              <1> 			; calculated disk size in 'set_disk_parms')
   237                              <1> 	; 29/08/2020
   238 00000206 8B4410              <1> 	mov	ax, [si+16]
   239 00000209 8B7C12              <1> 	mov	di, [si+18]
   240 0000020C 09C0                <1> 	or	ax, ax
   241 0000020E 7504                <1> 	jnz	short L10_LBA
   242 00000210 09FF                <1> 	or	di, di
   243 00000212 740B                <1> 	jz	short L10_A0h
   244                              <1> L10_LBA:
   245                              <1> 	;sub	bx, drv.status
   246 00000214 C1E302              <1> 	shl	bx, 2
   247                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   248                              <1> 	;mov	[bx], ax
   249                              <1> 	; 29/08/2020
   250 00000217 8987[2E6E]          <1> 	mov	[bx+drv.size], ax
   251                              <1> 	;mov	ax, [si+18]
   252                              <1> 	;;mov	[bx], ax
   253                              <1> 	;mov	[bx+2], ax ; BugFix ; 15/07/2020
   254                              <1> 	; 14/07/2020
   255                              <1> 	;mov	[bx+2], di ; 15/07/2020
   256                              <1> 	; 29/08/2020
   257 0000021B 89BF[306E]          <1> 	mov	[bx+drv.size+2], di
   258                              <1> L10_A0h: 
   259                              <1> 	; 17/07/2020
   260                              <1> 	; Note: Virtual CPU will jump here from above (!) test
   261                              <1> 	;	while running in QEMU
   262                              <1> 
   263                              <1> 	; Jump here to fix a ZERO (LBA) disk size problem 
   264                              <1> 	; for CHS disks (28/02/2015)
   265                              <1> 	
   266                              <1> 	; 30/12/2014
   267 0000021F BF0000              <1> 	mov	di, HD0_DPT
   268 00000222 88D0                <1> 	mov	al, dl
   269 00000224 83E003              <1> 	and 	ax, 3
   270 00000227 C0E005              <1> 	shl	al, 5 ; * 32
   271 0000022A 01C7                <1> 	add 	di, ax
   272 0000022C B80090              <1> 	mov	ax, DPT_SEGM
   273 0000022F 8EC0                <1> 	mov	es, ax
   274                              <1> 	;
   275 00000231 88E8                <1> 	mov	al, ch	; max. cylinder number (bits 0-7)
   276 00000233 88CC                <1> 	mov	ah, cl	
   277 00000235 C0EC06              <1> 	shr	ah, 6	; max. cylinder number (bits 8-9)
   278 00000238 40                  <1>  	inc	ax	; logical cylinders (limit 1024)
   279 00000239 AB                  <1> 	stosw		
   280 0000023A 88F0                <1> 	mov	al, dh	; max. head number
   281                              <1> 	;
   282 0000023C 30F6                <1> 	xor	dh, dh  ; 29/08/2020 (dh = 0 is needed here)
   283                              <1> 	;
   284 0000023E FEC0                <1> 	inc	al
   285 00000240 AA                  <1> 	stosb		; logical heads (limits 256)
   286 00000241 B0A0                <1> 	mov	al, 0A0h ; Indicates translated table
   287 00000243 AA                  <1> 	stosb
   288 00000244 8A440C              <1> 	mov	al, [si+12]
   289 00000247 AA                  <1> 	stosb		 ; physical sectors per track
   290 00000248 31C0                <1>  	xor	ax, ax
   291                              <1> 	;dec	ax	 ; 02/01/2015 
   292 0000024A AB                  <1> 	stosw		 ; precompensation (obsolete)
   293                              <1> 	;xor	al, al	 ; 02/01/2015	
   294 0000024B AA                  <1> 	stosb		 ; reserved
   295 0000024C B008                <1> 	mov	al, 8	 ; drive control byte
   296                              <1> 		         ; (do not disable retries, 
   297                              <1> 			 ; more than 8 heads)
   298 0000024E AA                  <1> 	stosb
   299 0000024F 8B4404              <1> 	mov	ax, [si+4]
   300 00000252 AB                  <1> 	stosw		 ; physical number of cylinders	
   301                              <1> 	;push	ax	 ; 02/01/2015
   302 00000253 8A4408              <1> 	mov	al, [si+8]
   303 00000256 AA                  <1> 	stosb		 ; physical num. of heads (limit 16)
   304 00000257 29C0                <1> 	sub 	ax, ax
   305                              <1> 	;pop	ax	 ; 02/01/2015	
   306 00000259 AB                  <1> 	stosw		 ; landing zone (obsolete)
   307 0000025A 88C8                <1> 	mov	al, cl	 ; logical sectors per track (limit 63)
   308 0000025C 243F                <1> 	and 	al, 3Fh	
   309 0000025E AA                  <1> 	stosb
   310                              <1> 	;sub	al, al	 ; checksum
   311                              <1> 	;stosb
   312                              <1> 	;
   313 0000025F 83C61A              <1> 	add	si, 26   ; (BIOS) DPTE address pointer
   314 00000262 AD                  <1> 	lodsw
   315 00000263 50                  <1> 	push	ax ; *	 ; (BIOS) DPTE offset
   316 00000264 AD                  <1> 	lodsw
   317 00000265 50                  <1> 	push	ax ; **	 ; (BIOS) DPTE segment
   318                              <1> 	;
   319                              <1> 	; checksum calculation
   320 00000266 89FE                <1> 	mov	si, di
   321 00000268 06                  <1> 	push	es
   322 00000269 1F                  <1> 	pop	ds
   323                              <1> 	;mov	cx, 16
   324 0000026A B90F00              <1> 	mov 	cx, 15
   325 0000026D 29CE                <1> 	sub	si, cx
   326 0000026F 30E4                <1> 	xor	ah, ah
   327                              <1> 	;del	cl
   328                              <1> L11:		
   329 00000271 AC                  <1> 	lodsb
   330 00000272 00C4                <1> 	add	ah, al
   331 00000274 E2FB                <1> 	loop	L11
   332                              <1> 	;
   333 00000276 88E0                <1> 	mov	al, ah
   334 00000278 F6D8                <1> 	neg	al	; -x+x = 0
   335 0000027A AA                  <1> 	stosb		; put checksum in byte 15 of the tbl
   336                              <1> 	;
   337 0000027B 1F                  <1> 	pop	ds ; **	; (BIOS) DPTE segment
   338 0000027C 5E                  <1> 	pop	si ; *	; (BIOS) DPTE offset	
   339                              <1> 	;
   340                              <1> 	; 14/07/2020
   341                              <1> 	; 0FFFFh:0FFFFh = invalid DPTE address
   342 0000027D 8B0C                <1> 	mov	cx, [si]
   343 0000027F 8B4402              <1> 	mov	ax, [si+2]
   344 00000282 21C1                <1> 	and	cx, ax
   345 00000284 41                  <1> 	inc	cx 
   346 00000285 7404                <1> 	jz	short L11c ; 0FFFFh:0FFFFh
   347 00000287 0B04                <1> 	or	ax, [si]
   348 00000289 752A                <1> 	jnz	short L11e ; <> 0
   349                              <1> L11c:
   350                              <1> 	; 17/07/2020
   351                              <1> 	; TRDOS 386 v2 DRVINIT assumptions:
   352                              <1> 	; (also by regarding QEMU, Bochs and VirtualBox settings)
   353                              <1> 	;	Hard disk 0 port address: 1F0h
   354                              <1> 	;	Hard disk 1 port address: 1F0h
   355                              <1> 	;	Hard disk 2 port address: 170h
   356                              <1> 	;	Hard disk 3 port address: 170h
   357                              <1> 
   358                              <1> 	; in QEMU, hda=hd0 (1F0h) and hdb=hd1 (1F0h) -IRQ14-
   359                              <1> 	;      and hdc=hd2 (170h) and hdd=hd3 (170h) -IRQ15-
   360                              <1> 
   361 0000028B B8F001              <1> 	mov	ax, 1F0h
   362                              <1> 
   363                              <1> 	; 15/07/2020
   364                              <1> 	; 14/07/2020
   365                              <1> 	; Invalid DPTE address...
   366                              <1> 	; Default DPTE parms must be set for DISK_IO_CONT
   367                              <1> 	; (diskio.s)
   368                              <1> 	; 17/07/2020
   369                              <1> 
   370                              <1> 	;mov	bl, dl
   371                              <1> 	;and	bl, 1
   372                              <1> 	;jz	short L11d
   373                              <1> 
   374 0000028E B3A0                <1> 	mov	bl, 0A0h
   375                              <1> 
   376 00000290 F6C201              <1> 	test	dl, 1
   377 00000293 7403                <1> 	jz	short L11g  ; Master (as default, for 80h & 82h))
   378                              <1> 	;shl	bl, 4 ; bl = 16 (bit 4 = 1 -> slave)
   379 00000295 80C310              <1> 	add	bl, 10h  ; Slave (as default, for 81h & 83h)
   380                              <1> L11g:
   381                              <1> 	; 17/07/2020
   382 00000298 80FA82              <1> 	cmp	dl, 82h	; Hard disk 3 or 4 ?
   383 0000029B 7203                <1> 	jb	short L11d ; Primary ATA channel (hd0, hd1)
   384                              <1> 			   ; (port address = 1F0h)
   385                              <1> 	
   386                              <1> 	; Secondary ATA channel (hd2, hd3)
   387                              <1> 	; (port address = 170h)
   388                              <1> 
   389 0000029D 2D8000              <1> 	sub	ax, 1F0h-170h
   390                              <1> L11d:
   391                              <1> 	; 14/07/2020
   392 000002A0 AB                  <1> 	stosw	; I/O PORT Base Address (1F0h, 170h)
   393 000002A1 050602              <1> 	add	ax, 206h
   394 000002A4 AB                  <1> 	stosw	; CONTROL PORT Address (3F6h, 376h)	
   395 000002A5 88D8                <1> 	mov	al, bl  ; Master/Slave bit (0 = Master)
   396                              <1> 	; 17/07/2020
   397                              <1> 	;or	al, 0A0h ; CHS (LBA enable bit = 0)
   398                              <1> 			 ; (Bits 5&7, reserved bits  =  1)
   399 000002A7 30E4                <1> 	xor	ah, ah
   400                              <1> 	;stosb	; Device/Head Register upper nibble
   401 000002A9 AB                  <1> 	stosw
   402 000002AA 30C0                <1> 	xor	al, al
   403 000002AC B90500              <1> 	mov	cx, 5
   404 000002AF F3AB                <1> 	rep	stosw ; clear remain part of the (fake) DPTE
   405 000002B1 0E                  <1> 	push	cs
   406 000002B2 1F                  <1> 	pop	ds
   407 000002B3 EB2E                <1> 	jmp	short L11f
   408                              <1> L11e:
   409                              <1> 	; 23/02/2015
   410 000002B5 57                  <1> 	push	di
   411                              <1> 	; ES:DI points to DPTE (FDPTE) location
   412                              <1> 	;;mov	cx, 8
   413                              <1> 	;mov	cl, 8
   414 000002B6 B90800              <1> 	mov	cx, 8 ; 14/07/2020
   415 000002B9 F3A5                <1> 	rep	movsw	
   416                              <1> 	;
   417                              <1> 	; 23/02/2015
   418                              <1> 	; (P)ATA drive and LBA validation
   419                              <1> 	; (invalidating SATA drives and setting
   420                              <1> 	; CHS type I/O for old type fixed disks)
   421 000002BB 5B                  <1> 	pop	bx
   422 000002BC 8CC8                <1> 	mov	ax, cs
   423 000002BE 8ED8                <1> 	mov	ds, ax
   424 000002C0 268B07              <1> 	mov	ax, [es:bx]
   425 000002C3 3DF001              <1> 	cmp	ax, 1F0h
   426 000002C6 7413                <1> 	je	short L11a
   427 000002C8 3D7001              <1> 	cmp	ax, 170h
   428 000002CB 740E                <1> 	je	short L11a
   429                              <1> 	; invalidation 
   430                              <1> 	; (because base port address is not 1F0h or 170h)
   431                              <1> 	;xor	bh, bh
   432                              <1> 	;mov	bl, dl
   433                              <1> 	; 29/08/2020
   434                              <1> 	;xor	dh, dh ; 0
   435 000002CD 89D3                <1> 	mov	bx, dx
   436                              <1> 	;sub	bl, 80h
   437                              <1> 	;mov	byte [bx+hd0_type], 0 ; not a valid disk drive !		
   438                              <1>         ;or	byte [bx+drv.status+2], 0F0h ; (failure sign)
   439                              <1> 	; 29/08/2020
   440 000002CF C687[806D]00        <1> 	mov	byte [bx+hd0_type-80h], 0
   441 000002D4 808F[CC6D]F0        <1> 	or	byte [bx+drv.status-7Eh], 0F0h
   442 000002D9 EB0F                <1> 	jmp	short L11b
   443                              <1> L11a:	
   444                              <1> 	; LBA validation
   445 000002DB 268A4704            <1> 	mov	al, [es:bx+4] ; Head register upper nibble
   446 000002DF A840                <1> 	test	al, 40h ; LBA bit (bit 6)
   447 000002E1 7507                <1> 	jnz	short L11b ; LBA type I/O is OK! (E0h or F0h)
   448                              <1> L11f:
   449                              <1> 	; force CHS type I/O for this drive (A0h or B0h)
   450                              <1> 	;sub	bh, bh
   451                              <1> 	;mov	bl, dl
   452                              <1> 	; 29/08/2020
   453                              <1> 	;xor	dh, dh ; 0
   454 000002E3 89D3                <1> 	mov	bx, dx
   455                              <1> 	;sub	bl, 80h ; 26/02/2015
   456                              <1>         ;and	byte [bx+drv.status+2], 0FEh ; clear bit 0
   457                              <1> 				; bit 0 = LBA ready bit
   458                              <1> 	; 29/08/2020
   459 000002E5 80A7[CC6D]FE        <1> 	and	byte [bx+drv.status-7Eh], 0FEh
   460                              <1> 	; 'diskio' procedure will check this bit !
   461                              <1> L11b:
   462 000002EA 3A16[FC6D]          <1> 	cmp	dl, [last_drv] ; 25/12/2014
   463 000002EE 7307                <1>         jnb     short L13
   464 000002F0 E9D1FE              <1>         jmp     L10
   465                              <1> 
   466                              <1> L12:
   467                              <1> 	; Restore data registers
   468 000002F3 8CC8                <1> 	mov	ax, cs
   469 000002F5 8ED8                <1> 	mov	ds, ax	
   470                              <1> L13:
   471                              <1> 	; 13/12/2014
   472 000002F7 0E                  <1> 	push	cs
   473 000002F8 07                  <1> 	pop	es
   474                              <1> L14:
   475                              <1> 	; clear keyboard buffer
   476 000002F9 B411                <1> 	mov 	ah, 11h
   477 000002FB CD16                <1> 	int 	16h
   478 000002FD 744D                <1> 	jz 	short L16 ; no keys in keyboard buffer
   479 000002FF B010                <1> 	mov	al, 10h
   480 00000301 CD16                <1> 	int 	16h
   481 00000303 EBF4                <1> 	jmp 	short L14
   482                              <1> 
   483                              <1> set_disk_parms:
   484                              <1> 	; 29/08/2020
   485                              <1> 	; 04/02/2016 (ebx -> bx)
   486                              <1> 	; 10/07/2015
   487                              <1> 	; 14/01/2015
   488                              <1> 	;push	bx
   489 00000305 28FF                <1> 	sub	bh, bh
   490 00000307 8A1E[FB6D]          <1> 	mov	bl, [drv]
   491 0000030B 80FB80              <1> 	cmp	bl, 80h
   492 0000030E 7203                <1> 	jb	short sdp0
   493 00000310 80EB7E              <1> 	sub	bl, 7Eh
   494                              <1> sdp0:	
   495                              <1> 	;add	bx, drv.status
   496                              <1>   	;mov	byte [bx], 80h ; 'Present' flag
   497                              <1> 	; 29/08/2020
   498 00000313 C687[4A6E]80        <1> 	mov	byte [bx+drv.status], 80h
   499                              <1> 	;
   500 00000318 88E8                <1> 	mov	al, ch ; last cylinder (bits 0-7)
   501 0000031A 88CC                <1> 	mov	ah, cl ; 
   502 0000031C C0EC06              <1> 	shr	ah, 6  ; last cylinder (bits 8-9)
   503                              <1> 	;sub	bx, drv.status
   504 0000031F D0E3                <1> 	shl	bl, 1
   505                              <1> 	;add	bx, drv.cylinders
   506 00000321 40                  <1> 	inc	ax  ; convert max. cyl number to cyl count		
   507                              <1> 	;mov	[bx], ax
   508                              <1> 	; 29/08/2020
   509 00000322 8987[046E]          <1> 	mov	[bx+drv.cylinders], ax
   510 00000326 50                  <1> 	push	ax ; ** cylinders
   511                              <1> 	;sub	bx, drv.cylinders
   512                              <1> 	;add	bx, drv.heads
   513 00000327 30E4                <1> 	xor	ah, ah
   514 00000329 88F0                <1> 	mov	al, dh ; heads
   515 0000032B 40                  <1> 	inc	ax
   516                              <1> 	;mov	[bx], ax
   517                              <1> 	; 29/08/2020
   518 0000032C 8987[126E]          <1>         mov	[bx+drv.heads], ax
   519                              <1> 	;sub     bx, drv.heads
   520                              <1>         ;add     bx, drv.spt
   521 00000330 30ED                <1> 	xor	ch, ch
   522 00000332 80E13F              <1> 	and	cl, 3Fh	; sectors (bits 0-6)
   523                              <1> 	;mov	[bx], cx
   524                              <1>         ; 29/08/2020
   525 00000335 898F[206E]          <1> 	mov	[bx+drv.spt], cx
   526                              <1> 	;sub	bx, drv.spt
   527 00000339 D1E3                <1> 	shl	bx, 1
   528                              <1> 	;add	bx, drv.size ; disk size (in sectors)
   529                              <1> 	; LBA size = cylinders * heads * secpertrack
   530 0000033B F7E1                <1> 	mul	cx 
   531 0000033D 89C2                <1> 	mov	dx, ax	; heads*spt					
   532 0000033F 58                  <1> 	pop	ax ; ** cylinders
   533 00000340 48                  <1> 	dec	ax ; 1 cylinder reserved (!?)
   534 00000341 F7E2                <1> 	mul	dx ; cylinders * (heads*spt)		
   535                              <1> 	;mov	[bx], ax
   536                              <1> 	;mov	[bx+2], dx
   537                              <1> 	; 29/08/2020
   538 00000343 8987[2E6E]          <1> 	mov	[bx+drv.size], ax
   539 00000347 8997[306E]          <1> 	mov	[bx+drv.size+2], dx
   540                              <1> 	;
   541                              <1> 	;pop	bx
   542 0000034B C3                  <1> 	retn
   543                              <1> 
   544                              <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[686D]                  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 B9F1620000              	mov  ecx, (bss_end - bss_start)/4
   475                                  	;shr  ecx, 2 ; bss section is already aligned for double words
   476 000003BE BF[E6860100]            	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[F66D0000]        	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[D8890100]          	mov	[free_pages], ecx
   500 000003DF 668B15[F86D0000]        	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[D8890100]          	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[D4890100]            	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[E8890100]          	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[D0890100]          	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[E0890100]            	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[E8890100]        	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[D8890100]          	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[D4890100]          	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[D8890100]          	sub	[free_pages], ecx ; 07/11/2014
   629                                  	;
   630 000004C4 8B35[D0890100]          	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[D0890100]          	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[D4890100]          	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[E4890100]            	mov	[first_page], eax
   701 00000533 A3[DC890100]            	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[D0890100]                    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[424D0100]            	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 E8D6030000              	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[E0490100]            	mov	esi, ilist
   803 00000595 8D3D[E8860100]          	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[750D0000]            	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[6E6D0000]        	lidt 	[idtd]
   850                                  	;
   851                                  	; TSS descriptor setup ; 24/03/2015
   852 000005EE B8[68890100]            	mov	eax, task_state_segment
   853 000005F3 66A3[1A6D0000]          	mov	[gdt_tss0], ax
   854 000005F9 C1C010                  	rol	eax, 16
   855 000005FC A2[1C6D0000]            	mov	[gdt_tss1], al
   856 00000601 8825[1F6D0000]          	mov	[gdt_tss2], ah
   857 00000607 66C705[CE890100]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[D4890100]          	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[6C890100]          	mov	[tss.esp0], esp
   891 00000635 66C705[70890100]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 E83E1D0000              	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[54090000]02        	cmp	byte [vbe3], 2 ; 02h
   927 00000660 770B                    	ja	short vbe3_pmid_chk
   928                                  	;jb	short display_mem_info
   929 00000662 0F82C2010000            	jb	display_mem_info ; 02/12/2020
   930 00000668 E9F6010000              	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[54090000]          	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 E99D010000              	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                                  display_vbios_product_name: ; 14/11/2020
   971                                  
   972                                  	; ESI points to 'PMID' (0C0000h + 'PMID' offset)
   973                                  
   974                                  	; 15/11/2020
   975                                  	;mov	[pmid_addr], si	; PMInfoBlock offset
   976                                  	;		; (in VGA bios, 0C0000h + offset)
   977                                  	; 02/12/2020
   978                                  	;push	esi ; * pmid_addr
   979 0000069E 89F7                    	mov	edi, esi
   980                                  
   981                                  	;mov	esi, [VBE3INFOBLOCK+22] ; 097E00h + 16h
   982                                  	;		; OemVendorNamePtr (seg16:off16)
   983 000006A0 8B35067E0900            	mov	esi, [VBE3INFOBLOCK+6] ; 097E00h + 06h
   984                                  			; OemStringPtr (seg16:off16)
   985 000006A6 30C0                    	xor	al, al  ; eax = 0
   986 000006A8 6696                    	xchg	ax, si	; ax = offset, si = 0
   987 000006AA C1EE0C                  	shr	esi, 12 ; (to convert segment to base addr)
   988 000006AD 6601C6                  	add	si, ax  ; esi has an address < 1 MB limit
   989                                  			; (OemVendorName is in VBE3INFOBLOCK)
   990                                  			; Example: 
   991                                  			; TRDOS 386 v2.0.3 VESA VBE3 protected mode
   992                                  			; interface development reference is ...
   993                                  			; NVIDIA GeForce FX5500 VGA BIOS -C000h:029Ch-
   994                                  			; Version 4.34.20.54.00 -C000h:02EDh- 	  
   995                                  			; ((OemString is 'NVIDIA'))
   996                                  			; ((OemVendorName is 'NVIDIA Corporation'))
   997                                  			; ((OemProductName is 'NV34 Board - p162-1nz))
   998                                  
   999                                  	;mov	ah, 0Eh ; Black background, yellow forecolor
  1000                                  	; 30/11/2020
  1001 000006B0 B40C                    	mov	ah, 0Ch ; Black background, light red forecolor
  1002                                  
  1003 000006B2 E8E13B0000              	call	print_kmsg
  1004                                  
  1005                                  	;mov	ah, 07h
  1006                                  
  1007 000006B7 BE[79860100]            	mov	esi, vesa_vbe3_bios_msg
  1008                                  	;call	print_kmsg
  1009 000006BC E8DD3B0000              	call	pkmsg_loop ; 30/11/2020
  1010                                  
  1011                                  	; 02/12/2020
  1012                                  	;pop	edi ; * pmid_addr
  1013                                  
  1014                                  	; 30/11/2020
  1015                                  	; 29/11/2020 - TRDOS 386 v2.0.3
  1016                                  
  1017                                  struc PMInfo  ;  VESA VBE3 PMInfoBlock ('PMID' block)
  1018                                  
  1019 00000000 <res 00000004>           .Signature:	resb 4  ; db 'PMID' ; PM Info Block Signature
  1020 00000004 <res 00000002>           .EntryPoint:	resw 1	; Offset of PM entry point within BIOS
  1021 00000006 <res 00000002>           .PMInitialize: resw 1	; Offset of PM initialization entry point
  1022 00000008 <res 00000002>           .BIOSDataSel:	resw 1 	; Selector to BIOS data area emulation block
  1023 0000000A <res 00000002>           .A0000Sel:	resw 1	; Selector to access A0000h physical mem
  1024 0000000C <res 00000002>           .B0000Sel:	resw 1  ; Selector to access B0000h physical mem
  1025 0000000E <res 00000002>           .B8000Sel:	resw 1	; Selector to access B8000h physical mem
  1026 00000010 <res 00000002>           .CodeSegSel:	resw 1	; Selector to access code segment as data
  1027 00000012 <res 00000001>           .InProtectMode: resb 1 ; Set to 1 when in protected mode
  1028 00000013 <res 00000001>           .Checksum:	resb 1	; Checksum byte for structure
  1029                                   .size:
  1030                                  
  1031                                  endstruc
  1032                                  
  1033                                  	; 29/11/2020
  1034                                  vbe3pminit:
  1035                                  	; 30/11/2020
  1036                                  	;cmp	byte [vbe3], 3 ; is VESA VBE3 PMI ready ?
  1037                                  	;jne	short di4
  1038                                  
  1039                                  	; Allocate 64KB contiguous (kernel) memory block
  1040 000006C1 31C0                    	xor	eax, eax
  1041 000006C3 B900000100              	mov	ecx, 65536
  1042 000006C8 E8B05D0000              	call	allocate_memory_block
  1043                                  	;jc	short di4
  1044 000006CD 0F8250010000            	jc	di0 ; 30/11/2020
  1045                                  
  1046                                  	; of course this block must be in the 1st 16MB
  1047                                  	; because vbe3 pmi segments will be 16 bit segments
  1048                                  	; (80286 type segment descriptors in GDT)
  1049                                  
  1050 000006D3 A3[20120300]            	mov	[vbe3bios_addr], eax
  1051                                  
  1052                                  	; set [pmid_addr] to the new location
  1053 000006D8 BE00000C00              	mov	esi, 0C0000h
  1054                                  
  1055                                  	; 30/11/2020
  1056 000006DD 29F7                    	sub	edi, esi ; izolate offset
  1057 000006DF 01C7                    	add	edi, eax ; new address
  1058 000006E1 893D[24120300]          	mov	[pmid_addr], edi ; new 'PMID' location	
  1059                                  
  1060                                  	; Move VIDEO BIOS from 0C0000h to EAX
  1061 000006E7 B900400000              	mov	ecx, 65536/4
  1062 000006EC 89C7                    	mov	edi, eax ; 30/11/2020
  1063 000006EE F3A5                    	rep	movsd
  1064                                  
  1065                                  	; 02/12/2020
  1066                                  	; 30/11/2020
  1067                                  	; set vbe3 segment selectors
  1068                                  
  1069                                  	; VBE3CS (VESA VBE3 video bios code segment)
  1070 000006F0 BF[226D0000]            	mov	edi, _vbe3_CS+2 ; base address bits 0..15
  1071 000006F5 66AB                    	stosw	; edi = _vbe3_CS+4
  1072 000006F7 C1C810                  	ror	eax, 16
  1073 000006FA 8807                    	mov	[edi], al ; base address, bits 16..23
  1074                                  
  1075                                  	; VBE3DS ('CodeSegSel' in PMInfoBlock)
  1076 000006FC BF[4C6D0000]            	mov	edi, _vbe3_DS+4 ; base addr bits 16..23
  1077 00000701 8807                    	mov	[edi], al 
  1078 00000703 C1C010                  	rol	eax, 16
  1079 00000706 668947FE                	mov	[edi-2], ax ; base address, bits 0..15
  1080                                  
  1081                                  	; VBE3BDS (BIOSDataSel in PMInfoBlock)
  1082 0000070A BF[2A6D0000]            	mov	edi, _vbe3_BDS+2 ; base addr bits 0..15
  1083 0000070F B800700900              	mov	eax, VBE3BIOSDATABLOCK ; 1536 bytes
  1084 00000714 66AB                    	stosw	; edi = _vbe3_BDS+4
  1085 00000716 C1E810                  	shr	eax, 16
  1086 00000719 8807                    	mov	[edi], al ; base address, bits 16..23
  1087                                  
  1088                                  	; VBE3SS (1024 bytes)
  1089 0000071B BF[526D0000]            	mov	edi, _vbe3_SS+2 ; base addr bits 0..15
  1090 00000720 B800600900              	mov	eax, VBE3STACKADDR ; size = 1024 bytes
  1091 00000725 66AB                    	stosw	; edi = _vbe3_SS+4
  1092 00000727 C1E810                  	shr	eax, 16
  1093 0000072A 8807                    	mov	[edi], al ; base address, bits 16..23
  1094                                  
  1095                                  	; stack pointer (esp) will be set to 1020
  1096                                  	; (before VBE3 PMI call)
  1097                                  
  1098                                  	; VBE3ES (max: 2048 bytes)
  1099 0000072C BF[5A6D0000]            	mov	edi, _vbe3_ES+2 ; base addr bits 0..15
  1100 00000731 B800760900              	mov	eax, VBE3SAVERESTOREBLOCK
  1101 00000736 66AB                    	stosw	; edi = _vbe3_ES+4
  1102 00000738 C1E810                  	shr	eax, 16
  1103 0000073B 8807                    	mov	[edi], al ; base address, bits 16..23 	
  1104                                  
  1105                                  	;Note: low word of _VBE3_ES base address will be
  1106                                  	;      set -again- by VBE3 PMI caller routine 
  1107                                  
  1108                                  	; 09/12/2020
  1109                                  	;; set pmi32 (as VBE3 PMI is ready)
  1110                                  	;inc	byte [pmi32] ; = 1 
  1111                                  
  1112                                  	; KCODE16 (set PMI far return segment)
  1113 0000073D BF[626D0000]            	mov	edi, _16bit_CS+2 ; base addr bits 0..15
  1114 00000742 B8[CA070000]            	mov	eax, pminit_return_addr16
  1115 00000747 66AB                    	stosw	; edi = _16bit_CS+4
  1116 00000749 C1E810                  	shr	eax, 16
  1117 0000074C 8807                    	mov	[edi], al ; base address, bits 16..23 
  1118                                  
  1119                                  	; 30/11/2020
  1120                                  	; clear mem from VBE3 BIOS data area emu block
  1121                                  	; to end of vbe3 buffers
  1122                                  
  1123                                  	; 01/12/2020
  1124 0000074E BF00700900              	mov	edi, VBE3BIOSDATABLOCK ; 97000h
  1125                                  	;mov	cx, (VBE3INFOBLOCK-VBE3BIOSDATABLOCK)/4
  1126                                  	;	; ecx = 3584/4 double words
  1127                                  	; 21/12/2020
  1128 00000753 66B90003                	mov	cx, (VBE3MODEINFOBLOCK-VBE3BIOSDATABLOCK)/4
  1129                                  		; ecx = 3072/4 double words
  1130                                  	;xor	eax, eax
  1131 00000757 30C0                    	xor	al, al
  1132 00000759 F3AB                    	rep	stosd
  1133                                  
  1134                                  	; Filling PMInfoBlock selector fields
  1135 0000075B 8B3D[24120300]          	mov	edi, [pmid_addr]
  1136 00000761 66C747083800            	mov	word [edi+PMInfo.BIOSDataSel], VBE3BDS
  1137 00000767 66C7470A4000            	mov	word [edi+PMInfo.A0000Sel], VBE3A000
  1138 0000076D 66C7470C4800            	mov	word [edi+PMInfo.B0000Sel], VBE3B000
  1139 00000773 66C7470E5000            	mov	word [edi+PMInfo.B8000Sel], VBE3B800	
  1140 00000779 66C747105800            	mov	word [edi+PMInfo.CodeSegSel], VBE3DS
  1141 0000077F C6471201                	mov	byte [edi+PMInfo.InProtectMode], 1
  1142                                  
  1143                                  	; Calculate and write checksum byte
  1144 00000783 89FE                    	mov	esi, edi
  1145 00000785 B113                    	mov	cl, PMInfo.size - 1
  1146                                  	;xor	ah, ah
  1147                                  pmid_chksum:
  1148 00000787 AC                      	lodsb	
  1149 00000788 00C4                    	add	ah, al
  1150 0000078A E2FB                    	loop	pmid_chksum
  1151 0000078C F6DC                    	neg	ah ; 1 -> 255, 255 -> 1
  1152 0000078E 8826                    	mov	byte [esi], ah  ; checksum
  1153                                  
  1154                                  	; far call PM initialization
  1155                                  	; (VBE3 video bios will return via 'retf')
  1156                                  
  1157 00000790 668B4706                	mov	ax, [edi+PMInfo.PMInitialize]
  1158                                  	; 30/11/2020
  1159 00000794 C1E010                  	shl	eax, 16 ; save entry address in hw
  1160                                  	; ax = 0 
  1161                                  
  1162                                  	; 02/12/2020
  1163 00000797 68[EE070000]            	push	pminit_ok ; normal, near return address
  1164                                  
  1165                                  	; 30/11/2020
  1166                                  _VBE3PMI_fcall:
  1167                                  	; ax = function, hw of eax = entry address
  1168 0000079C 9C                      	pushf	; save 32 bit flags
  1169 0000079D 56                      	push	esi ; *
  1170 0000079E 55                      	push	ebp ; **
  1171                                  
  1172 0000079F 89E5                    	mov	ebp, esp ; save 32 bit stack pointer
  1173                                  	
  1174 000007A1 89C6                    	mov	esi, eax
  1175                                  
  1176 000007A3 FA                      	cli
  1177                                  
  1178                                  	; Disable interrupts (clear interrupt flag)
  1179                                  	; Reset Interrupt MASK Registers (Master&Slave)
  1180 000007A4 B0FF                    	mov	al, 0FFh	; mask off all interrupts
  1181 000007A6 E621                    	out	21h, al		; on master PIC (8259)
  1182 000007A8 EB00                    	jmp 	$+2  ; (delay)
  1183 000007AA E6A1                    	out	0A1h, al	; on slave PIC (8259)
  1184                                  
  1185                                  	; 02/12/2020
  1186 000007AC 66B86000                	mov	ax, VBE3SS
  1187 000007B0 8ED0                    	mov	ss, ax
  1188                                  	
  1189 000007B2 BCFC030000              	mov	esp, 1020 ; 30/11/2020
  1190                                  
  1191                                  	; 01/12/2020
  1192                                  	;lss	esp, [stack16]
  1193                                  
  1194 000007B7 C1E810                  	shr	eax, 16	; now, entry address is in lw
  1195                                  
  1196                                  	; 30/11/2020 - 16 bit pm selector test (OK)
  1197                                  	; (32 bit stack push/pop & retf with 32 bit code segment)
  1198                                  	; (16 bit stack push/pop with 16 bit code segment)
  1199                                  	
  1200                                  	; return
  1201                                  	;push	KCODE16
  1202                                  	;push	0 ; 30/11/2020 (pminit_return_addr16)
  1203                                  
  1204                                  	; 30/11/2020 (16 bit stack during retf from video bios)
  1205 000007BA C7042400007000          	mov	dword [esp], KCODE16 << 16
  1206                                  				; ip = 0, cs = KCODE16 
  1207                                  	; 01/12/2020
  1208                                  	;mov	dword [VBE3STACKADDR+1020], KCODE16*65536
  1209                                  
  1210                                  	;mov	[jumpfar16], eax
  1211                                  
  1212                                  	; 02/12/2020
  1213                                  	; 30/11/2020 (32 bit stack during retf from kernel)
  1214                                  	; far jump/call via retf
  1215 000007C1 6A30                    	push	VBE3CS ; VBE3 video bios's code segment
  1216 000007C3 50                      	push	eax ; PMInitialize or EntryPoint
  1217                                  
  1218 000007C4 6689F0                  	mov	ax, si ; restore function
  1219                                  	
  1220                                  	; 02/12/2020
  1221 000007C7 31F6                    	xor	esi, esi ; (not necessary, it is not used)
  1222                                  	
  1223 000007C9 CB                      	retf 	; far return (to 16 bit code segment)
  1224                                  
  1225                                  	; 01/12/2020
  1226                                  	;db	0EAh  ; far jump to 16 bit code segment
  1227                                  ;jumpfar16:
  1228                                  	;dd	0		
  1229                                  	;dw	VBE3CS
  1230                                  
  1231                                  ;stack16:
  1232                                  	;dd	1020
  1233                                  	;dw	VBE3SS
  1234                                  
  1235                                  	align 2	
  1236                                  
  1237                                  pminit_return_addr16:
  1238                                  	; 02/12/2020
  1239                                  	; 30/11/2020
  1240                                  	;;db	66h 		     ; Prefix for 32-bit
  1241                                  	;db	0EAh 		     ; Opcode for far jump
  1242                                  	;dd	pminit_return_addr32 ; 32 bit Offset
  1243                                  	;dw	KCODE		     ; 32 bit code segment
  1244                                  	; 01/12/2020
  1245 000007CA EA[D1070000]0800        	jmp	KCODE:pminit_return_addr32
  1246                                  
  1247                                  pminit_return_addr32:
  1248                                  	; restore 32 bit kernel selectors and 32 bit stack addr
  1249 000007D1 BE10000000              	mov	esi, KDATA
  1250 000007D6 8EDE                    	mov	ds, si
  1251 000007D8 8EC6                    	mov	es, si
  1252 000007DA 8ED6                    	mov	ss, si
  1253 000007DC 89EC                    	mov	esp, ebp  ; top of stack = iretd return addr
  1254                                  
  1255 000007DE 5D                      	pop	ebp ; **
  1256 000007DF 5E                      	pop	esi ; *
  1257 000007E0 9D                      	popf	; restore 32 bit flags
  1258                                  
  1259                                  	; enable interrupts
  1260                                  
  1261 000007E1 FA                      	cli
  1262                                  
  1263                                  	; 21/12/2020
  1264 000007E2 50                      	push	eax
  1265                                  
  1266 000007E3 30C0                    	xor	al, al	   ; Enable all hardware interrupts!
  1267 000007E5 E621                    	out	21h, al	   ; (IBM PC-AT compatibility)
  1268 000007E7 EB00                    	jmp 	$+2	   ; (All conventional PC-AT hardware
  1269 000007E9 E6A1                    	out	0A1h, al   ;  interrupts will be in use.)	
  1270                                  			   ; (Even if related hardware component
  1271                                  			   ;  does not exist!)
  1272 000007EB 58                      	pop	eax
  1273                                  	
  1274 000007EC FB                      	sti
  1275                                  
  1276                                  	; top of stack = return address 
  1277                                  	; ('pminit_ok' for PMinit)
  1278                                  
  1279 000007ED C3                      	retn
  1280                                  
  1281                                  pminit_ok:
  1282                                  	; 03/12/2020
  1283                                  	; (set [pmid_addr] to PMI entry point for next calls)
  1284 000007EE 8305[24120300]04        	add	dword [pmid_addr], PMInfo.EntryPoint ; + 4
  1285                                  
  1286                                  	; 17/01/2021
  1287                                  	; copy EDID data from temporary location to final address
  1288 000007F5 803D[2F430000]4F        	cmp	byte [edid], 4Fh
  1289 000007FC 7511                    	jne	short vbe3h_chcl
  1290 000007FE B920000000              	mov	ecx, 32 ; 128 bytes, 32 dwords
  1291 00000803 BE007D0900              	mov	esi, VBE3EDIDINFOBLOCK ; 97D00h
  1292 00000808 BF[9C110300]            	mov	edi, edid_info
  1293 0000080D F3A5                    	rep	movsd
  1294                                  	; 17/01/2021
  1295                                  vbe3h_chcl:
  1296                                  	; 16/01/2021
  1297                                  	;; 06/12/2020
  1298                                  	;; Save video mode 03h regs/dac/bios state
  1299                                  	;
  1300                                  	;mov	ax, 4F04h ; VESA VBE Function 04h
  1301                                  	;		  ; Save/Restore State
  1302                                  	;sub	dl, dl	; 0 = return buffer size
  1303                                  	;mov	cx, 0Fh  ; ctrl/bios/dac/regs
  1304                                  	;
  1305                                  	;call	int10h_32bit_pmi
  1306                                   	;; bx = number of 64-byte blocks to hold the state buff
  1307                                  	;	
  1308                                  	;;mov	[vbe3stbufsize], bx
  1309                                  	;; 16/01/2021
  1310                                  	;or	word [vbe3stbsflags], 32768  ; set bit 15
  1311                                  	;mov	ax, bx
  1312                                  	;shl	ax, 6  ; * 64
  1313                                  	;mov	[vbestatebufsize+30], ax
  1314                                  	;
  1315                                  	;; 06/12/2020	
  1316                                  	;; check 'vbe3stbufsize' (it must be <= 32)
  1317                                  	;
  1318                                  	;cmp	bx, 32
  1319                                  	;ja	short display_mem_info ; light red forecolor
  1320                                  	;
  1321                                  	;; 16/01/2021
  1322                                  	;or	byte [vbe3stbsflags], 1 ; set bit 0
  1323                                  
  1324                                  	; 30/11/2020
  1325                                  	; Change VESA VBE3 BIOS text color in order to give
  1326                                  	; "VBE3 PMI initialization has been successed" meaning 	
  1327                                  
  1328 0000080F BE40810B00              	mov	esi, 0B8000h + 160*2 ; row 2
  1329 00000814 89F7                    	mov	edi, esi
  1330                                  vbe3h_chcl_next:
  1331 00000816 66AD                    	lodsw
  1332 00000818 80FC0C                  	cmp	ah, 0Ch	; light red forecolor
  1333 0000081B 750D                    	jne	short display_mem_info
  1334 0000081D B40E                    	mov	ah, 0Eh ; yellow forecolor
  1335 0000081F 66AB                    	stosw
  1336 00000821 EBF3                    	jmp	short vbe3h_chcl_next
  1337                                  
  1338                                  di0:
  1339                                  	; 30/11/2020
  1340                                  	; Memory allocation error !
  1341 00000823 C605[54090000]00        	mov	byte [vbe3], 0 ; disable VBE3
  1342                                  
  1343                                  display_mem_info:
  1344                                  	; 19/12/2020
  1345                                  	; temporary
  1346 0000082A E8853A0000              	call	default_lfb_info
  1347                                  	;
  1348                                  	; 06/11/2014
  1349 0000082F E80B3A0000              	call	memory_info
  1350                                  	; 14/08/2015
  1351                                  	;call getch ; 28/02/2015
  1352                                  drv_init:
  1353 00000834 FB                      	sti	; Enable Interrupts 
  1354                                  	; 06/02/2015
  1355 00000835 8B15[006E0000]          	mov	edx, [hd0_type] ; hd0, hd1, hd2, hd3
  1356 0000083B 668B1D[FE6D0000]        	mov	bx, [fd0_type] ; fd0, fd1
  1357                                  	; 22/02/2015
  1358 00000842 6621DB                  	and	bx, bx
  1359 00000845 756C                    	jnz	short di1
  1360                                  	;
  1361 00000847 09D2                    	or 	edx, edx
  1362 00000849 757A                    	jnz	short di2
  1363                                  	;
  1364                                  setup_error:
  1365 0000084B BE[E64C0100]            	mov 	esi, setup_error_msg
  1366                                  psem:	
  1367 00000850 AC                      	lodsb
  1368 00000851 08C0                    	or	al, al
  1369                                  	;jz	short haltx ; 22/02/2015
  1370 00000853 747B                    	jz	short di3
  1371 00000855 56                      	push	esi
  1372                                  	; 13/05/2016
  1373 00000856 BB07000000              	mov	ebx, 7	; Black background, 
  1374                                  			; light gray forecolor
  1375                                  			; Video page 0 (BH=0)
  1376 0000085B E89D1A0000              	call	_write_tty
  1377 00000860 5E                      	pop	esi
  1378 00000861 EBED                    	jmp	short psem
  1379                                  
  1380                                  check_boch_plex86_vbe:
  1381                                  	; 20/11/2020
  1382                                  	; check Bochs/Plex86 VGABios VBE extension
  1383                                  	; (check if TRDOS 386 v2 is running on emulators)
  1384                                  	; BOCHS/QEMU/VIRTUALBOX
  1385                                  	;
  1386                                  	; ref: vbe_display_api.txt
  1387                                  
  1388                                  	; bochs/plex86 VGAbios VBE source code
  1389                                  	;  by Jeroen Janssen (2002)
  1390                                  	;  and Volker Ruppert (2003-2020)
  1391                                  
  1392 00000863 29C0                    	sub	eax, eax ; 0
  1393 00000865 66BACE01                	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
  1394 00000869 66EF                    	out	dx, ax ; VBE_DISPI_INDEX_ID register
  1395                                  	;mov	ax, 0B0C0h ; VBE_DISPI_ID0
  1396                                  	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
  1397 0000086B 6642                    	inc	dx
  1398                                  	;out	dx, ax
  1399                                  	;nop
  1400 0000086D 66ED                    	in	ax, dx
  1401 0000086F 80FCB0                  	cmp	ah, 0B0h
  1402                                  	;jne	short not_boch_qemu_vbe
  1403 00000872 75B6                    	jne	short display_mem_info
  1404 00000874 3CC5                    	cmp	al, 0C5h ; it must be 0B0C4h or 0B0C5h ..
  1405                                  	;ja	short not_boch_qemu_vbe
  1406 00000876 77B2                    	ja	short display_mem_info
  1407 00000878 3CC0                    	cmp	al, 0C0h ; 0B0C0h to 0B0C5h .. ; Qemu
  1408                                  	;cmp	al, 0C4h ; 0BC04h or 0B0C5h is OK ; Bochs
  1409                                  	;jb	short not_boch_qemu_vbe
  1410 0000087A 72AE                    	jb	short display_mem_info
  1411                                  
  1412                                  	; save VESA VBE2 bios (bochs/qemu) signature
  1413                                  	; for enabling VBE2 functions in TRDOS 386 v2 kernel
  1414 0000087C A2[55090000]            	mov	[vbe2bios], al ; 0C4h or 0C5h (for BOCHS) 
  1415                                  			       ; (0C0h-0C5h for QEMU)
  1416 00000881 C605[82860100]32        	mov	byte [vbe_vnumber], "2"
  1417                                  	; 26/11/2020
  1418                                  	; "BOCHS/QEMU/VIRTUALBOX VBE2 Video BIOS ..".
  1419 00000888 BE[64860100]            	mov	esi, vbe2_bochs_vbios ; BOCH/QEMU vbios msg
  1420 0000088D B40E                    	mov	ah, 0Eh  ; Yellow font
  1421 0000088F E8043A0000              	call	print_kmsg
  1422                                  	
  1423                                  	; this is not necessary ! (20/11/2020)
  1424 00000894 803D[55090000]C4        	cmp	byte [vbe2bios], 0C4h 
  1425 0000089B 728D                    	jb	display_mem_info	; (QEMU) 
  1426                                  
  1427                                  	; Display kernel version message if 0E9h hack port
  1428                                  	; is enabled (bochs emulator feature)
  1429 0000089D 66BAE900                	mov	dx, 0E9h ; hack port for BOCHS
  1430 000008A1 BE[BD860100]            	mov	esi, kernel_version_msg
  1431                                  kvmsg_next_char:
  1432 000008A6 AC                      	lodsb	
  1433 000008A7 08C0                    	or	al, al
  1434 000008A9 7505                    	jnz	short put_kvmsg_in_hack_port
  1435                                  not_boch_qemu_vbe:
  1436 000008AB E97AFFFFFF               	jmp	display_mem_info
  1437                                  put_kvmsg_in_hack_port:	
  1438 000008B0 EE                      	out	dx, al
  1439 000008B1 EBF3                    	jmp	short kvmsg_next_char
  1440                                  
  1441                                  di1:
  1442                                  	; supress 'jmp short T6'
  1443                                  	;  (activate fdc motor control code)
  1444 000008B3 66C705[B6090000]90-     	mov	word [T5], 9090h ; nop
  1444 000008BB 90                 
  1445                                  	;
  1446                                  	;mov	ax, int_0Eh	; IRQ 6 handler
  1447                                  	;mov	di, 0Eh*4	; IRQ 6 vector
  1448                                  	;stosw
  1449                                  	;mov 	ax, cs
  1450                                  	;stosw
  1451                                  	;; 16/02/2015
  1452                                          ;;mov     dword [DISKETTE_INT], fdc_int ; IRQ 6 handler
  1453                                  	;
  1454 000008BC E82A490000              	CALL	DSKETTE_SETUP	; Initialize Floppy Disks
  1455                                  	;
  1456 000008C1 09D2                    	or	edx, edx
  1457 000008C3 740B                            jz      short di3
  1458                                  di2:
  1459 000008C5 E868490000              	call   	DISK_SETUP	; Initialize Fixed Disks
  1460 000008CA 0F827BFFFFFF                    jc      setup_error
  1461                                  di3:
  1462 000008D0 E83E390000              	call	setup_rtc_int	; 22/05/2015 (dsectrpm.s)
  1463                                  	;
  1464 000008D5 E8A2420100              	call	display_disks ; 07/03/2015  (Temporary)
  1465                                  ;haltx:
  1466                                  	; 14/08/2015
  1467                                  	;call	getch ; 22/02/2015
  1468                                  	;sti	; Enable interrupts (for CPU)
  1469                                  ;	; 29/01/2016
  1470                                  ;	sub	ah, ah ;  read time count
  1471                                  ;	call	int1Ah
  1472                                  ;	mov	edx, ecx ; 18.2 * seconds
  1473                                  ;md_info_msg_wait1:
  1474                                  ;	; 29/01/2016
  1475                                  ;	mov	ah, 1
  1476                                  ;	call	int16h
  1477                                  ;	jz	short md_info_msg_wait2
  1478                                  ;	xor	ah, ah ; 0
  1479                                  ;       call    int16h
  1480                                  ;	jmp 	short md_info_msg_ok
  1481                                  ;md_info_msg_wait2:
  1482                                  ;	sub	ah, ah  ; read time count
  1483                                  ;	call	int1Ah
  1484                                  ;	cmp	edx, ecx ; ; 18.2 * seconds
  1485                                  ;	jna	short md_info_msg_wait3
  1486                                  ;	xchg 	edx, ecx	
  1487                                  ;md_info_msg_wait3:
  1488                                  ;	sub	ecx, edx
  1489                                  ;	cmp	ecx, 127 ; 7 seconds (18.2 * 7)
  1490                                  ;	jb	short md_info_msg_wait1		
  1491                                  ;md_info_msg_ok:
  1492                                  
  1493                                  	; 15/12/2020
  1494                                  	; set initial values of LFB parameters
  1495                                  
  1496 000008DA 803D[54090000]02        	cmp	byte [vbe3], 2
  1497 000008E1 7214                    	jb	short di4
  1498                                  
  1499                                  	;mov	ax, [def_LFB_addr]
  1500                                  	;shl	eax, 16
  1501                                  	;mov	[LFB_ADDR], eax
  1502                                  	;mov	eax, 1024*768*3
  1503                                  	;mov	[LFB_SIZE], eax
  1504                                  
  1505 000008E3 BEFE7B0900              	mov	esi, VBE3MODEINFOBLOCK - 2
  1506 000008E8 66C7061801              	mov	word [esi], 0118h ; default vbe mode
  1507                                  				  ; 1024*768, 24bpp
  1508 000008ED E8AD310000              	call	set_lfbinfo_table
  1509                                  
  1510 000008F2 E8DC600000              	call	allocate_lfb_pages_for_kernel
  1511                                  di4:
  1512                                  	; 08/09/2016
  1513 000008F7 0F20C0                  	mov	eax, cr0
  1514 000008FA A810                    	test	al, 10h  ; Bit 4, ET (Extension Type)
  1515 000008FC 7408                    	jz	short sysinit
  1516                                  	; 27/02/2017
  1517 000008FE FE05[8C960100]          	inc	byte [fpready]
  1518                                  	; 80387 (FPU) is ready
  1519 00000904 DBE3                    	fninit ; Initialize Floating-Point Unit
  1520                                  sysinit:
  1521                                  	; 30/06/2015
  1522 00000906 E82B6B0000              	call	sys_init
  1523                                  	;
  1524                                  	;jmp 	cpu_reset ; 22/02/2015
  1525                                  hang:  
  1526                                  	; 23/02/2015
  1527                                  	;sti			; Enable interrupts
  1528 0000090B F4                      	hlt
  1529                                  	;
  1530                                  	;nop
  1531                                  	;; 03/12/2014
  1532                                  	;; 28/08/2014
  1533                                  	;mov	ah, 11h
  1534                                  	;call	getc
  1535                                  	;jz      _c8
  1536                                  	;
  1537                                  	; 23/02/2015
  1538                                  	; 06/02/2015
  1539                                  	; 07/09/2014
  1540 0000090C 31DB                    	xor	ebx, ebx
  1541 0000090E 8A1D[FE890100]          	mov	bl, [ptty]	; active_page
  1542 00000914 89DE                    	mov	esi, ebx
  1543 00000916 66D1E6                  	shl 	si, 1
  1544 00000919 81C6[008A0100]          	add	esi, ttychr
  1545 0000091F 668B06                  	mov	ax, [esi]
  1546 00000922 6621C0                  	and	ax, ax
  1547                                  	;jz	short _c8
  1548 00000925 74E4                    	jz	short hang
  1549 00000927 66C7060000              	mov	word [esi], 0
  1550 0000092C 80FB03                  	cmp	bl, 3		; Video page 3
  1551                                  	;jb	short _c8
  1552 0000092F 72DA                    	jb	short hang
  1553                                  	;	
  1554                                  	; 13/05/2016
  1555                                  	; 07/09/2014
  1556                                  nxtl:
  1557 00000931 6653                    	push	bx
  1558 00000933 66BB0E00                	mov	bx, 0Eh 	; Yellow character 
  1559                                  				; on black background
  1560                                  				; bh = 0 (video page 0)
  1561                                  				; Retro UNIX 386 v1 - Video Mode 0
  1562                                  				; (PC/AT Video Mode 3 - 80x25 Alpha.)
  1563 00000937 6650                    	push	ax
  1564 00000939 E8BF190000              	call 	_write_tty
  1565 0000093E 6658                    	pop	ax
  1566 00000940 665B                    	pop	bx
  1567 00000942 3C0D                    	cmp	al, 0Dh		; carriage return (enter)
  1568                                  	;jne	short _c8
  1569 00000944 75C5                    	jne	short hang
  1570 00000946 B00A                    	mov	al, 0Ah		; next line
  1571 00000948 EBE7                    	jmp	short nxtl
  1572                                  	
  1573                                  ;_c8:
  1574                                  ;	; 25/08/2014
  1575                                  ;	cli				; Disable interrupts
  1576                                  ;	mov	al, [scounter + 1]
  1577                                  ;	and	al, al
  1578                                  ;	jnz	hang
  1579                                  ;	call	rtc_p
  1580                                  ;	jmp     hang
  1581                                  
  1582                                  	; 27/08/2014
  1583                                  	; 20/08/2014
  1584                                  printk:
  1585                                          ;mov    edi, [scr_row]
  1586                                  pkl:
  1587 0000094A AC                      	lodsb
  1588 0000094B 08C0                    	or 	al, al
  1589 0000094D 7404                    	jz	short pkr
  1590 0000094F 66AB                    	stosw
  1591 00000951 EBF7                    	jmp	short pkl
  1592                                  pkr:
  1593 00000953 C3                      	retn
  1594                                  
  1595                                  ; 14/11/2020 (TRDOS 386 v2.0.3)
  1596 00000954 00                      vbe3:	db 0  ; VESA VBE version (must be 03h)
  1597                                  	      ; for using video bios calls in protected mode
  1598                                  vbe2bios:
  1599 00000955 B0                      	db 0B0h ; 
  1600                                  ;pmid_addr: 		
  1601                                  	;dw 0  ; > 0 if 'PMID' sign is found 
  1602                                  	;     ;	('pmid' offset addr in VGA bios seg, 0C000h)
  1603                                  	;; 02/12/2020
  1604                                  	;dw 0	; 32 bit address in pmid_addr
  1605                                  		
  1606                                  ; 28/02/2017
  1607                                  ; 22/01/2017
  1608                                  ; 15/01/2017
  1609                                  ; 14/01/2017
  1610                                  ; 02/01/2017
  1611                                  ; 25/12/2016
  1612                                  ; 19/12/2016
  1613                                  ; 10/12/2016 (callback)
  1614                                  ; 06/06/2016
  1615                                  ; 23/05/2016
  1616                                  ; 22/05/2016 - TRDOS 386 (TRDOS v2.0) Timer Event Modifications
  1617                                  ; 25/07/2015
  1618                                  ; 14/05/2015 (multi tasking -time sharing- 'clock', x_timer)
  1619                                  ; 17/02/2015
  1620                                  ; 06/02/2015 (unix386.s)
  1621                                  ; 11/12/2014 - 22/12/2014 (dsectrm2.s) 
  1622                                  ;
  1623                                  ; IBM PC-XT Model 286 Source Code - BIOS2.ASM (06/10/85)
  1624                                  ;
  1625                                  ;-- HARDWARE INT  08 H - ( IRQ LEVEL 0 ) ---------------------------------------
  1626                                  ;	THIS ROUTINE HANDLES THE TIMER INTERRUPT FROM FROM CHANNEL 0 OF        :
  1627                                  ;	THE 8254 TIMER.  INPUT FREQUENCY IS 1.19318 MHZ AND THE DIVISOR        :
  1628                                  ;	IS 65536, RESULTING IN APPROXIMATELY 18.2 INTERRUPTS EVERY SECOND.     :
  1629                                  ;									       :
  1630                                  ;	THE INTERRUPT HANDLER MAINTAINS A COUNT (40:6C) OF INTERRUPTS SINCE    :
  1631                                  ;	POWER ON TIME, WHICH MAY BE USED TO ESTABLISH TIME OF DAY.	       :
  1632                                  ;	THE INTERRUPT HANDLER ALSO DECREMENTS THE MOTOR CONTROL COUNT (40:40)  :
  1633                                  ;	OF THE DISKETTE, AND WHEN IT EXPIRES, WILL TURN OFF THE 	       :
  1634                                  ;	DISKETTE MOTOR(s), AND RESET THE MOTOR RUNNING FLAGS.		       :
  1635                                  ;	THE INTERRUPT HANDLER WILL ALSO INVOKE A USER ROUTINE THROUGH	       :
  1636                                  ;	INTERRUPT 1CH AT EVERY TIME TICK.  THE USER MUST CODE A 	       :
  1637                                  ;	ROUTINE AND PLACE THE CORRECT ADDRESS IN THE VECTOR TABLE.	       :
  1638                                  ;-------------------------------------------------------------------------------
  1639                                  ;
  1640                                  
  1641                                  timer_int:	; IRQ 0
  1642                                  ;int_08h:	; Timer
  1643                                  	; 14/10/2015
  1644                                  	; Here, we are simulating system call entry (for task switch)
  1645                                  	; (If multitasking is enabled, 
  1646                                  	; 'clock' procedure may jump to 'sysrelease')
  1647                                  
  1648 00000956 1E                      	push	ds
  1649 00000957 06                      	push	es
  1650 00000958 0FA0                    	push	fs
  1651 0000095A 0FA8                    	push	gs
  1652                                  
  1653 0000095C 60                      	pushad	; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  1654 0000095D 66B91000                	mov     cx, KDATA
  1655 00000961 8ED9                            mov     ds, cx
  1656 00000963 8EC1                            mov     es, cx
  1657 00000965 8EE1                            mov     fs, cx
  1658 00000967 8EE9                            mov     gs, cx
  1659                                  
  1660 00000969 0F20D9                  	mov	ecx, cr3
  1661 0000096C 890D[5C040300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  1662                                  
  1663                                  	; 14/01/2017
  1664 00000972 3B0D[D0890100]          	cmp 	ecx, [k_page_dir]
  1665 00000978 7409                    	je	short T3
  1666                                  
  1667 0000097A 8B0D[D0890100]          	mov	ecx, [k_page_dir]
  1668 00000980 0F22D9                  	mov	cr3, ecx
  1669                                  T3:
  1670                                  	;sti				; INTERRUPTS BACK ON
  1671 00000983 66FF05[508A0100]        	INC	word [TIMER_LOW]	; INCREMENT TIME
  1672 0000098A 7507                    	JNZ	short T4		; GO TO TEST_DAY
  1673 0000098C 66FF05[528A0100]        	INC	word [TIMER_HIGH]	; INCREMENT HIGH WORD OF TIME
  1674                                  T4:					; TEST_DAY
  1675 00000993 66833D[528A0100]18      	CMP	word [TIMER_HIGH],018H	; TEST FOR COUNT EQUALING 24 HOURS
  1676 0000099B 7519                    	JNZ	short T5		; GO TO DISKETTE_CTL
  1677 0000099D 66813D[508A0100]B0-     	CMP	word [TIMER_LOW],0B0H
  1677 000009A5 00                 
  1678 000009A6 750E                    	JNZ	short T5		; GO TO DISKETTE_CTL
  1679                                  
  1680                                  ;-----	TIMER HAS GONE 24 HOURS
  1681                                  	;;SUB	AX,AX
  1682                                  	;MOV	[TIMER_HIGH],AX
  1683                                  	;MOV	[TIMER_LOW],AX
  1684 000009A8 29C0                    	sub	eax, eax
  1685 000009AA A3[508A0100]            	mov	[TIMER_LH], eax
  1686                                  	;	
  1687 000009AF C605[548A0100]01        	MOV	byte [TIMER_OFL],1
  1688                                  
  1689                                  ;-----	TEST FOR DISKETTE TIME OUT
  1690                                  
  1691                                  T5:
  1692                                  	; 23/12/2014
  1693 000009B6 EB1D                    	jmp	short T6		; will be replaced with nop, nop
  1694                                  					; (9090h) if a floppy disk
  1695                                  					; is detected.
  1696                                  	;mov	al,[CS:MOTOR_COUNT]
  1697 000009B8 A0[578A0100]            	mov	al, [MOTOR_COUNT]
  1698 000009BD FEC8                    	dec	al
  1699                                  	;mov	[CS:MOTOR_COUNT], al	; DECREMENT DISKETTE MOTOR CONTROL
  1700 000009BF A2[578A0100]            	mov	[MOTOR_COUNT], al
  1701                                  	;mov	[ORG_MOTOR_COUNT], al
  1702 000009C4 750F                    	JNZ	short T6		; RETURN IF COUNT NOT OUT
  1703 000009C6 B0F0                    	mov 	al,0F0h
  1704                                  	;AND	[CS:MOTOR_STATUS],al 	; TURN OFF MOTOR RUNNING BITS
  1705 000009C8 2005[568A0100]          	and	[MOTOR_STATUS], al
  1706                                  	;and	[ORG_MOTOR_STATUS], al
  1707 000009CE B00C                    	MOV	AL,0CH			; bit 3 = enable IRQ & DMA, 
  1708                                  					; bit 2 = enable controller
  1709                                  					;	1 = normal operation
  1710                                  					;	0 = reset	
  1711                                  					; bit 0, 1 = drive select
  1712                                  					; bit 4-7 = motor running bits 
  1713 000009D0 66BAF203                	MOV	DX,03F2H		; FDC CTL PORT
  1714 000009D4 EE                      	OUT	DX,AL			; TURN OFF THE MOTOR
  1715                                  T6:	
  1716                                  	;inc	word [CS:wait_count]	; 22/12/2014 (byte -> word)
  1717                                  					; TIMER TICK INTERRUPT
  1718                                  	;;inc	word [wait_count] ;;27/02/2015
  1719                                  	;INT	1CH			; TRANSFER CONTROL TO A USER ROUTINE
  1720                                  	;cli
  1721 000009D5 E857040000              	call 	u_timer			; TRANSFER CONTROL TO A USER ROUTINE
  1722                                  	; 23/05/2016
  1723 000009DA E8DD220100              	call	clock			; Multi Tasking control procedure
  1724                                  T7:
  1725                                  	; 14/10/2015
  1726 000009DF B020                    	MOV	AL,EOI			; GET END OF INTERRUPT MASK
  1727 000009E1 FA                      	CLI				; DISABLE INTERRUPTS TILL STACK CLEARED
  1728 000009E2 E620                    	OUT	INTA00,AL		; END OF INTERRUPT TO 8259 - 1	
  1729                                  	;
  1730                                  rtc_int_2:
  1731                                  	; 26/12/2016
  1732                                  	;mov	ecx, [cr3reg]
  1733                                  	; 13/01/2017
  1734 000009E4 803D[D4030300]00        	cmp	byte [u.t_lock], 0  	; T_LOCK
  1735 000009EB 7730                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !
  1736                                  	; 28/02/2017
  1737                                  	; We need to exit if the user's IRQ callback service is in progress!
  1738                                  	; (To prevent a conflict!)
  1739 000009ED 803D[D8030300]00        	cmp	byte [u.r_lock], 0	; R_LOCK, IRQ callback service lock !
  1740 000009F4 7727                    	ja	short timer_int_return  ; Timer Lock : 'sysrele' is needed !	
  1741                                  	; 15/01/2017
  1742 000009F6 803D[60960100]02        	cmp	byte [priority], 2
  1743 000009FD 733A                    	jnb	short T8  ; current process has a timer event (15/01/2017)
  1744                                  	; 22/05/2016
  1745 000009FF 803D[61960100]00        	cmp	byte [p_change], 0 ; in 'set_run_sequence', in 'rtc_p'
  1746 00000A06 7615                    	jna	short timer_int_return ; 23/05/2016
  1747                                  
  1748                                  	; 15/01/2017
  1749                                  	
  1750                                  	; present process must be changed with high priority process	
  1751                                  	;xor	al, al
  1752 00000A08 31C0                    	xor	eax, eax ; 26/12/2016
  1753 00000A0A A2[61960100]            	mov	[p_change], al ; 0
  1754                                  	;mov	byte [priority], 2 ; 15/01/2017 (there is a timer event)
  1755                                  
  1756 00000A0F 803D[5B030300]FF        	cmp     byte [sysflg], 0FFh ; user or system space ?
  1757 00000A16 7416                    	je	short rtc_int_3     ; user space ([sysflg]= 0FFh)
  1758                                  
  1759                                  	; system space, wait for 'sysret'
  1760                                  	; to change running process 	
  1761                                  	; with high priority (event) process
  1762                                  
  1763 00000A18 A2[A8030300]            	mov	[u.quant], al ; 0
  1764                                  
  1765                                  timer_int_return: ; 23/05/2016 - jump from 'rtc_int' ('rtc_int_2')
  1766 00000A1D 8B0D[5C040300]          	mov 	ecx, [cr3reg] 	; previous value/content of cr3 register
  1767 00000A23 0F22D9                   	mov	cr3, ecx	; restore cr3 register content
  1768                                  	;
  1769 00000A26 61                      	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
  1770                                  	;
  1771 00000A27 0FA9                    	pop	gs
  1772 00000A29 0FA1                    	pop	fs
  1773 00000A2B 07                      	pop	es
  1774 00000A2C 1F                      	pop	ds
  1775                                  	;
  1776 00000A2D CF                      	iretd	; return from interrupt
  1777                                  
  1778                                  rtc_int_3:
  1779 00000A2E FE05[5B030300]          	inc	byte [sysflg] 	; now, we are in system space
  1780                                  	;
  1781 00000A34 E9E3CE0000                      jmp     sysrelease ; change running process immediatelly 
  1782                                  
  1783                                  T8:
  1784                                  	; 13/01/2017 (eax -> ebx)
  1785                                  	; callback checking... (19/12/2016)
  1786 00000A39 31DB                    	xor	ebx, ebx
  1787 00000A3B 871D[D0030300]          	xchg	ebx, [u.tcb] ; callback address (0 = normal return)
  1788 00000A41 09DB                    	or	ebx, ebx
  1789 00000A43 74D8                    	jz	short timer_int_return
  1790                                  
  1791                                  	; Set user's callback routine as return address from this interrupt
  1792                                  	; and set normal return address as return address from callback
  1793                                  	; routine!!! (19/12/2016)
  1794                                  	
  1795                                  	; 14/01/2017
  1796                                  	; 13/01/2017 - Timer Lock (T_LOCK)
  1797 00000A45 FE05[D4030300]          	inc	byte [u.t_lock]
  1798 00000A4B 8A0D[5B030300]          	mov	cl, [sysflg]
  1799 00000A51 880D[D5030300]          	mov	[u.t_mode], cl 
  1800                                  
  1801 00000A57 8B2D[6C890100]          	mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  1802 00000A5D 83ED14                  	sub	ebp, 20		; eip, cs, eflags, esp, ss
  1803 00000A60 892D[5C030300]           	mov	[u.sp], ebp
  1804 00000A66 8925[60030300]          	mov	[u.usp], esp
  1805                                  
  1806                                  	;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  1807                                  
  1808 00000A6C 8B44241C                	mov	eax, [esp+28] ; pushed eax
  1809 00000A70 A3[64030300]            	mov	[u.r0], eax
  1810                                  
  1811 00000A75 E83E0F0100              	call	wswap ; save user's registers & status
  1812                                  
  1813                                  	; software int is in ring 0 but timer int must return to ring 3
  1814                                  	; so, ring 3 return address and stack registers
  1815                                  	; (eip, cs, eflags, esp, ss) 
  1816                                  	; must be copied to timer int return
  1817                                  	; eip will be replaced by callback service routine address
  1818                                  
  1819 00000A7A C605[5B030300]FF        	mov	byte [sysflg], 0FFh ; user mode
  1820                                  
  1821                                  	; system mode (system call)
  1822                                  	;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  1823                                  			    ; ESP (u), SS (UDATA)
  1824                                  
  1825 00000A81 8B4510                  	mov	eax, [ebp+16]	; SS (UDATA
  1826 00000A84 89E6                    	mov	esi, esp
  1827 00000A86 50                      	push	eax
  1828 00000A87 50                      	push	eax
  1829 00000A88 89E7                    	mov	edi, esp
  1830 00000A8A 893D[60030300]          	mov	[u.usp], edi
  1831 00000A90 B908000000              	mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  1832 00000A95 F3A5                    	rep	movsd
  1833 00000A97 B104                    	mov	cl, 4	
  1834 00000A99 F3AB                    	rep	stosd
  1835 00000A9B 893D[5C030300]          	mov	[u.sp], edi
  1836 00000AA1 89EE                    	mov	esi, ebp
  1837 00000AA3 B105                    	mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  1838 00000AA5 F3A5                    	rep	movsd
  1839                                  
  1840 00000AA7 8B0D[B8030300]          	mov	ecx, [u.pgdir]
  1841 00000AAD 890D[5C040300]          	mov	[cr3reg], ecx
  1842                                  
  1843                                  	; 13/01/207 (eax -> ebx)
  1844                                  	; EBX = callback routine address (virtual, not physical address!)
  1845                                  
  1846                                  	; 09/01/2017
  1847                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'sysrele'
  1848                                  	;     system call !!!	
  1849                                  	; 25/12/2016
  1850                                  	; Callback Note: (19/12/2016)
  1851                                  	; !!! CALLBACK ROUTINE MUST BE ENDED/RETURNED WITH 'RETN' !!!
  1852                                  	;	pushf ; save flags	
  1853                                  	; 	<callback service code>
  1854                                  	; 	popf  ; restore flags
  1855                                  	; 	retn ; return to normal running address
  1856                                  	;
  1857                                  
  1858                                  	; 15/01/2017
  1859                                  	; 14/01/2017
  1860                                  	; 13/01/2017 (eax -> ebx)
  1861                                  	; 10/01/2017
  1862                                  set_callback_addr:
  1863                                  	; 09/01/2017 (**)
  1864                                  	; 02/01/2017 (*)
  1865                                  	; 25/12/2016 (*)
  1866                                  	; 19/12/2016 (TRDOS 386 feature only!)
  1867                                  	;
  1868                                  	; This routine sets return address
  1869                                  	; to start of user's interrupt
  1870                                  	; service (callback) address
  1871                                  	;; and sets callback 'retn' address to normal
  1872                                  	;; return address of user's running code! 
  1873                                  	;
  1874                                  	; INPUT:
  1875                                  	;	EBX = callback routine/service address
  1876                                  	;	      (virtual, not physical address!)	
  1877                                  	;	[u.sp] = kernel stack, points to
  1878                                  	;		 user's EIP,CS,EFLAGS,ESP,SS
  1879                                  	;		 registers.
  1880                                  	; OUTPUT:
  1881                                  	;	EIP (user) = callback (service) address
  1882                                  	;	CS (user) = UCODE
  1883                                  	;	EFLAGS (user) = flags before callback 	 
  1884                                  	;       ESP (user) = ESP-4 (user, before callback) 
  1885                                  	;	[ESP](user) = EIP (user) before callback
  1886                                  	;
  1887                                  	; Note: If CPU was in user mode while entering 
  1888                                  	;	the timer interrupt service routine,
  1889                                  	;	'IRET' will get return to callback routine
  1890                                  	;	immediately. If CPU was in system/kernel mode  
  1891                                  	;	'iret' will get return to system call and
  1892                                  	;	then, callback routine will be return address
  1893                                  	;	from system call. (User's callback/service code
  1894                                  	;	will be able to return to normal return address
  1895                                  	;	via an 'retn' at the end.) 
  1896                                  	;
  1897                                  	; Note(**): User's callback service code must be ended
  1898                                  	;	with a 'sysrele' sytstem call ! (09/01/2017)
  1899                                  	;
  1900                                  	;	For example:
  1901                                  	;
  1902                                  	;	timer_callback:
  1903                                  	;	    ...	 
  1904                                    	;	    inc	dword [time_counter]
  1905                                  	;	    ...
  1906                                  	;	    mov eax, 39 ; 'sysrele'
  1907                                  	;	    int 40h ; TRDOS 386 system call (interrupt)		
  1908                                  	;
  1909                                  	;
  1910                                  	;; Note(*): User's callback service code must preserve cpu 
  1911                                  	;;	flags if it has any instructions which changes
  1912                                  	;;	flags in the service code. (25/12/2016)
  1913                                  	;;
  1914                                  	;;	For example:
  1915                                  	;;
  1916                                  	;;	timer_callback:
  1917                                  	;;	    pushf ; save flags
  1918                                  	;;	    ; this instruction changes zero flag
  1919                                    	;;	    inc	dword [time_counter]
  1920                                  	;;	    popf ; restore flags
  1921                                  	;;	    retn ; return to normal user code
  1922                                  	;;		  (which is interrupted by the 
  1923                                  	;;		   timer interput) 	
  1924                                  	;;
  1925                                  
  1926                                  	; 15/01/2017
  1927 00000AB3 8B2D[5C030300]          	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  1928 00000AB9 895D00                  	mov	[ebp], ebx
  1929 00000ABC E95CFFFFFF              	jmp	timer_int_return
  1930                                  
  1931                                  	; 15/01/2017
  1932                                  	; 13/01/2017
  1933                                  	; 19/12/2016
  1934                                  	; 06/06/2016
  1935                                  	; 23/05/2016
  1936                                  	; 22/05/2016
  1937                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1938                                  	; 26/02/2015
  1939                                  	; 07/09/2014
  1940                                  	; 25/08/2014
  1941                                  rtc_int:       ; Real Time Clock Interrupt (IRQ 8)
  1942                                  	; 22/05/2016
  1943 00000AC1 1E                      	push	ds ; ** ; 23/05/2016
  1944 00000AC2 50                      	push	eax ; *
  1945 00000AC3 66B81000                	mov	ax, KDATA
  1946 00000AC7 8ED8                    	mov	ds, ax
  1947                                  	;
  1948 00000AC9 8A25[4E8A0100]          	mov	ah, [RTC_2Hz] ;  2 Hz interrupt to 1 Hz function
  1949 00000ACF 80F401                  	xor	ah, 1
  1950 00000AD2 8825[4E8A0100]          	mov	[RTC_2Hz], ah ; 1 = 0.5 second, 0 = 1 second
  1951 00000AD8 753B                    	jnz	short rtc_int_return ; half second
  1952                                  	; 1 second
  1953                                  rtc_int_0:
  1954                                  	; 22/05/2016
  1955 00000ADA 58                      	pop	eax ; *
  1956                                  	;
  1957                                  	; 14/10/2015 ('timer_int')
  1958                                  	; Here, we are simulating system call entry (for task switch)
  1959                                  	; (If multitasking is enabled, 
  1960                                  	; 'clock' procedure may jump to 'sysrelease')
  1961                                  	;push	ds ; ** ; 23/05/2016
  1962 00000ADB 06                      	push	es
  1963 00000ADC 0FA0                    	push	fs
  1964 00000ADE 0FA8                    	push	gs
  1965 00000AE0 60                      	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
  1966 00000AE1 66B91000                	mov     cx, KDATA
  1967                                          ;mov    ds, cx ; 06/06/2016
  1968 00000AE5 8EC1                            mov     es, cx
  1969 00000AE7 8EE1                            mov     fs, cx
  1970 00000AE9 8EE9                            mov     gs, cx
  1971                                  	;
  1972 00000AEB 0F20D9                  	mov	ecx, cr3
  1973 00000AEE 890D[5C040300]          	mov	[cr3reg], ecx ; save current cr3 register value/content
  1974                                  	;
  1975 00000AF4 803D[D4030300]00        	cmp	byte [u.t_lock], 0 ; timer lock (callback) status ?
  1976 00000AFB 7711                    	ja	short rtc_int_1	   ; yes
  1977                                  
  1978                                  	; 15/01/2017
  1979 00000AFD 3B0D[D0890100]          	cmp 	ecx, [k_page_dir]
  1980 00000B03 7409                    	je	short rtc_int_1
  1981                                  
  1982 00000B05 8B0D[D0890100]          	mov	ecx, [k_page_dir]
  1983 00000B0B 0F22D9                  	mov	cr3, ecx
  1984                                  rtc_int_1:
  1985                                  	; Timer event (kernel) functions must be performed with
  1986                                  	; 1 second intervals - TRDOS 386 (TRDOS v2.0) feature ! -
  1987                                   	;	
  1988                                  	; 25/08/2014
  1989 00000B0E E81A030000              	call	rtc_p  ; 19/05/2016 - major modification 
  1990                                  	
  1991                                  	; 23/05/2016
  1992 00000B13 28E4                    	sub	ah, ah ; 0
  1993                                  	; 22/05/2016 - TRDOS 386 timer event modifications
  1994                                  rtc_int_return: ; 19/05/2016
  1995                                  	; 22/02/2015 - dsectpm.s
  1996                                  	; [ source: http://wiki.osdev.org/RTC ]
  1997                                  	; read status register C to complete procedure
  1998                                  	;(it is needed to get a next IRQ 8) 
  1999 00000B15 B00C                    	mov	al, 0Ch ; 
  2000 00000B17 E670                    	out	70h, al ; select register C
  2001 00000B19 90                      	nop
  2002 00000B1A E471                    	in	al, 71h ; just throw away contents
  2003                                  	; 22/02/2015
  2004 00000B1C B020                    	MOV	AL,EOI		; END OF INTERRUPT
  2005                                  	;CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  2006 00000B1E E6A0                    	OUT	INTB00,AL	; FOR CONTROLLER #2
  2007                                  
  2008                                  	; 23/05/2016
  2009 00000B20 B020                    	MOV	AL,EOI		; GET END OF INTERRUPT MASK
  2010 00000B22 FA                      	CLI			; DISABLE INTERRUPTS TILL STACK CLEARED
  2011 00000B23 E620                    	OUT	INTA00,AL	; END OF INTERRUPT TO 8259 - 1	
  2012                                  	;
  2013                                  	; 23/05/2016
  2014 00000B25 20E4                    	and	ah, ah
  2015 00000B27 0F84B7FEFFFF                    jz      rtc_int_2
  2016                                  	
  2017                                  	; ah = 1 (half second)
  2018 00000B2D 58                      	pop	eax ; *
  2019 00000B2E 1F                      	pop	ds  ; **
  2020 00000B2F CF                      	iretd
  2021                                  
  2022                                  ; ////////////////
  2023                                  
  2024                                  	; 28/08/2014
  2025                                  irq0:
  2026 00000B30 6A00                            push 	dword 0
  2027 00000B32 EB48                    	jmp	short which_irq
  2028                                  irq1:
  2029 00000B34 6A01                            push 	dword 1
  2030 00000B36 EB44                    	jmp	short which_irq
  2031                                  irq2:
  2032 00000B38 6A02                            push 	dword 2
  2033 00000B3A EB40                    	jmp	short which_irq
  2034                                  irq3:
  2035                                  	; 20/11/2015
  2036                                  	; 24/10/2015
  2037 00000B3C 2EFF15[7A2F0100]        	call	dword [cs:com2_irq3]
  2038 00000B43 6A03                    	push 	dword 3
  2039 00000B45 EB35                    	jmp	short which_irq
  2040                                  irq4:
  2041                                  	; 20/11/2015
  2042                                  	; 24/10/2015
  2043 00000B47 2EFF15[762F0100]        	call	dword [cs:com1_irq4]
  2044 00000B4E 6A04                            push 	dword 4
  2045 00000B50 EB2A                    	jmp	short which_irq
  2046                                  irq5:
  2047 00000B52 6A05                            push 	dword 5
  2048 00000B54 EB26                    	jmp	short which_irq
  2049                                  irq6:
  2050 00000B56 6A06                            push 	dword 6
  2051 00000B58 EB22                    	jmp	short which_irq
  2052                                  irq7:
  2053 00000B5A 6A07                            push 	dword 7
  2054 00000B5C EB1E                    	jmp	short which_irq
  2055                                  irq8:
  2056 00000B5E 6A08                            push 	dword 8
  2057 00000B60 EB1A                    	jmp	short which_irq
  2058                                  irq9:
  2059 00000B62 6A09                            push 	dword 9
  2060 00000B64 EB16                    	jmp	short which_irq
  2061                                  irq10:
  2062 00000B66 6A0A                            push 	dword 10
  2063 00000B68 EB12                    	jmp	short which_irq
  2064                                  irq11:
  2065 00000B6A 6A0B                            push 	dword 11
  2066 00000B6C EB0E                    	jmp	short which_irq
  2067                                  irq12:
  2068 00000B6E 6A0C                            push 	dword 12
  2069 00000B70 EB0A                    	jmp	short which_irq
  2070                                  irq13:
  2071 00000B72 6A0D                            push 	dword 13
  2072 00000B74 EB06                    	jmp	short which_irq
  2073                                  irq14:
  2074 00000B76 6A0E                            push 	dword 14
  2075 00000B78 EB02                    	jmp	short which_irq
  2076                                  irq15:
  2077 00000B7A 6A0F                            push 	dword 15
  2078                                  	;jmp	short which_irq
  2079                                  
  2080                                  	; 22/01/2017
  2081                                  	; 19/10/2015
  2082                                  	; 29/08/2014
  2083                                  	; 21/08/2014
  2084                                  which_irq:
  2085 00000B7C 870424                  	xchg	eax, [esp]  ; 28/08/2014
  2086 00000B7F 53                      	push	ebx
  2087 00000B80 56                      	push	esi
  2088 00000B81 57                      	push	edi
  2089 00000B82 1E                      	push 	ds
  2090 00000B83 06                      	push 	es
  2091                                  	;
  2092 00000B84 88C3                    	mov	bl, al
  2093                                  	;
  2094 00000B86 B810000000              	mov	eax, KDATA
  2095 00000B8B 8ED8                    	mov	ds, ax
  2096 00000B8D 8EC0                    	mov	es, ax
  2097                                  	; 19/10/2015
  2098 00000B8F FC                      	cld
  2099                                          ; 27/08/2014
  2100 00000B90 8105[D8490100]A000-             add     dword [scr_row], 0A0h
  2100 00000B98 0000               
  2101                                  	;
  2102 00000B9A B417                    	mov	ah, 17h	; blue (1) background, 
  2103                                  			; light gray (7) forecolor
  2104 00000B9C 8B3D[D8490100]                  mov     edi, [scr_row]
  2105 00000BA2 B049                    	mov	al, 'I'
  2106 00000BA4 66AB                    	stosw
  2107 00000BA6 B052                    	mov	al, 'R'
  2108 00000BA8 66AB                    	stosw
  2109 00000BAA B051                    	mov	al, 'Q'
  2110 00000BAC 66AB                    	stosw
  2111 00000BAE B020                    	mov	al, ' '
  2112 00000BB0 66AB                    	stosw
  2113 00000BB2 88D8                    	mov	al, bl
  2114 00000BB4 3C0A                    	cmp	al, 10
  2115 00000BB6 7208                    	jb	short ii1
  2116 00000BB8 B031                    	mov	al, '1'
  2117 00000BBA 66AB                    	stosw
  2118 00000BBC 88D8                    	mov	al, bl
  2119 00000BBE 2C0A                    	sub	al, 10
  2120                                  ii1:
  2121 00000BC0 0430                    	add	al, '0'
  2122 00000BC2 66AB                    	stosw
  2123 00000BC4 B020                    	mov	al, ' '
  2124 00000BC6 66AB                    	stosw
  2125 00000BC8 B021                    	mov	al, '!'
  2126 00000BCA 66AB                    	stosw
  2127 00000BCC B020                    	mov	al, ' '
  2128 00000BCE 66AB                    	stosw
  2129                                  	; 23/02/2015
  2130 00000BD0 80FB07                  	cmp	bl, 7 ; check for IRQ 8 to IRQ 15 
  2131 00000BD3 7604                    	jna	ii2
  2132                                  	; 22/01/2017
  2133 00000BD5 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2134 00000BD7 E6A0                    	out	0A0h, al ; the 2nd 8259
  2135                                  ii2:
  2136 00000BD9 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2137 00000BDB E620                    	out	20h, al ; the 2nd 8259
  2138 00000BDD E9CD010000              	jmp     iiret
  2139                                  	;
  2140                                  	; 22/08/2014
  2141                                  	;mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2142                                  	;out	20h, al	; 8259 PORT
  2143                                  	;
  2144                                  	;pop	es
  2145                                  	;pop	ds
  2146                                  	;pop	edi
  2147                                  	;pop	esi
  2148                                  	;pop	ebx
  2149                                  	;pop 	eax
  2150                                  	;iret
  2151                                  
  2152                                  	; 02/04/2015
  2153                                  	; 25/08/2014
  2154                                  exc0:
  2155 00000BE2 6A00                            push 	dword 0
  2156 00000BE4 E990000000                      jmp     cpu_except
  2157                                  exc1:
  2158 00000BE9 6A01                            push 	dword 1
  2159 00000BEB E989000000                      jmp     cpu_except
  2160                                  exc2:
  2161 00000BF0 6A02                            push 	dword 2
  2162 00000BF2 E982000000                      jmp     cpu_except
  2163                                  exc3:
  2164 00000BF7 6A03                            push 	dword 3
  2165 00000BF9 EB7E                            jmp     cpu_except
  2166                                  exc4:
  2167 00000BFB 6A04                            push 	dword 4
  2168 00000BFD EB7A                            jmp     cpu_except
  2169                                  exc5:
  2170 00000BFF 6A05                            push 	dword 5
  2171 00000C01 EB76                            jmp     cpu_except
  2172                                  exc6:
  2173 00000C03 6A06                            push 	dword 6
  2174 00000C05 EB72                            jmp     cpu_except
  2175                                  exc7:
  2176 00000C07 6A07                            push 	dword 7
  2177 00000C09 EB6E                            jmp     cpu_except
  2178                                  exc8:
  2179                                  	; [esp] = Error code
  2180 00000C0B 6A08                            push 	dword 8
  2181 00000C0D EB5C                            jmp     cpu_except_en
  2182                                  exc9:
  2183 00000C0F 6A09                            push 	dword 9
  2184 00000C11 EB66                            jmp     cpu_except
  2185                                  exc10:
  2186                                  	; [esp] = Error code
  2187 00000C13 6A0A                            push 	dword 10
  2188 00000C15 EB54                            jmp     cpu_except_en
  2189                                  exc11:
  2190                                  	; [esp] = Error code
  2191 00000C17 6A0B                            push 	dword 11
  2192 00000C19 EB50                            jmp     cpu_except_en
  2193                                  exc12:
  2194                                  	; [esp] = Error code
  2195 00000C1B 6A0C                            push 	dword 12
  2196 00000C1D EB4C                            jmp     cpu_except_en
  2197                                  exc13:
  2198                                  	; [esp] = Error code
  2199 00000C1F 6A0D                            push 	dword 13
  2200 00000C21 EB48                            jmp     cpu_except_en
  2201                                  exc14:
  2202                                  	; [esp] = Error code
  2203 00000C23 6A0E                            push 	dword 14
  2204 00000C25 EB44                    	jmp	short cpu_except_en
  2205                                  exc15:
  2206 00000C27 6A0F                            push 	dword 15
  2207 00000C29 EB4E                            jmp     cpu_except
  2208                                  exc16:
  2209 00000C2B 6A10                            push 	dword 16
  2210 00000C2D EB4A                            jmp     cpu_except
  2211                                  exc17:
  2212                                  	; [esp] = Error code
  2213 00000C2F 6A11                            push 	dword 17
  2214 00000C31 EB38                    	jmp	short cpu_except_en
  2215                                  exc18:
  2216 00000C33 6A12                            push 	dword 18
  2217 00000C35 EB42                    	jmp	short cpu_except
  2218                                  exc19:
  2219 00000C37 6A13                            push 	dword 19
  2220 00000C39 EB3E                    	jmp	short cpu_except
  2221                                  exc20:
  2222 00000C3B 6A14                            push 	dword 20
  2223 00000C3D EB3A                    	jmp	short cpu_except
  2224                                  exc21:
  2225 00000C3F 6A15                            push 	dword 21
  2226 00000C41 EB36                    	jmp	short cpu_except
  2227                                  exc22:
  2228 00000C43 6A16                            push 	dword 22
  2229 00000C45 EB32                    	jmp	short cpu_except
  2230                                  exc23:
  2231 00000C47 6A17                            push 	dword 23
  2232 00000C49 EB2E                    	jmp	short cpu_except
  2233                                  exc24:
  2234 00000C4B 6A18                            push 	dword 24
  2235 00000C4D EB2A                    	jmp	short cpu_except
  2236                                  exc25:
  2237 00000C4F 6A19                            push 	dword 25
  2238 00000C51 EB26                    	jmp	short cpu_except
  2239                                  exc26:
  2240 00000C53 6A1A                            push 	dword 26
  2241 00000C55 EB22                    	jmp	short cpu_except
  2242                                  exc27:
  2243 00000C57 6A1B                            push 	dword 27
  2244 00000C59 EB1E                    	jmp	short cpu_except
  2245                                  exc28:
  2246 00000C5B 6A1C                            push 	dword 28
  2247 00000C5D EB1A                    	jmp	short cpu_except
  2248                                  exc29:
  2249 00000C5F 6A1D                            push 	dword 29
  2250 00000C61 EB16                    	jmp	short cpu_except
  2251                                  exc30:
  2252 00000C63 6A1E                            push 	dword 30
  2253 00000C65 EB04                    	jmp	short cpu_except_en
  2254                                  exc31:
  2255 00000C67 6A1F                            push 	dword 31
  2256 00000C69 EB0E                            jmp     short cpu_except
  2257                                  
  2258                                  	; 19/10/2015
  2259                                  	; 19/09/2015
  2260                                  	; 01/09/2015
  2261                                  	; 28/08/2015
  2262                                  	; 28/08/2014
  2263                                  cpu_except_en:
  2264 00000C6B 87442404                	xchg	eax, [esp+4] ; Error code
  2265 00000C6F 36A3[78050300]          	mov	[ss:error_code], eax
  2266 00000C75 58                      	pop	eax  ; Exception number
  2267 00000C76 870424                  	xchg	eax, [esp]
  2268                                  		; eax = eax before exception
  2269                                  		; [esp] -> exception number
  2270                                  		; [esp+4] -> EIP to return
  2271                                  	; 22/01/2017
  2272                                  	; 19/10/2015
  2273                                  	; 19/09/2015
  2274                                  	; 01/09/2015
  2275                                  	; 28/08/2015
  2276                                  	; 29/08/2014
  2277                                  	; 28/08/2014
  2278                                  	; 25/08/2014
  2279                                  	; 21/08/2014
  2280                                  cpu_except:	; CPU Exceptions
  2281 00000C79 FC                      	cld
  2282 00000C7A 870424                  	xchg	eax, [esp] 
  2283                                  		; eax = Exception number
  2284                                  		; [esp] = eax (before exception)	
  2285 00000C7D 53                      	push	ebx
  2286 00000C7E 56                      	push	esi
  2287 00000C7F 57                      	push	edi
  2288 00000C80 1E                      	push 	ds
  2289 00000C81 06                      	push 	es
  2290                                  	; 28/08/2015
  2291 00000C82 66BB1000                	mov	bx, KDATA
  2292 00000C86 8EDB                    	mov	ds, bx
  2293 00000C88 8EC3                    	mov	es, bx
  2294 00000C8A 0F20DB                  	mov	ebx, cr3
  2295 00000C8D 53                      	push	ebx ; (*) page directory
  2296                                  	; 19/10/2015
  2297 00000C8E FC                      	cld
  2298                                  	; 25/03/2015
  2299 00000C8F 8B1D[D0890100]          	mov	ebx, [k_page_dir]
  2300 00000C95 0F22DB                  	mov	cr3, ebx
  2301                                  	; 28/08/2015
  2302 00000C98 83F80E                  	cmp	eax, 0Eh ; 14, PAGE FAULT	
  2303 00000C9B 750F                    	jne	short cpu_except_nfp
  2304 00000C9D E809520000              	call	page_fault_handler
  2305 00000CA2 21C0                    	and 	eax, eax
  2306 00000CA4 0F8401010000                    jz	iiretp ; 01/09/2015
  2307 00000CAA B00E                    	mov	al, 0Eh ; 14
  2308                                  cpu_except_nfp:
  2309                                  	; 23/08/2016
  2310 00000CAC 803D[CA6F0000]03        	cmp	byte [CRT_MODE], 3
  2311 00000CB3 7409                    	je	short cpu_except_mode_3
  2312 00000CB5 50                      	push	eax
  2313 00000CB6 B003                    	mov	al, 3
  2314 00000CB8 E8AB0E0000              	call	_set_mode
  2315 00000CBD 58                      	pop	eax
  2316                                  cpu_except_mode_3:
  2317                                  	; 02/04/2015
  2318 00000CBE BB[0B090000]            	mov	ebx, hang
  2319 00000CC3 875C241C                	xchg	ebx, [esp+28]
  2320                                  		; EIP (points to instruction which faults)
  2321                                  	  	; New EIP (hang)
  2322 00000CC7 891D[7C050300]          	mov	[FaultOffset], ebx
  2323 00000CCD C744242008000000        	mov	dword [esp+32], KCODE ; kernel's code segment
  2324 00000CD5 814C242400020000        	or	dword [esp+36], 200h ; enable interrupts (set IF)
  2325                                  	;
  2326 00000CDD 88C4                    	mov	ah, al
  2327 00000CDF 240F                    	and	al, 0Fh
  2328 00000CE1 3C09                    	cmp	al, 9
  2329 00000CE3 7602                    	jna	short h1ok
  2330 00000CE5 0407                    	add	al, 'A'-':'
  2331                                  h1ok:
  2332 00000CE7 C0EC04                  	shr	ah, 4
  2333 00000CEA 80FC09                  	cmp	ah, 9
  2334 00000CED 7603                    	jna	short h2ok
  2335 00000CEF 80C407                  	add	ah, 'A'-':'
  2336                                  h2ok:	
  2337 00000CF2 86E0                    	xchg 	ah, al	
  2338 00000CF4 66053030                	add	ax, '00'
  2339 00000CF8 66A3[304C0100]          	mov	[excnstr], ax
  2340                                  	;
  2341                                  	; 29/08/2014
  2342 00000CFE A1[7C050300]            	mov	eax, [FaultOffset]
  2343 00000D03 51                      	push	ecx
  2344 00000D04 52                      	push	edx
  2345 00000D05 89E3                    	mov	ebx, esp
  2346                                  	; 28/08/2015
  2347 00000D07 B910000000              	mov	ecx, 16	  ; divisor value to convert binary number
  2348                                  			  ; to hexadecimal string
  2349                                  	;mov	ecx, 10	    ; divisor to convert	
  2350                                  			    ; binary number to decimal string
  2351                                  b2d1:
  2352 00000D0C 31D2                    	xor	edx, edx
  2353 00000D0E F7F1                    	div	ecx
  2354 00000D10 6652                    	push	dx
  2355 00000D12 39C8                    	cmp	eax, ecx
  2356 00000D14 73F6                    	jnb	short b2d1
  2357 00000D16 BF[3B4C0100]            	mov	edi, EIPstr ; EIP value
  2358                                  			    ; points to instruction which faults	
  2359                                  	; 28/08/2015
  2360 00000D1B 89C2                    	mov	edx, eax
  2361                                  b2d2:
  2362                                  	;add	al, '0'
  2363 00000D1D 8A82[1F430000]          	mov	al, [edx+hexchrs]
  2364 00000D23 AA                      	stosb		    ; write hexadecimal digit to its place	
  2365 00000D24 39E3                    	cmp	ebx, esp
  2366 00000D26 7606                    	jna	short b2d3
  2367 00000D28 6658                    	pop	ax
  2368 00000D2A 88C2                    	mov	dl, al
  2369 00000D2C EBEF                    	jmp	short b2d2
  2370                                  b2d3:
  2371 00000D2E B068                    	mov 	al, 'h' ; 28/08/2015
  2372 00000D30 AA                      	stosb
  2373 00000D31 B020                    	mov	al, 20h	    ; space
  2374 00000D33 AA                      	stosb
  2375 00000D34 30C0                    	xor	al, al	    ; to do it an ASCIIZ string	
  2376 00000D36 AA                      	stosb
  2377                                  	;
  2378 00000D37 5A                      	pop	edx
  2379 00000D38 59                      	pop	ecx
  2380                                  	;
  2381 00000D39 B44F                    	mov	ah, 4Fh	; red (4) background, 
  2382                                  			; white (F) forecolor
  2383 00000D3B BE[204C0100]            	mov	esi, exc_msg ; message offset
  2384                                  	;
  2385                                  	; 20/01/2017 (!cpu exception!)
  2386                                  	;
  2387 00000D40 8105[D8490100]A000-             add    dword [scr_row], 0A0h
  2387 00000D48 0000               
  2388 00000D4A 8B3D[D8490100]                  mov    edi, [scr_row]
  2389                                  	;	
  2390 00000D50 C605[5B030300]00        	mov	byte [sysflg], 0  ; system mode
  2391 00000D57 FB                              sti
  2392                                  	;
  2393 00000D58 E8EDFBFFFF              	call 	printk
  2394                                  	;
  2395 00000D5D B410                    	mov	ah, 10h
  2396 00000D5F E881010000              	call	int16h ; getc
  2397                                  	;
  2398 00000D64 B003                    	mov	al, 3
  2399 00000D66 E8FD0D0000              	call	_set_mode
  2400                                  	;
  2401 00000D6B B801000000              	mov	eax, 1
  2402 00000D70 E90ECD0000              	jmp	sysexit ; terminate process !!!
  2403                                  	
  2404                                  	; 22/01/2017
  2405                                  	; 18/04/2016
  2406                                  	; 28/08/2015
  2407                                  	; 23/02/2015
  2408                                  	; 20/08/2014
  2409                                  ignore_int:
  2410 00000D75 50                      	push	eax
  2411 00000D76 53                      	push	ebx ; 23/02/2015
  2412 00000D77 56                      	push	esi
  2413 00000D78 57                      	push	edi
  2414 00000D79 1E                      	push 	ds
  2415 00000D7A 06                      	push 	es
  2416                                  	; 18/04/2016
  2417 00000D7B 66B81000                	mov	ax, KDATA
  2418 00000D7F 8ED8                    	mov	ds, ax
  2419 00000D81 8EC0                    	mov	es, ax
  2420                                  	; 28/08/2015
  2421 00000D83 0F20D8                  	mov	eax, cr3
  2422 00000D86 50                      	push	eax ; (*) page directory
  2423                                  	;
  2424 00000D87 B467                    	mov	ah, 67h	; brown (6) background, 
  2425                                  			; light gray (7) forecolor
  2426 00000D89 BE[E84A0100]            	mov	esi, int_msg ; message offset
  2427                                  piemsg:
  2428                                          ; 27/08/2014
  2429 00000D8E 8105[D8490100]A000-             add     dword [scr_row], 0A0h
  2429 00000D96 0000               
  2430 00000D98 8B3D[D8490100]                  mov     edi, [scr_row]
  2431                                          ;
  2432 00000D9E E8A7FBFFFF              	call 	printk
  2433                                  	;
  2434                                  	; 23/02/2015
  2435 00000DA3 B020                    	mov	al, 20h  ; END OF INTERRUPT COMMAND TO
  2436 00000DA5 E6A0                    	out	0A0h, al ; the 2nd 8259
  2437                                  	; 22/08/2014
  2438 00000DA7 B020                    	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
  2439 00000DA9 E620                    	out	20h, al	; 8259 PORT
  2440                                  iiretp: 
  2441                                  	; 22/01/2017
  2442                                  	; 01/09/2015
  2443                                  	; 28/08/2015
  2444 00000DAB 58                      	pop	eax ; (*) page directory
  2445 00000DAC 0F22D8                  	mov	cr3, eax
  2446                                  iiret:
  2447 00000DAF 07                      	pop	es
  2448 00000DB0 1F                      	pop	ds
  2449 00000DB1 5F                      	pop	edi
  2450 00000DB2 5E                      	pop	esi
  2451 00000DB3 5B                      	pop	ebx ; 29/08/2014
  2452 00000DB4 58                      	pop 	eax
  2453 00000DB5 CF                      	iretd
  2454                                  
  2455                                  	; 23/05/2016
  2456                                  	; 22/08/2014
  2457                                  	; IBM PC/AT BIOS source code ----- 10/06/85 (bios.asm)
  2458                                  	; (INT 1Ah)
  2459                                  	;; Linux (v0.12) source code (main.c) by Linus Torvalds (1991)
  2460                                  time_of_day:
  2461 00000DB6 E8DF5E0000              	call	UPD_IPR			; WAIT TILL UPDATE NOT IN PROGRESS
  2462 00000DBB 726F                            jc      short time_of_day_retn ; 23/05/2016
  2463 00000DBD B000                    	mov	al, CMOS_SECONDS
  2464 00000DBF E8F15E0000              	call	CMOS_READ
  2465 00000DC4 A2[408A0100]            	mov	[time_seconds], al 
  2466 00000DC9 B002                    	mov	al, CMOS_MINUTES
  2467 00000DCB E8E55E0000              	call	CMOS_READ
  2468 00000DD0 A2[418A0100]            	mov	[time_minutes], al 
  2469 00000DD5 B004                    	mov	al, CMOS_HOURS
  2470 00000DD7 E8D95E0000              	call	CMOS_READ
  2471 00000DDC A2[428A0100]                    mov     [time_hours], al
  2472 00000DE1 B006                    	mov	al, CMOS_DAY_WEEK 
  2473 00000DE3 E8CD5E0000              	call	CMOS_READ
  2474 00000DE8 A2[438A0100]            	mov	[date_wday], al
  2475 00000DED B007                     	mov	al, CMOS_DAY_MONTH
  2476 00000DEF E8C15E0000              	call	CMOS_READ
  2477 00000DF4 A2[448A0100]            	mov	[date_day], al
  2478 00000DF9 B008                    	mov	al, CMOS_MONTH
  2479 00000DFB E8B55E0000              	call	CMOS_READ
  2480 00000E00 A2[458A0100]            	mov	[date_month], al
  2481 00000E05 B009                    	mov	al, CMOS_YEAR
  2482 00000E07 E8A95E0000              	call	CMOS_READ
  2483 00000E0C A2[468A0100]            	mov	[date_year], al
  2484 00000E11 B032                    	mov	al, CMOS_CENTURY
  2485 00000E13 E89D5E0000              	call	CMOS_READ
  2486 00000E18 A2[478A0100]            	mov	[date_century], al
  2487                                  	;
  2488 00000E1D B000                    	mov	al, CMOS_SECONDS
  2489 00000E1F E8915E0000              	call 	CMOS_READ
  2490 00000E24 3A05[408A0100]          	cmp	al, [time_seconds]
  2491 00000E2A 758A                    	jne	short time_of_day
  2492                                  
  2493                                  time_of_day_retn:
  2494 00000E2C C3                      	retn
  2495                                  
  2496                                  	; 15/01/2017
  2497                                  	; 10/06/2016
  2498                                  	; 07/06/2016
  2499                                  	; 06/06/2016
  2500                                  	; 23/05/2016
  2501                                  rtc_p:
  2502 00000E2D B101                    	mov	cl, 1 ; 15/01/2017
  2503 00000E2F EB02                    	jmp	short rtc_p0
  2504                                  u_timer: 
  2505                                  	; Timer Events with 18.2 Hz Timer Ticks
  2506                                  	; (and also timer events with RTC seconds)
  2507 00000E31 28C9                    	sub	cl, cl ; mov cl, 0 ; 15/01/2017
  2508                                  rtc_p0:
  2509                                  	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  2510                                  	; Major Modification:
  2511                                  	; Check and Perform Timer Events (for RTC)
  2512                                  	; 25/08/2014 - 07/09/2014
  2513                                  	; Retro UNIX 386 v1:
  2514                                   	; Print Real Time Clock content
  2515                                  	
  2516                                  	; 15/01/2017
  2517 00000E33 880D[60960100]          	mov	byte [priority], cl ; 0 or 1 (not 2)
  2518 00000E39 8A2D[63960100]          	mov	ch, [timer_events]
  2519 00000E3F 20ED                    	and	ch, ch
  2520 00000E41 7420                    	jz	short rtc_p3
  2521                                  
  2522 00000E43 BE[60040300]            	mov	esi, timer_set  ; beginning address of
  2523                                  				; timer events space
  2524                                  rtc_p1:
  2525 00000E48 8B06                    	mov	eax, [esi]	
  2526 00000E4A 20C0                    	and	al, al ; 0 = free, >0 = process no.
  2527 00000E4C 7416                    	jz	short rtc_p4
  2528                                  	;
  2529 00000E4E C1C810                  	ror	eax, 16
  2530                                  	; ah = response value, al = interrupt type
  2531                                  	; 15/01/2017
  2532                                  	; cl = interrupt source
  2533                                  	;       1 = RTC, 0 = PIT  	 	
  2534 00000E51 38C8                    	cmp	al, cl 
  2535 00000E53 750A                    	jne	short rtc_p2 ; not as requested or undefined !
  2536 00000E55 3C01                    	cmp	al, 1 ; 1 ; RTC interrupt ?
  2537 00000E57 7410                    	je	short rtc_p5 ; yes, check for response
  2538                                  	; 06/06/2016 - 18.2 Hz Timer Ticks
  2539 00000E59 836E080A                	sub	dword [esi+8], 10 ; 1 tick = 10
  2540 00000E5D 7613                    	jna	short rtc_p6  ; continue for responding
  2541                                  rtc_p2:
  2542                                  	; 15/01/2017 (cl -> ch)
  2543                                  	; 07/06/2016
  2544 00000E5F FECD                    	dec	ch    ; remain count of timer events	
  2545 00000E61 7501                    	jnz	short rtc_p4
  2546                                  rtc_p3:	 
  2547 00000E63 C3                      	retn
  2548                                  rtc_p4:	
  2549                                  	;cmp	esi, timer_set + 240 ; 15*16 (last event)
  2550                                  	;jnb	short rtc_p3 ; end of timer event space
  2551 00000E64 83C610                  	add	esi, 16 ; next timer event
  2552 00000E67 EBDF                    	jmp	short rtc_p1
  2553                                  rtc_p5:	 
  2554                                  	; current timer count ; 06/06/2016 (182)
  2555 00000E69 816E08B6000000          	sub	dword [esi+8], 182 ; 1 second (10*18.2)
  2556 00000E70 77ED                    	ja	short rtc_p2  ; check for the next 
  2557                                  rtc_p6:	
  2558                                  	; it is the time of response! 
  2559 00000E72 8B5E04                  	mov	ebx, [esi+4] ; set (count limit) value
  2560 00000E75 895E08                  	mov	[esi+8], ebx ; reset count down value
  2561                                  			     ; to count limit
  2562                                  	; 19/12/2016
  2563                                  	; 10/12/2016 - timer callback modification
  2564 00000E78 8B7E0C                  	mov	edi, [esi+12] ; response (or callback) address	
  2565 00000E7B 807E0100                	cmp	byte [esi+1], 0 ; >0 = callback
  2566 00000E7F 762A                    	jna	short rtc_p8
  2567                                  
  2568                                  	; timer callback !
  2569 00000E81 0FB61E                  	movzx	ebx, byte [esi] ; process number (>0)
  2570 00000E84 89D8                    	mov	eax, ebx
  2571 00000E86 C0E302                  	shl	bl, 2 ; *4
  2572 00000E89 89BB[0C010300]          	mov	[ebx+p.tcb-4], edi ; user's callback service addr
  2573 00000E8F 3A05[B3030300]          	cmp	al, [u.uno]
  2574 00000E95 7521                    	jne	short rtc_p9
  2575 00000E97 893D[D0030300]          	mov	[u.tcb], edi
  2576                                  rtc_p7:
  2577                                  	; 15/01/2017
  2578 00000E9D B002                    	mov	al, 2
  2579 00000E9F A2[60960100]            	mov	[priority], al ; 2
  2580                                  	; 10/01/2017
  2581                                  	;mov	byte [u.pri], 2
  2582 00000EA4 A2[A9030300]            	mov	[u.pri], al ; 2
  2583 00000EA9 EBB4                    	jmp	short rtc_p2
  2584                                  rtc_p8:
  2585                                  	; response address is physical address of
  2586                                  	; the program's response (signal return) byte
  2587                                  	; 06/06/2016
  2588                                  	;mov	edi, [esi+12] ; response address
  2589 00000EAB 8827                    	mov	[edi], ah     ; response value 
  2590                                  	;
  2591 00000EAD C1C010                  	rol	eax, 16
  2592                                  	; 15/01/2017
  2593 00000EB0 3A05[B3030300]          	cmp	al, [u.uno] ; running process ?
  2594 00000EB6 74E5                    	je	short rtc_p7
  2595                                  rtc_p9:
  2596                                  	; al = process number  ; 10/06/2016
  2597 00000EB8 B202                    	mov	dl, 2 ; priority, 2 = event (high)	
  2598 00000EBA E8B11D0100              	call	set_run_sequence ; 19/05/2016
  2599 00000EBF EB9E                    	jmp	short rtc_p2 ; 10/06/2016
  2600                                  
  2601                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  2602                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  2603                                  default_irq7:
  2604 00000EC1 6650                    	push	ax
  2605 00000EC3 B00B                    	mov	al, 0Bh  ; In-Service register
  2606 00000EC5 E620                    	out	20h, al
  2607 00000EC7 EB00                            jmp short $+2
  2608 00000EC9 EB00                    	jmp short $+2
  2609 00000ECB E420                    	in	al, 20h
  2610 00000ECD 2480                    	and 	al, 80h ; bit 7 (is it real IRQ 7 or fake?)
  2611 00000ECF 7404                            jz      short irq7_iret ; Fake (spurious) IRQ, do not send EOI 
  2612 00000ED1 B020                            mov     al, 20h ; EOI
  2613 00000ED3 E620                    	out	20h, al 
  2614                                  irq7_iret:
  2615 00000ED5 6658                    	pop	ax
  2616 00000ED7 CF                      	iretd
  2617                                  	
  2618                                  bcd_to_ascii:
  2619                                  	; 25/08/2014
  2620                                  	; INPUT ->
  2621                                  	;	al = Packed BCD number
  2622                                  	; OUTPUT ->
  2623                                  	;	ax  = ASCII word/number
  2624                                  	;
  2625                                  	; Erdogan Tan - 1998 (proc_hex) - TRDOS.ASM (2004-2011)
  2626                                  	;
  2627 00000ED8 D410                    	db 0D4h,10h                     ; Undocumented inst. AAM
  2628                                  					; AH = AL / 10h
  2629                                  					; AL = AL MOD 10h
  2630 00000EDA 660D3030                	or ax,'00'                      ; Make it ASCII based
  2631                                  
  2632 00000EDE 86E0                            xchg ah, al 
  2633                                  	
  2634 00000EE0 C3                      	retn
  2635                                  
  2636                                  ; 15/12/2020
  2637                                  real_mem_16m_64k: 
  2638 00000EE1 0000                    	dw 0	; Real size of system memory (if > 16MB)
  2639                                  		; as number of 64K blocks - 256
  2640                                  		; (This is for saving real system memory
  2641                                  		; because if system memory is larger than
  2642                                  		; 3 GB and if a VESA VBE video bios
  2643                                  		; is detected, 'mem_16m_64K' may be
  2644                                  		; decreased to reserve LFB space 
  2645                                  		; at the end of system memory.)
  2646                                  		; Upper memory space from LFB base address
  2647                                  		; to 4GB will not be included by M.A.T.
  2648                                  def_LFB_addr:	
  2649 00000EE3 0000                    	dw 0 	; HW of default LFB addr (for mode 118h)	
  2650                                  	
  2651                                  
  2652                                  %include 'keyboard.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - keyboard.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 15/01/2017
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 17/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; keyboard.inc (17/10/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - KEYBOARD.INC
    20                              <1> ; Last Modification: 17/10/2015
    21                              <1> ;		    (Keyboard Data is in 'KYBDATA.INC')	
    22                              <1> ;
    23                              <1> ; ///////// KEYBOARD FUNCTIONS (PROCEDURES) ///////////////
    24                              <1> 
    25                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
    26                              <1> 
    27                              <1> ; 03/12/2014
    28                              <1> ; 26/08/2014
    29                              <1> ; KEYBOARD I/O
    30                              <1> ; (INT_16h - Retro UNIX 8086 v1 - U9.ASM, 30/06/2014)
    31                              <1> 
    32                              <1> ;NOTE: 'k0' to 'k7' are name of OPMASK registers.
    33                              <1> ;	(The reason of using '_k' labels!!!) (27/08/2014)    
    34                              <1> ;NOTE: 'NOT' keyword is '~' unary operator in NASM.
    35                              <1> ;	('NOT LC_HC' --> '~LC_HC') (bit reversing operator)
    36                              <1> 
    37                              <1> int16h:	; 30/06/2015
    38                              <1> ;getc:
    39 00000EE5 9C                  <1> 	pushfd	; 28/08/2014
    40 00000EE6 0E                  <1> 	push 	cs
    41 00000EE7 E801000000          <1> 	call 	KEYBOARD_IO_1 ; getc_int
    42 00000EEC C3                  <1> 	retn	
    43                              <1> 
    44                              <1> getc_int:
    45                              <1> 	; 28/02/2015
    46                              <1> 	; 03/12/2014 (derivation from pc-xt-286 bios source code -1986-, 
    47                              <1> 	;	      instead of pc-at bios - 1985-)
    48                              <1> 	; 28/08/2014 (_k1d)
    49                              <1> 	; 30/06/2014
    50                              <1> 	; 03/03/2014
    51                              <1> 	; 28/02/2014
    52                              <1> 	; Derived from "KEYBOARD_IO_1" procedure of IBM "pc-xt-286" 
    53                              <1> 	; rombios source code (21/04/1986)
    54                              <1> 	;	 'keybd.asm', INT 16H, KEYBOARD_IO
    55                              <1> 	;
    56                              <1> 	; KYBD --- 03/06/86  KEYBOARD BIOS
    57                              <1> 	;
    58                              <1> 	;--- INT 16 H -----------------------------------------------------------------
    59                              <1> 	; KEYBOARD I/O								      :
    60                              <1> 	;	THESE ROUTINES PROVIDE READ KEYBOARD SUPPORT			      :
    61                              <1> 	; INPUT									      :
    62                              <1> 	;	(AH)= 00H  READ THE NEXT ASCII CHARACTER ENTERED FROM THE KEYBOARD,   :
    63                              <1> 	;		   RETURN THE RESULT IN (AL), SCAN CODE IN (AH).              :
    64                              <1> 	;		   THIS IS THE COMPATIBLE READ INTERFACE, EQUIVALENT TO THE   :
    65                              <1> 	;                  STANDARD PC OR PCAT KEYBOARD				      :	
    66                              <1> 	;-----------------------------------------------------------------------------:
    67                              <1> 	;	(AH)= 01H  SET THE ZERO FLAG TO INDICATE IF AN ASCII CHARACTER IS     :
    68                              <1> 	;		   AVAILABLE TO BE READ FROM THE KEYBOARD BUFFER.	      :
    69                              <1> 	;		   (ZF)= 1 -- NO CODE AVAILABLE			              :
    70                              <1> 	;		   (ZF)= 0 -- CODE IS AVAILABLE  (AX)= CHARACTER              :
    71                              <1> 	;		   IF (ZF)= 0, THE NEXT CHARACTER IN THE BUFFER TO BE READ IS :
    72                              <1> 	;		   IN (AX), AND THE ENTRY REMAINS IN THE BUFFER.              :
    73                              <1> 	;		   THIS WILL RETURN ONLY PC/PCAT KEYBOARD COMPATIBLE CODES    :
    74                              <1> 	;-----------------------------------------------------------------------------:	
    75                              <1> 	;	(AH)= 02H  RETURN THE CURRENT SHIFT STATUS IN AL REGISTER             :
    76                              <1> 	;		   THE BIT SETTINGS FOR THIS CODE ARE INDICATED IN THE        :
    77                              <1> 	;		   EQUATES FOR @KB_FLAG		                              :
    78                              <1> 	;-----------------------------------------------------------------------------:	
    79                              <1> 	;	(AH)= 03H  SET TYPAMATIC RATE AND DELAY                               :
    80                              <1> 	;	      (AL) = 05H                                                      :
    81                              <1> 	;	      (BL) = TYPAMATIC RATE (BITS 5 - 7 MUST BE RESET TO 0)           :
    82                              <1> 	;		       							      :
    83                              <1> 	;                     REGISTER     RATE      REGISTER     RATE                :
    84                              <1> 	;                      VALUE     SELECTED     VALUE     SELECTED              :
    85                              <1> 	;                     --------------------------------------------            :
    86                              <1> 	;			00H        30.0        10H        7.5                 :
    87                              <1> 	;			01H        26.7        11H        6.7                 :
    88                              <1> 	;			02H        24.0        12H        6.0                 :
    89                              <1> 	;			03H        21.8        13H        5.5                 :
    90                              <1> 	;			04H        20.0        14H        5.0                 :
    91                              <1> 	;			05H        18.5        15H        4.6                 :
    92                              <1> 	;			06H        17.1        16H        4.3                 :
    93                              <1> 	;			07H        16.0        17H        4.0                 :
    94                              <1> 	;			08H        15.0        18H        3.7                 :
    95                              <1> 	;			09H        13.3        19H        3.3                 :
    96                              <1> 	;			0AH        12.0        1AH        3.0                 :
    97                              <1> 	;			0BH        10.9        1BH        2.7                 :
    98                              <1>         ;			0CH        10.0        1CH        2.5                 :
    99                              <1> 	;			0DH         9.2        1DH        2.3                 :
   100                              <1> 	;			0EH         8.6        1EH        2.1                 :
   101                              <1> 	;			0FH         8.0        1FH        2.0                 :
   102                              <1> 	;									      :
   103                              <1> 	;	      (BH) = TYPAMATIC DELAY  (BITS 2 - 7 MUST BE RESET TO 0)         :
   104                              <1> 	;		       							      :
   105                              <1> 	;                     REGISTER     DELAY                                      :
   106                              <1> 	;                      VALUE       VALUE                                      :
   107                              <1> 	;                     ------------------                                      :
   108                              <1> 	;			00H        250 ms                                     :
   109                              <1> 	;			01H        500 ms                                     :
   110                              <1> 	;			02H        750 ms                                     :
   111                              <1> 	;			03H       1000 ms                                     :
   112                              <1> 	;-----------------------------------------------------------------------------:
   113                              <1> 	;	(AH)= 05H  PLACE ASCII CHARACTER/SCAN CODE COMBINATION IN KEYBOARD    :
   114                              <1> 	;		   BUFFER AS IF STRUCK FROM KEYBOARD                          :
   115                              <1> 	;		   ENTRY:  (CL) = ASCII CHARACTER		              :
   116                              <1> 	;		           (CH) = SCAN CODE                                   :
   117                              <1> 	;		   EXIT:   (AH) = 00H = SUCCESSFUL OPERATION                  :
   118                              <1> 	;		           (AL) = 01H = UNSUCCESSFUL - BUFFER FULL            :
   119                              <1> 	;		   FLAGS:  CARRY IF ERROR                                     :
   120                              <1> 	;-----------------------------------------------------------------------------:		
   121                              <1> 	;	(AH)= 10H  EXTENDED READ INTERFACE FOR THE ENHANCED KEYBOARD,         :
   122                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=0                            :
   123                              <1> 	;-----------------------------------------------------------------------------:
   124                              <1> 	;	(AH)= 11H  EXTENDED ASCII STATUS FOR THE ENHANCED KEYBOARD,           :
   125                              <1> 	;		   OTHERWISE SAME AS FUNCTION AH=1                            :
   126                              <1> 	;-----------------------------------------------------------------------------:	
   127                              <1> 	;	(AH)= 12H  RETURN THE EXTENDED SHIFT STATUS IN AX REGISTER            :
   128                              <1> 	;		   AL = BITS FROM KB_FLAG, AH = BITS FOR LEFT AND RIGHT       :
   129                              <1> 	;		   CTL AND ALT KEYS FROM KB_FLAG_1 AND KB_FLAG_3              :
   130                              <1> 	; OUTPUT					                              :
   131                              <1> 	;	AS NOTED ABOVE, ONLY (AX) AND FLAGS CHANGED	                      :
   132                              <1> 	;	ALL REGISTERS RETAINED		                                      :
   133                              <1> 	;------------------------------------------------------------------------------
   134                              <1> 
   135                              <1> ; 15/01/2017
   136                              <1> ; 14/01/2017
   137                              <1> ; 02/01/2017
   138                              <1> ; 29/05/2016
   139                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   140                              <1> int32h:  ; Keyboard BIOS
   141                              <1> 
   142                              <1> KEYBOARD_IO_1:	
   143                              <1> 	;sti				; INTERRUPTS BACK ON
   144                              <1> 	; 29/05/2016
   145 00000EED 80642408BE          <1>         and     byte [esp+8], 10111110b ; clear zero flag and cary flag
   146                              <1> 	;
   147 00000EF2 1E                  <1> 	push	ds			; SAVE CURRENT DS
   148 00000EF3 53                  <1> 	push	ebx			; SAVE BX TEMPORARILY
   149                              <1> 	;push	ecx			; SAVE CX TEMPORARILY
   150 00000EF4 66BB1000            <1>         mov     bx, KDATA 
   151 00000EF8 8EDB                <1> 	mov	ds, bx			; PUT SEGMENT VALUE OF DATA AREA INTO DS
   152                              <1> 
   153                              <1> 	; 14/01/2017
   154 00000EFA 8B1C24              <1> 	mov	ebx, [esp]
   155                              <1> 	;; 15/01/2017
   156                              <1> 	; 02/01/2017
   157                              <1> 	;;mov	byte [intflg], 32h	; keyboard interrupt 
   158 00000EFD FB                  <1> 	sti
   159                              <1> 	;
   160                              <1> 
   161 00000EFE 08E4                <1> 	or	ah, ah			; CHECK FOR (AH)= 00H
   162 00000F00 743A                <1> 	jz	short _K1		; ASCII_READ
   163 00000F02 FECC                <1> 	dec	ah                      ; CHECK FOR (AH)= 01H
   164 00000F04 7453                <1>         jz      short _K2               ; ASCII_STATUS
   165 00000F06 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 02H
   166 00000F08 0F8494000000        <1>         jz      _K3                     ; SHIFT STATUS
   167 00000F0E FECC                <1> 	dec	ah			; CHECK FOR (AH)= 03H	
   168 00000F10 0F8493000000        <1>         jz      _K300                   ; SET TYPAMATIC RATE/DELAY
   169 00000F16 80EC02              <1> 	sub	ah, 2			; CHECK FOR (AH)= 05H	
   170 00000F19 0F84BC000000        <1>         jz      _K500                   ; KEYBOARD WRITE         
   171                              <1> _KIO1:	
   172 00000F1F 80EC0B              <1> 	sub	ah, 11			; AH =  10H
   173 00000F22 740C                <1> 	jz	short _K1E		; EXTENDED ASCII READ
   174 00000F24 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 11H
   175 00000F26 7422                <1> 	jz	short _K2E		; EXTENDED_ASCII_STATUS
   176 00000F28 FECC                <1> 	dec	ah			; CHECK FOR (AH)= 12H
   177 00000F2A 7458                <1> 	jz	short _K3E		; EXTENDED_SHIFT_STATUS
   178                              <1> _KIO_EXIT:
   179                              <1> 	; 02/01/2017
   180 00000F2C FA                  <1> 	cli
   181                              <1> 	;;mov	byte [intflg], 0 ;; 15/01/2017
   182                              <1> 	;
   183                              <1> 	;pop	ecx			; RECOVER REGISTER
   184 00000F2D 5B                  <1> 	pop	ebx			; RECOVER REGISTER
   185 00000F2E 1F                  <1> 	pop	ds			; RECOVER SEGMENT
   186 00000F2F CF                  <1> 	iretd				; INVALID COMMAND, EXIT
   187                              <1> 
   188                              <1> 	;-----	ASCII CHARACTER
   189                              <1> _K1E:	
   190 00000F30 E8D3000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER (EXTENDED)
   191 00000F35 E848010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
   192 00000F3A EBF0                <1> 	jmp	short _KIO_EXIT         ; GIVE IT TO THE CALLER
   193                              <1> _K1:	
   194 00000F3C E8C7000000          <1> 	call	_K1S			; GET A CHARACTER FROM THE BUFFER
   195 00000F41 E847010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
   196 00000F46 72F4                <1> 	jc	short _K1		; CARRY SET MEANS TROW CODE AWAY
   197                              <1> _K1A:
   198 00000F48 EBE2                <1> 	jmp	short _KIO_EXIT         ; RETURN TO CALLER
   199                              <1> 
   200                              <1> 	;-----	ASCII STATUS
   201                              <1> _K2E:	
   202 00000F4A E804010000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER (EXTENDED)
   203 00000F4F 7420                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
   204 00000F51 9C                  <1> 	pushf				; SAVE ZF FROM TEST
   205 00000F52 E82B010000          <1> 	call	_KIO_E_XLAT		; ROUTINE TO XLATE FOR EXTENDED CALLS
   206 00000F57 EB17                <1> 	jmp	short _K2A	        ; GIVE IT TO THE CALLER
   207                              <1> _K2:	
   208 00000F59 E8F5000000          <1> 	call	_K2S			; TEST FOR CHARACTER IN BUFFER
   209 00000F5E 7411                <1> 	jz	short _K2B		; RETURN IF BUFFER EMPTY
   210 00000F60 9C                  <1> 	pushf				; SAVE ZF FROM TEST
   211 00000F61 E827010000          <1> 	call	_KIO_S_XLAT		; ROUTINE TO XLATE FOR STANDARD CALLS
   212 00000F66 7308                <1> 	jnc	short _K2A	        ; CARRY CLEAR MEANS PASS VALID CODE
   213 00000F68 9D                  <1> 	popf				; INVALID CODE FOR THIS TYPE OF CALL
   214 00000F69 E89A000000          <1> 	call	_K1S			; THROW THE CHARACTER AWAY
   215 00000F6E EBE9                <1> 	jmp	short _K2		; GO LOOK FOR NEXT CHAR, IF ANY
   216                              <1> _K2A:
   217 00000F70 9D                  <1> 	popf				; RESTORE ZF FROM TEST
   218                              <1> _K2B:
   219                              <1> 	; 02/01/2017
   220 00000F71 FA                  <1> 	cli
   221                              <1> 	;; mov	byte [intflg], 0 ;; 15/01/2017
   222                              <1> 	;
   223                              <1> 	;pop	ecx			; RECOVER REGISTER
   224 00000F72 5B                  <1> 	pop	ebx			; RECOVER REGISTER
   225 00000F73 1F                  <1> 	pop	ds			; RECOVER SEGMENT
   226                              <1> 	; (*) 29/05/2016
   227                              <1> 	; (*) retf 4			; THROW AWAY (e)FLAGS
   228 00000F74 7208                <1> 	jc	short _k2d
   229 00000F76 7505                <1> 	jnz	short _k2c
   230 00000F78 804C240840          <1> 	or	byte [esp+8], 01000000b	; set zero flag bit of eflags register
   231                              <1> _k2c:
   232 00000F7D CF                  <1> 	iretd
   233                              <1> _k2d:
   234                              <1> 	; 29/05/2016 -set carry flag on stack-
   235                              <1> 	; [esp] = EIP
   236                              <1> 	; [esp+4] = CS
   237                              <1> 	; [esp+8] = E-FLAGS
   238 00000F7E 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
   239                              <1> 	; [esp+12] = ESP (user)
   240                              <1> 	; [esp+16] = SS (User)
   241 00000F83 CF                  <1> 	iretd
   242                              <1> 
   243                              <1> 	
   244                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
   245                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
   246                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
   247                              <1> 	; // RETF instruction:
   248                              <1> 	;
   249                              <1> 	; IF OperandMode=32 THEN
   250                              <1>  	;    Load CS:EIP from stack;
   251                              <1>  	;    Set CS RPL to CPL;
   252                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
   253                              <1>  	;    Load SS:eSP from stack;
   254                              <1>  	; ELSE (* OperandMode=16 *)
   255                              <1>  	;    Load CS:IP from stack;
   256                              <1>  	;    Set CS RPL to CPL;
   257                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
   258                              <1> 	;    Load SS:eSP from stack;
   259                              <1>  	; FI;
   260                              <1> 	;
   261                              <1> 	; //
   262                              <1> 
   263                              <1> 	;-----	SHIFT STATUS
   264                              <1> _K3E:                                   ; GET THE EXTENDED SHIFT STATUS FLAGS
   265 00000F84 8A25[966F0000]      <1> 	mov	ah, [KB_FLAG_1]		; GET SYSTEM SHIFT KEY STATUS
   266 00000F8A 80E404              <1> 	and	ah, SYS_SHIFT		; MASK ALL BUT SYS KEY BIT
   267                              <1> 	;mov	cl, 5			; SHIFT THEW SYSTEMKEY BIT OVER TO
   268                              <1> 	;shl	ah, cl			; BIT 7 POSITION
   269 00000F8D C0E405              <1>         shl	ah, 5
   270 00000F90 A0[966F0000]        <1> 	mov	al, [KB_FLAG_1]		; GET SYSTEM SHIFT STATES BACK
   271 00000F95 2473                <1> 	and	al, 01110011b		; ELIMINATE SYS SHIFT, HOLD_STATE AND INS_SHIFT
   272 00000F97 08C4                <1> 	or	ah, al                  ; MERGE REMAINING BITS INTO AH
   273 00000F99 A0[986F0000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT CTL AND ALT
   274 00000F9E 240C                <1> 	and	al, 00001100b		; ELIMINATE LC_E0 AND LC_E1
   275 00000FA0 08C4                <1> 	or	ah, al			; OR THE SHIFT FLAGS TOGETHER
   276                              <1> _K3:
   277 00000FA2 A0[956F0000]        <1> 	mov	al, [KB_FLAG]		; GET THE SHIFT STATUS FLAGS
   278                              <1> 	;jmp	short _KIO_EXIT		; RETURN TO CALLER
   279 00000FA7 EB83                <1> 	jmp	_KIO_EXIT
   280                              <1> 
   281                              <1> 	;-----	SET TYPAMATIC RATE AND DELAY
   282                              <1> _K300:
   283 00000FA9 3C05                <1> 	cmp	al, 5			; CORRECT FUNCTION CALL?
   284                              <1> 	;jne	short _KIO_EXIT		; NO, RETURN
   285 00000FAB 0F857BFFFFFF        <1>      	jne	_KIO_EXIT
   286 00000FB1 F6C3E0              <1> 	test	bl, 0E0h		; TEST FOR OUT-OF-RANGE RATE
   287 00000FB4 0F8572FFFFFF        <1>         jnz     _KIO_EXIT               ; RETURN IF SO
   288 00000FBA F6C7FC              <1> 	test	BH, 0FCh		; TEST FOR OUT-OF-RANGE DELAY
   289 00000FBD 0F8569FFFFFF        <1>         jnz     _KIO_EXIT               ; RETURN IF SO
   290 00000FC3 B0F3                <1> 	mov	al, KB_TYPA_RD		; COMMAND FOR TYPAMATIC RATE/DELAY		
   291 00000FC5 E8DA060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
   292                              <1> 	;mov	cx, 5			; SHIFT COUNT
   293                              <1> 	;shl	bh, cl			; SHIFT DELAY OVER
   294 00000FCA C0E705              <1> 	shl	bh, 5
   295 00000FCD 88D8                <1> 	mov	al, bl			; PUT IN RATE
   296 00000FCF 08F8                <1> 	or	al, bh			; AND DELAY
   297 00000FD1 E8CE060000          <1> 	call	SND_DATA		; SEND TO KEYBOARD	
   298 00000FD6 E951FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER
   299                              <1> 
   300                              <1> 	;-----	WRITE TO KEYBOARD BUFFER
   301                              <1> _K500:
   302 00000FDB 56                  <1> 	push	esi			; SAVE SI (esi)
   303 00000FDC FA                  <1> 	cli				; 
   304 00000FDD 8B1D[A66F0000]      <1>      	mov	ebx, [BUFFER_TAIL]	; GET THE 'IN TO' POINTER TO THE BUFFER
   305 00000FE3 89DE                <1> 	mov	esi, ebx		; SAVE A COPY IN CASE BUFFER NOT FULL
   306 00000FE5 E8D3000000          <1> 	call	_K4			; BUMP THE POINTER TO SEE IF BUFFER IS FULL
   307 00000FEA 3B1D[A26F0000]      <1> 	cmp	ebx, [BUFFER_HEAD]	; WILL THE BUFFER OVERRUN IF WE STORE THIS?
   308 00000FF0 740D                <1> 	je	short _K502		; YES - INFORM CALLER OF ERROR		
   309 00000FF2 66890E              <1> 	mov	[esi], cx		; NO - PUT ASCII/SCAN CODE INTO BUFFER	
   310 00000FF5 891D[A66F0000]      <1> 	mov	[BUFFER_TAIL], ebx	; ADJUST 'IN TO' POINTER TO REFLECT CHANGE
   311 00000FFB 28C0                <1> 	sub	al, al			; TELL CALLER THAT OPERATION WAS SUCCESSFUL
   312 00000FFD EB02                <1> 	jmp	short _K504		; SUB INSTRUCTION ALSO RESETS CARRY FLAG
   313                              <1> _K502:
   314 00000FFF B001                <1> 	mov	al, 01h			; BUFFER FULL INDICATION
   315                              <1> _K504:
   316 00001001 FB                  <1> 	sti				
   317 00001002 5E                  <1> 	pop	esi			; RECOVER SI (esi)
   318 00001003 E924FFFFFF          <1>         jmp     _KIO_EXIT               ; RETURN TO CALLER WITH STATUS IN AL
   319                              <1> 
   320                              <1> 	;-----	READ THE KEY TO FIGURE OUT WHAT TO DO -----
   321                              <1> _K1S:
   322 00001008 FA                  <1> 	cli	; 03/12/2014
   323 00001009 8B1D[A26F0000]      <1>         mov     ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
   324 0000100F 3B1D[A66F0000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
   325                              <1> 	;jne	short _K1U		; IF ANYTHING IN BUFFER SKIP INTERRUPT
   326 00001015 750F                <1> 	jne	short _k1x ; 03/12/2014
   327                              <1> 	;
   328                              <1> 	; 03/12/2014
   329                              <1> 	; 28/08/2014
   330                              <1> 	; PERFORM OTHER FUNCTION ?? here !
   331                              <1> 	;; MOV	AX, 9002h		; MOVE IN WAIT CODE & TYPE
   332                              <1> 	;; INT 	15H			; PERFORM OTHER FUNCTION
   333                              <1> _K1T:                                   ; ASCII READ
   334 00001017 FB                  <1> 	sti				; INTERRUPTS BACK ON DURING LOOP
   335 00001018 90                  <1> 	nop				; ALLOW AN INTERRUPT TO OCCUR
   336                              <1> _K1U:	
   337 00001019 FA                  <1> 	cli				; INTERRUPTS BACK OFF
   338 0000101A 8B1D[A26F0000]      <1>         mov    	ebx, [BUFFER_HEAD] 	; GET POINTER TO HEAD OF BUFFER
   339 00001020 3B1D[A66F0000]      <1>         cmp     ebx, [BUFFER_TAIL] 	; TEST END OF BUFFER
   340                              <1> _k1x:
   341 00001026 53                  <1> 	push	ebx			; SAVE ADDRESS		
   342 00001027 9C                  <1> 	pushf				; SAVE FLAGS
   343 00001028 E82F070000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   344 0000102D 8A1D[976F0000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   345 00001033 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   346 00001035 80E307              <1> 	and	bl, 07h	; KB_LEDS	; ISOLATE INDICATOR BITS
   347 00001038 7406                <1> 	jz	short _K1V		; IF NO CHANGE BYPASS UPDATE
   348 0000103A E8C9060000          <1> 	call	SND_LED1
   349 0000103F FA                  <1> 	cli				; DISABLE INTERRUPTS
   350                              <1> _K1V:
   351 00001040 9D                  <1> 	popf				; RESTORE FLAGS
   352 00001041 5B                  <1> 	pop	ebx			; RESTORE ADDRESS
   353 00001042 74D3                <1>         je      short _K1T              ; LOOP UNTIL SOMETHING IN BUFFER
   354                              <1> 	;
   355 00001044 668B03              <1> 	mov	ax, [ebx] 		; GET SCAN CODE AND ASCII CODE
   356 00001047 E871000000          <1>         call    _K4                     ; MOVE POINTER TO NEXT POSITION
   357 0000104C 891D[A26F0000]      <1>         mov     [BUFFER_HEAD], ebx      ; STORE VALUE IN VARIABLE
   358 00001052 C3                  <1> 	retn				; RETURN
   359                              <1> 
   360                              <1> 	;-----	READ THE KEY TO SEE IF ONE IS PRESENT -----
   361                              <1> _K2S:
   362 00001053 FA                  <1> 	cli				; INTERRUPTS OFF
   363 00001054 8B1D[A26F0000]      <1>         mov     ebx, [BUFFER_HEAD]      ; GET HEAD POINTER
   364 0000105A 3B1D[A66F0000]      <1>         cmp     ebx, [BUFFER_TAIL]      ; IF EQUAL (Z=1) THEN NOTHING THERE
   365 00001060 668B03              <1> 	mov	ax, [ebx]
   366 00001063 9C                  <1> 	pushf				; SAVE FLAGS
   367 00001064 6650                <1> 	push	ax			; SAVE CODE
   368 00001066 E8F1060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   369 0000106B 8A1D[976F0000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   370 00001071 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   371 00001073 80E307              <1> 	and	bl, 07h ; KB_LEDS	; ISOLATE INDICATOR BITS
   372 00001076 7405                <1> 	jz	short _K2T		; IF NO CHANGE BYPASS UPDATE
   373 00001078 E874060000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
   374                              <1> _K2T:
   375 0000107D 6658                <1> 	pop	ax			; RESTORE CODE
   376 0000107F 9D                  <1> 	popf				; RESTORE FLAGS
   377 00001080 FB                  <1> 	sti				; INTERRUPTS BACK ON
   378 00001081 C3                  <1> 	retn				; RETURN
   379                              <1> 
   380                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR EXTENDED CALLS -----
   381                              <1> _KIO_E_XLAT:
   382 00001082 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
   383 00001084 7506                <1> 	jne	short _KIO_E_RET	; NO, PASS IT ON
   384 00001086 08E4                <1>         or 	ah, ah			; AH = 0 IS SPECIAL CASE
   385 00001088 7402                <1>         jz	short _KIO_E_RET        ; PASS THIS ON UNCHANGED
   386 0000108A 30C0                <1> 	xor	al, al			; OTHERWISE SET AL = 0
   387                              <1> _KIO_E_RET:				
   388 0000108C C3                  <1> 	retn				; GO BACK
   389                              <1> 
   390                              <1> 	;-----	ROUTINE TO TRANSLATE SCAN CODE PAIRS FOR STANDARD CALLS -----
   391                              <1> _KIO_S_XLAT:
   392 0000108D 80FCE0              <1> 	cmp	ah, 0E0h		; IS IT KEYPAD ENTER OR / ?
   393 00001090 750F                <1> 	jne	short _KIO_S2		; NO, CONTINUE
   394 00001092 3C0D                <1> 	cmp	al, 0Dh			; KEYPAD ENTER CODE?
   395 00001094 7408                <1>         je	short _KIO_S1		; YES, MASSAGE A BIT
   396 00001096 3C0A                <1> 	cmp	al, 0Ah			; CTRL KEYPAD ENTER CODE?
   397 00001098 7404                <1>         je	short _KIO_S1		; YES, MASSAGE THE SAME
   398 0000109A B435                <1> 	mov	ah, 35h			; NO, MUST BE KEYPAD /
   399                              <1> _kio_ret: ; 03/12/2014
   400 0000109C F8                  <1> 	clc
   401 0000109D C3                  <1> 	retn
   402                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
   403                              <1> _KIO_S1:				
   404 0000109E B41C                <1> 	mov	ah, 1Ch			; CONVERT TO COMPATIBLE OUTPUT
   405                              <1> 	;jmp	short _KIO_USE		; GIVE TO CALLER
   406 000010A0 C3                  <1> 	retn
   407                              <1> _KIO_S2:		
   408 000010A1 80FC84              <1> 	cmp	ah, 84h			; IS IT ONE OF EXTENDED ONES?
   409 000010A4 7715                <1> 	ja	short _KIO_DIS		; YES, THROW AWAY AND GET ANOTHER CHAR
   410 000010A6 3CF0                <1> 	cmp	al, 0F0h		; IS IT ONE OF THE FILL-INs?
   411 000010A8 7506                <1>         jne	short _KIO_S3		; NO, TRY LAST TEST
   412 000010AA 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
   413 000010AC 740C                <1>         jz	short _KIO_USE		; PASS THIS ON UNCHANGED
   414 000010AE EB0B                <1> 	jmp	short _KIO_DIS		; THROW AWAY THE REST
   415                              <1> _KIO_S3:
   416 000010B0 3CE0                <1> 	cmp	al, 0E0h		; IS IT AN EXTENSION OF A PREVIOUS ONE?
   417                              <1> 	;jne	short _KIO_USE		; NO, MUST BE A STANDARD CODE
   418 000010B2 75E8                <1> 	jne	short _kio_ret
   419 000010B4 08E4                <1> 	or	ah, ah			; AH = 0 IS SPECIAL CASE
   420 000010B6 7402                <1>         jz	short _KIO_USE		; JUMP IF AH = 0
   421 000010B8 30C0                <1> 	xor	al, al			; CONVERT TO COMPATIBLE OUTPUT
   422                              <1> 	;jmp	short _KIO_USE		; PASS IT ON TO CALLER
   423                              <1> _KIO_USE:
   424                              <1> 	;clc				; CLEAR CARRY TO INDICATE GOOD CODE
   425 000010BA C3                  <1> 	retn				; RETURN	
   426                              <1> _KIO_DIS:
   427 000010BB F9                  <1> 	stc				; SET CARRY TO INDICATE DISCARD CODE
   428 000010BC C3                  <1> 	retn				; RETURN
   429                              <1> 
   430                              <1> 	;-----	INCREMENT BUFFER POINTER ROUTINE -----
   431                              <1> _K4:    
   432 000010BD 43                  <1> 	inc     ebx
   433 000010BE 43                  <1> 	inc	ebx			; MOVE TO NEXT WORD IN LIST
   434 000010BF 3B1D[9E6F0000]      <1>         cmp     ebx, [BUFFER_END] 	; AT END OF BUFFER?
   435                              <1>         ;jne    short _K5               ; NO, CONTINUE
   436 000010C5 7206                <1> 	jb	short _K5
   437 000010C7 8B1D[9A6F0000]      <1>         mov     ebx, [BUFFER_START]     ; YES, RESET TO BUFFER BEGINNING
   438                              <1> _K5:
   439 000010CD C3                  <1> 	retn
   440                              <1> 
   441                              <1> ; 20/02/2015
   442                              <1> ; 05/12/2014
   443                              <1> ; 26/08/2014
   444                              <1> ; KEYBOARD (HARDWARE) INTERRUPT -  IRQ LEVEL 1
   445                              <1> ; (INT_09h - Retro UNIX 8086 v1 - U9.ASM, 07/03/2014)
   446                              <1> ;
   447                              <1> ; Derived from "KB_INT_1" procedure of IBM "pc-at" 
   448                              <1> ; rombios source code (06/10/1985)
   449                              <1> ; 'keybd.asm', HARDWARE INT 09h - (IRQ Level 1)
   450                              <1> 
   451                              <1> ; EQUATES (IBM PC-XT-286 BIOS, 1986, 'POSQEQU.INC')
   452                              <1> 
   453                              <1> ;--------- 8042 COMMANDS -------------------------------------------------------
   454                              <1> ENA_KBD		equ	0AEh		; ENABLE KEYBOARD COMMAND
   455                              <1> DIS_KBD		equ	0ADh		; DISABLE KEYBOARD COMMAND
   456                              <1> SHUT_CMD	equ	0FEh		; CAUSE A SHUTDOWN COMMAND
   457                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
   458                              <1> STATUS_PORT	equ	064h		; 8042 STATUS PORT
   459                              <1> INPT_BUF_FULL	equ	00000010b 	; 1 = +INPUT BUFFER FULL
   460                              <1> PORT_A		equ	060h		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
   461                              <1> ;---------- 8042 KEYBOARD RESPONSE ---------------------------------------------
   462                              <1> KB_ACK		equ	0FAh		; ACKNOWLEDGE PROM TRANSMISSION
   463                              <1> KB_RESEND	equ	0FEh		; RESEND REQUEST
   464                              <1> KB_OVER_RUN	equ	0FFh		; OVER RUN SCAN CODE
   465                              <1> ;---------- KEYBOARD/LED COMMANDS ----------------------------------------------
   466                              <1> KB_ENABLE	equ	0F4h		; KEYBOARD ENABLE
   467                              <1> LED_CMD		equ	0EDh		; LED WRITE COMMAND
   468                              <1> KB_TYPA_RD	equ	0F3h		; TYPAMATIC RATE/DELAY COMMAND
   469                              <1> ;---------- KEYBOARD SCAN CODES ------------------------------------------------
   470                              <1> NUM_KEY		equ	69		; SCAN CODE FOR	 NUMBER LOCK KEY
   471                              <1> SCROLL_KEY	equ	70		; SCAN CODE FOR	 SCROLL LOCK KEY
   472                              <1> ALT_KEY		equ	56		; SCAN CODE FOR	 ALTERNATE SHIFT KEY
   473                              <1> CTL_KEY		equ	29		; SCAN CODE FOR	 CONTROL KEY
   474                              <1> CAPS_KEY	equ	58		; SCAN CODE FOR	 SHIFT LOCK KEY
   475                              <1> DEL_KEY		equ	83		; SCAN CODE FOR	 DELETE KEY
   476                              <1> INS_KEY		equ	82		; SCAN CODE FOR	 INSERT KEY
   477                              <1> LEFT_KEY	equ	42		; SCAN CODE FOR	 LEFT SHIFT
   478                              <1> RIGHT_KEY	equ	54		; SCAN CODE FOR	 RIGHT SHIFT
   479                              <1> SYS_KEY		equ	84		; SCAN CODE FOR	 SYSTEM KEY
   480                              <1> ;---------- ENHANCED KEYBOARD SCAN CODES ---------------------------------------
   481                              <1> ID_1		equ	0ABh		; 1ST ID CHARACTER FOR KBX
   482                              <1> ID_2		equ	041h		; 2ND ID CHARACTER FOR KBX
   483                              <1> ID_2A		equ	054h		; ALTERNATE 2ND ID CHARACTER FOR KBX
   484                              <1> F11_M		equ	87		; F11 KEY MAKE
   485                              <1> F12_M		equ	88		; F12 KEY MAKE
   486                              <1> MC_E0		equ	224		; GENERAL MARKER CODE
   487                              <1> MC_E1		equ	225		; PAUSE KEY MARKER CODE
   488                              <1> ;---------- FLAG EQUATES WITHIN @KB_FLAG----------------------------------------
   489                              <1> RIGHT_SHIFT	equ	00000001b	; RIGHT SHIFT KEY DEPRESSED
   490                              <1> LEFT_SHIFT	equ	00000010b	; LEFT SHIFT KEY DEPRESSED
   491                              <1> CTL_SHIFT	equ	00000100b	; CONTROL SHIFT KEY DEPRESSED
   492                              <1> ALT_SHIFT	equ	00001000b	; ALTERNATE SHIFT KEY DEPRESSED
   493                              <1> SCROLL_STATE	equ	00010000b	; SCROLL LOCK STATE IS ACTIVE
   494                              <1> NUM_STATE	equ	00100000b	; NUM LOCK STATE IS ACTIVE
   495                              <1> CAPS_STATE	equ	01000000b	; CAPS LOCK STATE IS ACTIVE
   496                              <1> INS_STATE	equ	10000000b	; INSERT STATE IS ACTIVE
   497                              <1> ;---------- FLAG EQUATES WITHIN	@KB_FLAG_1 -------------------------------------
   498                              <1> L_CTL_SHIFT	equ	00000001b	; LEFT CTL KEY DOWN
   499                              <1> L_ALT_SHIFT	equ	00000010b	; LEFT ALT KEY DOWN
   500                              <1> SYS_SHIFT	equ	00000100b	; SYSTEM KEY DEPRESSED AND HELD
   501                              <1> HOLD_STATE	equ	00001000b	; SUSPEND KEY HAS BEEN TOGGLED
   502                              <1> SCROLL_SHIFT	equ	00010000b	; SCROLL LOCK KEY IS DEPRESSED
   503                              <1> NUM_SHIFT	equ	00100000b	; NUM LOCK KEY IS DEPRESSED
   504                              <1> CAPS_SHIFT	equ	01000000b	; CAPS LOCK KEY IS DEPRE55ED
   505                              <1> INS_SHIFT	equ	10000000b	; INSERT KEY IS DEPRESSED
   506                              <1> ;---------- FLAGS EQUATES WITHIN @KB_FLAG_2 -----------------------------------
   507                              <1> KB_LEDS		equ	00000111b	; KEYBOARD LED STATE BITS
   508                              <1> ;		equ	00000001b	; SCROLL LOCK INDICATOR
   509                              <1> ;		equ	00000010b	; NUM LOCK INDICATOR
   510                              <1> ;		equ	00000100b	; CAPS LOCK INDICATOR
   511                              <1> ;		equ	00001000b	; RESERVED (MUST BE ZERO)
   512                              <1> KB_FA		equ	00010000b	; ACKNOWLEDGMENT RECEIVED
   513                              <1> KB_FE		equ	00100000b	; RESEND RECEIVED FLAG
   514                              <1> KB_PR_LED	equ	01000000b	; MODE INDICATOR UPDATE
   515                              <1> KB_ERR		equ	10000000b	; KEYBOARD TRANSMIT ERROR FLAG
   516                              <1> ;----------- FLAGS EQUATES WITHIN @KB_FLAG_3 -----------------------------------
   517                              <1> LC_E1		equ	00000001b	; LAST CODE WAS THE E1 HIDDEN CODE
   518                              <1> LC_E0		equ	00000010b	; LAST CODE WAS THE E0 HIDDEN CODE
   519                              <1> R_CTL_SHIFT	equ	00000100b	; RIGHT CTL KEY DOWN
   520                              <1> R_ALT_SHIFT	equ	00001000b	; RIGHT ALT KEY DOWN
   521                              <1> GRAPH_ON	equ	00001000b	; ALT GRAPHICS KEY DOWN (WT ONLY)	
   522                              <1> KBX		equ	00010000b	; ENHANCED KEYBOARD INSTALLED
   523                              <1> SET_NUM_LK	equ	00100000b	; FORCE NUM LOCK IF READ ID AND KBX
   524                              <1> LC_AB		equ	01000000b	; LAST CHARACTER WAS FIRST ID CHARACTER
   525                              <1> RD_ID		equ	10000000b	; DOING A READ ID (MUST BE BIT0)
   526                              <1> ;
   527                              <1> ;----------- INTERRUPT EQUATES -------------------------------------------------
   528                              <1> EOI		equ	020h		; END OF INTERRUPT COMMAND TO 8259
   529                              <1> INTA00		equ	020h		; 8259 PORT
   530                              <1> 
   531                              <1> 
   532                              <1> kb_int:
   533                              <1> 
   534                              <1> ; 17/10/2015 ('ctrlbrk') 
   535                              <1> ; 05/12/2014
   536                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-)
   537                              <1> ; 26/08/2014
   538                              <1> ;
   539                              <1> ; 03/06/86  KEYBOARD BIOS
   540                              <1> ;
   541                              <1> ;--- HARDWARE INT 09H -- (IRQ LEVEL 1) ------------------------------------------
   542                              <1> ;										;
   543                              <1> ;	KEYBOARD INTERRUPT ROUTINE						;
   544                              <1> ;										;
   545                              <1> ;--------------------------------------------------------------------------------
   546                              <1> 
   547                              <1> KB_INT_1:
   548 000010CE FB                  <1> 	sti				; ENABLE INTERRUPTS
   549                              <1> 	;push	ebp
   550 000010CF 50                  <1> 	push	eax
   551 000010D0 53                  <1> 	push	ebx
   552 000010D1 51                  <1> 	push	ecx
   553 000010D2 52                  <1> 	push	edx
   554 000010D3 56                  <1> 	push	esi
   555 000010D4 57                  <1> 	push	edi
   556 000010D5 1E                  <1> 	push	ds
   557 000010D6 06                  <1> 	push	es
   558 000010D7 FC                  <1> 	cld				; FORWARD DIRECTION
   559 000010D8 66B81000            <1> 	mov	ax, KDATA
   560 000010DC 8ED8                <1> 	mov	ds, ax
   561 000010DE 8EC0                <1> 	mov	es, ax
   562                              <1> 	;
   563                              <1> 	;-----	WAIT FOR KEYBOARD DISABLE COMMAND TO BE ACCEPTED
   564 000010E0 B0AD                <1> 	mov	al, DIS_KBD		; DISABLE THE KEYBOARD COMMAND
   565 000010E2 E8A9050000          <1> 	call	SHIP_IT			; EXECUTE DISABLE
   566 000010E7 FA                  <1> 	cli				; DISABLE INTERRUPTS
   567 000010E8 B900000100          <1> 	mov	ecx, 10000h		; SET MAXIMUM TIMEOUT
   568                              <1> KB_INT_01:
   569 000010ED E464                <1> 	in	al, STATUS_PORT		; READ ADAPTER STATUS
   570 000010EF A802                <1> 	test	al, INPT_BUF_FULL	; CHECK INPUT BUFFER FULL STATUS BIT
   571 000010F1 E0FA                <1> 	loopnz	KB_INT_01		; WAIT FOR COMMAND TO BE ACCEPTED
   572                              <1> 	;
   573                              <1> 	;-----	READ CHARACTER FROM KEYBOARD INTERFACE
   574 000010F3 E460                <1> 	in	al, PORT_A		; READ IN THE CHARACTER
   575                              <1> 	;
   576                              <1> 	;-----	SYSTEM HOOK INT 15H - FUNCTION 4FH (ON HARDWARE INT LEVEL 9H) 	
   577                              <1> 	;MOV	AH, 04FH		; SYSTEM INTERCEPT - KEY CODE FUNCTION
   578                              <1> 	;STC				; SET CY=1 (IN CASE OF IRET)
   579                              <1> 	;INT	15H			; CASETTE CALL (AL)=KEY SCAN CODE
   580                              <1> 	;				; RETURNS CY=1 FOR INVALID FUNCTION
   581                              <1> 	;JC	KB_INT_02		; CONTINUE IF CARRY FLAG SET ((AL)=CODE)
   582                              <1> 	;JMP	K26			; EXIT IF SYSTEM HANDLES SCAN CODE
   583                              <1> 	;				; EXT HANDLES HARDWARE EOI AND ENABLE		
   584                              <1> 	;
   585                              <1> 	;-----	CHECK FOR A RESEND COMMAND TO KEYBOARD
   586                              <1> KB_INT_02:				; 	  (AL)= SCAN CODE
   587 000010F5 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
   588 000010F6 3CFE                <1> 	cmp	al, KB_RESEND		; IS THE INPUT A RESEND
   589 000010F8 7411                <1>         je      short KB_INT_4          ; GO IF RESEND
   590                              <1> 	;
   591                              <1> 	;-----	CHECK FOR RESPONSE TO A COMMAND TO KEYBOARD
   592 000010FA 3CFA                <1> 	cmp	al, KB_ACK		; IS THE INPUT AN ACKNOWLEDGE
   593 000010FC 751A                <1>         jne     short KB_INT_2          ; GO IF NOT
   594                              <1> 	;
   595                              <1> 	;-----	A COMMAND TO THE KEYBOARD WAS ISSUED
   596 000010FE FA                  <1> 	cli				; DISABLE INTERRUPTS
   597 000010FF 800D[976F0000]10    <1> 	or	byte [KB_FLAG_2], KB_FA ; INDICATE ACK RECEIVED
   598 00001106 E97A020000          <1>         jmp     K26                     ; RETURN IF NOT (ACK RETURNED FOR DATA)
   599                              <1> 	;
   600                              <1> 	;-----	RESEND THE LAST BYTE
   601                              <1> KB_INT_4:
   602 0000110B FA                  <1> 	cli				; DISABLE INTERRUPTS
   603 0000110C 800D[976F0000]20    <1> 	or	byte [KB_FLAG_2], KB_FE ; INDICATE RESEND RECEIVED
   604 00001113 E96D020000          <1>         jmp     K26                     ; RETURN IF NOT ACK RETURNED FOR DATA)
   605                              <1> 	;
   606                              <1> ;-----	UPDATE MODE INDICATORS IF CHANGE IN STATE
   607                              <1> KB_INT_2:
   608 00001118 6650                <1> 	push 	ax			; SAVE DATA IN
   609 0000111A E83D060000          <1> 	call	MAKE_LED		; GO GET MODE INDICATOR DATA BYTE
   610 0000111F 8A1D[976F0000]      <1> 	mov	bl, [KB_FLAG_2] 	; GET PREVIOUS BITS
   611 00001125 30C3                <1> 	xor	bl, al			; SEE IF ANY DIFFERENT
   612 00001127 80E307              <1> 	and	bl, KB_LEDS		; ISOLATE INDICATOR BITS
   613 0000112A 7405                <1> 	jz	short UP0		; IF NO CHANGE BYPASS UPDATE
   614 0000112C E8C0050000          <1> 	call	SND_LED			; GO TURN ON MODE INDICATORS
   615                              <1> UP0:
   616 00001131 6658                <1> 	pop	ax			; RESTORE DATA IN
   617                              <1> ;------------------------------------------------------------------------
   618                              <1> ;	START OF KEY PROCESSING						;
   619                              <1> ;------------------------------------------------------------------------
   620 00001133 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE IN AH ALSO
   621                              <1> 	;
   622                              <1> 	;-----	TEST FOR OVERRUN SCAN CODE FROM KEYBOARD
   623 00001135 3CFF                <1> 	cmp	al, KB_OVER_RUN		; IS THIS AN OVERRUN CHAR
   624 00001137 0F843F050000        <1>         je      K62			; BUFFER_FULL_BEEP
   625                              <1> 	;
   626                              <1> K16:	
   627 0000113D 8A3D[986F0000]      <1> 	mov	bh, [KB_FLAG_3]		; LOAD FLAGS FOR TESTING
   628                              <1> 	;
   629                              <1> 	;-----	TEST TO SEE IF A READ_ID IS IN PROGRESS
   630 00001143 F6C7C0              <1> 	test 	bh, RD_ID+LC_AB 	; ARE WE DOING A READ ID?
   631 00001146 7449                <1> 	jz	short NOT_ID		; CONTINUE IF NOT
   632 00001148 7917                <1> 	jns	short TST_ID_2		; IS THE RD_ID FLAG ON?
   633 0000114A 3CAB                <1> 	cmp	al, ID_1		; IS THIS THE 1ST ID CHARACTER?
   634 0000114C 7507                <1> 	jne	short RST_RD_ID
   635 0000114E 800D[986F0000]40    <1> 	or	byte [KB_FLAG_3], LC_AB ; INDICATE 1ST ID WAS OK
   636                              <1> RST_RD_ID:
   637 00001155 8025[986F0000]7F    <1> 	and	byte [KB_FLAG_3], ~RD_ID ; RESET THE READ ID FLAG
   638                              <1>         ;jmp    short ID_EX		; AND EXIT
   639 0000115C E924020000          <1> 	jmp	K26
   640                              <1> 	;
   641                              <1> TST_ID_2:
   642 00001161 8025[986F0000]BF    <1> 	and	byte [KB_FLAG_3], ~LC_AB ; RESET FLAG
   643 00001168 3C54                <1> 	cmp	al, ID_2A		; IS THIS THE 2ND ID CHARACTER?
   644 0000116A 7419                <1>         je	short KX_BIT		; JUMP IF SO
   645 0000116C 3C41                <1> 	cmp	al, ID_2		; IS THIS THE 2ND ID CHARACTER?
   646                              <1>         ;jne	short ID_EX		; LEAVE IF NOT
   647 0000116E 0F8511020000        <1> 	jne	K26
   648                              <1> 	;
   649                              <1> 	;-----	A READ ID SAID THAT IT WAS ENHANCED KEYBOARD
   650 00001174 F6C720              <1> 	test	bh, SET_NUM_LK 		; SHOULD WE SET NUM LOCK?
   651 00001177 740C                <1>         jz      short KX_BIT		; EXIT IF NOT
   652 00001179 800D[956F0000]20    <1> 	or	byte [KB_FLAG], NUM_STATE ; FORCE NUM LOCK ON
   653 00001180 E86C050000          <1> 	call	SND_LED			; GO SET THE NUM LOCK INDICATOR
   654                              <1> KX_BIT:
   655 00001185 800D[986F0000]10    <1> 	or	byte [KB_FLAG_3], KBX	; INDICATE ENHANCED KEYBOARD WAS FOUND
   656 0000118C E9F4010000          <1> ID_EX:	jmp     K26			; EXIT
   657                              <1> 	;
   658                              <1> NOT_ID:
   659 00001191 3CE0                <1> 	cmp	al, MC_E0		; IS THIS THE GENERAL MARKER CODE?
   660 00001193 750C                <1> 	jne	short TEST_E1
   661 00001195 800D[986F0000]12    <1> 	or	byte [KB_FLAG_3], LC_E0+KBX ; SET FLAG BIT, SET KBX, AND
   662                              <1> 	;jmp	short EXIT		; THROW AWAY THIS CODE
   663 0000119C E9EB010000          <1> 	jmp	K26A	
   664                              <1> TEST_E1:	
   665 000011A1 3CE1                <1> 	cmp	al, MC_E1		; IS THIS THE PAUSE KEY?
   666 000011A3 750C                <1> 	jne	short NOT_HC
   667 000011A5 800D[986F0000]11    <1> 	or	byte [KB_FLAG_3], LC_E1+KBX ; SET FLAG BIT, SET KBX, AND
   668 000011AC E9DB010000          <1> EXIT:	jmp	K26A			; THROW AWAY THIS CODE
   669                              <1> 	;
   670                              <1> NOT_HC:
   671 000011B1 247F                <1> 	and	al, 07Fh		; TURN OFF THE BREAK BIT
   672 000011B3 F6C702              <1> 	test	bh, LC_E0		; LAST CODE THE E0 MARKER CODE
   673 000011B6 7414                <1> 	jz	short NOT_LC_E0		; JUMP IF NOT
   674                              <1> 	;
   675 000011B8 BF[826E0000]        <1> 	mov	edi, _K6+6		; IS THIS A SHIFT KEY?
   676 000011BD AE                  <1> 	scasb
   677 000011BE 0F84C1010000        <1>         je      K26 ; K16B              ; YES, THROW AWAY & RESET FLAG
   678 000011C4 AE                  <1> 	scasb
   679 000011C5 757C                <1> 	jne	short K16A		; NO, CONTINUE KEY PROCESSING
   680                              <1> 	;jmp	short K16B		; YES, THROW AWAY & RESET FLAG
   681 000011C7 E9B9010000          <1> 	jmp	K26
   682                              <1> 	;
   683                              <1> NOT_LC_E0:
   684 000011CC F6C701              <1> 	test	bh, LC_E1		; LAST CODE THE E1 MARKER CODE?
   685 000011CF 7435                <1> 	jz	short T_SYS_KEY		; JUMP IF NOT
   686 000011D1 B904000000          <1> 	mov	ecx, 4			; LENGHT OF SEARCH
   687 000011D6 BF[806E0000]        <1> 	mov	edi, _K6+4		; IS THIS AN ALT, CTL, OR SHIFT?
   688 000011DB F2AE                <1> 	repne	scasb			; CHECK IT
   689                              <1> 	;je	short EXIT		; THROW AWAY IF SO
   690 000011DD 0F84A9010000        <1> 	je	K26A			
   691                              <1> 	;
   692 000011E3 3C45                <1> 	cmp	al, NUM_KEY		; IS IT THE PAUSE KEY?
   693                              <1> 	;jne	short K16B		; NO, THROW AWAY & RESET FLAG
   694 000011E5 0F859A010000        <1> 	jne	K26
   695 000011EB F6C480              <1> 	test	ah, 80h			; YES, IS IT THE BREAK OF THE KEY?
   696                              <1> 	;jnz	short K16B		; YES, THROW THIS AWAY, TOO	
   697 000011EE 0F8591010000        <1> 	jnz	K26
   698                              <1>         ; 20/02/2015 
   699 000011F4 F605[966F0000]08    <1> 	test	byte [KB_FLAG_1],HOLD_STATE ;  NO, ARE WE PAUSED ALREADY?
   700                              <1> 	;jnz	short K16B		;  YES, THROW AWAY
   701 000011FB 0F8584010000        <1> 	jnz	K26
   702 00001201 E9E1020000          <1> 	jmp     K39P                    ; NO, THIS IS THE REAL PAUSE STATE
   703                              <1> 	;
   704                              <1> 	;-----	TEST FOR SYSTEM KEY
   705                              <1> T_SYS_KEY:
   706 00001206 3C54                <1> 	cmp	al, SYS_KEY		; IS IT THE SYSTEM KEY?
   707 00001208 7539                <1> 	jnz	short K16A		; CONTINUE IF NOT
   708                              <1> 	;
   709 0000120A F6C480              <1> 	test	ah, 80h			; CHECK IF THIS A BREAK CODE
   710 0000120D 7524                <1> 	jnz	short K16C		; DO NOT TOUCH SYSTEM INDICATOR IF TRUE
   711                              <1> 	;
   712 0000120F F605[966F0000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; SEE IF IN SYSTEM KEY HELD DOWN 
   713                              <1>         ;jnz	short K16B		; IF YES, DO NOT PROCESS SYSTEM INDICATOR	
   714 00001216 0F8569010000        <1> 	jnz     K26			
   715                              <1> 	;
   716 0000121C 800D[966F0000]04    <1> 	or	byte [KB_FLAG_1], SYS_SHIFT ; INDICATE SYSTEM KEY DEPRESSED
   717 00001223 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   718 00001225 E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
   719                              <1> 					; INTERRUPT-RETURN-NO-EOI
   720 00001227 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   721 00001229 E862040000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
   722                              <1> 	; !!! SYSREQ !!! function/system call (INTERRUPT) must be here !!!
   723                              <1> 	;MOV	AL, 8500H		; FUNCTION VALUE FOR MAKE OF SYSTEM KEY
   724                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
   725                              <1> 	;INT	15H			; USER INTERRUPT	
   726 0000122E E965010000          <1>         jmp     K27A                    ; END PROCESSING
   727                              <1> 	;
   728                              <1> ;K16B:	jmp	K26			; IGNORE SYSTEM KEY
   729                              <1> 	;
   730                              <1> K16C:
   731 00001233 8025[966F0000]FB    <1> 	and	byte [KB_FLAG_1], ~SYS_SHIFT ; TURN OFF SHIFT KEY HELD DOWN
   732 0000123A B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   733 0000123C E620                <1> 	out	20h, al ;out INTA00, al ; SEND COMMAND TO INTERRUPT CONTROL PORT
   734                              <1> 					; INTERRUPT-RETURN-NO-EOI
   735                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   736                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
   737                              <1> 	;
   738                              <1> 	;MOV	AX, 8501H		; FUNCTION VALUE FOR BREAK OF SYSTEM KEY
   739                              <1> 	;STI				; MAKE SURE INTERRUPTS ENABLED
   740                              <1> 	;INT	15H			; USER INTERRUPT
   741                              <1> 	;JMP	K27A			; INGONRE SYSTEM KEY				
   742                              <1> 	;
   743 0000123E E94E010000          <1> 	jmp     K27			; IGNORE SYSTEM KEY
   744                              <1> 	;
   745                              <1> 	;-----	TEST FOR SHIFT KEYS
   746                              <1> K16A:
   747 00001243 8A1D[956F0000]      <1> 	mov	bl, [KB_FLAG]		; PUT STATE FLAGS IN BL
   748 00001249 BF[7C6E0000]        <1> 	mov	edi, _K6		; SHIFT KEY TABLE offset
   749 0000124E B908000000          <1> 	mov	ecx, _K6L		; LENGTH
   750 00001253 F2AE                <1> 	repne	scasb			; LOOK THROUGH THE TABLE FOR A MATCH
   751 00001255 88E0                <1> 	mov	al, ah			; RECOVER SCAN CODE
   752 00001257 0F8510010000        <1>         jne     K25                     ; IF NO MATCH, THEN SHIFT NOT FOUND
   753                              <1> 	;
   754                              <1> 	;------	SHIFT KEY FOUND
   755                              <1> K17:
   756 0000125D 81EF[7D6E0000]      <1>         sub     edi, _K6+1              ; ADJUST PTR TO SCAN CODE MATCH
   757 00001263 8AA7[846E0000]      <1>        	mov     ah, [edi+_K7]       	; GET MASK INTO AH
   758 00001269 B102                <1> 	mov	cl, 2			; SETUP COUNT FOR FLAG SHIFTS
   759 0000126B A880                <1> 	test	al, 80h			; TEST FOR BREAK KEY
   760 0000126D 0F8596000000        <1>         jnz     K23                     ; JUMP OF BREAK
   761                              <1> 	;
   762                              <1> 	;-----	SHIFT MAKE FOUND, DETERMINE SET OR TOGGLE
   763                              <1> K17C:
   764 00001273 80FC10              <1> 	cmp	ah, SCROLL_SHIFT
   765 00001276 732B                <1> 	jae	short K18		; IF SCROLL SHIFT OR ABOVE, TOGGLE KEY
   766                              <1> 	;
   767                              <1> 	;-----	PLAIN SHIFT KEY, SET SHIFT ON
   768 00001278 0825[956F0000]      <1> 	or	[KB_FLAG], ah		; TURN ON SHIFT BIT
   769 0000127E A80C                <1>         test	al, CTL_SHIFT+ALT_SHIFT ; IS IT ALT OR CTRL?
   770                              <1> 	;jnz	short K17D		; YES, MORE FLAGS TO SET
   771 00001280 0F84FF000000        <1> 	jz	K26			; NO, INTERRUPT RETURN
   772                              <1> K17D:
   773 00001286 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF NEW KEYS?
   774 00001289 740B                <1> 	jz 	short K17E		; NO, JUMP
   775 0000128B 0825[986F0000]      <1> 	or	[KB_FLAG_3], ah		; SET BITS FOR RIGHT CTRL, ALT
   776 00001291 E9EF000000          <1> 	jmp	K26			; INTERRUPT RETURN
   777                              <1> K17E:
   778 00001296 D2EC                <1> 	shr	ah, cl			; MOVE FLAG BITS TWO POSITIONS
   779 00001298 0825[966F0000]      <1> 	or	[KB_FLAG_1], ah		; SET BITS FOR LEFT CTRL, ALT
   780 0000129E E9E2000000          <1> 	jmp	K26
   781                              <1> 	;
   782                              <1> 	;-----	TOGGLED SHIFT KEY, TEST FOR 1ST MAKE OR NOT
   783                              <1> K18:					; SHIFT-TOGGLE
   784 000012A3 F6C304              <1> 	test	bl, CTL_SHIFT 		; CHECK CTL SHIFT STATE
   785                              <1>         ;jz    	short K18A              ; JUMP IF NOT CTL STATE
   786 000012A6 0F85C1000000        <1>         jnz     K25                     ; JUMP IF CTL STATE
   787                              <1> K18A:
   788 000012AC 3C52                <1> 	cmp	al, INS_KEY		; CHECK FOR INSERT KEY
   789 000012AE 7524                <1> 	jne	short K22		; JUMP IF NOT INSERT KEY
   790 000012B0 F6C308              <1> 	test	bl, ALT_SHIFT 		; CHECK FOR ALTERNATE SHIFT
   791                              <1>       	;jz	short K18B		; JUMP IF NOT ALTERNATE SHIFT	
   792 000012B3 0F85B4000000        <1>         jnz     K25                     ; JUMP IF ALTERNATE SHIFT
   793                              <1> K18B:
   794 000012B9 F6C702              <1> 	test	bh, LC_E0 ;20/02/2015	; IS THIS NEW INSERT KEY?
   795 000012BC 7516                <1> 	jnz	short K22		; YES, THIS ONE'S NEVER A '0'
   796                              <1> K19:	
   797 000012BE F6C320              <1> 	test	bl, NUM_STATE 		; CHECK FOR BASE STATE
   798 000012C1 750C                <1> 	jnz	short K21		; JUMP IF NUM LOCK IS ON
   799 000012C3 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST FOR SHIFT STATE
   800 000012C6 740C                <1> 	jz	short K22		; JUMP IF BASE STATE
   801                              <1> K20:					; NUMERIC ZERO, NOT INSERT KEY
   802 000012C8 88C4                <1> 	mov	ah, al			; PUT SCAN CODE BACK IN AH
   803 000012CA E99E000000          <1>         jmp     K25                     ; NUMERAL '0', STNDRD. PROCESSING
   804                              <1> K21:					; MIGHT BE NUMERIC
   805 000012CF F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT
   806 000012D2 74F4                <1> 	jz	short K20		; IS NUMERIC, STD. PROC.
   807                              <1> 	;
   808                              <1> K22:					; SHIFT TOGGLE KEY HIT; PROCESS IT
   809 000012D4 8425[966F0000]      <1> 	test	ah, [KB_FLAG_1] 	; IS KEY ALREADY DEPRESSED
   810 000012DA 0F85A5000000        <1>         jnz     K26                     ; JUMP IF KEY ALREADY DEPRESSED
   811                              <1> K22A:
   812 000012E0 0825[966F0000]      <1>         or      [KB_FLAG_1], ah 	; INDICATE THAT THE KEY IS DEPRESSED
   813 000012E6 3025[956F0000]      <1> 	xor	[KB_FLAG], ah		; TOGGLE THE SHIFT STATE
   814                              <1> 	;
   815                              <1> 	;-----	TOGGLE LED IF CAPS, NUM  OR SCROLL KEY DEPRESSED
   816 000012EC F6C470              <1> 	test	ah, CAPS_SHIFT+NUM_SHIFT+SCROLL_SHIFT ; SHIFT TOGGLE?
   817 000012EF 7409                <1> 	jz	short K22B		; GO IF NOT
   818                              <1> 	;
   819 000012F1 6650                <1> 	push	ax			; SAVE SCAN CODE AND SHIFT MASK
   820 000012F3 E8F9030000          <1> 	call	SND_LED			; GO TURN MODE INDICATORS ON
   821 000012F8 6658                <1> 	pop	ax			; RESTORE SCAN CODE
   822                              <1> K22B:
   823 000012FA 3C52                <1> 	cmp	al, INS_KEY		; TEST FOR 1ST MAKE OF INSERT KEY
   824 000012FC 0F8583000000        <1>         jne     K26                     ; JUMP IF NOT INSERT KEY
   825 00001302 88C4                <1> 	mov	ah, al		        ; SCAN CODE IN BOTH HALVES OF AX
   826 00001304 E999000000          <1>         jmp     K28                     ; FLAGS UPDATED, PROC. FOR BUFFER
   827                              <1> 	;
   828                              <1> 	;-----	BREAK SHIFT FOUND
   829                              <1> K23:					; BREAK-SHIFT-FOUND
   830 00001309 80FC10              <1> 	cmp	ah, SCROLL_SHIFT	; IS THIS A TOGGLE KEY
   831 0000130C F6D4                <1> 	not	ah			; INVERT MASK
   832 0000130E 7355                <1> 	jae	short K24		; YES, HANDLE BREAK TOGGLE
   833 00001310 2025[956F0000]      <1> 	and	[KB_FLAG], ah		; TURN OFF SHIFT BIT
   834 00001316 80FCFB              <1> 	cmp	ah, ~CTL_SHIFT		; IS THIS ALT OR CTL?
   835 00001319 7730                <1> 	ja	short K23D		; NO, ALL DONE
   836                              <1> 	;
   837 0000131B F6C702              <1> 	test	bh, LC_E0		; 2ND ALT OR CTL?
   838 0000131E 7408                <1> 	jz	short K23A		; NO, HANSLE NORMALLY
   839 00001320 2025[986F0000]      <1> 	and 	[KB_FLAG_3], ah		; RESET BIT FOR RIGHT ALT OR CTL
   840 00001326 EB08                <1> 	jmp	short K23B		; CONTINUE
   841                              <1> K23A:
   842 00001328 D2FC                <1> 	sar	ah, cl			; MOVE THE MASK BIT TWO POSITIONS
   843 0000132A 2025[966F0000]      <1> 	and	[KB_FLAG_1], ah		; RESET BIT FOR LEFT ALT AND CTL
   844                              <1> K23B:
   845 00001330 88C4                <1> 	mov	ah, al			; SAVE SCAN CODE
   846 00001332 A0[986F0000]        <1> 	mov	al, [KB_FLAG_3]		; GET RIGHT ALT & CTRL FLAGS
   847 00001337 D2E8                <1> 	shr	al, cl			; MOVE TO BITS 1 & 0
   848 00001339 0A05[966F0000]      <1> 	or	al, [KB_FLAG_1]		; PUT IN LEFT ALT & CTL FLAGS
   849 0000133F D2E0                <1> 	shl	al, cl			; MOVE BACK TO BITS 3 & 2
   850 00001341 240C                <1> 	and	al, ALT_SHIFT+CTL_SHIFT ; FILTER OUT OTHER GARBAGE
   851 00001343 0805[956F0000]      <1> 	or	[KB_FLAG], al		; PUT RESULT IN THE REAL FLAGS	
   852 00001349 88E0                <1> 	mov	al, ah
   853                              <1> K23D:
   854 0000134B 3CB8                <1> 	cmp	al, ALT_KEY+80h		; IS THIS ALTERNATE SHIFT RELEASE
   855 0000134D 7536                <1> 	jne	short K26		; INTERRUPT RETURN
   856                              <1> 	;	
   857                              <1> 	;-----	ALTERNATE SHIFT KEY RELEASED, GET THE VALUE INTO BUFFER
   858 0000134F A0[996F0000]        <1> 	mov	al, [ALT_INPUT]
   859 00001354 B400                <1> 	mov	ah, 0			; SCAN CODE OF 0
   860 00001356 8825[996F0000]      <1> 	mov	[ALT_INPUT], ah 	; ZERO OUT THE FIELD
   861 0000135C 3C00                <1> 	cmp	al, 0			; WAS THE INPUT = 0?
   862 0000135E 7425                <1> 	je	short K26		; INTERRUPT_RETURN
   863                              <1>         ; 29/01/2016
   864                              <1> 	;jmp     K61                    ; IT WASN'T, SO PUT IN BUFFER
   865 00001360 E9D0020000          <1> 	jmp	_K60
   866                              <1> 	;
   867                              <1> K24:					; BREAK-TOGGLE
   868 00001365 2025[966F0000]      <1> 	and	[KB_FLAG_1], ah 	; INDICATE NO LONGER DEPRESSED
   869 0000136B EB18                <1> 	jmp	short K26		; INTERRUPT_RETURN
   870                              <1> 	;
   871                              <1> 	;-----	TEST FOR HOLD STATE
   872                              <1> 					; AL, AH = SCAN CODE
   873                              <1> K25:					; NO-SHIFT-FOUND
   874 0000136D 3C80                <1> 	cmp	al, 80h			; TEST FOR BREAK KEY
   875 0000136F 7314                <1> 	jae	short K26		; NOTHING FOR BREAK CHARS FROM HERE ON
   876 00001371 F605[966F0000]08    <1> 	test	byte [KB_FLAG_1], HOLD_STATE ; ARE WE IN HOLD STATE
   877 00001378 7428                <1> 	jz	short K28		; BRANCH AROUND TEST IF NOT
   878 0000137A 3C45                <1> 	cmp	al, NUM_KEY
   879 0000137C 7407                <1> 	je	short K26		; CAN'T END HOLD ON NUM_LOCK
   880 0000137E 8025[966F0000]F7    <1> 	and	byte [KB_FLAG_1], ~HOLD_STATE ; TURN OFF THE HOLD STATE BIT
   881                              <1> 	;
   882                              <1> K26:
   883 00001385 8025[986F0000]FC    <1> 	and	byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
   884                              <1> K26A:					; INTERRUPT-RETURN
   885 0000138C FA                  <1> 	cli				; TURN OFF INTERRUPTS
   886 0000138D B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
   887 0000138F E620                <1> 	out	20h, al	;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
   888                              <1> K27:					; INTERRUPT-RETURN-NO-EOI
   889 00001391 B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
   890 00001393 E8F8020000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
   891                              <1> K27A:
   892 00001398 FA                  <1> 	cli				; DISABLE INTERRUPTS
   893                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017 ;; 15/01/2017
   894 00001399 07                  <1> 	pop	es			; RESTORE REGISTERS
   895 0000139A 1F                  <1> 	pop	ds
   896 0000139B 5F                  <1> 	pop	edi
   897 0000139C 5E                  <1> 	pop	esi
   898 0000139D 5A                  <1> 	pop	edx
   899 0000139E 59                  <1> 	pop	ecx
   900 0000139F 5B                  <1> 	pop	ebx
   901 000013A0 58                  <1> 	pop	eax
   902                              <1> 	;pop	ebp
   903 000013A1 CF                  <1> 	iretd				; RETURN
   904                              <1> 
   905                              <1> 	;-----	NOT IN	HOLD STATE
   906                              <1> K28:					; NO-HOLD-STATE
   907 000013A2 3C58                <1> 	cmp	al, 88			; TEST FOR OUT-OF-RANGE SCAN CODES
   908 000013A4 77DF                <1> 	ja	short K26		; IGNORE IF OUT-OF-RANGE	
   909                              <1> 	;
   910 000013A6 F6C308              <1> 	test	bl, ALT_SHIFT 		; ARE WE IN ALTERNATE SHIFT
   911                              <1>         ;jz	short K28A		; IF NOT ALTERNATE
   912 000013A9 0F84F1000000        <1>         jz      K38
   913                              <1> 	;
   914 000013AF F6C710              <1> 	test	bh, KBX			; IS THIS THE ENCHANCED KEYBOARD?
   915 000013B2 740D                <1> 	jz	short K29		; NO, ALT STATE IS REAL
   916                              <1> 	 ;28/02/2015
   917 000013B4 F605[966F0000]04    <1> 	test	byte [KB_FLAG_1], SYS_SHIFT ; YES, IS SYSREQ KEY DOWN?
   918                              <1> 	;jz	short K29		;  NO, ALT STATE IS REAL
   919 000013BB 0F85DF000000        <1> 	jnz	K38			; YES, THIS IS PHONY ALT STATE 
   920                              <1>         ;				; DUE TO PRESSING SYSREQ	
   921                              <1> ;K28A:	jmp	short K38
   922                              <1> 	;
   923                              <1> 	;-----	TEST FOR RESET KEY SEQUENCE (CTL ALT DEL)
   924                              <1> K29:					; TEST-RESET
   925 000013C1 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT ALSO?
   926 000013C4 740B                <1> 	jz	short K31		; NO_RESET
   927 000013C6 3C53                <1> 	cmp	al, DEL_KEY		; CTL-ALT STATE, TEST FOR DELETE KEY
   928 000013C8 7507                <1> 	jne	short K31		; NO_RESET, IGNORE
   929                              <1> 	;
   930                              <1> 	;-----	CTL-ALT-DEL HAS BEEN FOUND
   931                              <1>  	; 26/08/2014
   932                              <1> cpu_reset:
   933                              <1> 	; IBM PC/AT ROM BIOS source code - 10/06/85 (TEST4.ASM - PROC_SHUTDOWN)
   934                              <1> 	; Send FEh (system reset command) to the keyboard controller.
   935 000013CA B0FE                <1> 	mov	al, SHUT_CMD		; SHUTDOWN COMMAND
   936 000013CC E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROL PORT
   937                              <1> khere:
   938 000013CE F4                  <1> 	hlt				; WAIT FOR 80286 RESET
   939 000013CF EBFD                <1> 	jmp 	short khere		; INSURE HALT
   940                              <1> 
   941                              <1> 	;
   942                              <1> 	;-----	IN ALTERNATE SHIFT, RESET NOT FOUND
   943                              <1> K31:					; NO-RESET
   944 000013D1 3C39                <1> 	cmp	al, 57			; TEST FOR SPACE KEY
   945 000013D3 7507                <1> 	jne	short K311		; NOT THERE
   946 000013D5 B020                <1> 	mov	al, ' '			; SET SPACE CHAR
   947 000013D7 E948020000          <1>         jmp     K57                     ; BUFFER_FILL
   948                              <1> K311:
   949 000013DC 3C0F                <1> 	cmp	al, 15			; TEST FOR TAB KEY
   950 000013DE 7509                <1> 	jne	short K312		; NOT THERE
   951 000013E0 66B800A5            <1> 	mov	ax, 0A500h		; SET SPECIAL CODE FOR ALT-TAB
   952 000013E4 E93B020000          <1>         jmp     K57                     ; BUFFER_FILL
   953                              <1> K312:
   954 000013E9 3C4A                <1> 	cmp	al, 74			; TEST FOR KEY PAD -
   955 000013EB 0F84A2000000        <1>         je      K37B                    ; GO PROCESS
   956 000013F1 3C4E                <1> 	cmp	al, 78			; TEST FOR KEY PAD +
   957 000013F3 0F849A000000        <1>         je      K37B                    ; GO PROCESS
   958                              <1> 	;
   959                              <1> 	;-----	LOOK FOR KEY PAD ENTRY
   960                              <1> K32:					; ALT-KEY-PAD
   961 000013F9 BF[586E0000]        <1> 	mov	edi, K30		; ALT-INPUT-TABLE offset
   962 000013FE B90A000000          <1> 	mov	ecx, 10			; LOOK FOR ENTRY USING KEYPAD
   963 00001403 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH
   964 00001405 7525                <1> 	jne	short K33		; NO_ALT_KEYPAD
   965 00001407 F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OF THE NEW KEYS?
   966 0000140A 0F858A000000        <1>         jnz     K37C                    ; YES, JUMP, NOT NUMPAD KEY
   967 00001410 81EF[596E0000]      <1> 	sub	edi, K30+1		; DI NOW HAS ENTRY VALUE
   968 00001416 A0[996F0000]        <1> 	mov	al, [ALT_INPUT] 	; GET THE CURRENT BYTE
   969 0000141B B40A                <1> 	mov	ah, 10			; MULTIPLY BY 10
   970 0000141D F6E4                <1> 	mul	ah
   971 0000141F 6601F8              <1> 	add	ax, di			; ADD IN THE LATEST ENTRY
   972 00001422 A2[996F0000]        <1> 	mov	[ALT_INPUT], al 	; STORE IT AWAY
   973                              <1> ;K32A:
   974 00001427 E959FFFFFF          <1>         jmp     K26                     ; THROW AWAY THAT KEYSTROKE
   975                              <1> 	;
   976                              <1> 	;-----	LOOK FOR SUPERSHIFT ENTRY
   977                              <1> K33:					; NO-ALT-KEYPAD
   978 0000142C C605[996F0000]00    <1>         mov     byte [ALT_INPUT], 0     ; ZERO ANY PREVIOUS ENTRY INTO INPUT
   979 00001433 B91A000000          <1> 	mov	ecx, 26			; (DI),(ES) ALREADY POINTING
   980 00001438 F2AE                <1> 	repne	scasb			; LOOK FOR MATCH IN ALPHABET
   981 0000143A 7450                <1> 	je	short K37A		; MATCH FOUND, GO FILLL THE BUFFER
   982                              <1> 	;
   983                              <1> 	;-----	LOOK FOR TOP ROW OF ALTERNATE SHIFT
   984                              <1> K34:					; ALT-TOP-ROW
   985 0000143C 3C02                <1> 	cmp	al, 2			; KEY WITH '1' ON IT
   986 0000143E 7253                <1> 	jb	short K37B		; MUST BE ESCAPE
   987 00001440 3C0D                <1> 	cmp	al, 13			; IS IT IN THE REGION
   988 00001442 7705                <1> 	ja	short K35		; NO, ALT SOMETHING ELSE
   989 00001444 80C476              <1> 	add	ah, 118			; CONVERT PSEUDO SCAN CODE TO RANGE
   990 00001447 EB43                <1> 	jmp	short K37A		; GO FILL THE BUFFER
   991                              <1> 	;
   992                              <1> 	;-----	TRANSLATE ALTERNATE SHIFT PSEUDO SCAN CODES
   993                              <1> K35:					; ALT-FUNCTION
   994 00001449 3C57                <1> 	cmp	al, F11_M		; IS IT F11?	
   995 0000144B 7209                <1> 	jb	short K35A ; 20/02/2015	; NO, BRANCH
   996 0000144D 3C58                <1> 	cmp	al, F12_M		; IS IT F12?
   997 0000144F 7705                <1> 	ja	short K35A ; 20/02/2015	; NO, BRANCH
   998 00001451 80C434              <1> 	add	ah, 52			; CONVERT TO PSEUDO SCAN CODE
   999 00001454 EB36                <1> 	jmp	short K37A		; GO FILL THE BUFFER
  1000                              <1> K35A:
  1001 00001456 F6C702              <1> 	test	bh, LC_E0		; DO WE HAVE ONE OF THE NEW KEYS?
  1002 00001459 7422                <1> 	jz	short K37		; NO, JUMP
  1003 0000145B 3C1C                <1> 	cmp	al, 28			; TEST FOR KEYPAD ENTER
  1004 0000145D 7509                <1>         jne     short K35B              ; NOT THERE
  1005 0000145F 66B800A6            <1> 	mov	ax, 0A600h		; SPECIAL CODE
  1006 00001463 E9BC010000          <1> 	jmp	K57			; BUFFER FILL
  1007                              <1> K35B:
  1008 00001468 3C53                <1> 	cmp	al, 83			; TEST FOR DELETE KEY
  1009 0000146A 742E                <1> 	je	short K37C		; HANDLE WITH OTHER EDIT KEYS
  1010 0000146C 3C35                <1> 	cmp	al, 53			; TEST FOR KEYPAD /
  1011                              <1> 	;jne	short K32A		; NOT THERE, NO OTHER E0 SPECIALS	
  1012 0000146E 0F8511FFFFFF        <1>         jne     K26
  1013 00001474 66B800A4            <1> 	mov	ax, 0A400h		; SPECIAL CODE
  1014 00001478 E9A7010000          <1> 	jmp	K57			; BUFFER FILL
  1015                              <1> K37:
  1016 0000147D 3C3B                <1> 	cmp	al, 59			; TEST FOR FUNCTION KEYS (F1)
  1017 0000147F 7212                <1>         jb      short K37B		; NO FN, HANDLE W/OTHER EXTENDED
  1018 00001481 3C44                <1> 	cmp	al, 68			; IN KEYPAD REGION?
  1019                              <1>         ;ja	short K32A		; IF SO, IGNORE
  1020 00001483 0F87FCFEFFFF        <1>         ja      K26
  1021 00001489 80C42D              <1> 	add	ah, 45			; CONVERT TO PSEUDO SCAN CODE
  1022                              <1> K37A:
  1023 0000148C B000                <1> 	mov	al, 0			; ASCII CODE OF ZERO
  1024 0000148E E991010000          <1>         jmp     K57                     ; PUT IT IN THE BUFFER
  1025                              <1> K37B:
  1026 00001493 B0F0                <1> 	mov	al, 0F0h		; USE SPECIAL ASCII CODE
  1027 00001495 E98A010000          <1> 	jmp     K57                     ; PUT IT IN THE BUFFER
  1028                              <1> K37C:
  1029 0000149A 0450                <1> 	add	al, 80			; CONVERT SCAN CODE (EDIT KEYS)
  1030 0000149C 88C4                <1> 	mov	ah, al			; (SCAN CODE NOT IN AH FOR INSERT)
  1031 0000149E EBEC                <1> 	jmp     short K37A              ; PUT IT IN THE BUFFER
  1032                              <1> 	;
  1033                              <1> 	;-----	NOT IN ALTERNATE SHIFT
  1034                              <1> K38:					; NOT-ALT-SHIFT
  1035                              <1> 					; BL STILL HAS SHIFT FLAGS
  1036 000014A0 F6C304              <1> 	test	bl, CTL_SHIFT 		; ARE WE IN CONTROL SHIFT?
  1037                              <1> 	;jnz	short K38A		; YES, START PROCESSING	
  1038 000014A3 0F84B0000000        <1>         jz      K44                     ; NOT-CTL-SHIFT
  1039                              <1> 	;
  1040                              <1> 	;-----	CONTROL SHIFT, TEST SPECIAL CHARACTERS
  1041                              <1> 	;-----	TEST FOR BREAK
  1042                              <1> K38A:
  1043 000014A9 3C46                <1> 	cmp	al, SCROLL_KEY		; TEST FOR BREAK
  1044 000014AB 7531                <1> 	jne	short K39		; JUMP, NO-BREAK
  1045 000014AD F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1046 000014B0 7405                <1> 	jz	short K38B		; NO, BREAK IS VALID	
  1047 000014B2 F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  1048 000014B5 7427                <1> 	jz	short K39		; NO-BREAK, TEST FOR PAUSE	
  1049                              <1> K38B:
  1050 000014B7 8B1D[A26F0000]      <1> 	mov	ebx, [BUFFER_HEAD] 	; RESET BUFFER TO EMPTY
  1051 000014BD 891D[A66F0000]      <1> 	mov	[BUFFER_TAIL], ebx
  1052 000014C3 C605[946F0000]80    <1> 	mov	byte [BIOS_BREAK], 80h  ; TURN ON BIOS_BREAK BIT
  1053                              <1> 	;
  1054                              <1> 	;-----	ENABLE KEYBOARD
  1055 000014CA B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  1056 000014CC E8BF010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1057                              <1> 	;
  1058                              <1> 	; CTRL+BREAK code here !!!
  1059                              <1> 	;INT	1BH			; BREAK INTERRUPT VECTOR
  1060                              <1> 	; 17/10/2015	
  1061 000014D1 E80A610000          <1> 	call	ctrlbrk ; control+break subroutine
  1062                              <1> 	;
  1063 000014D6 6629C0              <1> 	sub	ax, ax			; PUT OUT DUMMY CHARACTER
  1064 000014D9 E946010000          <1>         jmp     K57                     ; BUFFER_FILL
  1065                              <1> 	;
  1066                              <1> 	;-----	TEST FOR PAUSE
  1067                              <1> K39:					; NO_BREAK
  1068 000014DE F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1069 000014E1 7537                <1> 	jnz	short K41		; YES, THEN THIS CAN'T BE PAUSE	
  1070 000014E3 3C45                <1> 	cmp	al, NUM_KEY		; LOOK FOR PAUSE KEY
  1071 000014E5 7533                <1> 	jne	short K41		; NO-PAUSE
  1072                              <1> K39P:
  1073 000014E7 800D[966F0000]08    <1> 	or	byte [KB_FLAG_1], HOLD_STATE ; TURN ON THE HOLD FLAG
  1074                              <1> 	;
  1075                              <1> 	;-----	ENABLE KEYBOARD
  1076 000014EE B0AE                <1> 	mov	al, ENA_KBD		; ENABLE KEYBOARD
  1077 000014F0 E89B010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1078                              <1> K39A:
  1079 000014F5 B020                <1> 	mov	al, EOI			; END OF INTERRUPT TO CONTROL PORT
  1080 000014F7 E620                <1> 	out	20h, al ;out INTA00, al	; ALLOW FURTHER KEYSTROKE INTERRUPTS
  1081                              <1> 	;
  1082                              <1> 	;-----	DURING PAUSE INTERVAL, TURN COLOR CRT BACK ON
  1083 000014F9 803D[CA6F0000]07    <1>         cmp     byte [CRT_MODE], 7      ; IS THIS BLACK AND WHITE CARD
  1084 00001500 740A                <1>         je      short K40              	; YES, NOTHING TO DO
  1085 00001502 66BAD803            <1> 	mov	dx, 03D8h		; PORT FOR COLOR CARD
  1086 00001506 A0[CB6F0000]        <1>         mov     al, [CRT_MODE_SET] 	; GET THE VALUE OF THE CURRENT MODE
  1087 0000150B EE                  <1> 	out	dx, al			; SET THE CRT MODE, SO THAT CRT IS ON
  1088                              <1> 	;
  1089                              <1> K40:					; PAUSE-LOOP
  1090 0000150C F605[966F0000]08    <1>         test    byte [KB_FLAG_1], HOLD_STATE ; CHECK HOLD STATE FLAG
  1091 00001513 75F7                <1> 	jnz	short K40		; LOOP UNTIL FLAG TURNED OFF
  1092                              <1> 	;
  1093 00001515 E977FEFFFF          <1>         jmp     K27                     ; INTERRUPT_RETURN_NO_EOI
  1094                              <1>         ;
  1095                              <1> 	;-----	TEST SPECIAL CASE KEY 55
  1096                              <1> K41:					; NO-PAUSE
  1097 0000151A 3C37                <1> 	cmp	al, 55			; TEST FOR */PRTSC KEY
  1098 0000151C 7513                <1> 	jne	short K42		; NOT-KEY-55
  1099 0000151E F6C710              <1> 	test	bh, KBX			; IS THIS THE ENHANCED KEYBOARD?
  1100 00001521 7405                <1> 	jz	short K41A		; NO, CTL-PRTSC IS VALID	
  1101 00001523 F6C702              <1> 	test	bh, LC_E0		; YES, WAS LAST CODE AN E0?
  1102 00001526 7421                <1> 	jz	short K42B		; NO, TRANSLATE TO A FUNCTION
  1103                              <1> K41A:	
  1104 00001528 66B80072            <1> 	mov	ax, 114*256		; START/STOP PRINTING SWITCH
  1105 0000152C E9F3000000          <1>         jmp     K57                     ; BUFFER_FILL
  1106                              <1> 	;
  1107                              <1> 	;-----	SET UP TO TRANSLATE CONTROL SHIFT
  1108                              <1> K42:					; NOT-KEY-55
  1109 00001531 3C0F                <1> 	cmp	al, 15			; IS IT THE TAB KEY?
  1110 00001533 7414                <1> 	je	short K42B		; YES, XLATE TO FUNCTION CODE
  1111 00001535 3C35                <1> 	cmp	al, 53			; IS IT THE / KEY?
  1112 00001537 750E                <1> 	jne	short K42A		; NO, NO MORE SPECIAL CASES	
  1113 00001539 F6C702              <1> 	test	bh, LC_E0		; YES, IS IT FROM THE KEY PAD?
  1114 0000153C 7409                <1> 	jz	short K42A		; NO, JUST TRANSLATE
  1115 0000153E 66B80095            <1> 	mov	ax, 9500h		; YES, SPECIAL CODE FOR THIS ONE
  1116 00001542 E9DD000000          <1> 	jmp	K57			; BUFFER FILL	
  1117                              <1> K42A: 
  1118                              <1> 	;;mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  1119 00001547 3C3B                <1> 	cmp	al, 59			; IS IT IN CHARACTER TABLE?
  1120                              <1>         ;jb	short K45F              ; YES, GO TRANSLATE CHAR
  1121                              <1> 	;;jb	K56 ; 20/02/2015
  1122                              <1> 	;;jmp	K64 ; 20/02/2015
  1123                              <1> K42B:
  1124 00001549 BB[8C6E0000]        <1> 	mov	ebx, _K8		; SET UP TO TRANSLATE CTL
  1125 0000154E 0F82AE000000        <1> 	jb	K56 ;; 20/02/2015	
  1126 00001554 E9B9000000          <1> 	jmp	K64	
  1127                              <1>         ;
  1128                              <1> 	;-----	NOT IN CONTROL SHIFT
  1129                              <1> K44:					; NOT-CTL-SHIFT
  1130 00001559 3C37                <1> 	cmp	al, 55			; PRINT SCREEN KEY?
  1131 0000155B 7528                <1> 	jne	short K45		; NOT PRINT SCREEN
  1132 0000155D F6C710              <1> 	test	bh, KBX			; IS THIS ENHANCED KEYBOARD?
  1133 00001560 7407                <1> 	jz	short K44A		; NO, TEST FOR SHIFT STATE	
  1134 00001562 F6C702              <1> 	test	bh, LC_E0		; YES, LAST CODE A MARKER?
  1135 00001565 7507                <1> 	jnz	short K44B		; YES, IS PRINT SCREEN
  1136 00001567 EB41                <1> 	jmp	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  1137                              <1> K44A:
  1138 00001569 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; NOT 101 KBD, SHIFT KEY DOWN?
  1139 0000156C 743C                <1> 	jz	short K45C		; NO, TRANSLATE TO '*' CHARACTER
  1140                              <1> 	;
  1141                              <1> 	;-----	ISSUE INTERRUPT TO INDICATE PRINT SCREEN FUNCTION
  1142                              <1> K44B:
  1143 0000156E B0AE                <1> 	mov	al, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  1144 00001570 E81B010000          <1> 	call	SHIP_IT			; EXECUTE ENABLE
  1145 00001575 B020                <1> 	mov	al, EOI			; END OF CURRENT INTERRUPT
  1146 00001577 E620                <1> 	out	20h, al ;out INTA00, al	; SO FURTHER THINGS CAN HAPPEN
  1147                              <1> 	; Print Screen !!!		; ISSUE PRINT SCREEN INTERRUPT (INT 05h)
  1148                              <1> 	;PUSH 	BP			; SAVE POINTER
  1149                              <1> 	;INT 	5H			; ISSUE PRINT SCREEN INTERRUPT
  1150                              <1> 	;POP	BP			; RESTORE POINTER
  1151 00001579 8025[986F0000]FC    <1>         and     byte [KB_FLAG_3], ~(LC_E0+LC_E1) ; ZERO OUT THESE FLAGS
  1152 00001580 E90CFEFFFF          <1>         jmp     K27                     ; GO BACK WITHOUT EOI OCCURRING
  1153                              <1> 	;
  1154                              <1> 	;-----	HANDLE IN-CORE KEYS
  1155                              <1> K45:					; NOT-PRINT-SCREEN
  1156 00001585 3C3A                <1> 	cmp	al, 58			; TEST FOR IN-CORE AREA
  1157 00001587 7734                <1> 	ja	short K46		; JUMP IF NOT
  1158 00001589 3C35                <1> 	cmp	al, 53			; IS THIS THE '/' KEY?
  1159 0000158B 7505                <1> 	jne	short K45A		; NO, JUMP
  1160 0000158D F6C702              <1> 	test	bh, LC_E0		; WAS THE LAST CODE THE MARKER?
  1161 00001590 7518                <1> 	jnz	short K45C		; YES, TRANSLATE TO CHARACTER
  1162                              <1> K45A:
  1163 00001592 B91A000000          <1> 	mov	ecx, 26			; LENGHT OF SEARCH
  1164 00001597 BF[626E0000]        <1> 	mov	edi, K30+10		; POINT TO TABLE OF A-Z CHARS
  1165 0000159C F2AE                <1> 	repne	scasb			; IS THIS A LETTER KEY?
  1166                              <1> 		; 20/02/2015
  1167 0000159E 7505                <1> 	jne	short K45B              ; NO, SYMBOL KEY
  1168                              <1> 	;
  1169 000015A0 F6C340              <1> 	test	bl, CAPS_STATE		; ARE WE IN CAPS_LOCK?
  1170 000015A3 750C                <1> 	jnz	short K45D		; TEST FOR SURE
  1171                              <1> K45B:
  1172 000015A5 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  1173 000015A8 750C                <1> 	jnz	short K45E		; YES, UPPERCASE
  1174                              <1> 					; NO, LOWERCASE
  1175                              <1> K45C:
  1176 000015AA BB[E46E0000]        <1> 	mov	ebx, K10		; TRANSLATE TO LOWERCASE LETTERS
  1177 000015AF EB51                <1> 	jmp	short K56	
  1178                              <1> K45D:					; ALMOST-CAPS-STATE
  1179 000015B1 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; CL ON. IS SHIFT ON, TOO?
  1180 000015B4 75F4                <1> 	jnz	short K45C		; SHIFTED TEMP OUT OF CAPS STATE
  1181                              <1> K45E:
  1182 000015B6 BB[3C6F0000]        <1> 	mov	ebx, K11		; TRANSLATE TO UPPER CASE LETTERS
  1183 000015BB EB45                <1> K45F:	jmp	short K56
  1184                              <1> 	;
  1185                              <1> 	;-----	TEST FOR KEYS F1 - F10
  1186                              <1> K46:					; NOT IN-CORE AREA
  1187 000015BD 3C44                <1> 	cmp	al, 68			; TEST FOR F1 - F10
  1188                              <1> 	;ja	short K47		; JUMP IF NOT
  1189                              <1> 	;jmp	short K53		; YES, GO DO FN KEY PROCESS			
  1190 000015BF 7635                <1> 	jna	short K53		
  1191                              <1> 	;
  1192                              <1> 	;-----	HANDLE THE NUMERIC PAD KEYS
  1193                              <1> K47:					; NOT F1 - F10
  1194 000015C1 3C53                <1> 	cmp	al, 83			; TEST NUMPAD KEYS
  1195 000015C3 772D                <1> 	ja	short K52		; JUMP IF NOT
  1196                              <1> 	;
  1197                              <1> 	;-----	KEYPAD KEYS, MUST TEST NUM LOCK FOR DETERMINATION
  1198                              <1> K48:
  1199 000015C5 3C4A                <1> 	cmp	al , 74			; SPECIAL CASE FOR MINUS
  1200 000015C7 74ED                <1> 	je	short K45E		; GO TRANSLATE
  1201 000015C9 3C4E                <1> 	cmp	al , 78			; SPECIAL CASE FOR PLUS
  1202 000015CB 74E9                <1> 	je	short K45E		; GO TRANSLATE
  1203 000015CD F6C702              <1> 	test	bh, LC_E0		; IS THIS ONE OFTHE NEW KEYS?
  1204 000015D0 750A                <1> 	jnz	short K49		; YES, TRANSLATE TO BASE STATE
  1205                              <1> 	;		
  1206 000015D2 F6C320              <1> 	test 	bl, NUM_STATE		; ARE WE IN NUM LOCK
  1207 000015D5 7514                <1> 	jnz	short K50		; TEST FOR SURE
  1208 000015D7 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; ARE WE IN SHIFT STATE?
  1209                              <1> 	;jnz	short K51		; IF SHIFTED, REALLY NUM STATE
  1210 000015DA 75DA                <1> 	jnz	short K45E
  1211                              <1> 	;
  1212                              <1> 	;-----	BASE CASE FOR KEYPAD
  1213                              <1> K49:					
  1214 000015DC 3C4C                <1> 	cmp	al, 76			; SPECIAL CASE FOR BASE STATE 5
  1215 000015DE 7504                <1> 	jne	short K49A		; CONTINUE IF NOT KEYPAD 5
  1216 000015E0 B0F0                <1> 	mov	al, 0F0h		; SPECIAL ASCII CODE	
  1217 000015E2 EB40                <1> 	jmp	short K57		; BUFFER FILL
  1218                              <1> K49A:
  1219 000015E4 BB[E46E0000]        <1> 	mov	ebx, K10		; BASE CASE TABLE	
  1220 000015E9 EB27                <1> 	jmp	short K64		; CONVERT TO PSEUDO SCAN
  1221                              <1> 	;
  1222                              <1> 	;-----	MIGHT BE NUM LOCK, TEST SHIFT STATUS
  1223                              <1> K50:					; ALMOST-NUM-STATE
  1224 000015EB F6C303              <1>         test    bl, LEFT_SHIFT+RIGHT_SHIFT
  1225 000015EE 75EC                <1> 	jnz 	short K49		; SHIFTED TEMP OUT OF NUM STATE
  1226 000015F0 EBC4                <1> K51:	jmp	short K45E		; REALLY NUM STATE
  1227                              <1> 	;
  1228                              <1> 	;-----	TEST FOR THE NEW KEYS ON WT KEYBOARDS 
  1229                              <1> K52:					; NOT A NUMPAD KEY
  1230 000015F2 3C56                <1> 	cmp	al, 86			; IS IT THE NEW WT KEY?
  1231                              <1> 	;jne	short K53		; JUMP IF NOT
  1232                              <1> 	;jmp	short K45B		; HANDLE WITH REST OF LETTER KEYS
  1233 000015F4 74AF                <1> 	je	short K45B		
  1234                              <1> 	;
  1235                              <1> 	;-----	MUST BE F11 OR F12 
  1236                              <1> K53:					; F1 - F10 COME HERE, TOO
  1237 000015F6 F6C303              <1> 	test	bl, LEFT_SHIFT+RIGHT_SHIFT ; TEST SHIFT STATE
  1238 000015F9 74E1                <1> 	jz	short K49		; JUMP, LOWER CASE PSEUDO SC'S
  1239                              <1> 		; 20/02/2015 
  1240 000015FB BB[3C6F0000]        <1> 	mov	ebx, K11		; UPPER CASE PSEUDO SCAN CODES
  1241 00001600 EB10                <1> 	jmp	short K64		; TRANSLATE SCAN
  1242                              <1> 	;
  1243                              <1> 	;-----	TRANSLATE THE CHARACTER
  1244                              <1> K56:					; TRANSLATE-CHAR
  1245 00001602 FEC8                <1> 	dec	al			; CONVERT ORIGIN
  1246 00001604 D7                  <1> 	xlat    			; CONVERT THE SCAN CODE TO ASCII
  1247 00001605 F605[986F0000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  1248 0000160C 7416                <1> 	jz	short K57		; NO, GO FILL BUFFER
  1249 0000160E B4E0                <1> 	mov	ah, MC_E0		; YES, PUT SPECIAL MARKER IN AH
  1250 00001610 EB12                <1> 	jmp	short K57		; PUT IT INTO THE BUFFER	
  1251                              <1> 	;
  1252                              <1> 	;-----	TRANSLATE SCAN FOR PSEUDO SCAN CODES
  1253                              <1> K64:					; TRANSLATE-SCAN-ORGD
  1254 00001612 FEC8                <1> 	dec	al			; CONVERT ORIGIN
  1255 00001614 D7                  <1>        	xlat    	                ; CTL TABLE SCAN
  1256 00001615 88C4                <1> 	mov	ah, al			; PUT VALUE INTO AH
  1257 00001617 B000                <1> 	mov	al, 0			; ZERO ASCII CODE
  1258 00001619 F605[986F0000]02    <1> 	test	byte [KB_FLAG_3], LC_E0	; IS THIS A NEW KEY?
  1259 00001620 7402                <1> 	jz	short K57		; NO, GO FILL BUFFER
  1260 00001622 B0E0                <1> 	mov	al, MC_E0		; YES, PUT SPECIAL MARKER IN AL
  1261                              <1> 	;
  1262                              <1> 	;-----	PUT CHARACTER INTO BUFFER
  1263                              <1> K57:					; BUFFER_FILL
  1264 00001624 3CFF                <1> 	cmp	al, -1			; IS THIS AN IGNORE CHAR
  1265                              <1>         ;je	short K59		; YES, DO NOTHING WITH IT
  1266 00001626 0F8459FDFFFF        <1> 	je      K26			; YES, DO NOTHING WITH IT
  1267 0000162C 80FCFF              <1> 	cmp	ah, -1			; LOOK FOR -1 PSEUDO SCAN
  1268                              <1>         ;jne	short K61		; NEAR_INTERRUPT_RETURN
  1269 0000162F 0F8450FDFFFF        <1> 	je      K26			; INTERRUPT_RETURN
  1270                              <1> ;K59:					; NEAR_INTERRUPT_RETURN
  1271                              <1> ;	jmp	K26			; INTERRUPT_RETURN
  1272                              <1> 
  1273                              <1> _K60: ; 29/01/2016
  1274 00001635 80FC68              <1> 	cmp	ah, 68h	; ALT + F1 key
  1275 00001638 721F                <1> 	jb	short K61
  1276 0000163A 80FC6F              <1> 	cmp	ah, 6Fh ; ALT + F8 key	
  1277 0000163D 771A                <1> 	ja	short K61
  1278                              <1> 	;
  1279 0000163F 8A1D[FE890100]      <1> 	mov	bl, [ACTIVE_PAGE]
  1280 00001645 80C368              <1> 	add	bl, 68h
  1281 00001648 38E3                <1> 	cmp	bl, ah
  1282 0000164A 740D                <1> 	je	short K61
  1283 0000164C 6650                <1> 	push	ax
  1284 0000164E 88E0                <1> 	mov	al, ah
  1285 00001650 2C68                <1> 	sub	al, 68h
  1286 00001652 E858090000          <1> 	call	set_active_page
  1287 00001657 6658                <1> 	pop	ax
  1288                              <1> K61:					; NOT-CAPS-STATE
  1289 00001659 8B1D[A66F0000]      <1> 	mov	ebx, [BUFFER_TAIL] 	; GET THE END POINTER TO THE BUFFER
  1290 0000165F 89DE                <1> 	mov	esi, ebx		; SAVE THE VALUE
  1291 00001661 E857FAFFFF          <1> 	call	_K4			; ADVANCE THE TAIL
  1292 00001666 3B1D[A26F0000]      <1> 	cmp	ebx, [BUFFER_HEAD] 	; HAS THE BUFFER WRAPPED AROUND
  1293 0000166C 740E                <1> 	je	short K62		; BUFFER_FULL_BEEP
  1294 0000166E 668906              <1> 	mov	[esi], ax		; STORE THE VALUE
  1295 00001671 891D[A66F0000]      <1> 	mov	[BUFFER_TAIL], ebx 	; MOVE THE POINTER UP
  1296 00001677 E909FDFFFF          <1> 	jmp	K26
  1297                              <1> 	;;cli				; TURN OFF INTERRUPTS
  1298                              <1> 	;;mov	al, EOI			; END OF INTERRUPT COMMAND
  1299                              <1> 	;;out	INTA00, al		; SEND COMMAND TO INTERRUPT CONTROL PORT
  1300                              <1> 	;MOV	AL, ENA_KBD		; INSURE KEYBOARD IS ENABLED
  1301                              <1> 	;CALL	SHIP_IT			; EXECUTE ENABLE
  1302                              <1> 	;MOV	AX, 9102H		; MOVE IN POST CODE & TYPE
  1303                              <1> 	;INT	15H			; PERFORM OTHER FUNCTION
  1304                              <1> 	;;and	byte [KB_FLAG_3],~(LC_E0+LC_E1) ; RESET LAST CHAR H.C. FLAG
  1305                              <1> 	;JMP	K27A			; INTERRUPT_RETURN
  1306                              <1> 	;;jmp   K27                    
  1307                              <1> 	;
  1308                              <1> 	;-----	BUFFER IS FULL SOUND THE BEEPER
  1309                              <1> K62:
  1310 0000167C B020                <1> 	mov	al, EOI			; ENABLE INTERRUPT CONTROLLER CHIP
  1311 0000167E E620                <1> 	out	INTA00, al
  1312 00001680 66B9A602            <1> 	mov	cx, 678			; DIVISOR FOR 1760 HZ
  1313 00001684 B304                <1> 	mov	bl, 4			; SHORT BEEP COUNT (1/16 + 1/64 DELAY)
  1314 00001686 E86D0D0000          <1> 	call	beep			; GO TO COMMON BEEP HANDLER
  1315 0000168B E901FDFFFF          <1> 	jmp     K27			; EXIT   
  1316                              <1> 
  1317                              <1> SHIP_IT:
  1318                              <1> 	;---------------------------------------------------------------------------------
  1319                              <1> 	; SHIP_IT
  1320                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  1321                              <1> 	;	TO THE KEYBOARD CONTROLLER.
  1322                              <1> 	;---------------------------------------------------------------------------------
  1323                              <1> 	;
  1324 00001690 6650                <1> 	push	ax			; SAVE DATA TO SEND
  1325                              <1> 
  1326                              <1> 	;-----	WAIT FOR COMMAND TO ACCEPTED
  1327 00001692 FA                  <1> 	cli				; DISABLE INTERRUPTS TILL DATA SENT
  1328                              <1> 	; xor	ecx, ecx		; CLEAR TIMEOUT COUNTER
  1329 00001693 B900000100          <1> 	mov	ecx, 10000h			
  1330                              <1> S10:
  1331 00001698 E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD CONTROLLER STATUS
  1332 0000169A A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ITS INPUT BUFFER BUSY
  1333 0000169C E0FA                <1> 	loopnz	S10			; WAIT FOR COMMAND TO BE ACCEPTED
  1334                              <1> 
  1335 0000169E 6658                <1> 	pop	ax			; GET DATA TO SEND
  1336 000016A0 E664                <1> 	out	STATUS_PORT, al		; SEND TO KEYBOARD CONTROLLER
  1337 000016A2 FB                  <1> 	sti				; ENABLE INTERRUPTS AGAIN
  1338 000016A3 C3                  <1> 	retn				; RETURN TO CALLER
  1339                              <1> 
  1340                              <1> SND_DATA:
  1341                              <1> 	; ---------------------------------------------------------------------------------
  1342                              <1> 	; SND_DATA
  1343                              <1> 	;	THIS ROUTINES HANDLES TRANSMISSION OF COMMAND AND DATA BYTES
  1344                              <1> 	;	TO THE KEYBOARD AND RECEIPT OF ACKNOWLEDGEMENTS. IT ALSO
  1345                              <1> 	;	HANDLES ANY RETRIES IF REQUIRED
  1346                              <1> 	; ---------------------------------------------------------------------------------
  1347                              <1> 	;
  1348 000016A4 6650                <1> 	push	ax			; SAVE REGISTERS
  1349 000016A6 6653                <1> 	push	bx
  1350 000016A8 51                  <1> 	push	ecx
  1351 000016A9 88C7                <1> 	mov	bh, al			; SAVE TRANSMITTED BYTE FOR RETRIES
  1352 000016AB B303                <1> 	mov	bl, 3			; LOAD RETRY COUNT
  1353                              <1> SD0:
  1354 000016AD FA                  <1> 	cli				; DISABLE INTERRUPTS
  1355 000016AE 8025[976F0000]CF    <1> 	and	byte [KB_FLAG_2], ~(KB_FE+KB_FA) ; CLEAR ACK AND RESEND FLAGS
  1356                              <1> 	;
  1357                              <1> 	;-----	WAIT FOR COMMAND TO BE ACCEPTED
  1358 000016B5 B900000100          <1> 	mov	ecx, 10000h		; MAXIMUM WAIT COUNT
  1359                              <1> SD5:
  1360 000016BA E464                <1> 	in	al, STATUS_PORT		; READ KEYBOARD PROCESSOR STATUS PORT
  1361 000016BC A802                <1> 	test	al, INPT_BUF_FULL	; CHECK FOR ANY PENDING COMMAND
  1362 000016BE E0FA                <1> 	loopnz	SD5			; WAIT FOR COMMAND TO BE ACCEPTED
  1363                              <1> 	;
  1364 000016C0 88F8                <1> 	mov	al, bh			; REESTABLISH BYTE TO TRANSMIT
  1365 000016C2 E660                <1> 	out	PORT_A, al		; SEND BYTE
  1366 000016C4 FB                  <1> 	sti				; ENABLE INTERRUPTS
  1367                              <1> 	;mov	cx, 01A00h		; LOAD COUNT FOR 10 ms+
  1368 000016C5 B9FFFF0000          <1> 	mov	ecx, 0FFFFh
  1369                              <1> SD1:
  1370 000016CA F605[976F0000]30    <1> 	test	byte [KB_FLAG_2], KB_FE+KB_FA ; SEE IF EITHER BIT SET
  1371 000016D1 750F                <1> 	jnz	short SD3		; IF SET, SOMETHING RECEIVED GO PROCESS
  1372 000016D3 E2F5                <1> 	loop	SD1			; OTHERWISE WAIT
  1373                              <1> SD2:
  1374 000016D5 FECB                <1> 	dec	bl			; DECREMENT RETRY COUNT
  1375 000016D7 75D4                <1> 	jnz	short SD0		; RETRY TRANSMISSION
  1376 000016D9 800D[976F0000]80    <1> 	or	byte [KB_FLAG_2], KB_ERR ; TURN ON TRANSMIT ERROR FLAG
  1377 000016E0 EB09                <1> 	jmp	short SD4		; RETRIES EXHAUSTED FORGET TRANSMISSION
  1378                              <1> SD3:
  1379 000016E2 F605[976F0000]10    <1> 	test	byte [KB_FLAG_2], KB_FA ; SEE IF THIS IS AN ACKNOWLEDGE
  1380 000016E9 74EA                <1> 	jz	short SD2		; IF NOT, GO RESEND
  1381                              <1> SD4:	
  1382 000016EB 59                  <1> 	pop	ecx			; RESTORE REGISTERS
  1383 000016EC 665B                <1> 	pop	bx
  1384 000016EE 6658                <1> 	pop	ax
  1385 000016F0 C3                  <1> 	retn				; RETURN, GOOD TRANSMISSION
  1386                              <1> 
  1387                              <1> SND_LED:
  1388                              <1> 	; ---------------------------------------------------------------------------------
  1389                              <1> 	; SND_LED
  1390                              <1> 	;	THIS ROUTINES TURNS ON THE MODE INDICATORS.
  1391                              <1> 	;
  1392                              <1> 	;----------------------------------------------------------------------------------
  1393                              <1> 	;
  1394 000016F1 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1395 000016F2 F605[976F0000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  1396 000016F9 755F                <1> 	jnz 	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  1397                              <1> 	;
  1398 000016FB 800D[976F0000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  1399 00001702 B020                <1> 	mov	al, EOI			; END OF INTERRUPT COMMAND
  1400 00001704 E620                <1> 	out	20h, al ;out INTA00, al	; SEND COMMAND TO INTERRUPT CONTROL PORT
  1401 00001706 EB11                <1> 	jmp	short SL0		; GO SEND MODE INDICATOR COMMAND
  1402                              <1> SND_LED1:
  1403 00001708 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1404 00001709 F605[976F0000]40    <1> 	test	byte [KB_FLAG_2], KB_PR_LED ; CHECK FOR MODE INDICATOR UPDATE
  1405 00001710 7548                <1> 	jnz	short SL1		; DON'T UPDATE AGAIN IF UPDATE UNDERWAY
  1406                              <1> 	;
  1407 00001712 800D[976F0000]40    <1> 	or	byte [KB_FLAG_2], KB_PR_LED ; TURN ON UPDATE IN PROCESS
  1408                              <1> SL0:
  1409 00001719 B0ED                <1> 	mov	al, LED_CMD		; LED CMD BYTE
  1410 0000171B E884FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1411 00001720 FA                  <1> 	cli
  1412 00001721 E836000000          <1> 	call	MAKE_LED		; GO FORM INDICATOR DATA BYTE
  1413 00001726 8025[976F0000]F8    <1> 	and	byte [KB_FLAG_2], 0F8h	; ~KB_LEDS ; CLEAR MODE INDICATOR BITS
  1414 0000172D 0805[976F0000]      <1> 	or	[KB_FLAG_2], al 	; SAVE PRESENT INDICATORS FOR NEXT TIME
  1415 00001733 F605[976F0000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  1416 0000173A 750F                <1> 	jnz	short SL2		; IF SO, BYPASS SECOND BYTE TRANSMISSION
  1417                              <1> 	;
  1418 0000173C E863FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1419 00001741 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1420 00001742 F605[976F0000]80    <1> 	test	byte [KB_FLAG_2], KB_ERR ; TRANSMIT ERROR DETECTED
  1421 00001749 7408                <1> 	jz	short SL3		; IF NOT, DON'T SEND AN ENABLE COMMAND
  1422                              <1> SL2:
  1423 0000174B B0F4                <1> 	mov	al, KB_ENABLE		; GET KEYBOARD CSA ENABLE COMMAND
  1424 0000174D E852FFFFFF          <1> 	call	SND_DATA		; SEND DATA TO KEYBOARD
  1425 00001752 FA                  <1> 	cli				; TURN OFF INTERRUPTS
  1426                              <1> SL3:
  1427 00001753 8025[976F0000]3F    <1> 	and	byte [KB_FLAG_2], ~(KB_PR_LED+KB_ERR) ; TURN OFF MODE INDICATOR
  1428                              <1> SL1:					; UPDATE AND TRANSMIT ERROR FLAG
  1429 0000175A FB                  <1> 	sti				; ENABLE INTERRUPTS
  1430 0000175B C3                  <1> 	retn				; RETURN TO CALLER
  1431                              <1> 
  1432                              <1> MAKE_LED:
  1433                              <1> 	;---------------------------------------------------------------------------------
  1434                              <1> 	; MAKE_LED
  1435                              <1> 	;	THIS ROUTINES FORMS THE DATA BYTE NECESSARY TO TURN ON/OFF
  1436                              <1> 	;	THE MODE INDICATORS.
  1437                              <1> 	;---------------------------------------------------------------------------------
  1438                              <1> 	;
  1439                              <1> 	;push 	cx			; SAVE CX
  1440 0000175C A0[956F0000]        <1> 	mov	al, [KB_FLAG]		; GET CAPS & NUM LOCK INDICATORS
  1441 00001761 2470                <1> 	and	al, CAPS_STATE+NUM_STATE+SCROLL_STATE ; ISOLATE INDICATORS
  1442                              <1> 	;mov	cl, 4			; SHIFT COUNT
  1443                              <1> 	;rol	al, cl			; SHIFT BITS OVER TO TURN ON INDICATORS
  1444 00001763 C0C004              <1> 	rol	al, 4 ; 20/02/2015
  1445 00001766 2407                <1> 	and	al, 07h			; MAKE SURE ONLY MODE BITS ON
  1446                              <1> 	;pop	cx
  1447 00001768 C3                  <1> 	retn				; RETURN TO CALLER
  1448                              <1> 
  1449                              <1> ; % include 'kybdata.s'   ; KEYBOARD DATA
  1450                              <1> 
  1451                              <1> 
  1452                              <1> ; /// End Of KEYBOARD FUNCTIONS ///
  2653                                  
  2654                                  %include 'video.s' ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - video.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 12/02/2021
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; video.inc (13/08/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - VIDEO.INC
    20                              <1> ; Last Modification: 13/08/2015
    21                              <1> ;		  (Video Data is in 'VIDATA.INC')
    22                              <1> ;
    23                              <1> ; ///////// VIDEO (CGA) FUNCTIONS ///////////////
    24                              <1> 
    25                              <1> ; 16/01/2016 (32 bit modifications, TRDOS386 - TRDOS v2.0, video.s)
    26                              <1> ; INT 31H (TRDOS 386) = INT 10H (IBM PC/AT REAL MODE)
    27                              <1> 
    28                              <1> ; IBM PC-AT BIOS Source Code
    29                              <1> ; TITLE VIDEO1 --- 06/10/85 VIDEO DISPLAY BIOS
    30                              <1> 
    31                              <1> _int10h:
    32                              <1> 	; 23/03/2016
    33                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
    34 00001769 9C                  <1> 	pushfd
    35 0000176A 0E                  <1> 	push	cs
    36 0000176B E851000000          <1> 	call	VIDEO_IO_1
    37 00001770 C3                  <1> 	retn
    38                              <1> 
    39                              <1> ;--- INT 10 H -------------------------------------------------------------------
    40                              <1> ; VIDEO_IO									:
    41                              <1> ;	THESE ROUTINES PROVIDE THE CRT DISPLAY INTERFACE			:
    42                              <1> ;	THE FOLLOWING FUNCTIONS ARE PROVIDED:					:
    43                              <1> ;										:
    44                              <1> ;    (AH)= 00H	SET MODE (AL) CONTAINS MODE VALUE				:
    45                              <1> ;		(AL) = 00H  40X25 BW MODE (POWER ON DEFAULT)			:
    46                              <1> ;		(AL) = 01H  40X25 COLOR						:
    47                              <1> ;		(AL) = 02H  80X25 BW						:
    48                              <1> ;		(AL) = 03H  80X25 COLOR						:
    49                              <1> ;		              GRAPHICS MODES					:
    50                              <1> ;		(AL) = 04H  320X200 COLOR					:
    51                              <1> ;		(AL) = 05H  320X200 BW MODE					:
    52                              <1> ;		(AL) = 06H  640X200 BW MODE					:
    53                              <1> ;		(AL) = 07H   80X25 MONOCHROME (USED INTERNAL TO VIDEO ONLY)	:
    54                              <1> ;		*** NOTES -BW MODES OPERATE SAME AS COLOR MODES, BUT COLOR	:
    55                              <1> ;		           BURST IS NOT ENABLED					:
    56                              <1> ;		          -CURSOR IS NOT DISPLAYED IN GRAPHICS MODE		:
    57                              <1> ;    (AH)= 01H	SET CURSOR TYPE							:
    58                              <1> ;		(CH) = BITS 4-0 = START LINE FOR CURSOR				:
    59                              <1> ;		       ** HARDWARE WILL ALWAYS CAUSE BLINK			:
    60                              <1> ;		       ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING	:
    61                              <1> ;		          OR NO CURSOR AT ALL					:
    62                              <1> ;		(CL) = BITS 4-0 = END LINE FOR CURSOR				:
    63                              <1> ;    (AH)= 02H	SET CURSOR POSITION						:
    64                              <1> ;		(DH,DL) = ROW,COLUMN  (00H,00H) IS UPPER LEFT			:
    65                              <1> ;		(BH) = A PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
    66                              <1> ;    (AH)= 03H	READ CURSOR POSITION						:
    67                              <1> ;		(BH) = PAGE NUMBER (MUST BE 00H FOR GRAPHICS MODES)		:
    68                              <1> ;		ON EXIT (DH,DL) = ROW,COLUMN OF CURRENT CURSOR			:
    69                              <1> ;		        (CH,CL) = CURSOR MODE CURRENTLY SET			:
    70                              <1> ;    (AH)= 04H	READ LIGHT PEN POSITION						:
    71                              <1> ;		ON EXIT:							:
    72                              <1> ;		(AH) = 00H -- LIGHT PEN SWITCH NOT DOWN/NOT TRIGGERED		:
    73                              <1> ;		(AH) = 01H -- VALID LIGHT PEN VALUE IN REGISTERS		:
    74                              <1> ;		        (DH,DL) = ROW,COLUMN OF CHARACTER LP POSITION		:
    75                              <1> ;		        (CH) = RASTER LINE (0-199)				:
    76                              <1> ;		        (BX) = PIXEL COLUMN (0-319,639)				:
    77                              <1> ;    (AH)= 05H	SELECT ACTIVE DISPLAY PAGE (VALID ONLY FOR ALPHA MODES)		:
    78                              <1> ;		(AL) = NEW PAGE VALUE (0-7 FOR MODES 0&1, 0-3 FOR MODES 2&3)	:
    79                              <1> ;    (AH)= 06H	SCROLL ACTIVE PAGE UP						:
    80                              <1> ;		(AL) = NUMBER OF LINES. ( LINES BLANKED AT BOTTOM OF WINDOW )	:
    81                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
    82                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
    83                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
    84                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
    85                              <1> ;    (AH)= 07H	SCROLL ACTIVE PAGE DOWN						:
    86                              <1> ;		(AL) = NUMBER OF LINES, INPUT LINES BLANKED AT TOP OF WINDOW	:
    87                              <1> ;		        (AL) = 00H MEANS BLANK ENTIRE WINDOW			:
    88                              <1> ;		(CH,CL) = ROW,COLUMN OF UPPER LEFT CORNER OF SCROLL		:
    89                              <1> ;		(DH,DL) = ROW,COLUMN OF LOWER RIGHT CORNER OF SCROLL		:
    90                              <1> ;		(BH) = ATTRIBUTE TO BE USED ON BLANK LINE			:
    91                              <1> ;										:
    92                              <1> ;   CHARACTER HANDLING ROUTINES							:
    93                              <1> ;										:
    94                              <1> ;    (AH)= 08H	READ ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
    95                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
    96                              <1> ;		ON EXIT:							:
    97                              <1> ;		(AL) = CHAR READ						:
    98                              <1> ;		(AH) = ATTRIBUTE OF CHARACTER READ (ALPHA MODES ONLY)		:
    99                              <1> ;    (AH)= 09H	WRITE ATTRIBUTE/CHARACTER AT CURRENT CURSOR POSITION		:
   100                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
   101                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
   102                              <1> ;		(AL) = CHAR TO WRITE						:
   103                              <1> ;		(BL) = ATTRIBUTE OF CHARACTER (ALPHA)/COLOR OF CHAR (GRAPHICS)	:
   104                              <1> ;		         SEE NOTE ON WRITE DOT FOR BIT 7 OF BL = 1.		:
   105                              <1> ;    (AH) = 0AH	WRITE CHARACTER ONLY AT CURRENT CURSOR POSITION			:
   106                              <1> ;		(BH) = DISPLAY PAGE (VALID FOR ALPHA MODES ONLY)		:
   107                              <1> ;		(CX) = COUNT OF CHARACTERS TO WRITE				:
   108                              <1> ;		(AL) = CHAR TO WRITE						:
   109                              <1> ;		       NOTE: USE FUNCTION (AH)= 09H IN GRAPHICS MODES		:
   110                              <1> ;	FOR READ/WRITE CHARACTER INTERFACE WHILE IN GRAPHICS MODE, THE		:
   111                              <1> ;		CHARACTERS ARE FORMED FROM A CHARACTER GENERATOR IMAGE		:
   112                              <1> ;		MAINTAINED IN THE SYSTEM ROM. ONLY THE 1ST 128 CHARS		:
   113                              <1> ;		ARE CONTAINED THERE. TO READ/WRITE THE SECOND 128 CHARS,	:
   114                              <1> ;		THE USER MUST INITIALIZE THE POINTER AT INTERRUPT 1FH		:
   115                              <1> ;		(LOCATION 0007CH) TO POINT TO THE 1K BYTE TABLE CONTAINING	:
   116                              <1> ;		THE CODE POINTS FOR THE SECOND 128 CHARS (128-255).		:
   117                              <1> ;	FOR WRITE CHARACTER INTERFACE IN GRAPHICS MODE, THE REPLICATION FACTOR	:
   118                              <1> ;		CONTAINED IN (CX) ON ENTRY WILL PRODUCE VALID RESULTS ONLY	:
   119                              <1> ;		FOR CHARACTERS CONTAINED ON THE SAME ROW. CONTINUATION TO	:
   120                              <1> ;		SUCCEEDING LINES WILL NOT PRODUCE CORRECTLY.			:
   121                              <1> ;										:
   122                              <1> ;    GRAPHICS INTERFACE								:
   123                              <1> ;    (AH)= 0BH	SET COLOR PALETTE						:
   124                              <1> ;		(BH) = PALETTE COLOR ID BEING SET (0-127)			:
   125                              <1> ;		(BL) = COLOR VALUE TO BE USED WITH THAT COLOR ID		:
   126                              <1> ;		       NOTE: FOR THE CURRENT COLOR CARD, THIS ENTRY POINT HAS	:
   127                              <1> ;		               MEANING ONLY FOR 320X200 GRAPHICS.		:
   128                              <1> ;		       COLOR ID = 0 SELECTS THE BACKGROUND COLOR (0-15)		:
   129                              <1> ;		       COLOR ID = 1 SELECTS THE PALETTE TO BE USED:		:
   130                              <1> ;		               0 = GREEN(1)/RED(2)/YELLOW(3)			:
   131                              <1> ;		               1 = CYAN(1)/MAGENTA(2)/WHITE(3)			:
   132                              <1> ;		       IN 40X25 OR 80X25 ALPHA MODES, THE VALUE SET FOR 	:
   133                              <1> ;		               PALETTE COLOR 0 INDICATES THE BORDER COLOR	:
   134                              <1> ;		               TO BE USED (VALUES 0-31, WHERE 16-31 SELECT	:
   135                              <1> ;		               THE HIGH INTENSITY BACKGROUND SET.		:
   136                              <1> ;    (AH)= 0CH	WRITE DOT							:
   137                              <1> ;		(DX) = ROW NUMBER						:
   138                              <1> ;		(CX) = COLUMN NUMBER						:
   139                              <1> ;		(AL) = COLOR VALUE						:
   140                              <1> ;		        IF BIT 7 OF AL = 1, THEN THE COLOR VALUE IS EXCLUSIVE	:
   141                              <1> ;		        ORed WITH THE CURRENT CONTENTS OF THE DOT		:
   142                              <1> ;    (AH)= ODH	READ DOT							:
   143                              <1> ;		(DX) = ROW NUMBER						:
   144                              <1> ;		(CX) = COLUMN NUMBER						:
   145                              <1> ;		(AL) = RETURNS THE DOT READ					:
   146                              <1> ;										:
   147                              <1> ;    ASCII TELETYPE ROUTINE FOR OUTPUT						:
   148                              <1> ;										:
   149                              <1> ;    (AH)= 0EH	WRITE TELETYPE TO ACTIVE PAGE					:
   150                              <1> ;		(AL) = CHAR TO WRITE						:
   151                              <1> ;		(BL) = FOREGROUND COLOR IN GRAPHICS MODE			:
   152                              <1> ;		NOTE -- SCREEN WIDTH IS CONTROLLED BY PREVIOUS MODE SET		:
   153                              <1> ;    (AH)= 0FH	CURRENT VIDEO STATE						:
   154                              <1> ;		RETURNS THE CURRENT VIDEO STATE					:
   155                              <1> ;		(AL) = MODE CURRENTLY SET ( SEE (AH)=00H FOR EXPLANATION)	:
   156                              <1> ;		(AH) = NUMBER OR CHARACTER COLUMNS ON SCREEN			:
   157                              <1> ;		(BH) = CURRENT ACTIVE DISPLAY PAGE				:
   158                              <1> ;    (AH)= 10H	RESERVED							:
   159                              <1> ;    (AH)= 11H	RESERVED							:
   160                              <1> ;    (AH)= 12H	RESERVED							:
   161                              <1> ;    (AH)= 13H	WRITE STRING							:
   162                              <1> ;			ES:BP  -  POINTER T0 STRING TO BE WRITTEN		:
   163                              <1> ;			CX     -  LENGTH OF CHARACTER STRING TO WRITTEN		:
   164                              <1> ;			DX     -  CURSOR POSITION FOR STRING TO BE WRITTEN	:
   165                              <1> ;			BH     -  PAGE NUMBER					:
   166                              <1> ;		(AL)= 00H	WRITE CHARACTER STRING				:
   167                              <1> ;			BL     -  ATTRIBUTE					:
   168                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
   169                              <1> ;			CURSOR NOT MOVED					:
   170                              <1> ;		(AL)= 01H	WRITE CHARACTER STRING AND MOVE CURSOR		:
   171                              <1> ;			BL     -  ATTRIBUTE					:
   172                              <1> ;			STRING IS  <CHAR,CHAR, ... ,CHAR>			:
   173                              <1> ;			CURSOR MOVED						:
   174                              <1> ;		(AL)= 02H	WRITE CHARACTER AND ATTRIBUTE STRING		:
   175                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
   176                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
   177                              <1> ;			CURSOR IS NOT MOVED					:
   178                              <1> ;		(AL)= 03H WRITE CHARACTER AND ATTRIBUTE STRING AND MOVE CURSOR	:
   179                              <1> ;			       (VALID FOR ALPHA MODES ONLY)			:
   180                              <1> ;			STRING IS <CHAR,ATTR,CHAR,ATTR ..  ,CHAR,ATTR>		:
   181                              <1> ;			CURSOR IS MOVED						:
   182                              <1> ;		 NOTE:  CARRIAGE RETURN, LINE FEED, BACKSPACE, AND BELL ARE	:
   183                              <1> ;		        TREATED AS COMMANDS RATHER THAN PRINTABLE CHARACTERS.	:
   184                              <1> ;										:
   185                              <1> ;	BX,CX,DX,SI,DI,BP,SP,DS,ES,SS PRESERVED DURING CALLS EXCEPT FOR		:
   186                              <1> ;	BX,CX,DX RETURN VALUES ON FUNCTIONS 03H,04H,0DH AND 0FH. ON ALL CALLS	:
   187                              <1> ;	AX IS MODIFIED.								:
   188                              <1> ;--------------------------------------------------------------------------------
   189                              <1> 
   190 00001771 [221B0000]          <1> M1:	dd	SET_MODE	; TABLE OF ROUTINES WITHIN VIDEO I/O
   191 00001775 [EF1E0000]          <1> 	dd	SET_CTYPE
   192 00001779 [231F0000]          <1> 	dd	SET_CPOS
   193 0000177D [4B1F0000]          <1> 	dd	READ_CURSOR
   194                              <1> 	;dd	VIDEO_RETURN	; READ_LPEN
   195 00001781 [201B0000]          <1> 	dd	set_mode_ncm	; Set mode without clearing video memory
   196 00001785 [911F0000]          <1> 	dd	ACT_DISP_PAGE
   197 00001789 [23200000]          <1> 	dd	SCROLL_UP
   198 0000178D [4D210000]          <1> 	dd	SCROLL_DOWN
   199 00001791 [CD210000]          <1> 	dd	READ_AC_CURRENT
   200 00001795 [2A220000]          <1> 	dd	WRITE_AC_CURRENT
   201 00001799 [50220000]          <1> 	dd	WRITE_C_CURRENT
   202 0000179D [952B0000]          <1> 	dd	SET_COLOR
   203 000017A1 [002C0000]          <1> 	dd	WRITE_DOT
   204 000017A5 [CB2B0000]          <1> 	dd	READ_DOT
   205 000017A9 [E0220000]          <1> 	dd	WRITE_TTY
   206 000017AD [081B0000]          <1> 	dd	VIDEO_STATE
   207 000017B1 [94360000]          <1> 	dd	vga_pal_funcs	; 10/08/2016 (TRDOS 386)
   208 000017B5 [0D310000]          <1> 	dd	font_setup	; 10/07/2016 (TRDOS 386)
   209 000017B9 [571B0000]          <1> 	dd	VIDEO_RETURN	; RESERVED
   210 000017BD [5B240000]          <1> 	dd	WRITE_STRING	; 23/06/2016 (TRDOS 386)
   211                              <1> M1L	EQU	$ - M1
   212                              <1> 
   213                              <1> ; 06/12/2020
   214                              <1> ; 05/12/2020
   215                              <1> ; 03/12/2020
   216                              <1> ; 27/11/2020 - TRDOS 386 v2.0.3
   217                              <1> ; 14/01/2017
   218                              <1> ; 02/01/2017
   219                              <1> ; 04/07/2016
   220                              <1> ; 12/05/2016
   221                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   222                              <1> int31h:  ; Video BIOS
   223                              <1> 
   224                              <1> ; BH = Video page number
   225                              <1> ; BL = Color/Attribute
   226                              <1> ; AH = Function number
   227                              <1> ; AL = Character
   228                              <1> 
   229                              <1> VIDEO_IO_1:
   230                              <1> 	;sti				; INTERRUPTS BACK ON
   231 000017C1 FC                  <1> 	cld				; SET DIRECTION FORWARD
   232                              <1> 	
   233                              <1> 	;cmp	ah, M1L/4		; TEST FOR WITHIN TABLE RANGE
   234                              <1> 	;jnb	short M4		; BRANCH TO EXIT IF NOT A VALID COMMAND
   235                              <1> 
   236                              <1> 	; 26/11/2020
   237 000017C2 80FC14              <1> 	cmp	ah, M1L/4
   238 000017C5 7205                <1> 	jb	short VGA_func
   239                              <1> 
   240 000017C7 80FC4F              <1> 	cmp	ah, 4Fh
   241 000017CA 7532                <1> 	jne	short M4 ; invalid !
   242                              <1> 
   243                              <1> VGA_func: ; 26/11/2020
   244 000017CC 06                  <1> 	push	es ; *
   245 000017CD 1E                  <1> 	push	ds ; **			; SAVE WORK AND PARAMETER REGISTERS
   246                              <1> 
   247                              <1> 	; 26/11/2020
   248 000017CE 50                  <1> 	push	eax ; -
   249                              <1> 	
   250 000017CF 66B81000            <1> 	mov	ax, KDATA 		; POINT DS: TO DATA SEGMENT
   251 000017D3 8ED8                <1> 	mov	ds, ax
   252 000017D5 8EC0                <1> 	mov	es, ax
   253                              <1> 
   254                              <1> 	; 26/11/2020
   255 000017D7 58                  <1> 	pop	eax ; +
   256                              <1> 	;
   257 000017D8 FB                  <1> 	sti
   258 000017D9 80FC4F              <1> 	cmp	ah, 4Fh
   259 000017DC 747A                <1> 	je	short VBE_func
   260                              <1> 
   261                              <1> 	; 04/12/2020
   262 000017DE A3[58960100]        <1> 	mov	[video_eax], eax
   263                              <1> 
   264                              <1> 	; 21/12/2020
   265 000017E3 803D[CA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh	; Current mode is a VESA VBE mode ?
   266 000017EA 7213                <1> 	jb	short VGA_func_std
   267                              <1> 
   268 000017EC 08E4                <1> 	or	ah, ah			; set mode ?
   269 000017EE 750F                <1> 	jnz	short VGA_func_std	; no
   270                              <1> 
   271 000017F0 803D[54090000]03    <1> 	cmp	byte [vbe3], 3		; (real) VESA VBE 3 video bios ?
   272 000017F7 7506                <1> 	jne	short VGA_func_std	; no
   273                              <1> 
   274 000017F9 E989010000          <1> 	jmp	vesa_vbe3_pmi
   275                              <1> 
   276                              <1> 	; 21/12/2020
   277                              <1> M4:					; COMMAND NOT VALID
   278 000017FE CF                  <1> 	iretd				; DO NOTHING IF NOT IN VALID RANGE
   279                              <1> 
   280                              <1> VGA_func_std:
   281                              <1> 	; 06/12/2020
   282                              <1> 	; 03/12/2020
   283 000017FF 80FC0F              <1> 	cmp	ah, 0Fh
   284 00001802 773D                <1> 	ja	short VGA_funcs_0	; only CGA funcs will be handled by	
   285                              <1> 	; 06/12/2020			; vga bios firmware
   286                              <1> 	; 03/12/2020			
   287                              <1> 	;test	ah, 7Fh ; set mode ?
   288                              <1> 	;;or	ah, ah			; only 'set mode' will be handled by
   289                              <1> 	;jnz	short VGA_funcs_0	; vga bios firmware	
   290                              <1> 	;jz	short vbe_pmi32_0
   291                              <1> 
   292                              <1> 	; 28/11/2020
   293 00001804 803D[1C120300]00    <1> 	cmp	byte [pmi32], 0		; 32 bit protected mode interface for
   294 0000180B 7634                <1> 	jna	short VGA_funcs_0	; video hardware's vga bios firmware
   295                              <1> 					; ([pmi32] > 0 if it is activated)
   296                              <1> 					; note:
   297                              <1> 					; [vbe3] = 3 is required to activate
   298                              <1> 	; 07/12/2020
   299 0000180D 20E4                <1> 	and	ah, ah ; is this set mode ?
   300 0000180F 7413                <1> 	jz	short vbe_pmi32_2 ; yes
   301                              <1> 
   302 00001811 80FC04              <1> 	cmp	ah, 04h	 ; set mode ('no clear memory' option)
   303 00001814 742B                <1> 	je	short VGA_funcs_0
   304                              <1> 
   305                              <1> 	; 07/12/2020
   306 00001816 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
   307 0000181D 7622                <1> 	jna	short VGA_funcs_0  ; no	
   308                              <1> 
   309                              <1> 	; when mode 3 is active, 
   310                              <1> 	; video bios functions are not redirected
   311                              <1> 	; to VESA VBE3 PMI except 'set mode' function
   312                              <1> 
   313                              <1> vbe_pmi32_0:
   314                              <1> 	; 06/12/2020
   315                              <1> 	;or	ah, ah
   316                              <1> 	;jnz	short vbe_pmi32_2
   317                              <1> 	; ah = 0 ; 'set mode'
   318                              <1> 	;cmp	al, 3 ; 80x25 text mode, 16 colors, default mode for MainProg
   319                              <1> 	;jne	short vbe_pmi32_1
   320                              <1> 	;cmp	byte [CRT_MODE], 3 ; If current video mode <> 3 and requested
   321                              <1> 	;			; video mode is 3, use internal 'set mode';
   322                              <1> 	;			; otherwise, use vesa vbe 3 bios's 'set mode'.
   323                              <1> 	;jne	short VGA_funcs_0
   324                              <1> vbe_pmi32_1:
   325 0000181F E963010000          <1> 	jmp	vesa_vbe3_pmi
   326                              <1> ;vbe_pmi32_2:
   327                              <1> 	;cmp	ah, 04h ; set mode (no clear mem option)
   328                              <1> 	;jne	short vbe_pmi32_1
   329                              <1> 
   330                              <1> vbe_pmi32_2:
   331                              <1> 	; 07/12/2020
   332 00001824 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; current mode > 7 ?
   333 0000182B 77F2                <1> 	ja	short vbe_pmi32_1  ; yes
   334                              <1> 
   335 0000182D 3C07                <1> 	cmp	al, 7	; requested mode > 7 ?
   336 0000182F 7610                <1> 	jna	short VGA_funcs_0  ; no (CGA)
   337                              <1> 
   338 00001831 3C13                <1> 	cmp	al, 13h
   339 00001833 76EA                <1> 	jna	short vbe_pmi32_1
   340                              <1> 
   341 00001835 A880                <1> 	test	al, 80h
   342 00001837 7408                <1> 	jz	short VGA_funcs_0  ; unknown or special
   343                              <1> 
   344 00001839 3C87                <1> 	cmp	al, 87h	; requested mode > 7 ? 
   345                              <1> 			; (with no clear mem ops)
   346 0000183B 7604                <1> 	jna	short VGA_funcs_0  ; no (CGA)
   347                              <1> 
   348 0000183D 3C93                <1> 	cmp	al, 93h
   349 0000183F 76DE                <1> 	jna	short vbe_pmi32_1
   350                              <1> 
   351                              <1> 	; > 13h video modes are unknown or special
   352                              <1>  	; they must be handled by kernel	
   353                              <1> 
   354                              <1> 	; CGA video modes will be handled by kernel		
   355                              <1> 
   356                              <1> VGA_funcs_0:
   357 00001841 52                  <1> 	push	edx ; ***
   358 00001842 51                  <1> 	push	ecx ; ****
   359 00001843 53                  <1> 	push	ebx ; *****
   360 00001844 56                  <1> 	push	esi ; ******
   361 00001845 57                  <1> 	push	edi ; *******
   362 00001846 55                  <1> 	push	ebp ; ********
   363                              <1> 
   364                              <1> 	;mov	[video_eax], eax ; 12/05/2016 
   365 00001847 BF00800B00          <1> 	mov	edi, 0B8000h		; GET offset FOR COLOR CARD
   366                              <1> 
   367                              <1> 	; 23/03/2016
   368 0000184C C0E402              <1> 	shl	ah, 2  ; dword		; TIMES 2 FOR WORD TABLE LOOKUP
   369 0000184F 0FB6F4              <1> 	movzx	esi, ah			; MOVE OFFSET INTO LOOK UP REGISTER (SI)
   370                              <1> 	;mov	ah, [CRT_MODE]		; MOVE CURRENT MODE INTO (AH) REGISTER
   371                              <1> 
   372                              <1> 	;;15/01/2017
   373                              <1> 	; 14/01/2017
   374                              <1> 	; 02/01/2017
   375                              <1> 	;;mov	byte [intflg], 31h  ; video interrupt
   376                              <1> 	;sti ; 26/11/2020
   377                              <1> 	;
   378                              <1> 
   379 00001852 FFA6[71170000]      <1> 	JMP	dword [esi+M1]		; GO TO SELECTED FUNCTION
   380                              <1> 
   381                              <1> VBE_func:
   382                              <1> 	; 26/11/2020
   383                              <1> 	;sti
   384 00001858 55                  <1> 	push	ebp ; *** ; 27/11/2020	
   385 00001859 56                  <1> 	push	esi ; **** 
   386                              <1> 	
   387                              <1> 	; Note:
   388                              <1> 	; ebx, ecx, edx, edi, ebp registers
   389                              <1> 	; must be saved by VBE functions and
   390                              <1> 	; eax register must be set
   391                              <1> 	; (according to VBE 3 standard)
   392                              <1> 	; before return from this interrupt
   393                              <1> 	; (every function must restore and set
   394                              <1> 	; registers except esp, esi, es, ds)
   395                              <1> 
   396 0000185A 803D[54090000]02    <1> 	cmp	byte [vbe3], 2
   397 00001861 7741                <1> 	ja	short VESA_VBE3_PMI_CALL ; VBE3 video bios ('PMID')
   398                              <1> 	;je	short VBE_func_0  ; Bochs/Qemu/VirtualBox emulator
   399 00001863 726A                <1> 	jb	short VBE_unknown ; invalid ([vbe3] = 0)
   400                              <1> 
   401                              <1> 	;jmp	VESA_VBE3_PMI_CALL
   402                              <1> 
   403                              <1> VBE_func_0:	
   404                              <1> 	; Bochs/Plex86 VGAbios VBE extension
   405                              <1> 	; (TRDOS 386 v2.0.3 can use VBE graphics modes on emulators)
   406                              <1> 	; BOCHS/QEMU/VIRTUALBOX
   407                              <1>  
   408 00001865 8A25[55090000]      <1> 	mov	ah, [vbe2bios]
   409 0000186B 80FCC0              <1> 	cmp	ah, 0C0h		
   410 0000186E 725F                <1> 	jb	short VBE_unknown 	
   411 00001870 80FCC5              <1> 	cmp	ah, 0C5h
   412 00001873 775A                <1> 	ja	short VBE_unknown
   413                              <1> 
   414                              <1> 	; TRDOS 386 is running on BOCHS or QEMU
   415 00001875 B44F                <1> 	mov	ah, 4Fh
   416                              <1> VBE_func_1:
   417 00001877 0FB6F0              <1> 	movzx	esi, al ; VESA VBE function number
   418 0000187A 66C1E602            <1> 	shl	si, 2 ; dword
   419 0000187E 6683FE14            <1> 	cmp	si, N1L
   420 00001882 734B                <1> 	jnb	short VBE_unknown
   421                              <1> 	;sti
   422                              <1> 	
   423 00001884 FF96[90180000]      <1> 	call	dword [esi+N1] ; call VBE function
   424                              <1> 		
   425                              <1> 	;jmp	short VBE_bios_return
   426                              <1> 
   427                              <1> VBE_bios_return:
   428 0000188A FA                  <1> 	cli
   429 0000188B 5E                  <1> 	pop	esi ; ****
   430 0000188C 5D                  <1> 	pop	ebp ; *** ; 27/11/2020
   431 0000188D 07                  <1> 	pop	es  ; **
   432 0000188E 1F                  <1> 	pop	ds  ; *
   433 0000188F CF                  <1> 	iretd
   434                              <1> 
   435                              <1> 	; 26/11/2020
   436                              <1> N1:
   437 00001890 [F3180000]          <1> 	dd	vbe_biosfn_return_ctrl_info
   438 00001894 [203A0000]          <1> 	dd	vbe_biosfn_return_mode_info
   439 00001898 [DB3A0000]          <1> 	dd	vbe_biosfn_set_mode
   440 0000189C [AB3B0000]          <1> 	dd	vbe_biosfn_return_current_mode
   441 000018A0 [CA3B0000]          <1> 	dd	vbe_biosfn_save_restore_state
   442                              <1> 	;dd	vbe_biosfn_display_window_ctrl
   443                              <1> 	;dd	vbe_biosfn_set_get_log_scanline
   444                              <1> 	;dd	vbe_biosfn_set_get_disp_start
   445                              <1> 	;dd	vbe_biosfn_set_get_dac_pal_frm
   446                              <1> 	;dd	vbe_biosfn_set_get_palette_data
   447                              <1> 	
   448                              <1> N1L	EQU	$ - N1
   449                              <1> 
   450                              <1> 
   451                              <1> VESA_VBE3_PMI_CALL: ; VESA VBE video bios (firmware) functions
   452                              <1> 		    ; by using VESA VBE3 Protected Mode Interface
   453                              <1> 	
   454                              <1> 	; 29/11/2020
   455                              <1> 	; 26/11/2020 - TRDOS 386 v2.0.3 video.s
   456                              <1> 
   457                              <1> 	; We are here because..
   458                              <1> 	; 'PMID' has been verified by TRDOS 386 v2.0.3 kernel.
   459                              <1> 	; (Otherwise bochs/plex86 compatible VBE functions and
   460                              <1> 	;  modes would be used on BOCHS/QEMU/VIRTUALBOX emulators
   461                              <1> 	;  or only standard/old VGA graphics modes would be used.)   	
   462                              <1> 
   463                              <1> 	; (TRDOS 386 v2.0.3 can use VESA VBE graphics modes if
   464                              <1> 	;  the video bios is full compatible with VBE3 standard) 
   465                              <1> 
   466                              <1> 	; 29/11/2020
   467                              <1> 
   468 000018A4 0FB6F0              <1> 	movzx	esi, al ; VESA VBE 3 function number
   469 000018A7 66C1E602            <1> 	shl	si, 2 ; dword
   470 000018AB 6683FE14            <1> 	cmp	si, P1L
   471 000018AF 731E                <1> 	jnb	short VBE_unknown
   472                              <1> 	;sti
   473                              <1> 
   474 000018B1 57                  <1> 	push	edi ; *****
   475                              <1> 		
   476 000018B2 FF96[BB180000]      <1> 	call	dword [esi+P1] ; call VBE 3 function
   477                              <1> 
   478 000018B8 5F                  <1> 	pop	edi ; *****
   479                              <1> 		
   480 000018B9 EBCF                <1> 	jmp	short VBE_bios_return
   481                              <1> 
   482                              <1> P1:
   483 000018BB [D5180000]          <1> 	dd	vbe3_pmfn_return_ctrl_info
   484 000018BF [F9180000]          <1> 	dd	vbe3_pmfn_return_mode_info
   485 000018C3 [36190000]          <1> 	dd	vbe3_pmfn_set_mode
   486 000018C7 [31190000]          <1> 	dd	vbe3_pmfn_return_current_mode
   487 000018CB [281A0000]          <1> 	dd	vbe3_pmfn_save_restore_state
   488                              <1> 	;dd	vbe3_pmfn_display_window_ctrl
   489                              <1> 	;dd	vbe3_pmfn_set_get_log_scanline
   490                              <1> 	;dd	vbe3_pmfn_set_get_disp_start
   491                              <1> 	;dd	vbe3_pmfn_set_get_dac_pal_frm
   492                              <1> 	;dd	vbe3_pmfn_set_get_palette_data
   493                              <1> 	;dd	vbe3_pmfn_return_pmi ; invalid for TRDOS 386 v2
   494                              <1> 	;dd	vbe3_pmfn_set_get_pixel_clock
   495                              <1> 	
   496                              <1> P1L	EQU	$ - P1
   497                              <1> 
   498                              <1> ;	; 29/11/2020
   499                              <1> ;	mov	edi, VBE3MODEINFOBLOCK >> 4 ; / 16
   500                              <1> ;	
   501                              <1> ;	cmp	al, 04h
   502                              <1> ;	jb	short vbe3_pm_f ; function: 4F00h to 4F03h
   503                              <1> ;	ja	short vbe3_pmi_f5B ; function: 4F05h to 4F0Bh
   504                              <1> ;
   505                              <1> ;	; check buffer length (must be <= 2048 bytes)
   506                              <1> ;
   507                              <1> ;	and	dl, dl ; 0
   508                              <1> ;	jz	short vbe3_pm_f 
   509                              <1> ;		       ; Return Save/Restore State buffer size
   510                              <1> ;
   511                              <1> ;	push	ebx  ; buffer address
   512                              <1> ;	push	edx  ; function: save (01h) or restore (02h)
   513                              <1> ;	call	
   514                              <1> ;
   515                              <1> ;vbe3_pm_f03:
   516                              <1> ;	cmp	al, 2
   517                              <1> ;	ja	short vbe3_pm_f ; function 4F03h
   518                              <1> ;	jb	short vbe3_pm_f1
   519                              <1> ;
   520                              <1> ;
   521                              <1> ;vbe3_pm_f1:
   522                              <1> ;	
   523                              <1> ;
   524                              <1> ;vbe3_pmi_f5B:
   525                              <1> ;	cmp	al, 09h
   526                              <1> ;	jna	short vbe3_pm_f ; funcs 05h to 09h are usable 
   527                              <1> ;	
   528                              <1> ;	cmp	al, 0Bh ; Get/Set pixel clock, last function
   529                              <1> ;	jne	short VBE_unknown 
   530                              <1> ;			; (do not use 'uncertain' functions
   531                              <1> ;			; because of system-user buff transfers) 	
   532                              <1> ;vbe3_pm_f:
   533                              <1> ;	mov	byte [vbe3_pm_fn], al	; set
   534                              <1> ;	; prepare 16 bit pm segments & registers for pmi call 
   535                              <1> ;	call	VESA_VBE3_PM_FUNCTION
   536                              <1> ;
   537                              <1> ;
   538                              <1> 
   539                              <1> 	; 26/11/2020
   540                              <1> VBE_unknown:
   541 000018CF 66B80001            <1> 	mov	ax, 0100h  ; ah = 1 : Function call failed	
   542                              <1> 			   ; al = 0 : Function is not supported	
   543                              <1> 	
   544 000018D3 EBB5                <1> 	jmp	short VBE_bios_return
   545                              <1> 
   546                              <1> vbe3_pmfn_return_ctrl_info:
   547                              <1> 	; 12/12/2020
   548                              <1> 	;
   549                              <1> 	; VBE function 4F00h - Return VBE Controller Information
   550                              <1> 	;
   551                              <1> 	; Input:
   552                              <1> 	;      EDI = Pointer to buffer in which to place
   553                              <1> 	;	     VbeInfoBlock structure
   554                              <1> 	;
   555                              <1> 	;	AX = 4F00h
   556                              <1> 	; Output:
   557                              <1> 	;	AX = VBE return status
   558                              <1> 	;	     AX = 004Fh -> succeeded
   559                              <1> 	;	     AX <> 004Fh -> failed   
   560                              <1> 	; 
   561                              <1> 	; Modified registers: eax (+ edi for kernel's own call)
   562                              <1> 
   563                              <1> 	; NOTE: TRDOS 386 v2 (v2.0.3) kernel calls this function
   564                              <1> 	; during startup while cpu is in real mode
   565                              <1> 	; (by using int 10h, 4F02h) and saves VbeInfoBlock at
   566                              <1> 	; VBE3INFOBLOCK address (97E00h for TRDOS 386 v2.0.3).
   567                              <1> 	;	
   568                              <1> 	; So...
   569                              <1> 	; This VBE function is adjusted to return/move same info	
   570                              <1> 	; from VBE3INFOBLOCK to user's buffer in EDI.
   571                              <1> 
   572                              <1> 	; int 31h (int 10h) entrance
   573                              <1> 
   574 000018D5 21FF                <1> 	and	edi, edi
   575 000018D7 7424                <1> 	jz	short vbe3_func_fail ; invalid buffer address !
   576                              <1> 
   577                              <1> ;_vbe3_pmfn_return_ctrl_info:		
   578                              <1> 	;or	edi, edi
   579                              <1> 	;jnz	short _vbe_biosfn_return_ctrl_info
   580                              <1> 	;
   581                              <1> 	;; this option may not be necessary - 12/12/2020
   582                              <1> 	;
   583                              <1> 	;; edi = 0, kernel forces to get ctrl info again
   584                              <1> 	;;	   by using VESA VBE3 video bios's pmi
   585                              <1> 	;
   586                              <1> 	;;push	edi
   587                              <1> 	;; far call to VESA VBE3 PMI 
   588                              <1> 	;;mov	ax, 4F00h ; Return VBE Controller Info
   589                              <1> 	;mov	edi, VBE3INFOBLOCK-VBE3SAVERESTOREBLOCK
   590                              <1> 	;; ES selector base address = VBE3SAVERESTOREBLOCK 
   591                              <1> 	;call	int10h_32bit_pmi
   592                              <1> 	;;pop	edi
   593                              <1> 	;mov	edi, VBE3INFOBLOCK ; retn to the kernel sub
   594                              <1> 	;cmp	ax, 004Fh
   595                              <1> 	;je	short vbe_ctrl_info_retn
   596                              <1> 	;stc	
   597                              <1> 	;retn
   598                              <1> 
   599                              <1> _vbe_biosfn_return_ctrl_info:
   600 000018D9 57                  <1> 	push	edi
   601 000018DA 51                  <1> 	push	ecx
   602 000018DB BE007E0900          <1> 	mov	esi, VBE3INFOBLOCK
   603 000018E0 B900020000          <1> 	mov	ecx, 512
   604 000018E5 E81A020100          <1> 	call	transfer_to_user_buffer
   605 000018EA 59                  <1> 	pop	ecx
   606 000018EB 5F                  <1> 	pop	edi
   607 000018EC 720F                <1> 	jc	short vbe3_func_fail
   608                              <1> 
   609 000018EE 31C0                <1> 	xor	eax, eax
   610 000018F0 B04F                <1> 	mov	al, 4Fh ; successful
   611                              <1> ;vbe_ctrl_info_retn:
   612 000018F2 C3                  <1> 	retn
   613                              <1> 
   614                              <1> vbe_biosfn_return_ctrl_info:
   615                              <1> 	; 12/12/2020
   616                              <1> 	;
   617                              <1> 	; VBE function 4F00h - Return VBE Controller Information
   618                              <1> 	;
   619                              <1> 	; Input:
   620                              <1> 	;      EDI = Pointer to buffer in which to place
   621                              <1> 	;	     VbeInfoBlock structure
   622                              <1> 	;
   623                              <1> 	;	AX = 4F00h
   624                              <1> 	; Output:
   625                              <1> 	;	AX = VBE return status
   626                              <1> 	;	     AX = 004Fh -> succeeded
   627                              <1> 	;	     AX <> 004Fh -> failed   
   628                              <1> 	; 
   629                              <1> 	; Modified registers: eax
   630                              <1> 
   631 000018F3 21FF                <1> 	and	edi, edi
   632 000018F5 7406                <1> 	jz	short vbe3_func_fail ; invalid buffer addr !
   633 000018F7 EBE0                <1> 	jmp	short _vbe_biosfn_return_ctrl_info 
   634                              <1> 
   635                              <1> vbe3_pmfn_return_mode_info:
   636                              <1> 	; 21/12/2020
   637                              <1> 	; 12/12/2020
   638                              <1> 	;
   639                              <1> 	; VBE function 4F01h - Return VBE Mode Information
   640                              <1> 	;
   641                              <1> 	; Input:
   642                              <1> 	;	CX = Mode number (VESA VBE mode number)
   643                              <1> 	;      EDI = Pointer to ModeInfoBlock structure
   644                              <1> 	;	     (256 bytes) -User's buffer address-
   645                              <1> 	;      EDI = 0 -> kernel call
   646                              <1> 	;		  (do not transfer ModeInfoBlock
   647                              <1> 	;		  to user's buffer address)
   648                              <1> 	;	AX = 4F01h	
   649                              <1> 	; Output:
   650                              <1> 	;	AX = VBE return status
   651                              <1> 	;	     AX = 004Fh -> succeeded
   652                              <1> 	;	     AX <> 004Fh -> failed   
   653                              <1> 	; 
   654                              <1> 	; Modified registers: eax, esi, edi
   655                              <1> 
   656                              <1> 	; int 31h (int 10h) entrance
   657                              <1> 	
   658 000018F9 09FF                <1> 	or	edi, edi
   659 000018FB 7506                <1> 	jnz	short _vbe3_pmfn_return_mode_info
   660                              <1> 
   661                              <1> vbe3_func_fail:
   662 000018FD B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed	
   663                              <1> 			   ; al = 4Fh : Function is supported
   664 00001902 C3                  <1> 	retn
   665                              <1> 	
   666                              <1> 	; jump from '_vbe_biosfn_return_mode_info' 
   667                              <1> _vbe3_pmfn_return_mode_info:
   668 00001903 57                  <1> 	push	edi
   669                              <1> 
   670                              <1> 	;; clear vbe3 'mode info block' buffer
   671                              <1> 	;push	ecx
   672                              <1> 	;xor	eax, eax
   673                              <1> 	;mov	ecx, 256/4
   674                              <1> 	;mov	edi, VBE3MODEINFOBLOCK
   675                              <1> 	;rep	stosd
   676                              <1> 	;pop	ecx
   677                              <1> 
   678                              <1> 	; far call to VESA VBE3 PMI 
   679                              <1> 	;mov	ax, 4F01h ; Return VBE Mode Information
   680 00001904 BF00060000          <1> 	mov	edi, VBE3MODEINFOBLOCK-VBE3SAVERESTOREBLOCK
   681                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
   682 00001909 E8FC000000          <1> 	call	int10h_32bit_pmi
   683                              <1> 
   684 0000190E 5F                  <1> 	pop	edi
   685                              <1> 
   686                              <1> 	;cmp	ax, 004Fh
   687                              <1> 	;jne	short vbe3_func_retn  ; failed !
   688                              <1> 
   689 0000190F 21FF                <1> 	and	edi, edi
   690                              <1> 	;jz	short vbe3_func_success
   691                              <1> 	; 21/12/2020
   692 00001911 741D                <1> 	jz	short vbe3_func_retn
   693                              <1> 
   694 00001913 6683F84F            <1> 	cmp	ax, 004Fh
   695 00001917 7517                <1> 	jne	short vbe3_func_retn  ; failed !
   696                              <1> 
   697 00001919 51                  <1> 	push	ecx
   698 0000191A BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK		
   699 0000191F B900010000          <1> 	mov	ecx, 256
   700 00001924 E8DB010100          <1> 	call	transfer_to_user_buffer
   701 00001929 59                  <1> 	pop	ecx
   702 0000192A 72D1                <1> 	jc	short vbe3_func_fail
   703                              <1> 
   704 0000192C 31C0                <1> 	xor	eax, eax
   705 0000192E B04F                <1> 	mov	al, 4Fh ; successful
   706                              <1> vbe3_func_success:
   707                              <1> vbe3_func_retn:	
   708 00001930 C3                  <1> 	retn
   709                              <1> 
   710                              <1> vbe3_pmfn_return_current_mode:
   711                              <1> 	; 12/12/2020
   712                              <1> 	;
   713                              <1> 	; VBE function 4F03h - Return Current VBE Mode
   714                              <1> 	;
   715                              <1> 	; Input:
   716                              <1> 	;	none (AX = 4F03h)
   717                              <1> 	; Output:
   718                              <1> 	;	AX = VBE return status
   719                              <1> 	;	     AX = 004Fh -> succeeded
   720                              <1> 	;	     AX <> 004Fh -> failed
   721                              <1> 	;	BX = Current VBE mode
   722                              <1> 	;	  bit 0-13 = Mode number
   723                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
   724                              <1> 	;	         = 1 Linear frame buffer model
   725                              <1> 	;	  bit 15 
   726                              <1> 	;	      = 0 Memory cleared at last mode set
   727                              <1> 	;	      = 1 Memory not cleared at last mode set
   728                              <1> 	; 
   729                              <1> 	; Modified registers: eax, ebx
   730                              <1> 
   731                              <1> 	; int 31h (int 10h) entrance
   732                              <1> 	
   733                              <1> 	; far call to VESA VBE3 PMI 
   734                              <1> 
   735                              <1> 	;mov	eax, 4F03h ; Return Current VBE Mode
   736                              <1> vbe3_pmfn_far_call:
   737                              <1> 	; ES selector base address = VBE3SAVERESTOREBLOCK 
   738                              <1> 	;call	int10h_32bit_pmi
   739                              <1> 	;retn
   740 00001931 E9D4000000          <1> 	jmp	int10h_32bit_pmi
   741                              <1> 
   742                              <1> vbe3_pmfn_set_mode:
   743                              <1> 	; 22/12/2020
   744                              <1> 	; 21/12/2020
   745                              <1> 	; 12/12/2020
   746                              <1> 	;
   747                              <1> 	; VBE function 4F02h - Set VBE Mode
   748                              <1> 	;
   749                              <1> 	; Input:
   750                              <1> 	;	BX = Desired Mode to set
   751                              <1> 	;	  bit 0-13 = Mode number
   752                              <1> 	;	  bit 14 = 0 Windowed frame buffer model
   753                              <1> 	;	         = 1 Linear frame buffer model
   754                              <1> 	;	  bit 15 
   755                              <1> 	;	      = 0 Memory cleared at last mode set
   756                              <1> 	;	      = 1 Memory not cleared at last mode set
   757                              <1> 	; Output:
   758                              <1> 	;	AX = VBE return status
   759                              <1> 	;	     AX = 004Fh -> succeeded
   760                              <1> 	;	     AX <> 004Fh -> failed
   761                              <1> 	; 
   762                              <1> 	; Modified registers: eax, ebx, esi (21/12/2020)
   763                              <1> 
   764                              <1> 	; int 31h (int 10h) entrance
   765                              <1> 
   766                              <1> 	; 22/12/2020 (VESA VBE3 feature)
   767                              <1> 	; BX bit 11 is flag for
   768                              <1> 	;	user specified CRTC values for refresh rate
   769                              <1> 	; 'test bh, 8'
   770                              <1> 	; if bit 11 is set, EDI points to 'CRTCInfoBlock'
   771                              <1> 
   772                              <1> 	; 22/12/2020
   773                              <1> 	;; test bx for VBE video mode
   774                              <1> 	;test	bh, 1
   775                              <1> 	;jnz	short vbe3_sm_0
   776                              <1> 
   777                              <1> 	;; use internal VBE mode set procedure
   778                              <1> 	;; for non-vbe (std VGA/CGA) modes
   779                              <1> 	;
   780                              <1> 	;; (it is useful -as 4F02h function- 
   781                              <1> 	;;  to jump 'vbe_biosfn_set_mode'
   782                              <1> 	;;  instead of direct jump to '_set_mode')
   783                              <1> 	;; ((eliminates additional push-pops and settings))  
   784                              <1>  
   785                              <1> 	;jmp	vbe_biosfn_set_mode	
   786                              <1> 
   787                              <1> vbe3_sm_0: 
   788                              <1> 	;;push	ds  ; *
   789                              <1> 	;;push	es  ; **
   790                              <1> 	;;push	ebp ; ***
   791                              <1> 	;;push	esi ; **** 
   792                              <1> 	
   793                              <1> 	; Fit bx to VESA VBE2 type mode setting
   794                              <1> 	; (bx bit 11 is used for custom CRTC values in VBE3)
   795                              <1> 	; clear bit 9 to 11 (clear bh bit 1 to bit 3)
   796                              <1> 
   797                              <1> 	; 22/12/2020
   798 00001936 57                  <1> 	push	edi ; *****
   799 00001937 F6C708              <1> 	test	bh, 8	; Use user specified CRTC values
   800 0000193A 7530                <1> 	jnz	short vbe3_sm_3  ; for refresh rate
   801                              <1> vbe3_sm_4:
   802 0000193C 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
   803                              <1> 	;mov	[vbe_mode_x], bh
   804                              <1> 
   805 0000193F 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h ?
   806 00001946 7509                <1> 	jne	short vbe3_sm_1    ; no
   807                              <1> 
   808                              <1> 	; save mode 03h video pages and cursor positions
   809 00001948 57                  <1> 	push	edi ; **!***	
   810 00001949 51                  <1> 	push	ecx ; ******
   811                              <1> 	;push	esi
   812                              <1> 	
   813 0000194A E8CE040000          <1> 	call	save_mode3_multiscreen
   814                              <1> 	
   815                              <1> 	;pop	esi
   816 0000194F 59                  <1> 	pop	ecx ; ******
   817 00001950 5F                  <1> 	pop	edi ; **!***		
   818                              <1> vbe3_sm_1:
   819                              <1> 	; ax = 4F02h
   820                              <1> 	; bx = video mode number (vbe2 type)	
   821 00001951 E8B4000000          <1> 	call	int10h_32bit_pmi 
   822                              <1> 			; call to far call to VBE3 PMI
   823                              <1> 
   824 00001956 6683F84F            <1> 	cmp	ax, 004Fh ; succeeded ?
   825 0000195A 750E                <1> 	jne	short vbe3_sm_2
   826                              <1> 	; set current mode byte/sign to extended (SVGA) mode
   827 0000195C C605[CA6F0000]FF    <1> 	mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
   828                              <1> 	; set current VBE mode word to bx input
   829 00001963 66891D[1E120300]    <1> 	mov	[video_mode], bx
   830                              <1> vbe3_sm_2:
   831                              <1> 	; 22/12/2020
   832 0000196A 5F                  <1> 	pop	edi ; ***** 
   833 0000196B C3                  <1> 	retn
   834                              <1> 
   835                              <1> vbe3_sm_3:
   836                              <1> 	; 22/12/2020
   837                              <1> 	; copy user's CRTCInfoBlock to the buffer
   838 0000196C 51                  <1> 	push	ecx
   839 0000196D 89FE                <1> 	mov	esi, edi
   840 0000196F BF807D0900          <1> 	mov	edi, VBE3CRTCINFOBLOCK
   841 00001974 B940000000          <1> 	mov	ecx, 64
   842 00001979 E8D0010100          <1> 	call	transfer_from_user_buffer
   843 0000197E 59                  <1> 	pop	ecx
   844                              <1> 	; set offset (es base addr is VBE3SAVERESTOREBLOCK) 
   845 0000197F 81EF00760900        <1> 	sub	edi, VBE3SAVERESTOREBLOCK
   846 00001985 EBB5                <1> 	jmp	short vbe3_sm_4
   847                              <1> 	
   848                              <1> vesa_vbe3_pmi:
   849                              <1> 	; 12/12/2020
   850                              <1> 	; 08/12/2020
   851                              <1> 	; 07/12/2020
   852                              <1> 	; 05/12/2020, 06/12/2020
   853                              <1> 	; 03/12/2020, 04/12/2020
   854                              <1> 	; 28/11/2020 (TRDOS 386 v2.0.3)
   855                              <1> 	; VGA BIOS functions via
   856                              <1> 	; VESA VBE3 Protected Mode Inface
   857                              <1> 	; [vbe3] = 3 and [pmi32] > 0
   858                              <1> 
   859                              <1> 	; 04/12/2020
   860                              <1> 	; Only 'set mode' will be redirected to vbe3 video bios
   861                              <1> 	; (by setting mode 3 multiscreen paraters before and after) 
   862                              <1> 
   863                              <1> 	; 06/12/2020
   864 00001987 20E4                <1> 	and	ah, ah	; 0 = set mode function
   865 00001989 7402                <1> 	jz	short vbe3_pmi_0
   866 0000198B EB76                <1> 	jmp	vbe3_pmi_9 
   867                              <1> 
   868                              <1> vbe3_pmi_0:
   869                              <1> 	; 07/12/2020
   870 0000198D 88C4                <1> 	mov	ah, al
   871 0000198F 80E480              <1> 	and	ah, 80h ; 0 or 80h
   872 00001992 30E0                <1> 	xor	al, ah ; 8?h -> 0?h
   873                              <1> 
   874                              <1> 	;cmp	al, 13h ; mode number above 13h is returned
   875                              <1> 	;jna	short vbe3_pmi_1
   876                              <1> 	;		; back to default code due to uncertainty
   877                              <1> 	; 		; (>13h is not std for all svga bioses)
   878                              <1> 	;jmp	VGA_funcs_0
   879                              <1> vbe3_pmi_1:
   880                              <1> 	; 07/12/2020
   881                              <1> 	; Possible cases for VBE3 (PMI, ah=0) set mode:
   882                              <1> 	; current mode > 07h and requested mode: any 
   883                              <1> 	; current mode <= 07h and requested mode > 07h
   884                              <1> 
   885                              <1> 	; 06/12/2020
   886 00001994 8825[67960100]      <1> 	mov	byte [noclearmem], ah ; 0 or 80h
   887                              <1> 	; check current video mode if it is 03h
   888 0000199A 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; current mode
   889 000019A1 750B                <1> 	jne	short vbe3_pmi_3
   890                              <1> 	; 07/12/2020
   891                              <1> 	; check new video mode if it is 03h also
   892                              <1> 	;cmp	al, 3
   893                              <1> 	;jne	short vbe3_pmi_2
   894                              <1> 	;mov	byte [p_crt_mode], 80h 	; clear video memory
   895                              <1> 	;jmp	short vbe3_pmi_5
   896                              <1> vbe3_pmi_2:
   897                              <1> 	; case 1:
   898                              <1> 	; Current mode is 03h and new mode is not 03h
   899                              <1> 
   900                              <1> 	; save video pages and cursor positions
   901 000019A3 56                  <1> 	push	esi
   902 000019A4 57                  <1> 	push	edi
   903 000019A5 51                  <1> 	push	ecx
   904                              <1> 
   905                              <1> 	; 12/12/2020
   906                              <1> 	;mov	esi, 0B8000h ; mode 3 video memory
   907                              <1> 	;mov	edi, 98000h  ; backup location
   908                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
   909                              <1> 	;rep	movsd
   910                              <1> 	;
   911                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
   912                              <1> 	;xchg	cl, [ACTIVE_PAGE]
   913                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page	
   914                              <1> 	;
   915                              <1> 	;; save cursor positions
   916                              <1> 	;mov	esi, CURSOR_POSN
   917                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
   918                              <1> 	;mov	cl, 4
   919                              <1> 	;rep	movsd
   920                              <1> 
   921                              <1> 	; 12/12/2020
   922 000019A6 E872040000          <1> 	call	save_mode3_multiscreen
   923                              <1> 
   924 000019AB 59                  <1> 	pop	ecx
   925 000019AC 5F                  <1> 	pop	edi
   926 000019AD 5E                  <1> 	pop	esi
   927                              <1> vbe3_pmi_3:
   928                              <1> 	; 08/12/2020
   929                              <1> 	; 07/12/2020
   930                              <1> 	; case 3 or case 4
   931 000019AE A2[CA6F0000]        <1> 	mov	[CRT_MODE], al
   932 000019B3 3C03                <1> 	cmp	al, 3
   933 000019B5 7407                <1> 	je	short vbe3_pmi_4
   934                              <1> 	; case 4:
   935                              <1> 	; Current mode is not 03h and also new mode is not 03h
   936 000019B7 800D[65960100]80    <1> 	or	byte [p_crt_mode], 80h  ; 83h (case 1 -> case 4)
   937                              <1> 	;jmp	short vbe3_pmi_5
   938                              <1> vbe3_pmi_4:
   939                              <1> 	; case 3:
   940                              <1> 	;
   941                              <1> 	; Current mode is not 03h and new mode is 03h
   942                              <1> 
   943                              <1> ;vbe3_pmi_5:
   944                              <1> 	;mov	[CRT_MODE], al
   945                              <1> 
   946 000019BE E847000000          <1> 	call	int10h_32bit_pmi	
   947                              <1> 
   948 000019C3 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
   949                              <1> 	;jne	vbe3_pmi_8	; video mode <> 03h
   950 000019CA 7532                <1> 	jne	short vbe3_pmi_8	
   951                              <1> 
   952                              <1> 	;push	eax ; 04/12/2020
   953 000019CC 53                  <1> 	push	ebx
   954 000019CD 51                  <1> 	push	ecx
   955 000019CE 52                  <1> 	push	edx
   956 000019CF 57                  <1> 	push	edi ; 03/12/2020
   957                              <1> 
   958                              <1> 	; 12/12/2020
   959 000019D0 56                  <1> 	push	esi
   960 000019D1 E87A040000          <1> 	call	restore_mode3_multiscreen
   961 000019D6 5E                  <1> 	pop	esi
   962                              <1> 	; AL = active video page
   963                              <1> 
   964                              <1> 	; 12/12/2020
   965                              <1> 	;mov	al, [p_crt_page] ; previous mode 3 active page
   966                              <1> 	;
   967                              <1> 	;;test	byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
   968                              <1> 	;;jz	short vbe3_pmi_6 ; do not restore video pages
   969                              <1> 	;			 ; clear current video page
   970                              <1> 	;; case 3
   971                              <1> 	;
   972                              <1> 	;; ([p_crt_mode] = 03h)
   973                              <1> 	;
   974                              <1> 	;; New video mode is 3 while current video mode is not 3
   975                              <1> 	;; (multi screen) video pages will be restored from 098000h
   976                              <1> 	;
   977                              <1> 	;; restore video pages and cursor positions
   978                              <1> 	;
   979                              <1> 	;mov	[ACTIVE_PAGE], al ; current mode 3 active page
   980                              <1> 	;
   981                              <1> 	;push	esi
   982                              <1> 	;
   983                              <1> 	;; restore video pages
   984                              <1> 	;mov	esi, 98000h
   985                              <1> 	;mov	edi, 0B8000h
   986                              <1> 	;;mov	ecx, 2000h
   987                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
   988                              <1> 	;rep	movsd
   989                              <1> 	;
   990                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
   991                              <1> 	;
   992                              <1> 	;; restore cursor positions
   993                              <1> 	;mov	esi, cursor_pposn
   994                              <1> 	;mov	edi, CURSOR_POSN
   995                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
   996                              <1> 	;mov	cl, 4
   997                              <1> 	;rep 	movsd
   998                              <1> 	;
   999                              <1> 	;pop	esi
  1000                              <1> 	;
  1001                              <1> 	;; 07/12/2020
  1002                              <1> 	;; restore CRT_START according to ACTIVE_PAGE
  1003                              <1> 	;mov	[CRT_START], cx ; 0
  1004                              <1> 	;
  1005                              <1> 	;; check active page and set it again if it is not 0
  1006                              <1> 	;or	al, al
  1007                              <1> 	;jz	short vbe3_pmi_7
  1008                              <1> 	;
  1009                              <1> 	;mov	cl, al
  1010                              <1> ;vbe3_pmi_5:
  1011                              <1> 	;add	word [CRT_START], 4096
  1012                              <1> 	;dec	cl
  1013                              <1> 	;jnz	short vbe3_pmi_5
  1014                              <1> 
  1015 000019D7 B405                <1> 	mov	ah, 05h ; set current video page
  1016                              <1> 	;al = video page
  1017 000019D9 E82C000000          <1> 	call	int10h_32bit_pmi
  1018                              <1> 	
  1019                              <1> 	; check current cursor position & set it again if not 0,0
  1020                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  1021 000019DE 0FB6D8              <1> 	movzx	ebx, al
  1022 000019E1 D0E3                <1> 	shl	bl, 1
  1023 000019E3 81C3[EE890100]      <1> 	add	ebx, CURSOR_POSN
  1024 000019E9 668B13              <1> 	mov	dx, [ebx]
  1025 000019EC 6621D2              <1> 	and	dx, dx		
  1026 000019EF 7409                <1> 	jz	short vbe3_pmi_7
  1027                              <1> 	
  1028                              <1> 	;dx = cursor position (dl = column, dh = row)
  1029                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 06/12/2020
  1030 000019F1 88C7                <1> 	mov	bh, al
  1031 000019F3 B402                <1> 	mov	ah, 02h ; set cursor position
  1032 000019F5 E810000000          <1> 	call	int10h_32bit_pmi
  1033                              <1> 	
  1034                              <1> 	;jmp	short vbe3_pmi_7
  1035                              <1> 
  1036                              <1> ;vbe3_pmi_6:
  1037                              <1> ;	; 07/12/2020
  1038                              <1> ;	; case 1, previous mode is 03h, current mode is 03h
  1039                              <1> ;	; 03/12/2020
  1040                              <1> ;	cmp	byte [noclearmem], 0
  1041                              <1> ;	jna	short vbe3_pmi_7 ; do not clear memory
  1042                              <1> ;	; clear video page
  1043                              <1> ;	mov	ecx, 1024 ; 4096/4
  1044                              <1> ;	mov	eax, 07200720h
  1045                              <1> ;	mov	edi, 0B8000h ; [crt_base]
  1046                              <1> ;	add	di, [CRT_START]
  1047                              <1> ;	rep	stosd	; FILL THE REGEN BUFFER WITH BLANKS
  1048                              <1> 
  1049                              <1> vbe3_pmi_7:
  1050 000019FA 5F                  <1> 	pop	edi
  1051 000019FB 5A                  <1> 	pop	edx
  1052 000019FC 59                  <1> 	pop	ecx
  1053 000019FD 5B                  <1> 	pop	ebx
  1054                              <1> 	;pop	eax ; 04/12/2020
  1055                              <1> vbe3_pmi_8:
  1056                              <1> 	; 04/12/2020
  1057                              <1> 	;(TRDOS 386 v2.0.3, INT 31h, ah=0 return)
  1058 000019FE 31C0                <1> 	xor	eax, eax  ; eax = 0 -> succesful
  1059                              <1> vesa_vbe3_pmi_retn:
  1060 00001A00 07                  <1> 	pop	es  ; **
  1061 00001A01 1F                  <1> 	pop	ds  ; *
  1062 00001A02 CF                  <1> 	iretd
  1063                              <1> 
  1064                              <1> vbe3_pmi_9:
  1065                              <1> 	; 06/12/2020 
  1066                              <1> 	;cmp	ah, 10h ; Set/Get Palette Registers
  1067                              <1> 	;jnb	short vbe3_pmi_10
  1068                              <1> 	; 05/12/2020
  1069 00001A03 E802000000          <1> 	call	int10h_32bit_pmi
  1070 00001A08 EBF6                <1> 	jmp	short vesa_vbe3_pmi_retn
  1071                              <1> 
  1072                              <1> ;vbe3_pmi_10:
  1073                              <1> 	; 06/12/2020
  1074                              <1> 	;jmp	VGA_funcs_0
  1075                              <1> 
  1076                              <1> int10h_32bit_pmi:
  1077                              <1> 	; 03/12/2020
  1078                              <1> 	; 28/11/2020
  1079                              <1> 	; calling standard VGA Bios (INT 10h) functions
  1080                              <1> 	; by using 32 bit protected mode interface of
  1081                              <1> 	; VESA VBE3 Video Bios (with 'PMID' signature)
  1082                              <1> 
  1083                              <1> 	; 03/12/2020
  1084                              <1> 	; eax, ebx, ecx, edx, edi will be used by vbios pmi
  1085                              <1> 	; (esi and ebp will not be used) 
  1086                              <1> 
  1087                              <1> 	; 03/12/2020
  1088 00001A0A 56                  <1> 	push	esi
  1089 00001A0B C1E010              <1> 	shl	eax, 16  ; move function number (ax) to hw
  1090 00001A0E 8B35[24120300]      <1> 	mov	esi, [pmid_addr] ; linear address of
  1091                              <1> 				 ; PMInfo.Entrypoint pointer
  1092                              <1> 	;mov	ax, [esi+PMInfo.EntryPoint]	
  1093 00001A14 668B06              <1> 	mov	ax, [esi]	 
  1094 00001A17 C1C010              <1> 	rol	eax, 16 ; move PM entry address to hw
  1095                              <1> 			; and move function number to lw (ax)
  1096 00001A1A 5E                  <1> 	pop	esi
  1097                              <1> 
  1098                              <1> 	; top of stack: ; (*)
  1099                              <1> 	; return (the caller) address of "int10h_32bit_pmi"
  1100                              <1> 
  1101 00001A1B E97CEDFFFF          <1> 	jmp	_VBE3PMI_fcall ; will return to the caller (*)
  1102                              <1> 
  1103                              <1> _vbe3_pmfn_srs_8:
  1104                              <1> 	; 17/01/2021
  1105 00001A20 31DB                <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  1106                              <1> _vbe3_pmfn_srs_9: ; 24/01/2021
  1107 00001A22 66B8044F            <1> 	mov	ax, 4F04h
  1108 00001A26 EBE2                <1> 	jmp	short int10h_32bit_pmi
  1109                              <1> 
  1110                              <1> vbe3_pmfn_save_restore_state:
  1111                              <1> 	; 24/01/2021
  1112                              <1> 	; 23/01/2021
  1113                              <1> 	; 16/01/2021, 17/01/2021
  1114                              <1> 	; 14/01/2021
  1115                              <1> 	;
  1116                              <1> 	; VBE function 4F04h - Save/Restore Video State
  1117                              <1> 	;
  1118                              <1> 	; Input:
  1119                              <1> 	;	DL = sub function
  1120                              <1> 	;	CL = requested state
  1121                              <1> 	;      EBX = pointer to buffer (if DL<>00h)
  1122                              <1> 	;	AX = 4F04h 
  1123                              <1> 	; Output:
  1124                              <1> 	;	AX = 004Fh (successful)
  1125                              <1> 	;	AH > 0 -> error
  1126                              <1> 	;	BX = Number of 64-byte blocks 
  1127                              <1> 	;	     to hold the state buffer (if DL=00h)
  1128                              <1> 
  1129                              <1> 	; Modified registers: eax, ebx, esi, edi
  1130                              <1> 	
  1131 00001A28 21DB                <1> 	and	ebx, ebx ; user's buffer address
  1132 00001A2A 750A                <1> 	jnz	short _vbe3_pmfn_save_restore_state
  1133                              <1> 
  1134 00001A2C 08D2                <1> 	or	dl, dl
  1135 00001A2E 740C                <1> 	jz	short _vbe3_pmfn_srs_0
  1136                              <1> 
  1137                              <1> 	; function failed
  1138                              <1> 	;;mov	eax, 0100h
  1139                              <1> 	;sub	eax, eax
  1140                              <1> 	;inc	ah  ; eax = 0100h
  1141                              <1> 	;retn
  1142                              <1> 	; 16/01/2021
  1143                              <1> _vbe3_pmfn_srs_fail:
  1144 00001A30 B84F010000          <1> 	mov	eax, 014Fh ; ah = 1 : Function call failed	
  1145                              <1> 			   ; al = 4Fh : Function is supported
  1146                              <1> _vbe3_srs_retn:
  1147 00001A35 C3                  <1> 	retn
  1148                              <1> 
  1149                              <1> _vbe3_pmfn_save_restore_state:
  1150 00001A36 20D2                <1> 	and	dl, dl
  1151 00001A38 7559                <1> 	jnz	short _vbe3_pmfn_srs_2
  1152                              <1> _vbe3_pmfn_srs:
  1153 00001A3A 31DB                <1> 	xor	ebx, ebx
  1154                              <1> _vbe3_pmfn_srs_0:
  1155                              <1> 	; 24/01/2021
  1156 00001A3C 83F90F              <1> 	cmp	ecx, 0Fh
  1157                              <1> 	;ja	short _vbe3_pmfn_srs_1
  1158 00001A3F 77EF                <1> 	ja	short _vbe3_pmfn_srs_fail 
  1159                              <1> 
  1160                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  1161                              <1> 	; (when bit 2 is set, function causes cpu exception)
  1162                              <1> 	; BIOS data will not be saved and restored
  1163                              <1> 	; (to prevent protected mode page fault error)
  1164 00001A41 80E1FD              <1> 	and	cl, ~2 ; and cl, not 2
  1165                              <1> 	
  1166                              <1> 	; 24/01/2021
  1167                              <1> 	;mov	bl, 1
  1168 00001A44 FEC3                <1> 	inc	bl ; = 1
  1169 00001A46 66D3E3              <1> 	shl	bx, cl 
  1170 00001A49 66231D[28120300]    <1> 	and	bx, [vbe3stbsflags]
  1171 00001A50 7416                <1> 	jz	short _vbe3_pmfn_srs_1
  1172                              <1> 	;mov	bx, cx
  1173 00001A52 89CB                <1> 	mov	ebx, ecx ; <= 15
  1174 00001A54 D0E3                <1> 	shl	bl, 1 ; 0, 2, 8 .. 30
  1175 00001A56 668B9B[7B3C0000]    <1> 	mov	bx, [vbestatebufsize+ebx]
  1176 00001A5D 89DF                <1> 	mov	edi, ebx
  1177                              <1> 	; edi = state buffer size in bytes
  1178 00001A5F 66C1EB06            <1> 	shr	bx, 6 ; / 64
  1179 00001A63 66B84F00            <1> 	mov	ax, 4Fh
  1180 00001A67 C3                  <1> 	retn
  1181                              <1> _vbe3_pmfn_srs_1:
  1182                              <1> 	; ax = 4F04h
  1183                              <1> 	;call	int10h_32bit_pmi
  1184                              <1> 	; 24/01/2021
  1185                              <1> 	;call	_vbe3_pmfn_srs_8
  1186                              <1> 	; ebx = 0
  1187 00001A68 E8B5FFFFFF          <1> 	call	_vbe3_pmfn_srs_9	
  1188 00001A6D 6683F84F            <1> 	cmp	ax, 004Fh
  1189 00001A71 75C2                <1> 	jne	short _vbe3_srs_retn
  1190                              <1> 	; 24/01/2021
  1191                              <1> 	;cmp	ecx, 0Fh
  1192                              <1> 	;ja	short _vbe3_srs_retn
  1193                              <1> 	; 24/01/2021
  1194                              <1> 	;mov	ax, 1
  1195 00001A73 B001                <1> 	mov	al, 1
  1196 00001A75 66D3E0              <1> 	shl	ax, cl		
  1197 00001A78 660905[28120300]    <1> 	or	[vbe3stbsflags], ax ; set flag for state option
  1198                              <1> 	; 23/01/2021
  1199 00001A7F 89DF                <1> 	mov	edi, ebx
  1200 00001A81 89C8                <1> 	mov	eax, ecx
  1201 00001A83 D0E0                <1> 	shl	al, 1
  1202 00001A85 66C1E706            <1> 	shl	di, 6 ; * 64
  1203 00001A89 6689B8[7B3C0000]    <1> 	mov	[vbestatebufsize+eax], di
  1204                              <1> 				; save buf size for option 
  1205                              <1> 	;xchg	edi, ebx
  1206                              <1> 	; edi = state buffer size in bytes
  1207 00001A90 B04F                <1> 	mov	al, 4Fh
  1208 00001A92 C3                  <1> 	retn
  1209                              <1> 
  1210                              <1> _vbe3_pmfn_srs_2:
  1211                              <1> 	; 24/01/2021
  1212                              <1> 	; !!! CLEAR CL BIT 2 !!! 
  1213                              <1> 	; (when bit 2 is set, function causes cpu exception)
  1214                              <1> 	; BIOS data will not be saved and restored
  1215                              <1> 	; (to prevent protected mode page fault error)
  1216                              <1> 
  1217 00001A93 F6C1FD              <1> 	test	cl, ~2 ; test cl, not 2
  1218 00001A96 7498                <1> 	jz	short _vbe3_pmfn_srs_fail
  1219                              <1> 
  1220 00001A98 80FA02              <1> 	cmp	dl, 2
  1221 00001A9B 7748                <1> 	ja	short _vbe3_pmfn_srs_5
  1222                              <1> 
  1223                              <1> 	;and	cl, ~2 ; and cl, not 2
  1224                              <1> 
  1225 00001A9D 53                  <1> 	push	ebx ; * ; buffer address
  1226                              <1> 	; save or restore state
  1227                              <1> 	; (get required buffer size at first)
  1228 00001A9E 52                  <1> 	push	edx ; **
  1229 00001A9F 28D2                <1> 	sub	dl, dl ; 0
  1230 00001AA1 E894FFFFFF          <1> 	call	_vbe3_pmfn_srs
  1231 00001AA6 5A                  <1> 	pop	edx ; **
  1232                              <1> 	; 24/01/2021
  1233 00001AA7 5B                  <1> 	pop	ebx ; *
  1234 00001AA8 08E4                <1> 	or	ah, ah
  1235 00001AAA 7538                <1> 	jnz	short _vbe3_pmfn_srs_4 ; error
  1236                              <1> 
  1237                              <1> 	; edi = buffer size in bytes
  1238 00001AAC 81FF00080000        <1> 	cmp	edi, 2048
  1239 00001AB2 772B                <1> 	ja	short _vbe3_pmfn_srs_3
  1240                              <1> 
  1241 00001AB4 80FA01              <1> 	cmp	dl, 1
  1242 00001AB7 7531                <1> 	jne	short _vbe3_pmfn_srs_6 ; restore state
  1243                              <1> 	
  1244                              <1> 	; save video state
  1245                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  1246                              <1> 	;mov	ax, 4F04h
  1247                              <1> 	;call	int10h_32bit_pmi
  1248                              <1> 
  1249                              <1> 	; 24/01/2021
  1250 00001AB9 E842000000          <1> 	call	_vbe3_pmfn_srs_7
  1251                              <1> 	
  1252 00001ABE 6683F84F            <1> 	cmp	ax, 004Fh
  1253 00001AC2 7520                <1> 	jne	short _vbe3_pmfn_srs_4
  1254                              <1> 
  1255 00001AC4 09DB                <1> 	or	ebx, ebx  ; kernel ('sysvideo') ?
  1256 00001AC6 741C                <1> 	jz	short _vbe3_pmfn_srs_4 ; yes
  1257                              <1> 
  1258                              <1> 	; the caller is user
  1259 00001AC8 51                  <1> 	push	ecx ; *
  1260 00001AC9 89F9                <1> 	mov	ecx, edi ; state buffer size
  1261 00001ACB BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; source
  1262                              <1> 					; (vbe3 pmi buff)
  1263 00001AD0 89DF                <1> 	mov	edi, ebx	; destination (user buff)
  1264 00001AD2 E82D000100          <1> 	call	transfer_to_user_buffer
  1265 00001AD7 59                  <1> 	pop	ecx ; *
  1266 00001AD8 7205                <1> 	jc	short _vbe3_pmfn_srs_3
  1267                              <1> 
  1268 00001ADA 29C0                <1> 	sub	eax, eax
  1269 00001ADC B04F                <1> 	mov	al, 4Fh
  1270 00001ADE C3                  <1> 	retn
  1271                              <1> 
  1272                              <1> 	; 24/01/2021
  1273                              <1> _vbe3_pmfn_srs_3:
  1274 00001ADF B84F010000          <1> 	mov	eax, 014Fh
  1275                              <1> _vbe3_pmfn_srs_4:
  1276 00001AE4 C3                  <1> 	retn
  1277                              <1> _vbe3_pmfn_srs_5:
  1278 00001AE5 31C0                <1> 	xor	eax, eax
  1279 00001AE7 FEC4                <1> 	inc	ah
  1280                              <1> 	; eax = 0100h, function is not supported
  1281 00001AE9 C3                  <1> 	retn
  1282                              <1> 
  1283                              <1> _vbe3_pmfn_srs_6:
  1284                              <1> 	; restore video state
  1285                              <1> 	; 24/01/2021
  1286                              <1> 	;pop	ebx ; *
  1287                              <1> 	; 23/01/2021
  1288 00001AEA 09DB                <1> 	or	ebx, ebx ; 0 ?	
  1289 00001AEC 7412                <1> 	jz	short _vbe3_pmfn_srs_7 ; 'sysvideo' call
  1290                              <1> 	; 24/01/2021
  1291                              <1> 	;jz	_vbe3_pmfn_srs_8
  1292 00001AEE 89DE                <1> 	mov	esi, ebx
  1293                              <1> 	; esi = user's video state buffer
  1294 00001AF0 51                  <1> 	push	ecx ; *
  1295 00001AF1 89F9                <1> 	mov	ecx, edi ; state buffer size
  1296 00001AF3 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
  1297                              <1> 					; (vbe3 pmi buff)
  1298                              <1> 	;mov	esi, ebx	; source (user buff)
  1299 00001AF8 E851000100          <1> 	call	transfer_from_user_buffer
  1300 00001AFD 59                  <1> 	pop	ecx ; *
  1301 00001AFE 72DF                <1> 	jc	short _vbe3_pmfn_srs_3
  1302                              <1> _vbe3_pmfn_srs_7:
  1303 00001B00 53                  <1> 	push	ebx ; *
  1304                              <1> 	; restore video state
  1305                              <1> 	;xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
  1306                              <1> 	;mov	ax, 4F04h
  1307                              <1> 	;call	int10h_32bit_pmi
  1308                              <1> 	; 17/01/2021
  1309 00001B01 E81AFFFFFF          <1> 	call	_vbe3_pmfn_srs_8
  1310 00001B06 5B                  <1> 	pop	ebx ; *
  1311 00001B07 C3                  <1> 	retn
  1312                              <1> 
  1313                              <1> VIDEO_STATE:
  1314                              <1> 	; 26/06/2016
  1315                              <1> 	; 12/05/2016
  1316                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1317                              <1> 
  1318                              <1> ;---------------------------------------------------
  1319                              <1> ; VIDEO STATE
  1320                              <1> ;  RETURNS THE CURRENT VIDEO STATE IN AX
  1321                              <1> ;  AH = NUMBER OF COLUMNS ON THE SCREEN
  1322                              <1> ;  AL = CURRENT VIDEO MODE
  1323                              <1> ;  BH = CURRENT ACTIVE PAGE
  1324                              <1> ;---------------------------------------------------
  1325                              <1> 
  1326 00001B08 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS]	; GET NUMBER OF COLUMNS
  1327 00001B0E A0[CA6F0000]        <1> 	mov	al, [CRT_MODE]	; CURRENT MODE
  1328                              <1> 	;movzx	esi, al
  1329                              <1> 	;mov	ah, [esi+M6] 
  1330                              <1> 	; BH = active page
  1331 00001B13 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE] ; GET CURRENT ACTIVE PAGE
  1332 00001B19 FA                  <1> 	cli	; 02/01/2017
  1333 00001B1A 5D                  <1> 	pop	ebp		; RECOVER REGISTERS
  1334 00001B1B 5F                  <1> 	pop	edi
  1335 00001B1C 5E                  <1> 	pop	esi
  1336 00001B1D 59                  <1> 	pop	ecx		; DISCARD SAVED BX
  1337 00001B1E EB41                <1> 	jmp	short M15	; RETURN TO CALLER
  1338                              <1> 
  1339                              <1> set_mode_ncm:
  1340                              <1> 	; 17/11/2020 (TRDOS 386 v2.0.3)
  1341                              <1> 	; 04/07/2016 - TRDOS 386 (TRDOS v2.0)
  1342                              <1> 	; set mode without clearing the video memory
  1343                              <1> 	; (ony for graphics modes)
  1344                              <1> 
  1345                              <1> 	;cmp	al, 7 ; IBM PC CGA modes
  1346                              <1> 	;jna	short SET_MODE ; normal function (clear)
  1347                              <1> 	;; do not clear memory
  1348                              <1> 	;;mov	[noclearmem], al ; > 0
  1349                              <1> 	;mov	byte [noclearmem], 80h ; 17/11/2020
  1350                              <1> 	;call	_set_mode
  1351                              <1> 	;mov	byte [noclearmem], 0
  1352                              <1>         ;jmp     short VIDEO_RETURN
  1353                              <1> 
  1354                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  1355 00001B20 0C80                <1> 	or	al, 80h ; not clear memory option
  1356                              <1> 
  1357                              <1> 	; 05/12/2020
  1358                              <1> 	; 27/11/2020
  1359                              <1> 	; 17/11/2020
  1360                              <1> 	; 08/08/2016, 10/08/2016
  1361                              <1> 	; 29/07/2016, 30/07/2016
  1362                              <1> 	; 25/07/2016, 26/07/2016, 27/07/2016
  1363                              <1> 	; 02/07/2016, 18/07/2016, 23/07/2016
  1364                              <1> 	; 24/06/2016, 26/06/2016
  1365                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  1366                              <1> SET_MODE:
  1367                              <1> 	; For 32 bit TRDOS and Retro UNIX 386:
  1368                              <1> 	;	valid video mode: 03h only!
  1369                              <1> 	;	(VGA modes will be selected with another routine)
  1370                              <1> 	;
  1371                              <1> 	; set_txt_mode ; 80*25 (16 fore colors, 8 back colors)
  1372                              <1> 
  1373                              <1> 	; 27/11/2020
  1374                              <1> 	
  1375                              <1> 	; Check if current mode is 
  1376                              <1> 	; Bochs/Plex86 VBE graphics mode
  1377 00001B22 803D[CA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; VESA VBE graphics mode
  1378 00001B29 7220                <1> 	jb	short _set_mode_      ; signature  	
  1379                              <1> 				      ; VBE mode number is in	 
  1380                              <1> 				      ; [video_mode] bit 0to8
  1381 00001B2B 88C3                <1> 	mov	bl, al ; save video mode
  1382 00001B2D E89D240000          <1> 	call	dispi_get_enable
  1383 00001B32 50                  <1> 	push	eax ; save current VBE dispi status 
  1384                              <1> 	; Disable Bochs/Plex86 VBE dispi
  1385                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
  1386 00001B33 31C0                <1> 	xor	eax, eax ; 0 
  1387 00001B35 E869240000          <1> 	call	dispi_set_enable
  1388 00001B3A 88D8                <1> 	mov	al, bl ; restore video mode
  1389 00001B3C E827000000          <1> 	call	_set_mode
  1390 00001B41 58                  <1> 	pop	eax ; restore current VBE dispi status 
  1391 00001B42 7313                <1> 	jnc	short VIDEO_RETURN
  1392                              <1> 	; ! unimplemented or invalid video mode number !
  1393                              <1> 	; VBE dispi must be enabled again
  1394                              <1> 	; (return to run on current VBE graphics mode)
  1395                              <1> 	;;mov	al, [video_mode+1] ; bit 8 to 15
  1396                              <1> 	;;and	al, 0C0h ; isolate bit 14 and bit 15 
  1397                              <1> 	;;or	al, 1 ; VBE_DISPI_ENABLED
  1398 00001B44 E85A240000          <1> 	call	dispi_set_enable
  1399 00001B49 EB07                <1> 	jmp	short _video_func_err
  1400                              <1> 
  1401                              <1> _set_mode_:
  1402                              <1> 	; VGA bios (non-VBE) 'setmode' procedure
  1403                              <1> 
  1404                              <1> 	; 26/11/2020 (TRDOS v2.0.3)
  1405                              <1> 	
  1406                              <1> ;------------------------------------------------------
  1407                              <1> ; SET MODE					      :
  1408                              <1> ;	THIS ROUTINE INITIALIZES THE ATTACHMENT TO    :
  1409                              <1> ;	THE SELECTED MODE, THE SCREEN IS BLANKED.     :
  1410                              <1> ; INPUT						      :
  1411                              <1> ;	(AL) - MODE SELECTED (RANGE 0-7)	      :
  1412                              <1> ; OUTPUT					      :
  1413                              <1> ;	NONE					      :
  1414                              <1> ;------------------------------------------------------
  1415                              <1> 
  1416 00001B4B E818000000          <1> 	call	_set_mode ; 24/06/2016 (set_txt_mode)
  1417                              <1> 	; 26/11/2020
  1418 00001B50 7305                <1> 	jnc	short VIDEO_RETURN
  1419                              <1> 
  1420                              <1> 	; 26/11/2020
  1421                              <1> _video_func_err:
  1422 00001B52 31C0                <1> 	xor	eax, eax ; function call failed
  1423 00001B54 48                  <1> 	dec	eax  ; 0FFFFFFFFh ; - 1	
  1424 00001B55 EB05                <1> 	jmp	short _video_return	
  1425                              <1> 
  1426                              <1> ; 12/05/2016
  1427                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1428                              <1> 
  1429                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  1430                              <1> 
  1431                              <1> VIDEO_RETURN:
  1432 00001B57 A1[58960100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  1433                              <1> _video_return:
  1434 00001B5C FA                  <1> 	cli ; 02/01/2017
  1435 00001B5D 5D                  <1> 	pop	ebp ; ******** ; 26/11/2020
  1436 00001B5E 5F                  <1> 	pop	edi ; *******
  1437 00001B5F 5E                  <1> 	pop	esi ; ******
  1438 00001B60 5B                  <1> 	pop	ebx ; *****
  1439                              <1> M15:	; VIDEO_RETURN_C
  1440                              <1> 	;;15/01/2017
  1441                              <1> 	; 02/01/2017
  1442                              <1> 	;;mov	byte [intflg], 0
  1443                              <1> 	;
  1444 00001B61 59                  <1> 	pop	ecx ; **** ; 26/11/2020
  1445 00001B62 5A                  <1> 	pop	edx ; ***
  1446 00001B63 1F                  <1> 	pop	ds  ; **
  1447 00001B64 07                  <1> 	pop	es  ; *	; RECOVER SEGMENTS
  1448 00001B65 CF                  <1> 	iretd		; ALL DONE
  1449                              <1> 
  1450                              <1> set_txt_mode:
  1451                              <1> 	
  1452                              <1> 	; 29/07/2016
  1453                              <1> 	; 27/06/2016
  1454 00001B66 B003                <1> 	mov	al, 3 ; 26/11/2020 (bit 7 = 0)
  1455                              <1> 
  1456                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  1457                              <1> 	;mov	byte [noclearmem], 0
  1458                              <1> 
  1459                              <1> ; 10/08/2016
  1460                              <1> ; 08/08/2016
  1461                              <1> ; 30/07/2016
  1462                              <1> ; 29/07/2016
  1463                              <1> ; 25/07/2016, 26/07/2016, 27/07/2016
  1464                              <1> ; 07/07/2016, 18/07/2016, 23/07/2016
  1465                              <1> ; 02/07/2016, 03/07/2016, 04/07/2016
  1466                              <1> ; 26/06/2016
  1467                              <1> ; 24/06/2016 (set_txt_mode -> _set_mode)
  1468                              <1> ; 17/06/2016
  1469                              <1> ; 29/05/2016
  1470                              <1> ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  1471                              <1> 
  1472                              <1> _set_mode:
  1473                              <1> 	; 12/12/2020
  1474                              <1> 	; 26/11/2020
  1475                              <1> 	; call from 'biosfn_set_video_mode'
  1476                              <1> 	;	(bochs/plex86 video bios code)
  1477                              <1> 	; call from 'SET_MODE'
  1478                              <1> 	;	(TRDOS 386 v2 default, IBM PC/AT rom bios code)
  1479                              <1> 	; continue from 'set_txt_mode'	
  1480                              <1> 
  1481                              <1> 	; INPUT:
  1482                              <1> 	;	al = VGA video mode
  1483                              <1> 	; RETURN:
  1484                              <1> 	;	cf = 1 -> video mode not implemented
  1485                              <1> 	;	cf = 0 -> OK
  1486                              <1> 	;
  1487                              <1> 	; Modified registers: eax, bx, ecx, esi, edi, (ebp)
  1488                              <1> 
  1489                              <1> 	; 17/11/2020 (TRDOS v2.0.3)
  1490                              <1> 	; no clear memory option 
  1491                              <1> 	; (from mode number byte bit 7)
  1492 00001B68 88C4                <1> 	mov	ah, al
  1493 00001B6A 80E480              <1> 	and	ah, 80h
  1494                              <1> 	;mov	[noclearmem], al
  1495 00001B6D 8825[67960100]      <1> 	mov	[noclearmem], ah
  1496                              <1> 	;and	al, 7Fh ; clear bit 7
  1497                              <1> 	;;xor	[noclearmem], al ; clear bit 0 to 6
  1498                              <1> 	; 26/11/2020
  1499 00001B73 30E0                <1> 	xor	al, ah ; and al, 7Fh
  1500                              <1> 
  1501                              <1> 	; 19/11/2020
  1502                              <1> 
  1503                              <1> 	; Video mode 03h action principle:
  1504                              <1> 	;
  1505                              <1> 	; for case 1:
  1506                              <1> 	; Current mode is 03h and next/requested mode is not 03h
  1507                              <1> 	;	- save mode (set mode 03h flag)
  1508                              <1> 	;	- save 8 video pages (which are will be restored)	
  1509                              <1> 	;	- save active page number (which will be reactivated)
  1510                              <1> 	;	- set active page to 0 always (no multi screen)
  1511                              <1> 	;	- save 8 cursor positions (which will be restored)
  1512                              <1> 	; 	- use 'noclearmem' option
  1513                              <1> 	;	[p_crt_mode] = 0 -> 03h 
  1514                              <1> 	;
  1515                              <1> 	; for case 2:
  1516                              <1> 	; Current mode is 03h and next/requested mode is also 03h
  1517                              <1> 	;	- clear active video page if 'noclearmem' is not set
  1518                              <1> 	;	[p_crt_mode] = 0 -> 80h -> 0
  1519                              <1> 	;
  1520                              <1> 	; for case 3:
  1521                              <1> 	; Current mode is not 03h and next/requested mode is 03h
  1522                              <1> 	;	- restore video pages (8 video pages were saved)	
  1523                              <1> 	;	- restore active page number (which were saved)
  1524                              <1> 	;	- restore 8 cursor positions (which were saved)
  1525                              <1> 	;	- reset/clear mode 03h flag
  1526                              <1> 	;	[p_crt_mode] = 03h -> 0
  1527                              <1> 	;
  1528                              <1> 	; for case 4:
  1529                              <1> 	; Current mode is not 03h and next/requested mode is not 03h
  1530                              <1> 	; 	- use 'noclearmem' option
  1531                              <1> 	;	- set active page to 0 always
  1532                              <1> 	;	[p_crt_mode] = 03h -> 83h -> 03h
  1533                              <1> 	;
  1534                              <1> 	; initial (boot time) values:
  1535                              <1> 	;	[p_crt_mode] = 0 ("there isn't a page backup, yet")
  1536                              <1> 	;	  [CRT_MODE] = 3 (kernel's starting mode)
  1537                              <1> 
  1538                              <1> 	; 26/11/2020
  1539 00001B75 3C03                <1> 	cmp	al, 03h	    ; mode 3, 80x25 text, 16 colors
  1540 00001B77 7515                <1> 	jne	short _sm_0 ; (default mode for TRDOS 386 mainprog) 	
  1541                              <1> 
  1542                              <1> 	; case 2 or case 3
  1543                              <1> 
  1544                              <1> 	; check current video mode if it is 03h
  1545 00001B79 08E4                <1> 	or	ah, ah ; 80h or 0 ('noclearmem' option)
  1546 00001B7B 7521                <1> 	jnz	short _sm_1 ; do not clear display page
  1547                              <1>  	
  1548                              <1> 	; 26/11/2020
  1549                              <1> 	; Note:
  1550                              <1> 	; [CRT_MODE] = 0FFh for VESA VBE video modes
  1551                              <1> 	; [video_mode] = standard VGA and VESA VBE video modes
  1552                              <1> 	
  1553 00001B7D 3805[CA6F0000]      <1> 	cmp	[CRT_MODE], al	; 03h
  1554 00001B83 7520                <1> 	jne	short _sm_2	; case 3 ([p_crt_mode] = 03h)
  1555                              <1> 
  1556                              <1> 	; case 2
  1557                              <1> 
  1558                              <1> 	; [p_crt_mode] = 0
  1559                              <1> 
  1560                              <1> 	; 19/11/2020
  1561                              <1> 	; If '_set_mode' procedure is called for video mode 3
  1562                              <1> 	;     while video mode is 3, video page will be cleared
  1563                              <1> 	;     and cursor position of video page will be reset.	 
  1564                              <1> 
  1565                              <1> 	; clear display page
  1566 00001B85 C605[65960100]80    <1> 	mov	byte [p_crt_mode], 80h ; clear page sign
  1567 00001B8C EB1C                <1> 	jmp	short _sm_3	; bypass save video page routine
  1568                              <1> _sm_0:
  1569                              <1> 	; case 1 or case 4
  1570                              <1> 
  1571                              <1> 	; 05/12/2020
  1572 00001B8E 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; is current mode 03h?
  1573 00001B95 7507                <1> 	jne	short _sm_1	; case 4 ; [p_crt_mode] = 03h
  1574                              <1> 	
  1575                              <1> 	; case 1
  1576                              <1> 	; [p_crt_mode] = 0
  1577                              <1> 
  1578                              <1> 	; 19/11/2020
  1579                              <1> 	; If '_set_mode' procedure is called for a video mode
  1580                              <1> 	;     except video mode 3 while current video mode
  1581                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  1582                              <1> 	;     to 98000h address as backup, before mode change.	
  1583                              <1> 	
  1584                              <1> _sm_save_pm:
  1585                              <1> 	; 12/12/2020
  1586                              <1> 	;; 03/07/2016
  1587                              <1> 	;; save video pages
  1588                              <1> 	;mov	esi, 0B8000h
  1589                              <1> 	;mov	edi, 98000h ; 30/07/2016
  1590                              <1> 	;mov	ecx, (0B8000h-0B0000h)/4
  1591                              <1> 	;rep	movsd
  1592                              <1> 
  1593                              <1> 	;mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  1594                              <1> 	;; 26/11/2020
  1595                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  1596                              <1> 	;mov	[p_crt_page], cl  ; save as previous active page	
  1597                              <1> 	;
  1598                              <1> 	;; save cursor positions
  1599                              <1> 	;mov	esi, CURSOR_POSN
  1600                              <1> 	;mov	edi, cursor_pposn ; cursor positions backup
  1601                              <1> 	;mov	cl, 4
  1602                              <1> 	;rep	movsd
  1603                              <1> 
  1604                              <1> 	; 12/12/2020
  1605 00001B97 E881020000          <1> 	call	save_mode3_multiscreen
  1606                              <1> 
  1607                              <1> 	; 29/07/2016
  1608                              <1> 	;;mov	[ACTIVE_PAGE], cl ; 0
  1609                              <1> 	;xchg	cl, [ACTIVE_PAGE]
  1610                              <1> 	;mov	[p_crt_page], cl  ; previous page (for mode 3)	
  1611                              <1> 	
  1612                              <1> 	; [ACTIVE_PAGE] = 0 
  1613                              <1> 	
  1614 00001B9C EB07                <1> 	jmp	short _sm_2	; case 1 - 19/11/2020
  1615                              <1> _sm_1:
  1616                              <1> 	; 26/11/2020
  1617                              <1> 	; 19/11/2020
  1618                              <1> 	
  1619                              <1> 	; case 4
  1620 00001B9E 800D[65960100]80    <1> 	or	byte [p_crt_mode], 80h 
  1621                              <1> 				; here [p_crt_mode] must be 83h
  1622                              <1> 				;	  (for case 4)
  1623                              <1> 				; (because video mode 03h
  1624                              <1> 				; was changed before as in case 1) 
  1625                              <1> 
  1626                              <1> _sm_2:	; case 4 (jump to _sm_2) - 19/11/2020 
  1627                              <1> 
  1628                              <1> 	; 19/11/2020
  1629                              <1> 	; case 3
  1630                              <1> 	; If '_set_mode' procedure is called for video mode 3
  1631                              <1> 	;     while video mode is not 3 and if there is video
  1632                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  1633                              <1> 	;     video pages will be restored from 98000h.
  1634                              <1> 
  1635 00001BA5 A2[CA6F0000]        <1> 	mov	[CRT_MODE], al  ; save mode in global variable
  1636                              <1> _sm_3:
  1637                              <1> 	; 30/07/2016
  1638                              <1> 	; 26/07/2016
  1639                              <1> 	; 25/07/2016
  1640                              <1> 	; set_mode_vga:
  1641                              <1> 	; 18/07/2016
  1642                              <1> 	; 14/07/2016
  1643                              <1> 	; 09/07/2016
  1644                              <1> 	; 04/07/2016
  1645                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  1646                              <1> 	; /// video mode 13h ///
  1647                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  1648                              <1> 	; vgabios-0.7a (2011)
  1649                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  1650                              <1> 	; 'vgabios.c', 'vgatables.h'
  1651                              <1> 	;
  1652                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  1653                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  1654                              <1> 	;
  1655 00001BAA 88C4                <1> 	mov	ah, al
  1656 00001BAC B910000000          <1> 	mov	ecx, vga_mode_count 	
  1657 00001BB1 BE[E66F0000]        <1> 	mov	esi, vga_modes
  1658 00001BB6 31DB                <1> 	xor	ebx, ebx
  1659                              <1> _sm_4:
  1660 00001BB8 AC                  <1> 	lodsb
  1661 00001BB9 38C4                <1> 	cmp	ah, al
  1662 00001BBB 7406                <1> 	je	short _sm_5
  1663 00001BBD FEC3                <1> 	inc	bl
  1664 00001BBF E2F7                <1> 	loop	_sm_4
  1665                              <1> 
  1666                              <1> 	; UNIMPLEMENTED VIDEO MODE !
  1667                              <1> 	;xor	eax, eax
  1668                              <1>         ;mov	[video_eax], eax ; 0 
  1669                              <1> 
  1670                              <1> 	; 26/11/2020
  1671 00001BC1 F9                  <1> 	stc	; unimplemented video mode ! (cf=1)	
  1672                              <1> 
  1673 00001BC2 C3                  <1> 	retn
  1674                              <1> 
  1675                              <1> ;-----	eBX POINTS TO CORRECT ROW OF INITIALIZATION TABLE	
  1676                              <1> 
  1677                              <1> _sm_5: 	; 25/07/2016
  1678                              <1> 	;mov	esi, ebx
  1679                              <1> 	;add	esi, vga_memmodel
  1680                              <1> 	;mov	al, [esi]
  1681                              <1> 	; 19/11/2020
  1682 00001BC3 8A83[36700000]      <1> 	mov	al, [ebx+vga_memmodel]
  1683 00001BC9 A2[7E960100]        <1> 	mov	[VGA_MTYPE], al
  1684                              <1> 
  1685 00001BCE 89DF                <1> 	mov	edi, ebx
  1686 00001BD0 81C7[46700000]      <1> 	add	edi, vga_dac_s 	
  1687 00001BD6 C0E302              <1> 	shl	bl, 2 ; byte -> dword
  1688 00001BD9 81C3[F66F0000]      <1> 	add	ebx, vga_mode_tbl_ptr
  1689                              <1> 
  1690                              <1> 	;mov	dword [VGA_BASE], 0B8000h
  1691                              <1> 	;cmp	ah, 0Dh ; [CRT_MODE]
  1692                              <1> 	;jb	short M9 
  1693                              <1> 	;mov	dword [VGA_BASE], 0A0000h
  1694                              <1> ;M9:
  1695 00001BDF 8B33                <1> 	mov	esi, [ebx]
  1696 00001BE1 89F3                <1> 	mov	ebx, esi
  1697 00001BE3 83C614              <1> 	add	esi, vga_p_cm_pos ; ebx + 20
  1698 00001BE6 668B06              <1> 	mov	ax, [esi]       ; get the cursor mode from the table
  1699 00001BE9 66A3[E36F0000]      <1> 	mov	[CURSOR_MODE], ax ; save cursor mode (initial value)
  1700                              <1> 	; al = 6, ah = 7
  1701                              <1> 	; al = 0Dh, ah = 0Eh ; 25/07/2016
  1702 00001BEF E8A8020000          <1> 	call	cursor_shape_fix
  1703                              <1> 	; al = 14, ah = 15 (If [CHAR_HEIGHT] = 16)
  1704 00001BF4 668906              <1> 	mov	[esi], ax
  1705                              <1> 
  1706 00001BF7 56                  <1> 	push	esi ; *	
  1707                              <1> 
  1708 00001BF8 8A25[D16F0000]      <1> 	mov	ah, [VGA_MODESET_CTL]
  1709 00001BFE 80E408              <1> 	and	ah, 8 ; default palette loading ?
  1710 00001C01 7524                <1> 	jnz	short _sm_6
  1711 00001C03 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK (DAC mask register)
  1712 00001C07 B0FF                <1> 	mov	al, 0FFh ; PEL mask
  1713 00001C09 EE                  <1> 	out	dx, al
  1714 00001C0A 8A27                <1> 	mov	ah, [edi] ; DAC model (selection number)
  1715 00001C0C E87E100000          <1> 	call	load_dac_palette
  1716                              <1> 	; ecx = 0
  1717 00001C11 F605[D16F0000]02    <1> 	test	byte [VGA_MODESET_CTL], 2 ; gray scale summing
  1718 00001C18 740D                <1> 	jz	short _sm_6
  1719 00001C1A 53                  <1> 	push	ebx
  1720 00001C1B 29DB                <1> 	sub	ebx, ebx ; sub bl, bl
  1721 00001C1D 66B90001            <1>         mov     cx, 256 
  1722 00001C21 E8BC100000          <1> 	call	gray_scale_summing
  1723 00001C26 5B                  <1> 	pop	ebx	
  1724                              <1> _sm_6:
  1725                              <1> 	; Reset Attribute Ctl flip-flop
  1726 00001C27 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  1727 00001C2B EC                  <1>  	in	al, dx
  1728                              <1> 	; Set Attribute Ctl
  1729 00001C2C 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1730 00001C2E 83C623              <1> 	add	esi, 35  ; actl regs
  1731 00001C31 30E4                <1> 	xor	ah, ah ; 0
  1732 00001C33 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  1733                              <1> _sm_7:
  1734 00001C37 88E0                <1> 	mov	al, ah
  1735 00001C39 EE                  <1> 	out	dx, al ; index
  1736 00001C3A AC                  <1> 	lodsb
  1737                              <1> 	; DX = 3C0h = VGAREG_ACTL_WRITE_DATA
  1738 00001C3B EE                  <1> 	out	dx, al ; value
  1739 00001C3C FEC4                <1> 	inc	ah
  1740 00001C3E 80FC14              <1> 	cmp	ah, 20 ; number of actl registers
  1741 00001C41 72F4                <1> 	jb	short _sm_7
  1742                              <1> 	;
  1743 00001C43 88E0                <1> 	mov	al, ah ; 20
  1744 00001C45 EE                  <1> 	out	dx, al ; index
  1745 00001C46 28C0                <1> 	sub	al, al ; 0
  1746 00001C48 EE                  <1> 	out	dx, al ; value
  1747                              <1> 	;
  1748                              <1> 	; Set Sequencer Ctl
  1749 00001C49 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1750 00001C4B 83C605              <1> 	add	esi, 5 ; sequ regs
  1751                              <1> 	;
  1752 00001C4E 66BAC403            <1> 	mov	dx, 3C4h  ; VGAREG_SEQU_ADDRESS
  1753 00001C52 EE                  <1> 	out	dx, al ; 0
  1754 00001C53 6642                <1> 	inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  1755 00001C55 B003                <1> 	mov	al, 3
  1756 00001C57 EE                  <1> 	out	dx, al
  1757 00001C58 B401                <1> 	mov	ah, 1	
  1758                              <1> _sm_8:
  1759 00001C5A 88E0                <1> 	mov	al, ah
  1760                              <1> 	;mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  1761 00001C5C 664A                <1> 	dec	dx
  1762 00001C5E EE                  <1> 	out	dx, al ; index
  1763 00001C5F AC                  <1> 	lodsb
  1764 00001C60 6642                <1> 	inc	dx ; 3C5h ; VGAREG_SEQU_DATA
  1765 00001C62 EE                  <1> 	out	dx, al
  1766 00001C63 80FC04              <1> 	cmp	ah, 4 ; number of sequ regs
  1767 00001C66 7304                <1> 	jnb	short _sm_9		
  1768 00001C68 FEC4                <1> 	inc	ah 
  1769 00001C6A EBEE                <1> 	jmp	short _sm_8
  1770                              <1> _sm_9:
  1771                              <1> 	; Set Grafx Ctl
  1772 00001C6C 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1773 00001C6E 83C637              <1> 	add	esi, 55 ; grdc regs
  1774 00001C71 30E4                <1> 	xor	ah, ah ; 0
  1775                              <1> _sm_10:
  1776 00001C73 88E0                <1> 	mov	al, ah
  1777 00001C75 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  1778 00001C79 EE                  <1> 	out	dx, al	
  1779 00001C7A AC                  <1> 	lodsb
  1780 00001C7B 6642                <1> 	inc	dx ; 3CFh ; VGAREG_GRDC_DATA
  1781 00001C7D EE                  <1> 	out	dx, al
  1782 00001C7E FEC4                <1> 	inc	ah
  1783 00001C80 80FC09              <1> 	cmp	ah, 9 ; number of grdc regs
  1784 00001C83 72EE                <1> 	jb	short _sm_10
  1785                              <1> 	;
  1786                              <1> 	; Disable CRTC write protection
  1787 00001C85 66BAD403            <1> 	mov	dx, 3D4h  ; VGAREG_VGA_CRTC_ADDRESS
  1788                              <1> 	;mov	al, 11h
  1789                              <1> 	;our	dx, al
  1790                              <1> 	;inc	dx
  1791                              <1> 	;sub	al, al
  1792                              <1> 	;out	dx, al
  1793 00001C89 66B81100            <1> 	mov	ax, 11h
  1794 00001C8D 66EF                <1> 	out	dx, ax
  1795 00001C8F 89DE                <1> 	mov	esi, ebx ; addr of params tbl for selected mode
  1796 00001C91 83C60A              <1> 	add	esi, 10 ; crtc regs
  1797                              <1> 	; ah = 0
  1798                              <1> _sm_11:
  1799 00001C94 88E0                <1> 	mov	al, ah
  1800                              <1> 	; dx = 3D4h = VGAREG_VGA_CRTC_ADDRESS
  1801 00001C96 EE                  <1> 	out	dx, al ; index
  1802 00001C97 AC                  <1> 	lodsb
  1803 00001C98 6642                <1> 	inc	dx  ; VGAREG_VGA_CRTC_ADDRESS + 1
  1804 00001C9A EE                  <1> 	out	dx, al ; value
  1805 00001C9B 80FC18              <1> 	cmp	ah, 24 ; number of crtc registers - 1
  1806 00001C9E 7306                <1> 	jnb	short _sm_12
  1807 00001CA0 FEC4                <1> 	inc	ah
  1808 00001CA2 664A                <1> 	dec	dx ; 3D4h
  1809 00001CA4 EBEE                <1> 	jmp	short _sm_11
  1810                              <1> _sm_12:
  1811                              <1> 	; Set the misc register
  1812 00001CA6 66BACC03            <1> 	mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  1813 00001CAA 8A4309              <1> 	mov	al, [ebx+9] ; misc reg
  1814 00001CAD EE                  <1> 	out	dx, al
  1815                              <1> 	;
  1816                              <1> 	; Enable video
  1817 00001CAE 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  1818 00001CB2 B020                <1> 	mov	al, 20h  
  1819 00001CB4 EE                  <1>         out     dx, al   ; set bit 5 to 1
  1820 00001CB5 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  1821 00001CB9 EC                  <1> 	in	al, dx
  1822                              <1> 	;
  1823                              <1> 	; 17/11/2020
  1824                              <1> 	;cmp	byte [noclearmem], 0
  1825                              <1>         ;ja	short _sm_15
  1826                              <1> 
  1827 00001CBA F605[67960100]80    <1> 	test	byte [noclearmem], 80h
  1828 00001CC1 7540                <1> 	jnz	short _sm_15	
  1829                              <1> 
  1830                              <1> 	; 29/07/2016
  1831 00001CC3 31C0                <1> 	xor	eax, eax
  1832 00001CC5 B900400000          <1> 	mov	ecx, 4000h ; 16K words (32K)
  1833 00001CCA 803D[7E960100]02    <1> 	cmp     byte [VGA_MTYPE], 2  ; CTEXT, MTEXT, CGA
  1834 00001CD1 7715                <1> 	ja	short _sm_14    ; no ? (0A0000h)
  1835 00001CD3 BF00800B00          <1> 	mov	edi, 0B8000h
  1836 00001CD8 7409                <1> 	je	short _sm_13	; CGA graphics mode
  1837                              <1> 	; 08/08/2016
  1838 00001CDA A3[7A960100]        <1> 	mov	[VGA_INT43H], eax ; 0 ; default font 
  1839 00001CDF 66B82007            <1> 	mov	ax, 0720h	; CGA text mode
  1840                              <1> _sm_13:
  1841 00001CE3 F366AB              <1> 	rep	stosw
  1842 00001CE6 EB1B                <1> 	jmp	short _sm_15		
  1843                              <1> 
  1844                              <1> _sm_14:
  1845 00001CE8 BF00000A00          <1> 	mov	edi, 0A0000h
  1846                              <1> 	; ecx = 16384 dwords (64K)
  1847 00001CED 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  1848 00001CF1 B002                <1> 	mov	al, 2
  1849 00001CF3 EE                  <1> 	out	dx, al
  1850                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
  1851 00001CF4 6642                <1> 	inc	dx
  1852 00001CF6 EC                  <1> 	in	al, dx ; mmask
  1853 00001CF7 6650                <1> 	push	ax
  1854 00001CF9 B00F                <1> 	mov	al, 0Fh ; all planes
  1855 00001CFB EE                  <1> 	out	dx, al
  1856 00001CFC 30C0                <1> 	xor	al, al ; 0
  1857 00001CFE F3AB                <1> 	rep	stosd	; ecx = 163684 (64K)
  1858 00001D00 6658                <1> 	pop	ax
  1859 00001D02 EE                  <1> 	out	dx, al  ; mmask
  1860                              <1> _sm_15:
  1861                              <1> 	; ebx = addr of params tbl for selected mode
  1862                              <1> 	; 10/08/2016
  1863 00001D03 668B03              <1> 	mov	ax, [ebx] ; num of columns, 'twidth'
  1864 00001D06 A2[CC6F0000]        <1> 	mov	[CRT_COLS], al
  1865                              <1> 	;; 26/07/2016
  1866                              <1> 	;; CRTC_ADDRESS = 3D4h (always)
  1867                              <1> 	;mov	ah, [ebx+1] ; num of rows, 'theightm1'
  1868 00001D0B FEC4                <1> 	inc	ah ; 09/07/2016
  1869 00001D0D 8825[D26F0000]      <1> 	mov	[VGA_ROWS], ah
  1870                              <1> 	; 10/08/2016
  1871 00001D13 8A4302              <1> 	mov	al, [ebx+2]
  1872 00001D16 A2[CE6F0000]        <1> 	mov	[CHAR_HEIGHT], al 
  1873                              <1> 	; 29/07/2016
  1874                              <1> 	; length of regen buffer in bytes
  1875 00001D1B 668B4B03            <1> 	mov	cx, [ebx+3] ; 'slength_l'
  1876 00001D1F 66890D[68960100]    <1> 	mov	[CRT_LEN], cx
  1877                              <1> 	;
  1878                              <1> 	; 27/07/2016
  1879 00001D26 30E4                <1> 	xor	ah, ah
  1880 00001D28 A0[FE890100]        <1> 	mov	al, [ACTIVE_PAGE] ; may be > 0 for mode 3
  1881                              <1> 	;mul	word [CRT_LEN] ; 4096 for mode 3
  1882 00001D2D 66F7E1              <1> 	mul	cx ; 29/07/2016
  1883 00001D30 66A3[EC890100]      <1> 	mov	[CRT_START], ax
  1884                              <1> 	;
  1885 00001D36 B060                <1> 	mov	al, 60h
  1886                              <1> 	;cmp	byte [noclearmem], 0
  1887                              <1> 	;jna	short _sm_16
  1888                              <1> 	;add	al, 80h
  1889 00001D38 0A05[67960100]      <1> 	or	al, [noclearmem] ; 17/11/2020
  1890                              <1> _sm_16:
  1891 00001D3E A2[CF6F0000]        <1> 	mov	[VGA_VIDEO_CTL], al
  1892 00001D43 C605[D06F0000]F9    <1> 	mov	byte [VGA_SWITCHES], 0F9h
  1893 00001D4A 8025[D16F0000]7F    <1> 	and	byte [VGA_MODESET_CTL], 7Fh
  1894                              <1> 
  1895 00001D51 5E                  <1> 	pop	esi ; *
  1896                              <1> 
  1897                              <1> 	; 26/07/2016
  1898                              <1> 	; 07/07/2016
  1899 00001D52 668B0D[E36F0000]    <1> 	mov	cx, [CURSOR_MODE] ; restore cursor mode (initial value)
  1900 00001D59 66870E              <1> 	xchg	cx, [esi] ; cl = start line, ch = end line
  1901                              <1> 			  ; reset to initial value
  1902 00001D5C 86E9                <1> 	xchg 	ch, cl  ; ch = start line, cl = end line  
  1903 00001D5E 66890D[E36F0000]    <1> 	mov	[CURSOR_MODE], cx ; save (fixed) cursor mode
  1904                              <1> 
  1905                              <1> 	; 27/07/2016
  1906 00001D65 803D[7E960100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  1907 00001D6C 7317                <1> 	jnb	short _sm_17
  1908                              <1> 
  1909                              <1> 	; Set cursor shape
  1910                              <1> 	;mov	cx, 0607h
  1911                              <1> 	;call	_set_ctype
  1912                              <1> 
  1913                              <1> 	; 29/07/2016
  1914 00001D6E B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  1915 00001D70 E84D060000          <1> 	call	m16	; output cx register
  1916                              <1> 	
  1917                              <1> 	; 25/07/2016
  1918 00001D75 803D[CA6F0000]03    <1>         cmp     byte [CRT_MODE], 03h
  1919 00001D7C 7507                <1> 	jne	short _sm_17
  1920                              <1> 	; 26/07/2016
  1921                              <1> 
  1922 00001D7E A0[FE890100]        <1> 	mov	al, [ACTIVE_PAGE]
  1923 00001D83 EB0B                <1> 	jmp	short _sm_18
  1924                              <1> _sm_17:
  1925                              <1> 	; Set cursor pos for page 0..7
  1926                              <1> 	;sub	ax, ax ; eax = 0
  1927 00001D85 29C0                <1> 	sub	eax, eax ; 17/11/2020
  1928 00001D87 BF[EE890100]        <1> 	mov	edi, CURSOR_POSN
  1929 00001D8C AB                  <1> 	stosd	
  1930 00001D8D AB                  <1> 	stosd
  1931 00001D8E AB                  <1> 	stosd
  1932 00001D8F AB                  <1> 	stosd
  1933                              <1> 	;; Set active page 0
  1934                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  1935                              <1> _sm_18:
  1936                              <1> 	; 29/07/2016
  1937 00001D90 803D[7E960100]02    <1> 	cmp	byte [VGA_MTYPE], 2 ; CTEXT, MTEXT
  1938 00001D97 737F                <1>         jnb	_sm_23
  1939                              <1> 
  1940                              <1> 	;cmp	byte [CHAR_HEIGHT], 16
  1941                              <1> 	;je	short _sm_19
  1942                              <1> 
  1943                              <1>  	;; copy and activate 8x16 font
  1944                              <1> 	
  1945                              <1> 	; 26/07/2016
  1946 00001D99 B004                <1> 	mov	al, 04h
  1947                              <1> 	;sub	bl, bl
  1948                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set
  1949                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  1950 00001D9B E8E8160000          <1> 	call	load_text_8_16_pat
  1951                              <1> 
  1952                              <1> 	; video_func_1103h:
  1953                              <1> 	; biosfn_set_text_block_specifier:
  1954                              <1> 	; BL = font block selector code	
  1955                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  1956                              <1> 	; (It is as BL = 0 for TRDOS 386)
  1957 00001DA0 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  1958                              <1> 	;;mov	ah, bl
  1959                              <1> 	;sub	ah, ah ; 0
  1960                              <1> 	;mov	al, 03h
  1961                              <1> 	; 19/11/2020
  1962 00001DA4 66B80300            <1> 	mov	ax, 03h
  1963 00001DA8 66EF                <1> 	out	dx, ax
  1964                              <1> _sm_19:
  1965                              <1> 	; 29/07/2016
  1966                              <1> 	; 26/07/2016
  1967                              <1> 	; 24/06/2016
  1968                              <1> 	;mov	edi, 0B8000h
  1969                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  1970                              <1> 	;
  1971 00001DAA 30C0                <1> 	xor	al, al
  1972 00001DAC 3805[65960100]      <1>         cmp     [p_crt_mode], al ; 0 
  1973 00001DB2 7705                <1>         ja      short _sm_20 ; 03h, 80h or 83h
  1974                              <1> 
  1975                              <1> 	; case 1 - 19/11/2020
  1976                              <1> 	;
  1977                              <1> 	; If [pc_crt_mode] = 0, that means, previous mode is 03h
  1978                              <1> 	; and current mode is not 03h (case 1)
  1979                              <1> 
  1980                              <1> 	; 30/07/2016
  1981                              <1> 	; 24/06/2016
  1982                              <1> 	; TRDOS 386 (TRDOS v2) 'set mode' modification
  1983                              <1> 	; (for multiscreen feature):
  1984                              <1> 	; If '_set_mode' procedure is called for video mode 3
  1985                              <1> 	;     while video mode is 3, video page will be cleared
  1986                              <1> 	;     and cursor position of video page will be reset.	  
  1987                              <1> 	; If '_set_mode' procedure is called for a video mode
  1988                              <1> 	;     except video mode 3, while current video mode
  1989                              <1> 	;     is 3, all video pages of mode 3 will be copied 
  1990                              <1> 	;     to 98000h address as backup, before mode change.	 	
  1991                              <1> 	; If '_set_mode' procedure is called for video mode 3
  1992                              <1> 	;     while video mode is not 3 and if there is video
  1993                              <1> 	;     page backup for video mode 3, all (of 8) mode 3
  1994                              <1> 	;     video pages will be restored from 98000h.
  1995                              <1> 
  1996                              <1> 	; 19/11/2020
  1997                              <1> 	;mov	[ACTIVE_PAGE], al ; 0
  1998                              <1> 
  1999                              <1> 	; Here,
  2000                              <1> 	; video memory already cleared if [noclearmem] <> 80h
  2001                              <1> 	
  2002                              <1> 	;mov	ax, 0720h
  2003                              <1> 	;mov	cx, 4000h ; 16K words (32K)
  2004                              <1> 	;mov	edi, 0B8000h
  2005                              <1> 	;rep	stosw
  2006                              <1> 	;sub	al, al
  2007                              <1> 	
  2008                              <1> 	;jmp	short _sm_23
  2009                              <1> 
  2010                              <1> 	; Set hardware side for the new active video page
  2011                              <1>  
  2012 00001DB4 E9FB010000          <1> 	jmp	_set_active_page ; 19/11/2020	
  2013                              <1> 
  2014                              <1> _sm_20:
  2015                              <1> 	; 19/11/2020
  2016                              <1> 	; case 2 or case 3 or case 4 - 19/11/2020
  2017                              <1> 	
  2018                              <1> 	; 19/11/2020
  2019 00001DB9 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3  ; new video mode
  2020 00001DC0 754F                <1> 	jne	short _sm_22 ; al = 0 (& video mode <> 03h)
  2021                              <1> 			     ; case 4 - 19/11/2020
  2022                              <1> 			     ; ([p_crt_mode] = 83h) 		
  2023                              <1> 
  2024                              <1> 	; case 2 or case 3 - 19/11/2020	
  2025                              <1> 
  2026                              <1> 	;movzx	ebx, byte [ACTIVE_PAGE]
  2027                              <1> 	; 19/11/2020
  2028 00001DC2 A0[66960100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  2029                              <1> 	;movzx	ebx, al
  2030                              <1> 	;shl	bl, 1 ; * 2
  2031                              <1> 	;add	ebx, CURSOR_POSN
  2032                              <1> 
  2033                              <1> 	; 29/07/2016
  2034 00001DC7 F605[65960100]7F    <1> 	test    byte [p_crt_mode], 7Fh ; 83h or 80h or 03h
  2035 00001DCE 740F                <1> 	jz	short _sm_21	; do not restore video pages
  2036                              <1> 				; case 2 - 19/11/2020 
  2037                              <1> 	; case 3 - 19/11/2020
  2038                              <1> 
  2039                              <1> 	; ([p_crt_mode] = 03h)
  2040                              <1> 
  2041                              <1> 	; New video mode is 3 while current video mode is not 3
  2042                              <1> 	; (multi screen) video pages will be restored from 098000h
  2043                              <1> 
  2044                              <1> 	; 19/11/2020
  2045 00001DD0 A2[FE890100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  2046                              <1> 
  2047                              <1> 	; 12/12/2020
  2048                              <1> 	;; restore video pages
  2049                              <1> 	;mov	esi, 98000h ; 30/07/2016 
  2050                              <1> 	;mov	edi, 0B8000h
  2051                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  2052                              <1> 	;rep	movsd
  2053                              <1> 	;
  2054                              <1> 	;; 19/11/2020
  2055                              <1> 	;mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  2056                              <1> 	;
  2057                              <1> 	;; restore cursor positions
  2058                              <1> 	;mov	esi, cursor_pposn
  2059                              <1> 	;mov	edi, CURSOR_POSN
  2060                              <1> 	;;mov	ecx, 4	; restore all cursor positions (16 bytes)
  2061                              <1> 	;mov	cl, 4
  2062                              <1> 	;rep 	movsd
  2063                              <1> 	
  2064                              <1> 	; 12/12/2020
  2065 00001DD5 E89C000000          <1> 	call	_restore_mode3_multiscreen
  2066                              <1> 
  2067                              <1> 	;jmp	short _sm_23 ; do not clear current video pages
  2068                              <1> 
  2069                              <1> 	; 19/11/2020
  2070 00001DDA E9D5010000          <1> 	jmp	_set_active_page
  2071                              <1> 
  2072                              <1> _sm_21:
  2073                              <1> 	; 19/11/2020
  2074                              <1> 	; case 2 
  2075                              <1> 	;
  2076                              <1> 	; ([p_crt_mode] = 80h)
  2077                              <1> 	;
  2078                              <1> 	; User has requested to set video mode 3 again while
  2079                              <1> 	; current video mode is 3.. that means, set mode 03h
  2080                              <1> 	; parameters again and clear video page.
  2081                              <1> 	; ('noclearmem' option effects the result) 
  2082                              <1> 	
  2083                              <1> 	; 19/11/2020
  2084 00001DDF F605[67960100]80    <1> 	test	byte [noclearmem], 80h
  2085 00001DE6 7529                <1> 	jnz	short _sm_22	; 'do not clear video memory'
  2086                              <1> 				; continue with current text
  2087                              <1> 				; (user's option/choice) 
  2088                              <1> 	; clear video page
  2089                              <1> 	;mov	cx, [CRT_LEN] ; 4096
  2090                              <1> 	;shr	cx, 1 ; 2048 ; 16/11/2020
  2091 00001DE8 66B82007            <1> 	mov	ax, 0720h
  2092                              <1> 	; 26/11/2020
  2093 00001DEC B900080000          <1> 	mov	ecx, 2048 ; 4096/2
  2094 00001DF1 BF00800B00          <1> 	mov	edi, 0B8000h ; [crt_base]
  2095 00001DF6 66033D[EC890100]    <1> 	add	di, [CRT_START]
  2096 00001DFD F366AB              <1> 	rep	stosw	; FILL THE REGEN BUFFER WITH BLANKS
  2097                              <1> 	;
  2098                              <1> 	; 19/11/2020
  2099 00001E00 A0[FE890100]        <1> 	mov	al, [ACTIVE_PAGE] ; 0 to 7 (for video mode 3)
  2100 00001E05 0FB6D8              <1> 	movzx	ebx, al
  2101 00001E08 D0E3                <1> 	shl	bl, 1
  2102 00001E0A 66898B[EE890100]    <1> 	mov	[ebx+CURSOR_POSN], cx ; reset cursor position
  2103                              <1> _sm_22:
  2104                              <1> 	;mov	[p_crt_mode], al ; 0 ; reset
  2105                              <1> 	; 19/11/2020
  2106                              <1> 	;and	byte [p_crt_mode], 3 ; 83h -> 3, 80h -> 0  
  2107 00001E11 8025[65960100]7F    <1> 	and	byte [p_crt_mode], 7Fh ; 83h -> 3, 80h -> 0  
  2108                              <1> _sm_23:
  2109                              <1> 	; al = video page number
  2110                              <1> 	; [CRT_LEN] = length of regen buffer in bytes
  2111                              <1> 	;call	_set_active_page
  2112                              <1> 	; 16/11/2020
  2113 00001E18 E997010000          <1> 	jmp	_set_active_page
  2114                              <1> 
  2115                              <1> ;-----	NORMAL RETURN FROM ALL VIDEO RETURNS
  2116                              <1> 	;retn
  2117                              <1> 
  2118                              <1> save_mode3_multiscreen:
  2119                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  2120                              <1> 	; save mode 03h video pages and cursor positions
  2121                              <1> 	;
  2122                              <1> 	; Modified registers: ecx (=0), esi, edi
  2123                              <1> 	
  2124                              <1> 	; 12/12/2020
  2125                              <1> 	; moved here from '_set_mode'	
  2126                              <1> 	; 03/07/2016
  2127                              <1> 	; save video pages
  2128 00001E1D BE00800B00          <1> 	mov	esi, 0B8000h
  2129 00001E22 BF00800900          <1> 	mov	edi, 98000h ; 30/07/2016
  2130 00001E27 B900200000          <1> 	mov	ecx, (0B8000h-0B0000h)/4
  2131 00001E2C F3A5                <1> 	rep	movsd
  2132                              <1> 	
  2133 00001E2E C605[65960100]03    <1> 	mov	byte [p_crt_mode], 3 ; previous mode, backup sign
  2134                              <1> 	; 26/11/2020
  2135 00001E35 860D[FE890100]      <1> 	xchg	cl, [ACTIVE_PAGE]
  2136 00001E3B 880D[66960100]      <1> 	mov	[p_crt_page], cl  ; save as previous active page	
  2137                              <1> 	
  2138                              <1> 	; save cursor positions
  2139 00001E41 BE[EE890100]        <1> 	mov	esi, CURSOR_POSN
  2140 00001E46 BF[6A960100]        <1> 	mov	edi, cursor_pposn ; cursor positions backup
  2141 00001E4B B104                <1> 	mov	cl, 4
  2142 00001E4D F3A5                <1> 	rep	movsd
  2143 00001E4F C3                  <1> 	retn
  2144                              <1> 
  2145                              <1> restore_mode3_multiscreen:
  2146                              <1> 	; 12/12/2020 (TRDOS v2.0.3)
  2147                              <1> 	; restore mode 03h video pages and cursor positions
  2148                              <1> 	;
  2149                              <1> 	; Input:
  2150                              <1> 	;    settings from the last 'save_mode3_multiscreen'
  2151                              <1> 	;
  2152                              <1> 	; Output: 
  2153                              <1> 	;    AL = active video page = [ACTIVE_PAGE]
  2154                              <1> 	;
  2155                              <1> 	; Modified registers: al, ecx (=0), esi, edi
  2156                              <1> 
  2157 00001E50 A0[66960100]        <1> 	mov	al, [p_crt_page] ; previous mode 3 active page
  2158 00001E55 A2[FE890100]        <1> 	mov	[ACTIVE_PAGE], al ; current mode 3 active page
  2159                              <1> 
  2160                              <1> 	; 12/12/2020
  2161                              <1> 	; moved here from 'vesa_vbe3_pmi'	
  2162                              <1> 
  2163                              <1> 	; 07/12/2020
  2164                              <1> 	; restore CRT_START according to ACTIVE_PAGE
  2165                              <1> 	;mov	[CRT_START], cx ; 0
  2166                              <1> 	; 12/12/2020
  2167 00001E5A 66C705[EC890100]00- <1> 	mov	word [CRT_START], 0
  2167 00001E62 00                  <1>
  2168                              <1> 
  2169                              <1> 	; check active page and set it again if it is not 0
  2170 00001E63 08C0                <1> 	or	al, al
  2171                              <1> 	;;jz	short vbe3_pmi_7
  2172                              <1> 	;jz	short _restore_mode3_multiscreen
  2173 00001E65 740F                <1> 	jz	short r_m3_ms_1
  2174 00001E67 88C1                <1> 	mov	cl, al
  2175                              <1> ;vbe3_pmi_5:
  2176                              <1> r_m3_ms_0:
  2177 00001E69 668105[EC890100]00- <1> 	add	word [CRT_START], 4096
  2177 00001E71 10                  <1>
  2178 00001E72 FEC9                <1> 	dec	cl
  2179                              <1> 	;jnz	short vbe3_pmi_5
  2180 00001E74 75F3                <1> 	jnz	short r_m3_ms_0
  2181                              <1> r_m3_ms_1:
  2182                              <1> 	; 12/12/2020
  2183                              <1> 	; moved here from '_set_mode'	
  2184                              <1> _restore_mode3_multiscreen:
  2185                              <1> 	; Modified registers: ecx, esi, edi
  2186                              <1> 
  2187                              <1> 	; restore video pages
  2188 00001E76 BE00800900          <1> 	mov	esi, 98000h ; 30/07/2016 
  2189 00001E7B BF00800B00          <1> 	mov	edi, 0B8000h
  2190                              <1> 	;mov	cx, 2000h ; 8K dwords (32K)
  2191 00001E80 B900200000          <1> 	mov	ecx, 2000h
  2192 00001E85 F3A5                <1> 	rep	movsd
  2193                              <1> 
  2194                              <1> 	; 19/11/2020
  2195 00001E87 880D[65960100]      <1> 	mov	[p_crt_mode], cl ; reset ('case 3' end condition)
  2196                              <1> 
  2197                              <1> 	; restore cursor positions
  2198 00001E8D BE[6A960100]        <1> 	mov	esi, cursor_pposn
  2199 00001E92 BF[EE890100]        <1> 	mov	edi, CURSOR_POSN
  2200                              <1> 	;mov	ecx, 4	; restore all cursor positions (16 bytes)
  2201 00001E97 B104                <1> 	mov	cl, 4
  2202 00001E99 F3A5                <1> 	rep 	movsd
  2203 00001E9B C3                  <1> 	retn
  2204                              <1> 
  2205                              <1> cursor_shape_fix:
  2206                              <1> 	; 07/07/2016
  2207                              <1> 	; (Cursor start and cursor end line values -6,7-
  2208                              <1> 	; will be fixed depending on character height)
  2209                              <1> 	;
  2210                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  2211                              <1> 	; vgabios-0.7a (2011)
  2212                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  2213                              <1> 	; 'vgabios.c', ' biosfn_set_cursor_shape (CH,CL)'
  2214                              <1> 	;
  2215                              <1> 	; INPUT ->
  2216                              <1> 	;	AL = cursor start line (=6)
  2217                              <1> 	;	AH = cursor end line (=7)
  2218                              <1> 	; OUTPUT ->
  2219                              <1> 	;	AL = cursor start line (=14)
  2220                              <1> 	;	AH = cursor end line (=15)
  2221                              <1> 	;
  2222                              <1> 	;; if((modeset_ctl&0x01)&&(cheight>8)&&(CL<8)&&(CH<0x20))
  2223                              <1> 
  2224                              <1> 	;test	byte [VGA_MODESET_CTL], 1 ; VGA active
  2225                              <1> 	;jz	short csf_3
  2226 00001E9C 803D[CE6F0000]08    <1> 	cmp	byte [CHAR_HEIGHT], 8
  2227 00001EA3 7649                <1> 	jna	short csf_3
  2228 00001EA5 80FC08              <1> 	cmp	ah, 8
  2229 00001EA8 7344                <1> 	jnb	short csf_3
  2230 00001EAA 3C20                <1> 	cmp	al, 20h
  2231 00001EAC 7340                <1> 	jnb	short csf_3
  2232                              <1> 	;
  2233 00001EAE 6650                <1> 	push	ax
  2234                              <1> 	; {
  2235                              <1>    	; if(CL!=(CH+1))	
  2236 00001EB0 FEC0                <1> 	inc	al
  2237 00001EB2 38C4                <1> 	cmp	ah, al   ; ah != al + 1
  2238 00001EB4 740F                <1>         je      short csf_1
  2239                              <1> 	; CH = ((CH+1) * cheight / 8) -1;
  2240 00001EB6 8A25[CE6F0000]      <1> 	mov	ah, [CHAR_HEIGHT]
  2241 00001EBC F6E4                <1> 	mul	ah
  2242 00001EBE C0E803              <1> 	shr	al, 3 ; / 8
  2243 00001EC1 FEC8                <1> 	dec	al ; - 1
  2244 00001EC3 EB0E                <1> 	jmp	short csf_2 
  2245                              <1> csf_1: 	
  2246                              <1>  	; }
  2247                              <1>    	; else		; ah = al + 1
  2248                              <1>     	; {
  2249 00001EC5 FEC4                <1> 	inc	ah	; ah = ah + 1   
  2250                              <1> 	; CH = ((CL+1) * cheight / 8) - 2;
  2251 00001EC7 A0[CE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  2252 00001ECC F6E4                <1> 	mul	ah
  2253 00001ECE C0E803              <1> 	shr	al, 3 ; / 8
  2254 00001ED1 2C02                <1> 	sub	al, 2 ; - 2
  2255                              <1> 	; al = 14 (if [CHAR_HEIGHT] = 16)
  2256                              <1> csf_2:
  2257 00001ED3 880424              <1> 	mov	[esp], al
  2258 00001ED6 8A642401            <1> 	mov	ah, [esp+1]
  2259                              <1> 	; CL = ((CL+1) * cheight / 8) - 1;
  2260 00001EDA FEC4                <1> 	inc	ah 
  2261 00001EDC A0[CE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  2262 00001EE1 F6E4                <1> 	mul	ah
  2263 00001EE3 C0E803              <1> 	shr	al, 3 ; / 8
  2264 00001EE6 FEC8                <1> 	dec	al ; - 1
  2265 00001EE8 88442401            <1> 	mov	[esp+1], al
  2266                              <1> 	; ah = 15 (if [CHAR_HEIGHT] = 16)
  2267                              <1> 	;
  2268 00001EEC 6658                <1> 	pop	ax
  2269                              <1> csf_3:
  2270 00001EEE C3                  <1> 	retn
  2271                              <1> 
  2272                              <1> SET_CTYPE:
  2273                              <1> 	; 12/09/2016
  2274                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2275 00001EEF 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7
  2276 00001EF6 0F875BFCFFFF        <1> 	ja	VIDEO_RETURN ; 12/09/2016
  2277 00001EFC E805000000          <1> 	call	_set_ctype
  2278 00001F01 E951FCFFFF          <1>         jmp     VIDEO_RETURN
  2279                              <1> 
  2280                              <1> _set_ctype:
  2281                              <1> 	; 02/09/2014 (Retro UNIX 386 v1)
  2282                              <1> 	;
  2283                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2284                              <1> 
  2285                              <1> 	; (CH) = BITS 4-0 = START LINE FOR CURSOR
  2286                              <1> 	;  ** HARDWARE WILL ALWAYS CAUSE BLINK
  2287                              <1> 	;  ** SETTING BIT 5 OR 6 WILL CAUSE ERRATIC BLINKING
  2288                              <1> 	;     OR NO CURSOR AT ALL
  2289                              <1> 	; (CL) = BITS 4-0 = END LINE FOR CURSOR
  2290                              <1> 
  2291                              <1> ;------------------------------------------------
  2292                              <1> ; SET_CTYPE
  2293                              <1> ;	THIS ROUTINE SETS THE CURSOR VALUE
  2294                              <1> ; INPUT
  2295                              <1> ;	(CX) HAS CURSOR VALUE CH-START LINE, CL-STOP LINE
  2296                              <1> ; OUTPUT	
  2297                              <1> ;	NONE
  2298                              <1> ;------------------------------------------------
  2299                              <1> 
  2300                              <1> 	; 07/07/2016
  2301                              <1> 	; Fixing cursor start and stop line depending on
  2302                              <1> 	; current character height (=16)
  2303                              <1> 	; (Note: Default/initial values are 6 and 7.
  2304                              <1> 	; If set values are 6 (start) & 7 (stop) and 
  2305                              <1> 	; [CHAR_HEIGHT] = 16 :
  2306                              <1> 	; After fixing, start line will be 14, stop line
  2307                              <1> 	; will be 15.)
  2308 00001F06 6689C8              <1> 	mov	ax, cx
  2309 00001F09 86C4                <1> 	xchg	al, ah
  2310                              <1> 	; AL = start line, AH = stop line
  2311 00001F0B E88CFFFFFF          <1> 	call	cursor_shape_fix
  2312                              <1> 	; AL = start line (fixed), AH = stop line (fixed)
  2313 00001F10 6689C1              <1> 	mov	cx, ax
  2314 00001F13 86E9                <1> 	xchg	ch, cl
  2315                              <1> 	; CH = start line (fixed), CL = stop line (fixed)
  2316                              <1> 	;
  2317 00001F15 B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  2318 00001F17 66890D[E36F0000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  2319                              <1> 	;call	m16	; output cx register
  2320                              <1> 	;retn
  2321 00001F1E E99F040000          <1>         jmp     m16
  2322                              <1> 
  2323                              <1> SET_CPOS:
  2324                              <1> 	; 12/09/2016
  2325                              <1> 	; 07/07/2016
  2326                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2327 00001F23 80FF07              <1> 	cmp	bh, 7 ; video page > 7 ; 07/07/2016
  2328 00001F26 0F872BFCFFFF        <1> 	ja	VIDEO_RETURN
  2329                              <1> 	;
  2330 00001F2C 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7
  2331 00001F33 770A                <1> 	ja	short vga_set_cpos ; 12/09/2016	
  2332 00001F35 E85D040000          <1> 	call	_set_cpos
  2333 00001F3A E918FCFFFF          <1>         jmp     VIDEO_RETURN
  2334                              <1> 
  2335                              <1> vga_set_cpos:
  2336                              <1> 	; 12/09/2016
  2337                              <1> 	; 09/07/2016
  2338                              <1> 	; set cursor position
  2339                              <1> 	; NOTE: Hardware cursor position will not be set
  2340                              <1> 	;   in any VGA modes (>7)
  2341                              <1> 	;   But, cursor position will be saved into
  2342                              <1> 	;   [CURSOR_POSN].
  2343                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  2344                              <1> 	;   (page 0) for all graphics modes.
  2345                              <1> 
  2346 00001F3F 668915[EE890100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  2347                              <1> 	; 04/08/2016
  2348                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  2349                              <1> 	;call	_set_cpos
  2350 00001F46 E90CFCFFFF          <1> 	jmp     VIDEO_RETURN
  2351                              <1> 
  2352                              <1> READ_CURSOR:
  2353                              <1> 	; 12/09/2016
  2354                              <1> 	; 07/07/2016
  2355                              <1> 	; 12/05/2016
  2356                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2357                              <1> 	;
  2358                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2359                              <1> 
  2360                              <1> ;------------------------------------------------------
  2361                              <1> ; READ_CURSOR
  2362                              <1> ;	THIS ROUTINE READS THE CURRENT CURSOR VALUE FROM THE
  2363                              <1> ;	845, FORMATS IT, AND SENDS IT BACK TO THE CALLER
  2364                              <1> ; INPUT
  2365                              <1> ;	BH - PAGE OF CURSOR
  2366                              <1> ; OUTPUT
  2367                              <1> ;	DX - ROW, COLUMN OF THE CURRENT CURSOR POSITION
  2368                              <1> ;	CX - CURRENT CURSOR MODE
  2369                              <1> ;------------------------------------------------------
  2370                              <1> 
  2371                              <1> 	; BH = Video page number (0 to 7)
  2372                              <1> 
  2373                              <1> 	; 07/07/2016
  2374 00001F4B 80FF07              <1> 	cmp	bh, 7 ; video page > 7 (invalid)
  2375 00001F4E 7606                <1> 	jna	short read_cursor_1
  2376                              <1> 	; invalid video page (input) 
  2377 00001F50 31C9                <1> 	xor	ecx, ecx ; 0
  2378 00001F52 31D2                <1> 	xor	edx, edx ; 0
  2379 00001F54 EB15                <1> 	jmp	short read_cursor_2
  2380                              <1> read_cursor_1:
  2381                              <1> 	; 12/09/2016
  2382 00001F56 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; vga mode
  2383 00001F5D 7727                <1> 	ja	short vga_get_cpos
  2384                              <1> 	;
  2385 00001F5F E815000000          <1> 	call	get_cpos
  2386 00001F64 0FB70D[E36F0000]    <1> 	movzx	ecx, word [CURSOR_MODE]
  2387                              <1> read_cursor_2:
  2388 00001F6B 5D                  <1> 	pop	ebp
  2389 00001F6C 5F                  <1> 	pop	edi
  2390 00001F6D 5E                  <1> 	pop	esi
  2391 00001F6E 5B                  <1> 	pop	ebx
  2392 00001F6F 58                  <1> 	pop	eax  ; DISCARD SAVED CX AND DX
  2393 00001F70 58                  <1> 	pop	eax
  2394 00001F71 A1[58960100]        <1> 	mov	eax, [video_eax] ; 12/05/2016
  2395                              <1> 	;;15/01/2017
  2396                              <1> 	;;mov	byte [intflg], 0 ; 07/01/2017
  2397 00001F76 1F                  <1> 	pop	ds
  2398 00001F77 07                  <1> 	pop	es
  2399 00001F78 CF                  <1> 	iretd
  2400                              <1> 
  2401                              <1> get_cpos:
  2402                              <1> 	; 12/05/2016
  2403                              <1> 	; 16/01/2016
  2404                              <1> 	; BH = Video page number (0 to 7)
  2405                              <1> 	;
  2406 00001F79 D0E7                <1> 	shl	bh, 1 ; WORD OFFSET
  2407 00001F7B 0FB6F7              <1> 	movzx	esi, bh 
  2408 00001F7E 0FB796[EE890100]    <1> 	movzx	edx, word [esi+CURSOR_POSN]
  2409 00001F85 C3                  <1> 	retn
  2410                              <1> 
  2411                              <1> vga_get_cpos:
  2412                              <1> 	; 12/09/2016
  2413                              <1> 	; get cursor position (vga)
  2414 00001F86 0FB715[EE890100]    <1> 	movzx	edx, word [CURSOR_POSN] ; cursor pos for pg 0
  2415 00001F8D 31C9                <1> 	xor	ecx, ecx ; Cursor Mode = 0 (invalid)
  2416 00001F8F EBDA                <1> 	jmp     short read_cursor_2
  2417                              <1> 
  2418                              <1> ACT_DISP_PAGE:
  2419                              <1> 	; 07/07/2016
  2420                              <1> 	; 26/06/2016
  2421                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2422                              <1> 	;
  2423                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2424                              <1> 	;
  2425                              <1> ;-----------------------------------------------------
  2426                              <1> ; ACT_DISP_PAGE
  2427                              <1> ;	THIS ROUTINE SETS THE ACTIVE DISPLAY PAGE, ALLOWING
  2428                              <1> ;	THE FULL USE OF THE MEMORY SET ASIDE FOR THE VIDEO ATTACHMENT
  2429                              <1> ; INPUT
  2430                              <1> ;	AL HAS THE NEW ACTIVE DISPLAY PAGE
  2431                              <1> ; OUTPUT
  2432                              <1> ;	THE 6845 IS RESET TO DISPLAY THAT PAGE
  2433                              <1> ;-----------------------------------------------------
  2434                              <1> 	; 07/07/2016
  2435 00001F91 3C07                <1> 	cmp	al, 7	; > 7 = invalid video page number
  2436                              <1> 	;ja	VIDEO_RETURN
  2437 00001F93 7715                <1>         ja	short adp_2 ; 18/11/2020
  2438                              <1> 	;cmp	byte [CRT_MODE], 3
  2439                              <1> 	;je	short adp_1
  2440                              <1> 	; 18/11/2020
  2441 00001F95 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE]
  2442 00001F9B 80FC03              <1> 	cmp	ah, 3
  2443 00001F9E 7605                <1> 	jna	short adp_1 ; mode 01h, 00h (01h), 02h (03h), 03h
  2444 00001FA0 80FC07              <1> 	cmp	ah, 7	    ; mode 07h (03h)	
  2445 00001FA3 7505                <1> 	jne	short adp_2
  2446                              <1> 	;and 	al, al
  2447                              <1>         ;jnz	VIDEO_RETURN
  2448                              <1> 	;;sub	al, al ; 0 ; force to page 0
  2449                              <1> adp_1:	
  2450 00001FA5 E805000000          <1> 	call	set_active_page
  2451                              <1> adp_2:
  2452 00001FAA E9A8FBFFFF          <1>         jmp     VIDEO_RETURN
  2453                              <1> 
  2454                              <1> set_active_page:   ; tty_sw
  2455                              <1> 	; 09/12/2017
  2456                              <1> 	; 26/07/2016
  2457                              <1> 	; 26/06/2016
  2458                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2459                              <1> 	; 30/06/2015
  2460                              <1> 	; 04/03/2014  (act_disp_page --> tty_sw)
  2461                              <1> 	; 10/12/2013
  2462                              <1> 	; 04/12/2013
  2463                              <1> 	;
  2464 00001FAF A2[FE890100]        <1> 	mov	[ACTIVE_PAGE], al ; save active page value ; [ptty]
  2465                              <1> _set_active_page:
  2466                              <1> 	; 27/06/2015
  2467 00001FB4 0FB6D8              <1> 	movzx	ebx, al
  2468                              <1> 	;
  2469                              <1> 	;cbw	; 07/09/2014 (ah=0)
  2470 00001FB7 28E4                <1> 	sub	ah, ah ; 09/12/2017
  2471 00001FB9 66F725[68960100]    <1> 	mul	word [CRT_LEN]  ; get saved length of regen buffer
  2472                              <1> 				; display page times regen length
  2473                              <1> 	; 10/12/2013
  2474 00001FC0 66A3[EC890100]      <1> 	mov	[CRT_START], ax ; save start address for later
  2475 00001FC6 6689C1              <1> 	mov	cx, ax ; start address to cx
  2476                              <1> _M16:
  2477                              <1> 	;sar	cx, 1
  2478 00001FC9 66D1E9              <1> 	shr	cx, 1	; divide by 2 for 6845 handling
  2479 00001FCC B40C                <1> 	mov	ah, 12	; 6845 register for start address
  2480 00001FCE E8EF030000          <1> 	call	m16
  2481                              <1> 	;sal	bx, 1
  2482                              <1> 	; 01/09/2014
  2483 00001FD3 D0E3                <1> 	shl	bl, 1	; *2 for word offset
  2484 00001FD5 81C3[EE890100]      <1> 	add	ebx, CURSOR_POSN
  2485 00001FDB 668B13              <1> 	mov	dx, [ebx] ; get cursor for this page
  2486                              <1> 	; 16/01/2016
  2487                              <1> 	;call	m18
  2488                              <1> 	;retn
  2489 00001FDE E9CB030000          <1> 	jmp	m18
  2490                              <1> 
  2491                              <1> position:
  2492                              <1> 	; 24/06/2016
  2493                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  2494                              <1> 	; 27/06/2015
  2495                              <1> 	; 02/09/2014
  2496                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  2497                              <1> 	; 04/12/2013 (Retro UNIX 8086 v1)
  2498                              <1> 	;
  2499                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2500                              <1> 	;
  2501                              <1> ;-----------------------------------------
  2502                              <1> ; POSITION
  2503                              <1> ;	THIS SERVICE ROUTINE CALCULATES THE REGEN BUFFER ADDRESS
  2504                              <1> ;	OF A CHARACTER IN THE ALPHA MODE
  2505                              <1> ; INPUT
  2506                              <1> ;	AX = ROW, COLUMN POSITION
  2507                              <1> ; OUTPUT
  2508                              <1> ;	AX = OFFSET OF CHAR POSITION IN REGEN BUFFER
  2509                              <1> ;-----------------------------------------
  2510                              <1> 
  2511                              <1> 	; DX = ROW, COLUMN POSITION
  2512 00001FE3 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; 24/06/2016
  2513 00001FEA F6E6                <1> 	mul	dh	 ; row value
  2514 00001FEC 30F6                <1> 	xor	dh, dh   ; 0	
  2515 00001FEE 6601D0              <1> 	add	ax, dx	 ; add column value to the result
  2516 00001FF1 66D1E0              <1> 	shl	ax, 1	; * 2 for attribute bytes
  2517                              <1> 		; EAX = AX = OFFSET OF CHAR POSITION IN REGEN BUFFER 
  2518 00001FF4 C3                  <1> 	retn
  2519                              <1> 
  2520                              <1> find_position:
  2521                              <1> 	; 24/06/2016
  2522                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  2523                              <1> 	; 27/06/2015
  2524                              <1> 	; 07/09/2014
  2525                              <1> 	; 02/09/2014
  2526                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  2527                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2528                              <1> 
  2529 00001FF5 0FB6CF              <1> 	movzx	ecx, bh ; video page number
  2530 00001FF8 89CE                <1> 	mov	esi, ecx
  2531 00001FFA 66D1E6              <1> 	shl	si, 1
  2532 00001FFD 668B96[EE890100]    <1> 	mov	dx, [esi+CURSOR_POSN]
  2533 00002004 740C                <1> 	jz	short p21
  2534 00002006 6631F6              <1> 	xor	si, si
  2535                              <1> p20:
  2536 00002009 660335[68960100]    <1> 	add	si, [CRT_LEN] ; 24/06/2016
  2537                              <1> 	;add	si, 80*25*2 ; add length of buffer for one page		
  2538 00002010 E2F7                <1> 	loop	p20
  2539                              <1> p21:
  2540 00002012 6621D2              <1> 	and	dx, dx
  2541 00002015 7407                <1> 	jz	short p22
  2542 00002017 E8C7FFFFFF          <1> 	call 	position ; determine location in regen in page
  2543 0000201C 01C6                <1> 	add	esi, eax ; add location to start of regen page
  2544                              <1> p22:	
  2545                              <1> 	;mov	dx, [addr_6845] ; get base address of active display			
  2546                              <1> 	;mov	dx, 03D4h ; I/O address of color card
  2547                              <1> 	;add	dx, 6	; point at status port
  2548 0000201E 66BADA03            <1> 	mov	dx, 03DAh ; status port
  2549                              <1> 	; cx = 0
  2550 00002022 C3                  <1> 	retn
  2551                              <1> 
  2552                              <1> SCROLL_UP:
  2553                              <1> 	; 07/07/2016
  2554                              <1> 	; 26/06/2016
  2555                              <1> 	; 12/05/2016
  2556                              <1> 	; 30/01/2016
  2557                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2558                              <1> 	; 07/09/2014
  2559                              <1> 	; 02/09/2014
  2560                              <1> 	; 01/09/2014 (Retro UNIX 386 v1 - beginning)
  2561                              <1> 	; 04/04/2014
  2562                              <1> 	; 04/12/2013
  2563                              <1> 	;
  2564                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2565                              <1> 	;
  2566                              <1> ;----------------------------------------------
  2567                              <1> ; SCROLL UP
  2568                              <1> ;	THIS ROUTINE MOVES A BLOCK OF CHARACTERS UP
  2569                              <1> ;	ON THE SCREEN
  2570                              <1> ; INPUT
  2571                              <1> ;	(AH) = CURRENT CRT MODE
  2572                              <1> ;	(AL) = NUMBER OF ROWS TO SCROLL
  2573                              <1> ;	(CX) = ROW/COLUMN OF UPPER LEFT CORNER
  2574                              <1> ;	(DX) = ROW/COLUMN OF LOWER RIGHT CORNER
  2575                              <1> ;	(BH) = ATTRIBUTE TO BE USED ON BLANKED LINE
  2576                              <1> ;	(DS) = DATA SEGMENT
  2577                              <1> ;	(ES) = REGEN BUFFER SEGMENT
  2578                              <1> ; OUTPUT
  2579                              <1> ;	NONE -- THE REGEN BUFFER IS MODIFIED
  2580                              <1> ;--------------------------------------------
  2581                              <1> 
  2582                              <1> 	; 07/07/2016
  2583 00002023 38F5                <1> 	cmp	ch, dh
  2584 00002025 0F872CFBFFFF        <1> 	ja	VIDEO_RETURN
  2585 0000202B 38D1                <1> 	cmp	cl, dl
  2586 0000202D 0F8724FBFFFF        <1> 	ja	VIDEO_RETURN
  2587                              <1> 	;
  2588 00002033 E805000000          <1> 	call	_scroll_up
  2589 00002038 E91AFBFFFF          <1>         jmp     VIDEO_RETURN
  2590                              <1> 
  2591                              <1> _scroll_up:  ; from 'write_tty'
  2592                              <1> 	;
  2593                              <1> 	; cl = left upper column
  2594                              <1> 	; ch = left upper row
  2595                              <1> 	; dl = right lower column
  2596                              <1> 	; dh = right lower row
  2597                              <1> 	;
  2598                              <1> 	; al = line count 
  2599                              <1> 	; bl = attribute to be used on blanked line	
  2600                              <1> 	; bh = video page number (0 to 7)
  2601                              <1> 
  2602 0000203D E89C000000          <1> 	call	test_line_count ; 16/01/2016
  2603                              <1> 
  2604 00002042 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  2605                              <1> 	;;cmp	byte [CRT_MODE], 4
  2606                              <1> 	;cmp	ah, 4 ; 07/07/2016
  2607                              <1> 	;jnb	GRAPHICS_UP ; 26/06/2016
  2608                              <1> 	; 18/11/2020
  2609 00002048 80FC04              <1> 	cmp	ah, 4
  2610 0000204B 720A                <1>  	jb	short n0	
  2611 0000204D 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  2612                              <1> 		      ;	(80x25 text, mono)
  2613 00002050 7405                <1> 	je	short n0 ; same with mode 3 for TRDOS 386
  2614 00002052 E942050000          <1> 	jmp	GRAPHICS_UP
  2615                              <1> n0:
  2616                              <1> 	; 07/07/2016
  2617 00002057 80FF07              <1> 	cmp	bh, 7 ; video page number
  2618 0000205A 7606                <1> 	jna	short n1
  2619 0000205C 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE]
  2620                              <1> n1:
  2621 00002062 88DC                <1> 	mov	ah, bl ; attribute
  2622 00002064 6650                <1> 	push	ax ; *
  2623                              <1> 	;mov 	esi, [CRT_BASE]
  2624 00002066 BE00800B00          <1>         mov     esi, 0B8000h  
  2625 0000206B 3A3D[FE890100]      <1>         cmp     bh, [ACTIVE_PAGE]
  2626 00002071 750B                <1> 	jne	short n2
  2627                              <1> 	;
  2628 00002073 66A1[EC890100]      <1>         mov     ax, [CRT_START]
  2629 00002079 6601C6              <1>         add     si, ax
  2630 0000207C EB11                <1>         jmp     short n4
  2631                              <1> n2:
  2632 0000207E 20FF                <1>         and     bh, bh
  2633 00002080 740D                <1> 	jz	short n4
  2634 00002082 88F8                <1> 	mov	al, bh
  2635                              <1> n3:
  2636 00002084 660335[68960100]    <1>         add	si, [CRT_LEN]
  2637 0000208B FEC8                <1>         dec	al
  2638 0000208D 75F5                <1> 	jnz	short n3
  2639                              <1> n4:	
  2640 0000208F E85D000000          <1> 	call	scroll_position ; 16/01/2016
  2641 00002094 7420                <1>         jz      short n6 
  2642                              <1> 
  2643 00002096 01CE                <1>         add     esi, ecx ; from address for scroll
  2644 00002098 88F5                <1> 	mov	ch, dh  ; #rows in block
  2645 0000209A 28C5                <1> 	sub	ch, al	; #rows to be moved
  2646                              <1> n5:
  2647 0000209C E894000000          <1> 	call	n10 ; 16/01/2016
  2648                              <1> 	
  2649 000020A1 51                  <1>         push	ecx
  2650 000020A2 0FB60D[CC6F0000]    <1> 	movzx	ecx, byte [CRT_COLS] 
  2651 000020A9 00C9                <1> 	add	cl, cl
  2652 000020AB 01CE                <1>         add	esi, ecx  ; next line
  2653 000020AD 01CF                <1>         add	edi, ecx
  2654 000020AF 59                  <1> 	pop	ecx
  2655                              <1> 
  2656 000020B0 FECD                <1> 	dec	ch	 ; count of lines to move
  2657 000020B2 75E8                <1> 	jnz	short n5 ; row loop
  2658                              <1> 	; ch = 0
  2659 000020B4 88C6                <1> 	mov	dh, al	 ; #rows	
  2660                              <1> n6:
  2661                              <1> 	; attribute in ah
  2662 000020B6 B020                <1> 	mov	al, ' '	 ; fill with blanks
  2663                              <1> n7:
  2664 000020B8 E885000000          <1> 	call	n11 ; 16/01/2016
  2665                              <1> 
  2666 000020BD 8A0D[CC6F0000]      <1> 	mov	cl, [CRT_COLS]
  2667 000020C3 00C9                <1> 	add	cl, cl
  2668 000020C5 01CF                <1>         add	edi, ecx
  2669                              <1> 
  2670 000020C7 FECE                <1> 	dec	dh
  2671 000020C9 75ED                <1> 	jnz	short n7
  2672                              <1> n16:
  2673 000020CB 3A3D[FE890100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  2674 000020D1 750A                <1> 	jne	short n8
  2675                              <1> 	
  2676                              <1> 	;cmp	byte [CRT_MODE], 7 ; is this the black and white card
  2677                              <1> 	;je	short n8	   ; if so, skip the mode reset
  2678                              <1> 
  2679 000020D3 A0[CB6F0000]        <1> 	mov	al, [CRT_MODE_SET] ; get the value of mode set
  2680 000020D8 66BAD803            <1> 	mov	dx, 03D8h ; always set color card port
  2681 000020DC EE                  <1> 	out	dx, al
  2682                              <1> n8:
  2683 000020DD C3                  <1> 	retn
  2684                              <1> 
  2685                              <1> test_line_count:
  2686                              <1> 	; 12/05/2016
  2687                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2688                              <1> 	; 07/09/2014 (scroll_up)
  2689 000020DE 08C0                <1> 	or	al, al
  2690 000020E0 740E                <1> 	jz	short al_set2
  2691 000020E2 6652                <1> 	push	dx
  2692 000020E4 28EE                <1> 	sub	dh, ch  ; subtract upper row from lower row number
  2693 000020E6 FEC6                <1> 	inc	dh	; adjust difference by 1
  2694 000020E8 38C6                <1> 	cmp	dh, al 	; line count = amount of rows in window?
  2695 000020EA 7502                <1> 	jne	short al_set1 ; if not the we're all set
  2696 000020EC 30C0                <1> 	xor	al, al	; otherwise set al to zero
  2697                              <1> al_set1:
  2698 000020EE 665A                <1> 	pop	dx
  2699                              <1> al_set2:
  2700 000020F0 C3                  <1> 	retn
  2701                              <1> 
  2702                              <1> scroll_position:
  2703                              <1> 	; 26/06/2016
  2704                              <1> 	; 30/01/2016
  2705                              <1>         ; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2706                              <1> 	; 07/09/2014 (scroll_up)
  2707                              <1> 
  2708 000020F1 6652                <1> 	push	dx
  2709 000020F3 6689CA              <1> 	mov	dx, cx	; now, upper left position in DX
  2710 000020F6 E8E8FEFFFF          <1> 	call	position
  2711 000020FB 01C6                <1> 	add	esi, eax
  2712 000020FD 89F7                <1> 	mov	edi, esi
  2713 000020FF 665A                <1> 	pop	dx	; lower right position in DX
  2714 00002101 6629CA              <1> 	sub	dx, cx
  2715 00002104 FEC6                <1> 	inc	dh	; dh = #rows 
  2716 00002106 FEC2                <1> 	inc	dl	; dl = #cols in block
  2717 00002108 59                  <1> 	pop	ecx 	; return address
  2718 00002109 6658                <1> 	pop	ax	; * ; al = line count, ah = attribute
  2719 0000210B 51                  <1> 	push	ecx	; return address
  2720 0000210C 0FB7C8              <1> 	movzx	ecx, ax
  2721 0000210F 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS]
  2722 00002115 F6E4                <1> 	mul	ah	; determine offset to from address
  2723 00002117 6601C0              <1> 	add	ax, ax  ; *2 for attribute byte
  2724                              <1> 	;
  2725 0000211A 6650                <1> 	push	ax	; offset 
  2726 0000211C 6652                <1> 	push	dx
  2727                              <1> 	;
  2728                              <1> 	; 04/04/2014
  2729 0000211E 66BADA03            <1> 	mov	dx, 3DAh ; guaranteed to be color card here	
  2730                              <1> n9:                      ; wait_display_enable
  2731 00002122 EC                  <1>         in      al, dx   ; get port
  2732 00002123 A808                <1> 	test	al, RVRT ; wait for vertical retrace	
  2733 00002125 74FB                <1> 	jz	short n9 ; wait_display_enable
  2734 00002127 B025                <1> 	mov	al, 25h
  2735 00002129 B2D8                <1> 	mov	dl, 0D8h ; address control port
  2736 0000212B EE                  <1> 	out	dx, al	; turn off video during vertical retrace
  2737 0000212C 665A                <1> 	pop	dx	; #rows, #cols
  2738 0000212E 6658                <1>        	pop	ax	; offset
  2739 00002130 6691                <1> 	xchg	ax, cx	; 
  2740                              <1> 	; ecx = offset, al = line count, ah = attribute
  2741                              <1> 	;
  2742 00002132 08C0                <1> 	or	al, al
  2743 00002134 C3                  <1> 	retn
  2744                              <1> n10:
  2745                              <1> 	; Move rows
  2746 00002135 88D1                <1> 	mov	cl, dl	; get # of cols to move
  2747 00002137 56                  <1> 	push	esi
  2748 00002138 57                  <1> 	push	edi	; save start address
  2749                              <1> n10r:
  2750 00002139 66A5                <1> 	movsw		; move that line on screen
  2751 0000213B FEC9                <1> 	dec	cl
  2752 0000213D 75FA                <1>         jnz     short n10r
  2753 0000213F 5F                  <1> 	pop	edi
  2754 00002140 5E                  <1> 	pop	esi	; recover addresses
  2755 00002141 C3                  <1> 	retn
  2756                              <1> n11:
  2757                              <1> 	; Clear rows
  2758                              <1>                 	; dh =  #rows
  2759 00002142 88D1                <1>         mov	cl, dl	; get # of cols to clear
  2760 00002144 57                  <1>         push    edi     ; save address
  2761                              <1> n11r:
  2762 00002145 66AB                <1>         stosw           ; store fill character
  2763 00002147 FEC9                <1> 	dec	cl
  2764 00002149 75FA                <1>         jnz     short n11r
  2765 0000214B 5F                  <1>         pop     edi     ; recover address
  2766 0000214C C3                  <1> 	retn
  2767                              <1> 
  2768                              <1> SCROLL_DOWN:
  2769                              <1> 	; 07/07/2016
  2770                              <1> 	; 27/06/2016
  2771                              <1> 	; 26/06/2016
  2772                              <1> 	; 12/05/2016
  2773                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2774                              <1> 	;
  2775                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2776                              <1> 
  2777                              <1> ;------------------------------------------
  2778                              <1> ; SCROLL DOWN
  2779                              <1> ;	THIS ROUTINE MOVES THE CHARACTERS WITHIN A DEFINED
  2780                              <1> ;	BLOCK DOWN ON THE SCREEN, FILLING THE TOP LINES
  2781                              <1> ;	WITH A DEFINED CHARACTER
  2782                              <1> ; INPUT
  2783                              <1> ;	(AH) = CURRENT CRT MODE
  2784                              <1> ;	(AL) = NUMBER OF LINES TO SCROLL
  2785                              <1> ;	(CX) = UPPER LEFT CORNER OF RECION
  2786                              <1> ;	(DX) = LOWER RIGHT CORNER OF REGION
  2787                              <1> ;	(BH) = FILL CHARACTER
  2788                              <1> ;	(DS) = DATA SEGMENT
  2789                              <1> ;	(ES) = REGEN SEGMENT
  2790                              <1> ; OUTPUT
  2791                              <1> ;	NONE -- SCREEN IS SCROLLED
  2792                              <1> ;------------------------------------------
  2793                              <1> 
  2794                              <1> 	; 07/07/2016
  2795 0000214D 38F5                <1> 	cmp	ch, dh
  2796                              <1> 	;ja	VIDEO_RETURN
  2797 0000214F 7709                <1> 	ja	short _s_d_retn ; 18/11/2020
  2798 00002151 38D1                <1> 	cmp	cl, dl
  2799                              <1> 	;ja	VIDEO_RETURN
  2800 00002153 7705                <1> 	ja	short _s_d_retn ; 18/11/2020
  2801                              <1> 	;
  2802 00002155 E805000000          <1> 	call	_scroll_down
  2803                              <1> _s_d_retn:
  2804 0000215A E9F8F9FFFF          <1>         jmp     VIDEO_RETURN
  2805                              <1> 
  2806                              <1> _scroll_down: ; 27/06/2016
  2807                              <1> 
  2808                              <1> 	; cl = left upper column
  2809                              <1> 	; ch = left upper row
  2810                              <1> 	; dl = right lower column
  2811                              <1> 	; dh = right lower row
  2812                              <1> 	;
  2813                              <1> 	; al = line count 
  2814                              <1> 	; bl = attribute to be used on blanked line	
  2815                              <1> 	; bh = video page number (0 to 7)
  2816                              <1> 
  2817                              <1> 	; !!!!
  2818 0000215F FD                  <1> 	std		; DIRECTION FOR SCROLL DOWN
  2819                              <1> 	; !!!!
  2820 00002160 E879FFFFFF          <1> 	call	test_line_count ; 16/01/2016
  2821                              <1> 	
  2822 00002165 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  2823                              <1> 	;;cmp	byte [CRT_MODE], 4
  2824                              <1> 	;cmp	ah, 4 ; 07/07/2016
  2825                              <1> 	;jnb	GRAPHICS_DOWN ; 26/06/2016
  2826                              <1> 	; 18/11/2020
  2827 0000216B 80FC04              <1> 	cmp	ah, 4
  2828 0000216E 720A                <1>  	jb	short _n0	
  2829 00002170 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD 
  2830                              <1> 		      ;	(80x25 text, mono)
  2831 00002173 7405                <1> 	je	short _n0 ; same with mode 3 for TRDOS 386
  2832 00002175 E903080000          <1> 	jmp	GRAPHICS_DOWN
  2833                              <1> _n0:
  2834                              <1> 	; 07/07/2016
  2835 0000217A 80FF07              <1> 	cmp	bh, 7 ; video page number
  2836 0000217D 7606                <1> 	jna	short n12
  2837 0000217F 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE]
  2838                              <1> 	;
  2839                              <1> n12:			; CONTINUE_DOWN
  2840 00002185 88DC                <1> 	mov	ah, bl
  2841 00002187 6650                <1> 	push	ax	; * ; save attribute in ah
  2842 00002189 6689D0              <1> 	mov	ax, dx	; LOWER RIGHT CORNER
  2843 0000218C E860FFFFFF          <1> 	call	scroll_position	; GET REGEN LOCATION
  2844 00002191 741F                <1> 	jz	short n14
  2845 00002193 29CE                <1> 	sub	esi, ecx  ; SI IS FROM ADDRESS
  2846 00002195 88F5                <1> 	mov	ch, dh  ; #rows in block
  2847 00002197 28C5                <1> 	sub	ch, al	; #rows to be moved
  2848                              <1> n13:
  2849 00002199 E897FFFFFF          <1> 	call	n10	; MOVE ONE ROW
  2850                              <1> 
  2851 0000219E 51                  <1> 	push	ecx
  2852 0000219F 8A0D[CC6F0000]      <1> 	mov	cl, [CRT_COLS] 
  2853 000021A5 00C9                <1> 	add	cl, cl
  2854 000021A7 29CE                <1>         sub	esi, ecx  ; next line
  2855 000021A9 29CF                <1>         sub	edi, ecx
  2856 000021AB 59                  <1>         pop	ecx
  2857                              <1> 	
  2858 000021AC FECD                <1> 	dec	ch	 ; count of lines to move
  2859 000021AE 75E9                <1> 	jnz	short n13 ; row loop
  2860                              <1> 	; ch = 0
  2861 000021B0 88C6                <1> 	mov	dh, al	 ; #rows
  2862                              <1> n14:
  2863                              <1> 	; attribute in ah
  2864 000021B2 B020                <1> 	mov	al, ' '	 ; fill with blanks
  2865                              <1> n15:
  2866 000021B4 E889FFFFFF          <1> 	call	n11 ; 16/01/2016
  2867                              <1> 
  2868 000021B9 8A0D[CC6F0000]      <1> 	mov	cl, [CRT_COLS]
  2869 000021BF 00C9                <1> 	add	cl, cl
  2870 000021C1 29CF                <1>         sub	edi, ecx
  2871                              <1>         
  2872 000021C3 FECE                <1> 	dec	dh
  2873 000021C5 75ED                <1> 	jnz	short n15
  2874                              <1> 	;
  2875                              <1> 	; 18/11/2020
  2876 000021C7 FC                  <1> 	cld	; clear direction flag	
  2877                              <1> 	;
  2878 000021C8 E9FEFEFFFF          <1> 	jmp	n16 ; 27/06/2016
  2879                              <1> 
  2880                              <1> ;	cmp	bh, [ACTIVE_PAGE]
  2881                              <1> ;	jne	short n16
  2882                              <1> ;
  2883                              <1> ;	;cmp	byte [CRT_MODE], 7	; is this the black and white card
  2884                              <1> ;	;je	short n16		; if so, skip the mode reset
  2885                              <1> ;
  2886                              <1> ;	mov	al, [CRT_MODE_SET] ; get the value of mode set
  2887                              <1> ;	mov	dx, 03D8h ; always set color card port
  2888                              <1> ;	out	dx, al
  2889                              <1> ;n16:
  2890                              <1> ;	; !!!!
  2891                              <1> ;	cld		; Clear direction flag !
  2892                              <1> ;	; !!!!
  2893                              <1> ;	retn
  2894                              <1> 
  2895                              <1> READ_AC_CURRENT:
  2896                              <1> 	; 08/07/2016
  2897                              <1> 	; 26/06/2016
  2898                              <1> 	; 12/05/2016
  2899                              <1> 	; 18/01/2016
  2900                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  2901                              <1> 	;
  2902                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  2903                              <1> 	;
  2904                              <1> 	; 08/07/2016
  2905 000021CD 803D[CA6F0000]07    <1>         cmp     byte [CRT_MODE], 7 ; 6!?
  2906 000021D4 7607                <1> 	jna	short read_ac_c
  2907 000021D6 31C0                <1> 	xor	eax, eax
  2908 000021D8 E97FF9FFFF          <1>         jmp     _video_return 
  2909                              <1> read_ac_c:
  2910 000021DD E805000000          <1> 	call	_read_ac_current
  2911                              <1> 	; 12/05/2016
  2912                              <1>         ;jmp     VIDEO_RETURN
  2913 000021E2 E975F9FFFF          <1> 	jmp	_video_return
  2914                              <1> 
  2915                              <1> ;------------------------------------------------------------------------
  2916                              <1> ; READ_AC_CURRENT							:
  2917                              <1> ;	THIS ROUTINE READS THE ATTRIBUTE AND CHARACTER AT THE CURRENT	:
  2918                              <1> ;	CURSOR POSITION AND RETURNS THEM TO THE CALLER			:
  2919                              <1> ; INPUT									:
  2920                              <1> ;	(AH) = CURRENT CRT MODE						:
  2921                              <1> ;	(BH) = DISPLAY PAGE ( ALPHA MODES ONLY )			:
  2922                              <1> ;	(DS) = DATA SEGMENT						:
  2923                              <1> ;	(ES) = REGEN SEGMENT						:
  2924                              <1> ; OUTPUT								:
  2925                              <1> ;	(AL) = CHARACTER READ						:
  2926                              <1> ;	(AH) = ATTRIBUTE READ						:
  2927                              <1> ;------------------------------------------------------------------------
  2928                              <1> 
  2929                              <1> _read_ac_current:
  2930                              <1> 	; 26/06/2016
  2931                              <1> 	; 12/05/2016 
  2932                              <1> 	; 18/01/2016
  2933                              <1> 
  2934 000021E7 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  2935 000021ED 80FC04              <1> 	cmp	ah, 4
  2936 000021F0 720A                <1>  	jb	short p10
  2937                              <1> 	; 18/11/2020
  2938                              <1> 	;cmp	byte [CRT_MODE], 4
  2939                              <1> 	;jnb	GRAPHICS_READ ; 26/06/2016
  2940                              <1> 
  2941 000021F2 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD (80x25 monochrome text)
  2942 000021F5 7405                <1> 	je	short p10	 ; same with mode 3 in TRDOS 386
  2943 000021F7 E9D7080000          <1> 	jmp	GRAPHICS_READ
  2944                              <1> p10:
  2945 000021FC E8F4FDFFFF          <1> 	call	find_position	; GET REGEN LOCATION AND PORT ADDRESS
  2946                              <1> 	;
  2947                              <1> 	; esi = regen location
  2948                              <1> 	; dx = status port
  2949                              <1> 	;
  2950                              <1> 
  2951                              <1> 	; 18/11/2020
  2952                              <1> 	; convert display mode to a zero value 
  2953                              <1> 	; for 80 column color mode
  2954                              <1> 	;mov	ah, [CRT_MODE]	
  2955                              <1> 	;sub	ah, 2
  2956                              <1> 	;shr	ah, 1
  2957                              <1> 	;jnz	short p13
  2958                              <1> 
  2959                              <1> 	; 05/12/2020
  2960                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  2961                              <1> 	;xor	bl, bl	; 0
  2962 00002201 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  2963                              <1> 	;je	short p11    ; Note: Only mode 03h and mode 01h are
  2964                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  2965                              <1> 	;jmp	short p14    ;       (07h, 00h and 02h are redirected)		
  2966 00002208 7516                <1> 	jne	short p13
  2967                              <1> 
  2968                              <1> 	; 05/12/2020
  2969 0000220A 3A3D[FE890100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  2970 00002210 750E                <1> 	jne	short p13 
  2971                              <1> 
  2972                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  2973                              <1> p11:
  2974 00002212 FB                  <1> 	sti		; enable interrupts first
  2975                              <1> 	; 05/12/2020
  2976 00002213 90                  <1> 	nop
  2977                              <1> 	; 18/11/2020
  2978                              <1> 	;or	bl, bl
  2979                              <1> 	;jnz	short p13 ; mode 01h (and mode 00h) - 40x25 color text
  2980 00002214 FA                  <1> 	cli 		; block interrupts for single loop
  2981 00002215 EC                  <1> 	in	al, dx	; get status from the adapter
  2982 00002216 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  2983 00002218 75F8                <1> 	jnz	short p11 ; wait until it is
  2984                              <1> p12:			;  wait for either retrace high
  2985 0000221A EC                  <1> 	in	al, dx ; get status again
  2986 0000221B A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  2987 0000221D 74FB                <1> 	jz	short p12 ; wait until either retrace active
  2988                              <1> ;p14:
  2989 0000221F FB                  <1> 	sti
  2990                              <1> p13:
  2991 00002220 81C600800B00        <1> 	add	esi, 0B8000h 
  2992 00002226 668B06              <1> 	mov	ax, [esi]
  2993                              <1> 
  2994 00002229 C3                  <1> 	retn	; 18/01/2016
  2995                              <1> 
  2996                              <1> WRITE_AC_CURRENT:
  2997                              <1> 	; 08/07/2016
  2998                              <1> 	; 26/06/2016
  2999                              <1> 	; 24/06/2016
  3000                              <1> 	; 12/05/2016
  3001                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3002                              <1> 	;
  3003                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3004                              <1> 	;
  3005                              <1> ;----------------------------------------------------------------
  3006                              <1> ; WRITE_AC_CURRENT						:
  3007                              <1> ;	THTS ROUTINE WRITES THE ATTRIBUTE AND CHARACTER		:
  3008                              <1> ;	AT THE CURRENT CURSOR POSITION				:
  3009                              <1> ; INPUT								:
  3010                              <1> ;	(AH) = CURRENT CRT MODE					:
  3011                              <1> ;	(BH) = DISPLAY PAGE					:
  3012                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  3013                              <1> ;	(AL) = CHAR TO WRITE					:
  3014                              <1> ;	(BL) = ATTRIBUTE OF CHAR TO WRITE			:
  3015                              <1> ;	(DS) = DATA SEGMENT					:
  3016                              <1> ;	(ES) = REGEN SEGMENT					:
  3017                              <1> ; OUTPUT							:
  3018                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  3019                              <1> ;----------------------------------------------------------------
  3020                              <1> 
  3021                              <1> 	; 08/07/2016
  3022 0000222A 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  3023 00002231 760A                <1> 	jna	short write_ac_c
  3024                              <1> 
  3025 00002233 E8110B0000          <1> 	call	vga_write_char_attr
  3026 00002238 E91AF9FFFF          <1> 	jmp     VIDEO_RETURN	
  3027                              <1> 
  3028                              <1> write_ac_c:
  3029 0000223D E834000000          <1> 	call	_write_c_current
  3030                              <1> 
  3031 00002242 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  3032 00002245 889E[D36F0000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  3033                              <1> 
  3034 0000224B E907F9FFFF          <1>         jmp     VIDEO_RETURN
  3035                              <1> 
  3036                              <1> WRITE_C_CURRENT:
  3037                              <1> 	; 08/07/2016
  3038                              <1> 	; 26/06/2016
  3039                              <1> 	; 12/05/2016
  3040                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3041                              <1> 	;
  3042                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3043                              <1> 	;
  3044                              <1> ;----------------------------------------------------------------
  3045                              <1> ; WRITE_C_CURRENT						:
  3046                              <1> ;	THIS ROUTINE WRITES THE CHARACTER AT			:
  3047                              <1> ;	THE CURRENT CURSOR POSITION, ATTRIBUTE UNCHANGED	:
  3048                              <1> ; INPUT								:
  3049                              <1> ;	(AH) = CURRENT CRT MODE					:
  3050                              <1> ;	(BH) = DISPLAY PAGE					:
  3051                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE			:
  3052                              <1> ;	(AL) = CHAR TO WRITE					:
  3053                              <1> ;	(DS) = DATA SEGMENT					:
  3054                              <1> ;	(ES) = REGEN SEGMENT					:
  3055                              <1> ; OUTPUT							:
  3056                              <1> ;	DISPLAY REGEN BUFFER UPDATED				:
  3057                              <1> ;----------------------------------------------------------------
  3058                              <1> 
  3059                              <1> 	; 08/07/2016
  3060 00002250 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6!?
  3061 00002257 760A                <1> 	jna	short write_c_c
  3062                              <1> 
  3063 00002259 E8EB0A0000          <1> 	call	vga_write_char_only
  3064 0000225E E9F4F8FFFF          <1> 	jmp     VIDEO_RETURN	
  3065                              <1> 
  3066                              <1> write_c_c:
  3067                              <1> 	;and	bh, 7 ; video page number (<= 7)
  3068 00002263 0FB6F7              <1> 	movzx	esi, bh	
  3069 00002266 8A9E[D36F0000]      <1> 	mov	bl, [esi+chr_attrib]
  3070                              <1> 
  3071 0000226C E805000000          <1> 	call	_write_c_current
  3072 00002271 E9E1F8FFFF          <1>         jmp     VIDEO_RETURN
  3073                              <1> 
  3074                              <1> _write_c_current:  ; from 'write_tty'
  3075                              <1> 	; 18/11/2020
  3076                              <1> 	; 26/06/2016
  3077                              <1> 	; 24/06/2016
  3078                              <1> 	; 12/05/2016
  3079                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3080                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3081                              <1> 	; 18/01/2014
  3082                              <1> 	; 04/12/2013
  3083                              <1> 	;
  3084                              <1> 	; VIDEO.ASM - 06/10/85 VIDEO DISPLAY BIOS
  3085                              <1> 
  3086                              <1> 	; 18/11/2020
  3087 00002276 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE] ; current video mode	
  3088 0000227C 80FC04              <1> 	cmp	ah, 4
  3089 0000227F 720A                <1>  	jb	short p40
  3090                              <1> 	
  3091                              <1> 	;cmp	byte [CRT_MODE], 4
  3092                              <1>         ;jnb	GRAPHICS_WRITE ; 26/06/2016
  3093                              <1> 
  3094 00002281 80FC07              <1> 	cmp	ah, 7 ; TEST FOR BW CARD
  3095 00002284 7405                <1> 	je	short p40
  3096 00002286 E998070000          <1> 	jmp	GRAPHICS_WRITE
  3097                              <1> p40:
  3098                              <1> 	; al = character
  3099                              <1> 	; bl = color/attribute
  3100                              <1> 	; bh = video page
  3101                              <1> 	; cx = count of characters to write
  3102 0000228B 6652                <1> 	push	dx
  3103 0000228D 88DC                <1> 	mov	ah, bl  ; color/attribute (12/05/2016)
  3104 0000228F 6650                <1> 	push	ax	; save character & attribute/color
  3105 00002291 6651                <1> 	push	cx
  3106 00002293 E85DFDFFFF          <1> 	call 	find_position  ; get regen location and port address
  3107 00002298 6659                <1> 	pop	cx
  3108                              <1> 	; esi = regen location
  3109                              <1> 	; dx = status port
  3110                              <1> 	;
  3111 0000229A 81C600800B00        <1> 	add	esi, 0B8000h ; 30/08/2014 (crt_base) 
  3112                              <1> 	;
  3113                              <1> 	; 18/11/2020
  3114                              <1> 	; convert display mode to a zero value 
  3115                              <1> 	; for 80 column color mode
  3116                              <1> 	;mov	ah, [CRT_MODE]	
  3117                              <1> 	;sub	ah, 2
  3118                              <1> 	;shr	ah, 1
  3119                              <1> 	;jnz	short p44    ; 26/06/2016
  3120                              <1> 
  3121                              <1> 	; 05/12/2020
  3122                              <1> 	; 18/11/2020 (TRDOS 386 v2.0.3)
  3123                              <1> 	;xor	bl, bl	; 0
  3124 000022A0 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h ; 80x25 color text
  3125                              <1> 	;je	short p41    ; Note: Only mode 03h and mode 01h are
  3126                              <1> 	;inc	bl	; 1  ;       in use by TRDOS 386 as text modes	
  3127                              <1> 	;jmp	short p43    ;       (07h, 00h and 02h are redirected)			
  3128                              <1> 	; 05/12/2020
  3129 000022A7 751A                <1> 	jne	short p44
  3130                              <1> p46:
  3131                              <1> 	; 05/12/2020
  3132 000022A9 3A3D[FE890100]      <1> 	cmp     bh, [ACTIVE_PAGE]
  3133 000022AF 7512                <1> 	jne	short p44
  3134                              <1> 
  3135                              <1> 	; WAIT FOR HORIZONTAL RETRACE OR VERTICAL RETRACE IF COLOR 80
  3136                              <1> p41:
  3137                              <1> 	; 05/12/2020
  3138 000022B1 FB                  <1> 	sti		; enable interrupts first
  3139 000022B2 90                  <1> 	nop
  3140                              <1> 	; 18/11/2020
  3141                              <1> 	;or	bl, bl
  3142                              <1> 	;jnz	short p44 ; mode 01h (and mode 00h) - 40x25 color text
  3143 000022B3 FA                  <1> 	cli 		; block interrupts for single loop
  3144 000022B4 EC                  <1> 	in	al, dx	; get status from the adapter
  3145 000022B5 A808                <1> 	test	al, RVRT ; check for vertical retrace first
  3146 000022B7 7509                <1> 	jnz	short p43 ; Do fast write now if vertical retrace
  3147 000022B9 A801                <1> 	test	al, RHRZ ; is horizontal retrace low
  3148 000022BB 75F4                <1> 	jnz	short p41 ; wait until it is
  3149                              <1> p42:			;  wait for either retrace high
  3150 000022BD EC                  <1> 	in	al, dx ; get status again
  3151 000022BE A809                <1> 	test	al, RVRT+RHRZ ; is horizontal or vertical retrace high
  3152 000022C0 74FB                <1> 	jz	short p42 ; wait until either retrace active
  3153                              <1> p43:	
  3154 000022C2 FB                  <1> 	sti
  3155                              <1> p44:
  3156 000022C3 668B0424            <1> 	mov	ax, [esp] ; restore the character (al) & attribute (ah)
  3157 000022C7 668906              <1> 	mov	[esi], ax
  3158                              <1> 
  3159 000022CA 6649                <1> 	dec	cx
  3160 000022CC 740D                <1> 	jz	short p45
  3161                              <1> 
  3162 000022CE 46                  <1> 	inc	esi
  3163 000022CF 46                  <1> 	inc	esi
  3164                              <1> 
  3165                              <1> 	; 05/12/2020
  3166 000022D0 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h
  3167 000022D7 75EA                <1> 	jne	short p44
  3168                              <1> 	;jmp	short p41
  3169 000022D9 EBCE                <1> 	jmp	short p46
  3170                              <1> p45:	
  3171 000022DB 6658                <1> 	pop	ax
  3172 000022DD 665A                <1> 	pop	dx
  3173 000022DF C3                  <1> 	retn
  3174                              <1> 
  3175                              <1> ; 09/07/2016
  3176                              <1> ; 26/06/2016
  3177                              <1> ; 24/06/2016
  3178                              <1> ; 12/05/2016
  3179                              <1> ; 18/01/2016
  3180                              <1> ; 16/01/2016 - TRDOS 386 (TRDOS v2.0)
  3181                              <1> ; 30/06/2015
  3182                              <1> ; 27/06/2015
  3183                              <1> ; 11/03/2015
  3184                              <1> ; 02/09/2014
  3185                              <1> ; 30/08/2014
  3186                              <1> ; VIDEO FUNCTIONS
  3187                              <1> ; (write_tty - Retro UNIX 8086 v1 - U9.ASM, 01/02/2014)
  3188                              <1> 
  3189                              <1> WRITE_TTY:
  3190                              <1> 	; 09/12/2017
  3191                              <1> 	; 09/07/2016
  3192                              <1> 	; 01/07/2016
  3193                              <1> 	; 26/06/2016
  3194                              <1> 	; 24/06/2016
  3195                              <1> 	; 13/05/2016
  3196                              <1> 	; 12/05/2016
  3197                              <1> 	; 30/01/2016
  3198                              <1> 	; 18/01/2016
  3199                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
  3200                              <1> 	; 13/08/2015
  3201                              <1> 	; 02/09/2014
  3202                              <1> 	; 30/08/2014 (Retro UNIX 386 v1 - beginning)
  3203                              <1> 	; 01/02/2014 (Retro UNIX 8086 v1 - last update)
  3204                              <1> 	; 03/12/2013 (Retro UNIX 8086 v1 - beginning)	
  3205                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
  3206                              <1> 	;
  3207                              <1> 	; INPUT -> AL = Character to be written
  3208                              <1> 	;	   BL = Color (Forecolor, Backcolor)
  3209                              <1> 	;	   BH = Video Page (0 to 7)
  3210                              <1> 
  3211                              <1> 	; 09/07/2016
  3212 000022E0 803D[CA6F0000]07    <1>         cmp     byte [CRT_MODE], 7
  3213 000022E7 760A                <1> 	jna 	short write_tty_cga
  3214                              <1> 
  3215 000022E9 E8460D0000          <1> 	call	vga_write_teletype
  3216 000022EE E964F8FFFF          <1> 	jmp	VIDEO_RETURN
  3217                              <1> 
  3218                              <1> write_tty_cga:
  3219                              <1> 	; 13/05/2016
  3220                              <1> 	;call	_write_tty
  3221                              <1> 	; 01/07/2016
  3222 000022F3 E818000000          <1> 	call	_write_tty_m3
  3223 000022F8 E95AF8FFFF          <1> 	jmp	VIDEO_RETURN
  3224                              <1> 
  3225                              <1> RVRT	equ	00001000b	; VIDEO VERTICAL RETRACE BIT
  3226                              <1> RHRZ	equ	00000001b	; VIDEO HORIZONTAL RETRACE BIT
  3227                              <1> 
  3228                              <1> ; Derived from "WRITE_TTY" procedure of IBM "pc-at" rombios source code
  3229                              <1> ; (06/10/1985), 'video.asm', INT 10H, VIDEO_IO
  3230                              <1> ;
  3231                              <1> ; 06/10/85  VIDEO DISPLAY BIOS
  3232                              <1> ;
  3233                              <1> ;--- WRITE_TTY ------------------------------------------------------------------
  3234                              <1> ;										:
  3235                              <1> ;   THIS INTERFACE PROVIDES A TELETYPE LIKE INTERFACE TO THE			:
  3236                              <1> ;   VIDEO CARDS. THE INPUT CHARACTER IS WRITTEN TO THE CURRENT			:
  3237                              <1> ;   CURSOR POSITION, AND THE CURSOR IS MOVED TO THE NEXT POSITION.		:
  3238                              <1> ;   IF THE CURSOR LEAVES THE LAST COLUMN OF THE FIELD, THE COLUMN		:
  3239                              <1> ;   IS SET TO ZERO, AND THE ROW VALUE IS INCREMENTED. IF THE ROW		:
  3240                              <1> ;   ROW VALUE LEAVES THE FIELD, THE CURSOR IS PLACED ON THE LAST ROW,		:
  3241                              <1> ;   FIRST COLUMN, AND THE ENTIRE SCREEN IS SCROLLED UP ONE LINE.		:
  3242                              <1> ;   WHEN THE SCREEN IS SCROLLED UP, THE ATTRIBUTE FOR FILLING THE		:
  3243                              <1> ;   NEWLY BLANKED LINE IS READ FROM THE CURSOR POSITION ON THE PREVIOUS		:
  3244                              <1> ;   LINE BEFORE THE SCROLL, IN CHARACTER MODE. IN GRAPHICS MODE,		:
  3245                              <1> ;   THE 0 COLOR IS USED.							:
  3246                              <1> ;   ENTRY --									:
  3247                              <1> ;     (AH) = CURRENT CRT MODE							:
  3248                              <1> ;     (AL) = CHARACTER TO BE WRITTEN						:
  3249                              <1> ;	    NOTE THAT BACK SPACE, CARRIAGE RETURN, BELL AND LINE FEED ARE	:
  3250                              <1> ;	    HANDLED AS COMMANDS RATHER THAN AS DISPLAY GRAPHICS CHARACTERS	:
  3251                              <1> ;     (BL) = FOREGROUND COLOR FOR CHAR WRITE IF CURRENTLY IN A GRAPHICS MODE	:
  3252                              <1> ;   EXIT -- 									:
  3253                              <1> ;     ALL REGISTERS SAVED							:
  3254                              <1> ;--------------------------------------------------------------------------------
  3255                              <1> 
  3256                              <1> ; 18/11/2020 (TRDOS 386 v2.0.3)
  3257                              <1> ; 09/12/2017
  3258                              <1> ; 08/07/2016
  3259                              <1> ; 26/06/2016
  3260                              <1> ; 24/06/2016
  3261                              <1> _write_tty:
  3262                              <1> 	; 13/05/2016
  3263                              <1> 	; --- 18/11/2020 ---
  3264                              <1> 	; NOTE:
  3265                              <1> 	; Only kernel calls "_write_tty" procedure...
  3266                              <1> 	; TRDOS 386 v2 kernel uses video mode 3 for displaying
  3267                              <1> 	; (some error) messages and also mainprog command interpreter
  3268                              <1> 	; (in kernel) uses "_write_tty".
  3269                              <1> 	; So, here video mode must be set to 3 if it is not 3.
  3270                              <1>  
  3271 000022FD FA                  <1> 	cli	; disable interrupts
  3272                              <1> 	;
  3273                              <1> 	; 01/09/2014
  3274 000022FE 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3
  3275 00002305 7409                <1> 	je	short _write_tty_m3
  3276                              <1> 	;
  3277                              <1> set_mode_3:
  3278 00002307 53                  <1> 	push	ebx
  3279 00002308 50                  <1> 	push	eax
  3280                              <1> 	;call	_set_mode
  3281                              <1> 	; 18/11/2020 
  3282 00002309 E858F8FFFF          <1> 	call	set_txt_mode  ; set video mode to 03h 
  3283 0000230E 58                  <1> 	pop	eax
  3284 0000230F 5B                  <1> 	pop	ebx
  3285                              <1> 	;
  3286                              <1> _write_tty_m3: ; 24/06/2016 (m3 -> _write_tty_m3)
  3287 00002310 0FB6F7              <1> 	movzx 	esi, bh ; 12/05/2016
  3288 00002313 66D1E6              <1> 	shl	si, 1
  3289 00002316 81C6[EE890100]      <1> 	add	esi, CURSOR_POSN
  3290 0000231C 668B16              <1> 	mov	dx, [esi]
  3291                              <1> 	;
  3292                              <1> 	; dx now has the current cursor position
  3293                              <1> 	;
  3294 0000231F 3C0D                <1> 	cmp	al, 0Dh	; CR	; is it carriage return or control character
  3295 00002321 763E                <1> 	jbe	short u8
  3296                              <1> 	;
  3297                              <1> 	; write the char to the screen
  3298                              <1> u0:	
  3299                              <1> 	; al = character
  3300                              <1> 	; bl = attribute/color
  3301                              <1> 	; bh = video page number (0 to 7)
  3302                              <1> 	;
  3303 00002323 66B90100            <1> 	mov	cx, 1  ; 24/06/2016
  3304                              <1> 	; cx = count of characters to write
  3305                              <1> 	;
  3306 00002327 E84AFFFFFF          <1> 	call	_write_c_current ; 16/01/2015
  3307                              <1> 	;
  3308                              <1> 	; position the cursor for next char
  3309 0000232C FEC2                <1> 	inc	dl		; next column
  3310 0000232E 3A15[CC6F0000]      <1> 	cmp	dl, [CRT_COLS]  ; test for column overflow 
  3311 00002334 7561                <1>         jne     _set_cpos
  3312 00002336 B200                <1> 	mov	dl, 0		; column = 0
  3313                              <1> u10:				; (line feed found)
  3314 00002338 80FE18              <1> 	cmp	dh, 25-1 	; check for last row
  3315 0000233B 7220                <1> 	jb 	short u6
  3316                              <1> 	;
  3317                              <1> 	; scroll required
  3318                              <1> u1:	
  3319                              <1> 	; SET CURSOR POSITION (04/12/2013)
  3320 0000233D E855000000          <1> 	call	_set_cpos
  3321                              <1> 	;
  3322                              <1> 	; determine value to fill with during scroll
  3323                              <1> u2:
  3324                              <1> 	; bh = video page number
  3325                              <1> 	;
  3326 00002342 E8A0FEFFFF          <1> 	call	_read_ac_current ; 18/01/2016
  3327                              <1> 	;
  3328                              <1> 	; al = character, ah = attribute
  3329                              <1> 	; bh = video page number
  3330                              <1> 	; 18/11/2020
  3331 00002347 88E3                <1> 	mov	bl, ah ; color/attribute 	
  3332                              <1> u3:
  3333                              <1> 	;;mov	ax, 0601h 	; scroll one line
  3334                              <1> 	;;sub	cx, cx		; upper left corner
  3335                              <1> 	;;mov	dh, 25-1 	; lower right row
  3336                              <1> 	;;;mov	dl, [CRT_COLS]
  3337                              <1> 	;mov	dl, 80		; lower right column	
  3338                              <1> 	;;dec	dl
  3339                              <1> 	;;mov	dl, 79
  3340                              <1> 
  3341                              <1> 	;;call	scroll_up	; 04/12/2013
  3342                              <1> 	;;; 11/03/2015
  3343                              <1> 	; 02/09/2014
  3344                              <1> 	;;;mov	cx, [crt_ulc] ; Upper left corner  (0000h)
  3345                              <1> 	;;;mov	dx, [crt_lrc] ; Lower right corner (184Fh)
  3346                              <1> 	; 11/03/2015
  3347 00002349 6629C9              <1> 	sub	cx, cx
  3348                              <1> 	;mov	dx, 184Fh ; dl = 79 (column), dh = 24 (row)
  3349                              <1> 	; 18/11/2020
  3350 0000234C B618                <1> 	mov	dh, 25-1
  3351 0000234E 8A15[CC6F0000]      <1> 	mov	dl, [CRT_COLS]
  3352 00002354 FECA                <1> 	dec	dl
  3353                              <1> 	;
  3354 00002356 B001                <1> 	mov	al, 1		; scroll 1 line up
  3355                              <1> 		; ah = attribute
  3356                              <1> 	;mov	bl, al ; 12/05/2016
  3357 00002358 E9E0FCFFFF          <1> 	jmp	_scroll_up	; 16/01/2016
  3358                              <1> ;u4:
  3359                              <1> 	;;int	10h		; video-call return
  3360                              <1> 				; scroll up the screen
  3361                              <1> 				; tty return
  3362                              <1> ;u5:
  3363                              <1> 	;retn			; return to the caller
  3364                              <1> 
  3365                              <1> u6:				; set-cursor-inc
  3366 0000235D FEC6                <1> 	inc	dh		; next row
  3367                              <1> 				; set cursor
  3368                              <1> ;u7:					
  3369                              <1> 	;;mov	ah, 02h
  3370                              <1> 	;;jmp	short u4 	; establish the new cursor
  3371                              <1> 	;call	_set_cpos
  3372                              <1> 	;jmp 	short u5
  3373 0000235F EB36                <1> 	jmp     _set_cpos
  3374                              <1> 
  3375                              <1> 	; check for control characters
  3376                              <1> u8:
  3377 00002361 7432                <1> 	je	short u9
  3378 00002363 3C0A                <1> 	cmp	al, 0Ah		; is it a line feed (0Ah)
  3379 00002365 74D1                <1> 	je	short u10
  3380 00002367 3C07                <1> 	cmp	al, 07h 	; is it a bell
  3381 00002369 747E                <1> 	je	short u11
  3382 0000236B 3C08                <1> 	cmp	al, 08h		; is it a backspace
  3383                              <1> 	;jne	short u0
  3384 0000236D 741E                <1> 	je	short bs	; 12/12/2013
  3385                              <1> 	; 12/12/2013 (tab stop)
  3386 0000236F 3C09                <1> 	cmp	al, 09h		; is it a tab stop
  3387 00002371 75B0                <1> 	jne	short u0
  3388 00002373 88D0                <1> 	mov	al, dl
  3389                              <1> 	;cbw
  3390 00002375 30E4                <1> 	xor	ah, ah ; 09/12/2017
  3391 00002377 B108                <1> 	mov	cl, 8
  3392 00002379 F6F1                <1> 	div	cl
  3393 0000237B 28E1                <1> 	sub	cl, ah
  3394                              <1> ts:
  3395                              <1> 	; 02/09/2014
  3396                              <1> 	; 01/09/2014
  3397                              <1> 	;mov	al, 20h
  3398                              <1> tsloop:
  3399 0000237D 6651                <1> 	push	cx
  3400                              <1> 	; 18/11/2020
  3401                              <1> 	;push	ax
  3402                              <1> 	;;mov	bh, [ACTIVE_PAGE]
  3403                              <1> 	; 05/12/2020
  3404                              <1> 	;push	bx
  3405 0000237F B020                <1> 	mov	al, 20h ; al = space (blank) 
  3406                              <1> 			; bl = color/attribute
  3407 00002381 E88AFFFFFF          <1> 	call	_write_tty_m3 ; 24/06/2016 (m3 -> _write_tty_m3)
  3408                              <1> 	; 05/12/2020
  3409                              <1> 	; bx is preserved in '_write_tty_m3'
  3410                              <1> 	; 18/11/2020
  3411                              <1> 	;pop	bx  ; BL = color/attribute, Bh = video page 
  3412                              <1> 	;pop	ax  ; AL = character
  3413 00002386 6659                <1> 	pop	cx
  3414 00002388 FEC9                <1> 	dec	cl
  3415 0000238A 75F1                <1> 	jnz	short tsloop
  3416 0000238C C3                  <1> 	retn
  3417                              <1> bs:	
  3418                              <1> 	; back space found
  3419                              <1> 
  3420 0000238D 08D2                <1> 	or	dl, dl 		; is it already at start of line
  3421                              <1> 	;je	short u7 	; set_cursor
  3422 0000238F 7406                <1> 	jz	short _set_cpos
  3423 00002391 664A                <1> 	dec	dx     		; no -- just move it back
  3424                              <1> 	;jmp	short u7
  3425 00002393 EB02                <1> 	jmp	short _set_cpos
  3426                              <1> 
  3427                              <1> 	; carriage return found
  3428                              <1> u9:
  3429 00002395 B200                <1> 	mov	dl, 0 		; move to first column
  3430                              <1> 	;jmp	short u7
  3431                              <1> 	;jmp	short _set_cpos ; 30/01/2016
  3432                              <1> 
  3433                              <1> 	; line feed found
  3434                              <1> ;u10:
  3435                              <1> ;	cmp	dh, 25-1 	; bottom of screen
  3436                              <1> ;	jne	short u6 	; no, just set the cursor
  3437                              <1> ;       jmp     u1              ; yes, scroll the screen
  3438                              <1> 
  3439                              <1> _set_cpos:
  3440                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  3441                              <1> 	; 27/06/2015
  3442                              <1> 	; 01/09/2014
  3443                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3444                              <1> 	;
  3445                              <1> 	; 04/12/2013 - 12/12/2013 (Retro UNIX 8086 v1) 
  3446                              <1> 	;
  3447                              <1> 	; VIDEO.ASM - 06/10/85  VIDEO DISPLAY BIOS
  3448                              <1> 	;
  3449                              <1> ;----------------------------------------------
  3450                              <1> ; SET_CPOS
  3451                              <1> ;	THIS ROUTINE SETS THE CURRENT CURSOR POSITION TO THE
  3452                              <1> ;	NEW X-Y VALUES PASSED
  3453                              <1> ; INPUT
  3454                              <1> ;	DX - ROW,COLUMN OF NEW CURSOR
  3455                              <1> ;	BH - DISPLAY PAGE OF CURSOR
  3456                              <1> ; OUTPUT
  3457                              <1> ;	CURSOR ID SET AT 6845 IF DISPLAY PAGE IS CURRENT DISPLAY
  3458                              <1> ;----------------------------------------------
  3459                              <1> 	;
  3460 00002397 BE[EE890100]        <1> 	mov	esi, CURSOR_POSN
  3461 0000239C 0FB6C7              <1>         movzx   eax, bh	; BH = video page number
  3462                              <1> ;	or	al, al
  3463                              <1> ;	jz	short _set_cpos_0
  3464 0000239F D0E0                <1>         shl     al, 1   ; word offset
  3465 000023A1 01C6                <1>         add     esi, eax
  3466                              <1> ;_set_cpos_0:
  3467 000023A3 668916              <1> 	mov	[esi], dx ; save the pointer
  3468 000023A6 383D[FE890100]      <1> 	cmp	[ACTIVE_PAGE], bh
  3469 000023AC 7532                <1> 	jne	short m17
  3470                              <1> 	;call	m18	; CURSOR SET
  3471                              <1> ;m17:			; SET_CPOS_RETURN
  3472                              <1> 	; 01/09/2014
  3473                              <1> ;	retn
  3474                              <1> 		; DX  = row/column
  3475                              <1> m18:
  3476 000023AE E830FCFFFF          <1> 	call	position ; determine location in regen buffer	
  3477 000023B3 668B0D[EC890100]    <1> 	mov	cx, [CRT_START]
  3478 000023BA 6601C1              <1> 	add	cx, ax  ; add char position in regen buffer
  3479                              <1> 			; to the start address (offset) for this page
  3480 000023BD 66D1E9              <1> 	shr	cx, 1	; divide by 2 for char only count
  3481 000023C0 B40E                <1> 	mov	ah, 14	; register number for cursor
  3482                              <1> 	;call	m16	; output value to the 6845	
  3483                              <1> 	;retn
  3484                              <1> 
  3485                              <1> 	;-----	THIS ROUTINE OUTPUTS THE CX REGISTER
  3486                              <1> 	;	TO THE 6845 REGISTERS NAMED IN (AH)
  3487                              <1> m16:
  3488 000023C2 FA                  <1> 	cli
  3489                              <1> 	;mov	dx, [addr_6845] ; address register
  3490 000023C3 66BAD403            <1> 	mov 	dx, 03D4h ; I/O address of color card
  3491 000023C7 88E0                <1> 	mov	al, ah	; get value
  3492 000023C9 EE                  <1> 	out	dx, al	; register set
  3493 000023CA 6642                <1> 	inc	dx	; data register
  3494 000023CC EB00                <1> 	jmp	$+2	; i/o delay
  3495 000023CE 88E8                <1> 	mov	al, ch	; data
  3496 000023D0 EE                  <1> 	out	dx, al	
  3497 000023D1 664A                <1> 	dec	dx	
  3498 000023D3 88E0                <1> 	mov	al, ah
  3499 000023D5 FEC0                <1> 	inc	al	; point to other data register
  3500 000023D7 EE                  <1> 	out	dx, al	; set for second register
  3501 000023D8 6642                <1> 	inc	dx
  3502 000023DA EB00                <1> 	jmp	$+2	; i/o delay
  3503 000023DC 88C8                <1> 	mov	al, cl	; second data value
  3504 000023DE EE                  <1> 	out	dx, al
  3505 000023DF FB                  <1> 	sti
  3506                              <1> m17:
  3507 000023E0 C3                  <1> 	retn
  3508                              <1> 
  3509                              <1> _beep:
  3510                              <1> 	; 12/02/2021 (TRDOS v2.0.3)
  3511 000023E1 FA                  <1> 	cli
  3512 000023E2 E811000000          <1> 	call	beep
  3513 000023E7 FB                  <1> 	sti
  3514 000023E8 C3                  <1> 	retn
  3515                              <1> 
  3516                              <1> beeper: 
  3517                              <1> 	; 04/08/2016
  3518                              <1> 	; 12/05/2016 - TRDOS 386 (TRDOS v2.0)
  3519                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3520                              <1> 	; 18/01/2014
  3521                              <1> 	; 03/12/2013
  3522                              <1> 	; bell found
  3523                              <1> u11:
  3524 000023E9 FB                  <1> 	sti
  3525 000023EA 3A3D[FE890100]      <1> 	cmp	bh, [ACTIVE_PAGE]
  3526 000023F0 7553                <1> 	jne	short u12	; Do not sound the beep 
  3527                              <1> 				; if it is not written on the active page
  3528                              <1> beeper_gfx: ; 04/08/2016
  3529 000023F2 66B93305            <1> 	mov	cx, 1331 	; divisor for 896 hz tone
  3530 000023F6 B31F                <1> 	mov	bl, 31		; set count for 31/64 second for beep
  3531                              <1> 	;call	beep		; sound the pod bell
  3532                              <1> 	;jmp	short u5 	; tty_return
  3533                              <1> 	;retn
  3534                              <1> 	
  3535                              <1> TIMER	equ 	040h   		; 8254 TIMER - BASE ADDRESS
  3536                              <1> PORT_B	equ	061h		; PORT B READ/WRITE DIAGNOSTIC REGISTER
  3537                              <1> GATE2	equ	00000001b	; TIMER 2 INPUT CATE CLOCK BIT
  3538                              <1> SPK2	equ	00000010b	; SPEAKER OUTPUT DATA ENABLE BIT
  3539                              <1> 
  3540                              <1> beep:
  3541                              <1> 	; 12/02/2021
  3542                              <1> 	; 07/02/2015
  3543                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3544                              <1> 	; 18/01/2014
  3545                              <1> 	; 03/12/2013
  3546                              <1> 	;
  3547                              <1> 	; TEST4.ASM - 06/10/85  POST AND BIOS UTILITY ROUTINES
  3548                              <1> 	;
  3549                              <1> 	; ROUTINE TO SOUND THE BEEPER USING TIMER 2 FOR TONE
  3550                              <1> 	;
  3551                              <1> 	; ENTRY:
  3552                              <1> 	;    (BL) = DURATION COUNTER ( 1 FOR 1/64 SECOND )
  3553                              <1> 	;    (CX) = FREQUENCY DIVISOR (1193180/FREQUENCY) (1331 FOR 886 HZ)
  3554                              <1> 	; EXIT:				:
  3555                              <1> 	;    (AX),(BL),(CX) MODIFIED.
  3556                              <1> 
  3557 000023F8 9C                  <1> 	pushfd  ; 18/01/2014	; save interrupt status
  3558 000023F9 FA                  <1> 	cli			; block interrupts during update
  3559 000023FA B0B6                <1> 	mov	al, 10110110b	; select timer 2, lsb, msb binary
  3560 000023FC E643                <1> 	out	TIMER+3, al 	; write timer mode register
  3561 000023FE EB00                <1> 	jmp	$+2		; I/O delay
  3562 00002400 88C8                <1> 	mov	al, cl		; divisor for hz (low)
  3563 00002402 E642                <1> 	out	TIMER+2,AL	; write timer 2 count - lsb
  3564 00002404 EB00                <1> 	jmp	$+2		; I/O delay
  3565 00002406 88E8                <1> 	mov	al, ch		; divisor for hz (high)
  3566 00002408 E642                <1> 	out	TIMER+2, al	; write timer 2 count - msb
  3567 0000240A E461                <1> 	in	al, PORT_B	; get current setting of port
  3568 0000240C 88C4                <1> 	mov	ah, al		; save that setting
  3569 0000240E 0C03                <1> 	or	al, GATE2+SPK2	; gate timer 2 and turn speaker on
  3570 00002410 E661                <1> 	out	PORT_B, al	; and restore interrupt status
  3571                              <1> 	; 12/02/2021
  3572 00002412 9D                  <1> 	popfd	; 18/01/2014
  3573                              <1> 	;sti
  3574                              <1> g7:				; 1/64 second per count (bl)
  3575 00002413 B90B040000          <1> 	mov	ecx, 1035	; delay count for 1/64 of a second	
  3576 00002418 E829000000          <1> 	call	waitf		; go to beep delay 1/64 count
  3577 0000241D FECB                <1> 	dec	bl		; (bl) length count expired?
  3578 0000241F 75F2                <1> 	jnz	short g7	; no - continue beeping speaker
  3579                              <1> 	;
  3580 00002421 9C                  <1> 	pushfd	; 12/02/2021	; save interrupt status
  3581 00002422 FA                  <1> 	cli  	; 18/01/2014	; block interrupts during update
  3582 00002423 E461                <1> 	in	al, PORT_B	; get current port value
  3583                              <1>         ;or      al, not (GATE2+SPK2) ; isolate current speaker bits in case
  3584 00002425 0CFC                <1>         or      al, ~(GATE2+SPK2)
  3585 00002427 20C4                <1>         and	ah, al		; someone turned them off during beep
  3586 00002429 88E0                <1> 	mov	al, ah		; recover value of port
  3587                              <1>         ;or      al, not (GATE2+SPK2) ; force speaker data off
  3588 0000242B 0CFC                <1> 	or 	al, ~(GATE2+SPK2) ; isolate current speaker bits in case
  3589 0000242D E661                <1> 	out	PORT_B, al	; and stop speaker timer
  3590 0000242F 9D                  <1> 	popfd	; 12/02/2021		; restore interrupt flag state
  3591                              <1> 	;sti
  3592 00002430 B90B040000          <1> 	mov	ecx, 1035	; force 1/64 second delay (short)
  3593 00002435 E80C000000          <1> 	call	waitf		; minimum delay between all beeps
  3594 0000243A 9C                  <1> 	pushfd			; save interrupt status
  3595 0000243B FA                  <1> 	cli			; block interrupts during update
  3596 0000243C E461                <1> 	in	al, PORT_B	; get current port value in case	
  3597 0000243E 2403                <1> 	and	al, GATE2+SPK2	; someone turned them on
  3598 00002440 08E0                <1> 	or	al, ah		; recover value of port_b
  3599 00002442 E661                <1> 	out	PORT_B, al	; restore speaker status
  3600 00002444 9D                  <1> 	popfd			; restore interrupt flag state
  3601                              <1> u12:	
  3602 00002445 C3                  <1> 	retn
  3603                              <1> 
  3604                              <1> REFRESH_BIT equ	00010000b 	; REFRESH TEST BIT
  3605                              <1> 
  3606                              <1> WAITF:
  3607                              <1> waitf:
  3608                              <1> 	; 30/08/2014 (Retro UNIX 386 v1)
  3609                              <1> 	; 03/12/2013
  3610                              <1> 	;
  3611                              <1> ;	push ax			; save work register (ah)	
  3612                              <1> ;waitf1:
  3613                              <1> 				; use timer 1 output bits
  3614                              <1> ;	in	al, PORT_B	; read current counter output status
  3615                              <1> ;	and	al, REFRESH_BIT	; mask for refresh determine bit
  3616                              <1> ;	cmp	al, ah		; did it just change
  3617                              <1> ;	je	short waitf1	; wait for a change in output line
  3618                              <1> ;	;
  3619                              <1> ;	mov	ah, al		; save new lflag state
  3620                              <1> ;	loop	waitf1		; decrement half cycles till count end		
  3621                              <1> ;	;
  3622                              <1> ;	pop	ax		; restore (ah)
  3623                              <1> ;	retn			; return (cx)=0
  3624                              <1> 
  3625                              <1> ; 06/02/2015 (unix386.s <-- dsectrm2.s)
  3626                              <1> ; 17/12/2014 (dsectrm2.s)
  3627                              <1> ; WAITF
  3628                              <1> ; /// IBM PC-XT Model 286 System BIOS Source Code - Test 4 - 06/10/85 ///
  3629                              <1> ;
  3630                              <1> ;---WAITF-----------------------------------------------------------------------
  3631                              <1> ;	FIXED TIME WAIT ROUTINE (HARDWARE CONTROLLED - NOT PROCESSOR)
  3632                              <1> ; ENTRY:
  3633                              <1> ;	(CX) =	COUNT OF 15.085737 MICROSECOND INTERVALS TO WAIT
  3634                              <1> ;	      	MEMORY REFRESH TIMER 1 OUTPUT USED AS REFERENCE
  3635                              <1> ; EXIT:
  3636                              <1> ;	       	AFTER (CX) TIME COUNT (PLUS OR MINUS 16 MICROSECONDS)
  3637                              <1> ;	(CX) = 0	
  3638                              <1> ;-------------------------------------------------------------------------------
  3639                              <1> 
  3640                              <1> ; Refresh period: 30 micro seconds (15-80 us)
  3641                              <1> ; (16/12/2014 - AWARDBIOS 1999 - ATORGS.ASM, WAIT_REFRESH)
  3642                              <1> 
  3643                              <1> ;WAITF:					; DELAY FOR (CX)*15.085737 US
  3644 00002446 6650                <1> 	PUSH	AX			; SAVE WORK REGISTER (AH)
  3645                              <1> 	; 16/12/2014
  3646                              <1> 	;shr	cx, 1			; convert to count of 30 micro seconds
  3647 00002448 D1E9                <1> 	shr	ecx, 1	; 21/02/2015
  3648                              <1> ;17/12/2014	
  3649                              <1> ;WAITF1:
  3650                              <1> ;	IN	AL, PORT_B   ;061h	; READ CURRENT COUNTER OUTPUT STATUS
  3651                              <1> ;	AND	AL, REFRESH_BIT	;00010000b ; MASK FOR REFRESH DETERMINE BIT
  3652                              <1> ;	CMP	AL, AH			; DID IT JUST CHANGE
  3653                              <1> ;	JE	short WAITF1		; WAIT FOR A CHANGE IN OUTPUT LINE
  3654                              <1> ;	MOV	AH, AL			; SAVE NEW FLAG STATE
  3655                              <1> ;	LOOP	WAITF1			; DECREMENT HALF CYCLES TILL COUNT END		
  3656                              <1> 	;
  3657                              <1> 	; 17/12/2014
  3658                              <1> 	;
  3659                              <1> 	; Modification from 'WAIT_REFRESH' procedure of AWARD BIOS - 1999
  3660                              <1> 	;
  3661                              <1> ;WAIT_REFRESH:  Uses port 61, bit 4 to have CPU speed independent waiting.
  3662                              <1> ;   	INPUT:  CX = number of refresh periods to wait
  3663                              <1> ;     	       (refresh periods = 1 per 30 microseconds on most machines)
  3664                              <1> WR_STATE_0:
  3665 0000244A E461                <1> 	IN	AL,PORT_B		; IN AL,SYS1
  3666 0000244C A810                <1> 	TEST	AL,010H
  3667 0000244E 74FA                <1> 	JZ	SHORT WR_STATE_0
  3668                              <1> WR_STATE_1:
  3669 00002450 E461                <1> 	IN	AL,PORT_B		; IN AL,SYS1
  3670 00002452 A810                <1> 	TEST	AL,010H
  3671 00002454 75FA                <1> 	JNZ	SHORT WR_STATE_1
  3672 00002456 E2F2                <1>         LOOP    WR_STATE_0
  3673                              <1> 	;
  3674 00002458 6658                <1> 	POP	AX			; RESTORE (AH)
  3675 0000245A C3                  <1> 	RETn				; (CX) = 0
  3676                              <1> 
  3677                              <1> ; 09/07/2016
  3678                              <1> ; 01/07/2016
  3679                              <1> ; 24/06/2016
  3680                              <1> ; 23/06/2016 - TRDOS 386 (TRDOS v2.0)
  3681                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3682                              <1> ;-------------------------------------------------------------------------------
  3683                              <1> ; WRITE_STRING								       :
  3684                              <1> ;	THIS ROUTINE WRITES A STRING OF CHARACTERS TO THE CRT.		       :
  3685                              <1> ; INPUT 								       :
  3686                              <1> ;	(AL) = WRITE STRING COMMAND  0 - 3				       :
  3687                              <1> ;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				       :
  3688                              <1> ;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	       :
  3689                              <1> ;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		       :
  3690                              <1> ;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1       :
  3691                              <1> ;	(eBP) = SOURCE STRING OFFSET					       :
  3692                              <1> ; OUTPUT								       :
  3693                              <1> ;	NONE								       :
  3694                              <1> ;-------------------------------------------------------------------------------
  3695                              <1> 
  3696                              <1> ; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  3697                              <1> ; AL = 01h: Assign all characters the attribute in BL; update cursor
  3698                              <1> ; AL = 02h: Use attributes in string; do not update cursor
  3699                              <1> ; AL = 03h: Use attributes in string; update cursor
  3700                              <1> 
  3701                              <1> WRITE_STRING:
  3702                              <1> 	; 12/09/2016
  3703                              <1> 	; 09/07/2016
  3704                              <1> 	;cmp	byte [CRT_MODE], 7 ; 6?!
  3705                              <1> 	;ja	VIDEO_RETURN		; not a valid function for VGA modes
  3706                              <1> 	;
  3707 0000245B A2[64960100]        <1> 	mov	[w_str_cmd], al		; save (AL) command
  3708 00002460 3C04                <1> 	CMP	AL, 4			; TEST FOR INVALID WRITE STRING OPTION
  3709 00002462 0F83EFF6FFFF        <1> 	JNB	VIDEO_RETURN		; IF OPTION INVALID THEN RETURN
  3710                              <1> 
  3711                              <1>         ;JCXZ   VIDEO_RETURN            ; IF ZERO LENGTH STRING THEN RETURN
  3712                              <1> 
  3713 00002468 67E362              <1>         jcxz    P55			; 01/07/2016
  3714                              <1> 
  3715                              <1> 	; 01/07/2016
  3716                              <1> 	;and	ecx, 0FFFFh
  3717                              <1> 	; ECX = byte count
  3718                              <1> 	;push	ecx
  3719 0000246B 89EE                <1> 	mov	esi, ebp ; user buffer
  3720 0000246D BF00000700          <1> 	mov	edi, Cluster_Buffer  ; system buffer
  3721 00002472 E8D7F60000          <1> 	call	transfer_from_user_buffer
  3722                              <1> 	;pop	ecx
  3723 00002477 0F82DAF6FFFF        <1> 	jc	VIDEO_RETURN
  3724                              <1> 	; ecx = transfer (byte) count = character count
  3725 0000247D BD00000700          <1> 	mov	ebp, Cluster_Buffer
  3726                              <1> 	; 12/09/2016
  3727 00002482 803D[CA6F0000]07    <1> 	cmp	byte [CRT_MODE], 7 ; 6?!
  3728 00002489 0F87A1000000        <1> 	ja	vga_write_string
  3729                              <1> 	;
  3730 0000248F 0FB6F7              <1> 	movzx	esi, bh			; GET CURRENT CURSOR PAGE
  3731 00002492 66D1E6              <1> 	SAL	SI, 1			; CONVERT TO PAGE OFFSET  (SI= PAGE)
  3732                              <1> 	; *****
  3733 00002495 66FFB6[EE890100]    <1> 	PUSH	word [eSI+CURSOR_POSN]	; SAVE CURRENT CURSOR POSITION IN STACK
  3734                              <1> 
  3735                              <1> 	;MOV	AX,0200H		; SET NEW CURSOR POSITION
  3736                              <1> 	;INT	10H
  3737                              <1> P50next:	
  3738 0000249C 51                  <1> 	push	ecx ; ****
  3739 0000249D 53                  <1> 	push	ebx ; *** ; 18/11/2020
  3740 0000249E 56                  <1> 	push	esi ; **
  3741 0000249F 52                  <1> 	push	edx ; *
  3742 000024A0 E8F2FEFFFF          <1> 	call	_set_cpos
  3743                              <1> P50:
  3744 000024A5 8A4500              <1> 	MOV	AL, [eBP]		; GET CHARACTER FROM INPUT STRING
  3745 000024A8 45                  <1> 	INC	eBP			; BUMP POINTER TO CHARACTER
  3746                              <1> 
  3747                              <1> ;-----	TEST FOR SPECIAL CHARACTER'S
  3748                              <1> 
  3749 000024A9 3C08                <1> 	CMP	AL, 08H			; IS IT A BACKSPACE
  3750 000024AB 7410                <1> 	JE	short P51		; BACK_SPACE
  3751 000024AD 3C0D                <1> 	CMP	AL, 0Dh ; CR		; IS IT CARRIAGE RETURN
  3752 000024AF 740C                <1> 	JE	short P51		; CAR_RET
  3753 000024B1 3C0A                <1> 	CMP	AL, 0Ah ; LF		; IS IT A LINE FEED
  3754 000024B3 7408                <1> 	JE	short P51		; LINE_FEED
  3755                              <1> 	; 18/11/2020
  3756 000024B5 3C09                <1> 	cmp	al, 09h			; is it a tab stop
  3757 000024B7 7404                <1> 	je	short P51
  3758                              <1> 	;
  3759 000024B9 3C07                <1> 	CMP	AL, 07h			; IS IT A BELL
  3760 000024BB 7515                <1> 	JNE	short P52		; IF NOT THEN DO WRITE CHARACTER
  3761                              <1> P51:
  3762                              <1> 	;MOV	AH,0EH			; TTY_CHARACTER_WRITE
  3763                              <1> 	;INT	10H			; WRITE TTY CHARACTER TO THE CRT
  3764                              <1> 	
  3765 000024BD E84EFEFFFF          <1> 	call	_write_tty_m3
  3766                              <1> 
  3767 000024C2 5A                  <1> 	pop	edx ; *
  3768 000024C3 5E                  <1> 	pop	esi ; **
  3769                              <1> 
  3770 000024C4 668B96[EE890100]    <1> 	MOV	DX, [eSI+CURSOR_POSN]	; GET CURRENT CURSOR POSITION
  3771 000024CB EB44                <1> 	JMP	SHORT P54		; SET CURSOR POSITION AND CONTINUE
  3772                              <1> P55:
  3773 000024CD E985F6FFFF          <1> 	JMP	VIDEO_RETURN
  3774                              <1> P52:
  3775 000024D2 66B90100            <1> 	MOV	CX, 1			; SET CHARACTER WRITE AMOUNT TO ONE
  3776 000024D6 803D[64960100]02    <1> 	CMP	byte [w_str_cmd], 2	; IS THE ATTRIBUTE IN THE STRING
  3777 000024DD 7204                <1> 	JB	short P53		; IF NOT THEN SKIP
  3778 000024DF 8A5D00              <1> 	MOV	BL, [eBP]		; ELSE GET NEW ATTRIBUTE
  3779 000024E2 45                  <1> 	INC	eBP			; BUMP STRING POINTER
  3780                              <1> P53:
  3781                              <1> 	;MOV	AH,09H			; GOT_CHARACTER
  3782                              <1> 	;INT	10H			; WRITE CHARACTER TO THE CRT
  3783                              <1> 
  3784 000024E3 E88EFDFFFF          <1> 	call	_write_c_current
  3785                              <1> 	
  3786 000024E8 5A                  <1> 	pop	edx ; *	
  3787                              <1> 
  3788                              <1> 	; 05/12/2020
  3789                              <1> 	; bx is preserved in '_write_c_current'
  3790                              <1> 	; 18/11/2020
  3791                              <1> 	;mov	ebx, [esp+4]	; ***
  3792                              <1> 
  3793 000024E9 0FB6F7              <1> 	movzx	esi, bh ; video page number (0 to 7)	
  3794 000024EC 889E[D36F0000]      <1> 	mov	[esi+chr_attrib], bl ; color/attribute
  3795                              <1> 
  3796 000024F2 FEC2                <1> 	INC	DL			; INCREMENT COLUMN COUNTER
  3797 000024F4 3A15[CC6F0000]      <1> 	CMP	DL, [CRT_COLS]		; IF COLS ARE WITHIN RANGE FOR THIS MODE
  3798                              <1> 	;JB	short P54		;    THEN GO TO COLUMNS SET
  3799 000024FA 7214                <1> 	jb	short P56 ; 05/12/2020
  3800 000024FC FEC6                <1> 	INC	DH			; BUMP ROW COUNTER BY ONE
  3801 000024FE 28D2                <1> 	SUB	DL, DL			; SET COLUMN COUNTER TO ZERO
  3802 00002500 80FE19              <1> 	CMP	DH, 25			; IF ROWS ARE LESS THAN 25 THEN
  3803                              <1> 	;JB	short P54		; GO TO ROWS_COLUMNS_SET
  3804 00002503 720B                <1> 	jb	short P56 ; 05/12/2020
  3805                              <1> 
  3806                              <1> 	; 18/11/2020
  3807                              <1> 	;MOV	AX,0E0AH		; ELSE SCROLL SCREEN
  3808                              <1> 	;INT	10H			; RESET ROW COUNTER TO 24
  3809                              <1> 
  3810                              <1> 	; 18/11/2020
  3811 00002505 B00A                <1> 	mov	al, 0Ah	; line feed
  3812                              <1> 
  3813 00002507 E804FEFFFF          <1> 	call	_write_tty_m3
  3814                              <1> 	
  3815 0000250C 66BA0018            <1> 	mov	dx, 1800h		; Column = 0, Row = 24
  3816                              <1> P56:	
  3817                              <1> 	; 05/12/2020
  3818                              <1> 	; 18/11/2020
  3819 00002510 5E                  <1> 	pop	esi ; **
  3820                              <1> P54:					; ROW_COLUMNS_SET
  3821                              <1> 	;MOV	AX,0200H		; SET NEW CURSOR POSITION COMMAND
  3822                              <1> 	;INT	10H			; ESTABLISH NEW CURSOR POSITION
  3823                              <1> 
  3824                              <1> 	; 18/11/2020
  3825 00002511 5B                  <1> 	pop	ebx ; ***
  3826 00002512 59                  <1> 	pop	ecx ; ****
  3827                              <1> 
  3828                              <1> 	;LOOP	P50			; DO IT ONCE MORE UNTIL (CX) = ZERO
  3829 00002513 6649                <1> 	dec	cx
  3830 00002515 7585                <1> 	jnz	short P50next
  3831                              <1> 
  3832 00002517 665A                <1> 	POP	DX  ; *****		; RESTORE OLD CURSOR COORDINATES
  3833                              <1> 	
  3834 00002519 F605[64960100]01    <1> 	test	byte [w_str_cmd], 1	; IF CURSOR WAS NOT TO BE MOVED
  3835 00002520 0F8531F6FFFF        <1> 	JNZ	VIDEO_RETURN		; THEN EXIT WITHOUT RESETTING OLD VALUE
  3836                              <1> 	
  3837                              <1> 	;MOV	AX,0200H		; ELSE RESTORE OLD CURSOR POSITION
  3838                              <1> 	;INT	10H
  3839                              <1> 					; DONE - EXIT WRITE STRING
  3840 00002526 E86CFEFFFF          <1> 	call	_set_cpos
  3841 0000252B E927F6FFFF          <1> 	JMP	VIDEO_RETURN		; RETURN TO CALLER
  3842                              <1> 
  3843                              <1> vga_write_string:
  3844                              <1> 	; 12/09/2016 - TRDOS 386 (TRDOS v2.0)
  3845                              <1> 	;
  3846                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  3847                              <1> 	; vgabios-0.7a (2011)
  3848                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  3849                              <1> 	; 'vgabios.c', ' biosfn_write_string'
  3850                              <1> 
  3851                              <1> 	; INPUT 								  :
  3852                              <1> 	;	(AL) = WRITE STRING COMMAND  0 - 3				  :
  3853                              <1> 	;	(BH) = DISPLAY PAGE (ACTIVE PAGE)				  :
  3854                              <1> 	;	(CX) = COUNT OF CHARACTERS TO WRITE, IF (CX) = 0 THEN RETURN	  :
  3855                              <1> 	;	(DX) = CURSOR POSITION FOR START OF STRING WRITE		  :
  3856                              <1> 	;	(BL) = ATTRIBUTE OF CHARACTER TO WRITE IF (AL) = 0  OR	(AL) = 1  :
  3857                              <1> 	;	(eBP) = SOURCE STRING OFFSET					  :
  3858                              <1> 	; OUTPUT								  :
  3859                              <1> 	;	NONE								  :
  3860                              <1> 	;-------------------------------------------------------------------------;
  3861                              <1> 
  3862                              <1> 	; AL = 00h: Assign all characters the attribute in BL; do not update cursor
  3863                              <1> 	; AL = 01h: Assign all characters the attribute in BL; update cursor
  3864                              <1> 	; AL = 02h: Use attributes in string; do not update cursor
  3865                              <1> 	; AL = 03h: Use attributes in string; update cursor
  3866                              <1> 	
  3867                              <1> 	; biosfn_write_string(GET_AL(),GET_BH(),GET_BL(),CX,GET_DH(),GET_DL(),ES,BP);
  3868                              <1> 	; static void biosfn_write_string (flag,page,attr,count,row,col,seg,offset) 
  3869                              <1> 
  3870                              <1> 	; // Read curs info for the page
  3871                              <1>  	; biosfn_get_cursor_pos(page,&dummy,&oldcurs);
  3872                              <1> 	; bh = video page = 0
  3873                              <1> 	;movzx	esi, word [CURSOR_POSN] ; current cursor position for video page 0
  3874                              <1> 	
  3875                              <1> 	; // if row=0xff special case : use current cursor position
  3876                              <1> 	; if(row==0xff)
  3877                              <1> 	;  {col=oldcurs&0x00ff;
  3878                              <1> 	;   row=(oldcurs&0xff00)>>8;
  3879                              <1> 	;  }
  3880                              <1> 
  3881                              <1> 	;mov	al, [w_str_cmd]
  3882                              <1> 
  3883 00002530 80FEFF              <1> 	cmp	dh, 0FFh
  3884 00002533 7407                <1> 	je	short vga_wstr_1 ; user current cursor position
  3885                              <1> vga_wstr_0:
  3886                              <1> 	; set cursor position
  3887 00002535 668915[EE890100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  3888                              <1> vga_wstr_1:
  3889 0000253C 66FF35[EE890100]    <1> 	push	word [CURSOR_POSN] ; *
  3890                              <1> 
  3891                              <1> 	; ebp = string offset in system buffer (user buffer was copied to)	
  3892                              <1> 	
  3893                              <1> 	; while(count--!=0)
  3894                              <1> 	;  {
  3895                              <1> 	;   car=read_byte(seg,offset++);
  3896                              <1> 	;   if((flag&0x02)!=0)
  3897                              <1> 	;    attr=read_byte(seg,offset++);
  3898                              <1> 	;    biosfn_write_teletype(car,page,attr,WITH_ATTR);
  3899                              <1> 	;  }
  3900                              <1> 
  3901                              <1> 	;push	eax ; **
  3902                              <1> 	;test	al, 2
  3903 00002543 F605[64960100]02    <1> 	test	byte [w_str_cmd], 2
  3904 0000254A 751D                <1> 	jnz	short vga_wstr_3
  3905 0000254C 881D[FF890100]      <1> 	mov	[ccolor], bl
  3906                              <1> vga_wstr_2:
  3907 00002552 51                  <1> 	push	ecx
  3908 00002553 8A4500              <1> 	mov	al, [ebp]
  3909 00002556 E8D90A0000          <1> 	call	vga_write_teletype
  3910 0000255B 59                  <1> 	pop	ecx
  3911 0000255C 6649                <1> 	dec	cx
  3912 0000255E 741E                <1> 	jz	short vga_wstr_4
  3913 00002560 45                  <1> 	inc	ebp
  3914 00002561 8A1D[FF890100]      <1> 	mov	bl, [ccolor]
  3915 00002567 EBE9                <1> 	jmp	short vga_wstr_2
  3916                              <1> vga_wstr_3:
  3917 00002569 51                  <1> 	push	ecx
  3918 0000256A 8A4500              <1> 	mov	al, [ebp]
  3919 0000256D 45                  <1> 	inc	ebp
  3920 0000256E 8A5D00              <1> 	mov	bl, [ebp]
  3921 00002571 E8BE0A0000          <1> 	call	vga_write_teletype
  3922 00002576 59                  <1> 	pop	ecx
  3923 00002577 6649                <1> 	dec	cx
  3924 00002579 7403                <1> 	jz	short vga_wstr_4
  3925 0000257B 45                  <1> 	inc	ebp
  3926 0000257C EBEB                <1> 	jmp	short vga_wstr_3
  3927                              <1> vga_wstr_4:
  3928                              <1> 	; // Set back curs pos 
  3929                              <1> 	; if((flag&0x01)==0)
  3930                              <1> 	;  biosfn_set_cursor_pos(page,oldcurs);
  3931                              <1> 	; }
  3932                              <1> 	;pop	eax ; **
  3933 0000257E 665A                <1> 	pop	dx ; word [CURSOR_POSN] ; *
  3934                              <1> 	;test	al, 1
  3935 00002580 F605[64960100]01    <1> 	test	byte [w_str_cmd], 1
  3936 00002587 0F85CAF5FFFF        <1> 	jnz	VIDEO_RETURN
  3937 0000258D 668915[EE890100]    <1> 	mov 	[CURSOR_POSN], dx
  3938 00002594 E9BEF5FFFF          <1> 	JMP	VIDEO_RETURN
  3939                              <1> 
  3940                              <1> ; 07/07/2016
  3941                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  3942                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  3943                              <1> ;------------------------------------------------------
  3944                              <1> ;  SCROLL UP
  3945                              <1> ;   THIS ROUTINE SCROLLS UP THE INFORMATION ON THE CRT
  3946                              <1> ; ENTRY ---
  3947                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  3948                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  3949                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  3950                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  3951                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  3952                              <1> ;  DS = DATA SEGMENT
  3953                              <1> ;  ES = REGEN SEGMENT
  3954                              <1> ; EXIT --
  3955                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  3956                              <1> ;--------------------------------------------------------
  3957                              <1> 
  3958                              <1> 	; cl = upper left column
  3959                              <1> 	; ch = upper left row
  3960                              <1> 	; dl = lower rigth column
  3961                              <1> 	; dh = lower right row
  3962                              <1> 	;
  3963                              <1> 	; al = line count (AL=0 means blank entire fields)
  3964                              <1> 	; bl = fill value for blanked lines	
  3965                              <1> 	; bh = unused
  3966                              <1> 
  3967                              <1> GRAPHICS_UP:
  3968                              <1> 	; 07/07/2016
  3969                              <1> 	;AH = Current video mode, [CRT_MODE]
  3970 00002599 80FC07              <1> 	cmp	ah, 7
  3971 0000259C 7766                <1> 	ja	short vga_graphics_up
  3972                              <1> 	;je	n0
  3973                              <1> 
  3974 0000259E 88C7                <1> 	MOV	bh, al			; save line count in BH
  3975 000025A0 6689C8              <1> 	MOV	AX, CX			; GET UPPER LEFT POSITION INTO AX REG
  3976                              <1> 
  3977                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  3978                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  3979                              <1> 
  3980 000025A3 E8DA050000          <1> 	CALL	GRAPH_POSN
  3981 000025A8 0FB7F8              <1> 	MOVzx	eDI, AX			; SAVE RESULT AS DESTINATION ADDRESS
  3982                              <1> 
  3983                              <1> ;-----	DETERMINE SIZE OF WINDOW
  3984                              <1> 
  3985 000025AB 6629CA              <1> 	SUB	DX, CX
  3986 000025AE 6681C20101          <1>         ADD     DX, 101h                ; ADJUST VALUES
  3987 000025B3 C0E602              <1> 	SAL	DH, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  3988                              <1> 					; AND EVEN/ODD ROWS
  3989                              <1> ;-----	DETERMINE CRT MODE
  3990                              <1> 
  3991 000025B6 803D[CA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  3992 000025BD 7305                <1>         JNC     short _R7_              ; FIND_SOURCE
  3993                              <1> 
  3994                              <1> ;-----	MEDIUM RES UP
  3995 000025BF D0E2                <1> 	SAL	DL, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  3996 000025C1 66D1E7              <1> 	SAL	DI, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  3997                              <1> 
  3998                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  3999                              <1> _R7_:                                   ; FIND_SOURCE
  4000 000025C4 81C700800B00        <1> 	add	edi, 0B8000h
  4001 000025CA C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  4002 000025CD 7431                <1>         JZ      short _R11              ; IF ZERO, THEN BLANK ENTIRE FIELD
  4003 000025CF B050                <1> 	MOV	AL, 80			; 80 BYTES/ROW
  4004 000025D1 F6E7                <1> 	mul	bh			; determine offset to source
  4005 000025D3 0FB7F0              <1> 	movzx	esi, ax			; offset to source
  4006 000025D6 01FE                <1> 	add	eSI, eDI		; SET UP SOURCE
  4007 000025D8 88F4                <1> 	MOV	AH, DH			; NUMBER OF ROWS IN FIELD
  4008 000025DA 28FC                <1> 	sub	ah, bh			; determine number to move
  4009                              <1> 
  4010                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  4011                              <1> _R8:                                    ; ROW_LOOP
  4012 000025DC E813040000          <1>         CALL    _R17                    ; MOVE ONE ROW
  4013 000025E1 6681EEB01F          <1> 	SUB	SI, 2000h-80		; MOVE TO NEXT ROW
  4014 000025E6 6681EFB01F          <1> 	SUB	DI, 2000h-80
  4015 000025EB FECC                <1> 	DEC	AH			; NUMBER OF ROWS TO MOVE
  4016 000025ED 75ED                <1>         JNZ     short _R8               ; CONTINUE TILL ALL MOVED
  4017                              <1> 
  4018                              <1> ;-----	FILL IN THE VACATED LINE(S)
  4019                              <1> _R9:                                    ; CLEAR ENTRY
  4020 000025EF 88D8                <1> 	mov	al, bl			; attribute to fill with
  4021                              <1> _R10_:
  4022 000025F1 E81A040000          <1>         CALL    _R18                    ; CLEAR THAT ROW
  4023 000025F6 6681EFB01F          <1> 	SUB	DI, 2000h-80		; POINT TO NEXT LINE
  4024 000025FB FECF                <1> 	dec	bh			; number of lines to fill
  4025 000025FD 75F2                <1>         JNZ     short _R10_             ; CLEAR LOOP
  4026 000025FF C3                  <1> 	retn				; EVERYYHING DONE
  4027                              <1> 
  4028                              <1> _R11:                                   ; BLANK_FIELD
  4029 00002600 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  4030 00002602 EBEB                <1>         JMP     short _R9               ; CLEAR THE FIELD
  4031                              <1> 
  4032                              <1> vga_graphics_up:
  4033                              <1> 	; 08/08/2016
  4034                              <1> 	; 07/08/2016
  4035                              <1> 	; 04/08/2016
  4036                              <1> 	; 01/08/2016
  4037                              <1> 	; 31/07/2016
  4038                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4039                              <1> 	;
  4040                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4041                              <1> 	; vgabios-0.7a (2011)
  4042                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4043                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  4044                              <1> 	;
  4045                              <1> 
  4046                              <1> 	; cl = upper left column
  4047                              <1> 	; ch = upper left row
  4048                              <1> 	; dl = lower rigth column
  4049                              <1> 	; dh = lower right row
  4050                              <1> 	;
  4051                              <1> 	; al = line count (AL=0 means blank entire fields)
  4052                              <1> 	; bl = fill value for blanked lines	
  4053                              <1> 	; bh = unused
  4054                              <1> 	;
  4055                              <1> 	; ah = [CRT_MODE], current video mode	
  4056                              <1> 
  4057 00002604 88C7                <1> 	mov	bh, al ; 31/07/2016
  4058 00002606 BE[EE6F0000]        <1> 	mov	esi, vga_g_modes
  4059 0000260B 89F7                <1> 	mov	edi, esi
  4060 0000260D 83C708              <1> 	add	edi, vga_g_mode_count
  4061                              <1> vga_g_up_0:
  4062 00002610 AC                  <1> 	lodsb
  4063 00002611 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4064 00002613 7405                <1> 	je	short vga_g_up_1
  4065 00002615 39FE                <1> 	cmp	esi, edi
  4066 00002617 72F7                <1> 	jb	short vga_g_up_0
  4067                              <1> 	;xor	bh, bh ; 31/07/2016)
  4068 00002619 C3                  <1> 	retn	; nothing to do
  4069                              <1> vga_g_up_1:
  4070 0000261A 88F8                <1> 	mov	al, bh ; 31/07/2016
  4071 0000261C 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  4072                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  4073                              <1> 	
  4074                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  4075                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  4076                              <1>  	; if(nblines>nbrows)nblines=0;
  4077                              <1>  	; cols=clr-cul+1;
  4078                              <1> 
  4079 0000261F 3A35[D26F0000]      <1> 	cmp	dh, [VGA_ROWS]
  4080 00002625 7208                <1> 	jb	short vga_g_up_2
  4081 00002627 8A35[D26F0000]      <1> 	mov	dh, [VGA_ROWS]
  4082 0000262D FECE                <1> 	dec	dh
  4083                              <1> vga_g_up_2:
  4084 0000262F 3A15[CC6F0000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  4085 00002635 7208                <1> 	jb	short vga_g_up_3
  4086 00002637 8A15[CC6F0000]      <1> 	mov	dl, [CRT_COLS]
  4087 0000263D FECA                <1> 	dec	dl
  4088                              <1> vga_g_up_3:	
  4089 0000263F 3A05[D26F0000]      <1> 	cmp	al, [VGA_ROWS]
  4090 00002645 7602                <1> 	jna	short vga_g_up_4
  4091 00002647 28C0                <1> 	sub	al, al ; 0
  4092                              <1> vga_g_up_4:
  4093 00002649 88D7                <1> 	mov	bh, dl ; clr
  4094 0000264B 28CF                <1> 	sub	bh, cl ; cul
  4095 0000264D FEC7                <1> 	inc	bh ; cols = clr-cul+1
  4096                              <1> 
  4097 0000264F 20C0                <1> 	and	al, al ; nblines = 0
  4098 00002651 755D                <1> 	jnz	short vga_g_up_6
  4099 00002653 20ED                <1> 	and	ch, ch ; rul = 0
  4100 00002655 7559                <1> 	jnz	short vga_g_up_6
  4101 00002657 20C9                <1> 	and	cl, cl ; cul = 0
  4102 00002659 7555                <1> 	jnz	short vga_g_up_6
  4103                              <1> 
  4104 0000265B 6650                <1> 	push	ax
  4105 0000265D A0[D26F0000]        <1> 	mov	al, [VGA_ROWS]
  4106 00002662 FEC8                <1> 	dec	al  
  4107 00002664 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  4108 00002666 7546                <1> 	jne	short vga_g_up_5
  4109 00002668 A0[CC6F0000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  4110 0000266D FEC8                <1> 	dec	al 
  4111 0000266F 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  4112 00002671 753B                <1> 	jne	short vga_g_up_5
  4113 00002673 6658                <1> 	pop	ax
  4114                              <1> 
  4115 00002675 66B80502            <1> 	mov	ax, 0205h
  4116 00002679 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4117 0000267D 66EF                <1> 	out	dx, ax
  4118 0000267F A0[D26F0000]        <1> 	mov	al, [VGA_ROWS]
  4119 00002684 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  4120 0000268A F6E4                <1> 	mul	ah
  4121 0000268C 0FB7D0              <1> 	movzx	edx, ax
  4122                              <1> 	; 08/08/2016
  4123 0000268F 0FB605[CE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4124 00002696 F7E2                <1> 	mul	edx
  4125                              <1> 	; eax = byte count	
  4126 00002698 89C1                <1> 	mov	ecx, eax
  4127                              <1> 	;; 07/08/2016
  4128                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  4129                              <1> 	;mov	ecx, edx
  4130 0000269A 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  4131 0000269C BF00000A00          <1> 	mov	edi, 0A0000h
  4132 000026A1 F3AA                <1> 	rep	stosb		
  4133                              <1> 	
  4134 000026A3 66B80500            <1> 	mov	ax, 5
  4135 000026A7 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4136 000026AB 66EF                <1> 	out	dx, ax ; 0005h	
  4137                              <1> 
  4138 000026AD C3                  <1> 	retn
  4139                              <1> 
  4140                              <1> vga_g_up_5:
  4141 000026AE 6658                <1> 	pop	ax
  4142                              <1> 
  4143                              <1> vga_g_up_6:
  4144                              <1> 	; [ESI] = VGA memory model number for current video mode
  4145                              <1>         ;
  4146                              <1>         ; LINEAR8 equ 5
  4147                              <1>         ; PLANAR4 equ 4
  4148                              <1>         ; PLANAR1 equ 3
  4149                              <1> 
  4150 000026B0 803E04              <1> 	cmp	byte [esi], PLANAR4
  4151 000026B3 7424                <1> 	je	short vga_g_up_planar
  4152 000026B5 803E03              <1> 	cmp	byte [esi], PLANAR1
  4153 000026B8 741F                <1> 	je	short vga_g_up_planar
  4154                              <1> vga_g_up_linear8:
  4155                              <1> 	; 07/07/2016 (TEMPORARY)
  4156                              <1> 	;
  4157                              <1> 	; cl = upper left column ; cul
  4158                              <1> 	; ch = upper left row ; rul
  4159                              <1> 	; dl = lower rigth column ; clr
  4160                              <1> 	; dh = lower right row ; rlr
  4161                              <1> 
  4162                              <1> vga_g_up_l0:
  4163                              <1>  	;{for(i=rul;i<=rlr;i++)
  4164                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  4165 000026BA 08C0                <1> 	or	al, al
  4166 000026BC 7414                <1> 	jz	short vga_g_up_l2
  4167 000026BE 88C4                <1> 	mov	ah, al
  4168 000026C0 00EC                <1> 	add	ah, ch ; i+nblines
  4169                              <1> 	;jc	short vga_g_up_l2	
  4170 000026C2 38F4                <1> 	cmp	ah, dh
  4171 000026C4 770C                <1> 	ja	short vga_g_up_l2
  4172                              <1> 	; else
  4173                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  4174 000026C6 E8F2000000          <1> 	call	vgamem_copy_l8
  4175                              <1> vga_g_up_l1:
  4176 000026CB FEC5                <1> 	inc	ch
  4177 000026CD 38F5                <1> 	cmp	ch, dh
  4178 000026CF 76E9                <1> 	jna	short vga_g_up_l0
  4179 000026D1 C3                  <1> 	retn
  4180                              <1> vga_g_up_l2:
  4181                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  4182 000026D2 E850010000          <1> 	call	vgamem_fill_l8
  4183 000026D7 EBF2                <1> 	jmp	short vga_g_up_l1
  4184                              <1> 
  4185                              <1> vga_g_up_planar:
  4186                              <1> 	; cl = upper left column ; cul
  4187                              <1> 	; ch = upper left row ; rul
  4188                              <1> 	; dl = lower rigth column ; clr
  4189                              <1> 	; dh = lower right row ; rlr
  4190                              <1> vga_g_up_pl0:
  4191                              <1>  	;{for(i=rul;i<=rlr;i++)
  4192                              <1>   	; if((i+nblines>rlr)||(nblines==0))
  4193 000026D9 20C0                <1> 	and	al, al
  4194 000026DB 7414                <1> 	jz	short vga_g_up_pl2	
  4195 000026DD 88C4                <1> 	mov	ah, al
  4196 000026DF 00EC                <1> 	add	ah, ch ; i+nblines
  4197                              <1> 	;jc	short vga_g_up_pl2
  4198 000026E1 38F4                <1> 	cmp	ah, dh
  4199 000026E3 770C                <1> 	ja	short vga_g_up_pl2
  4200                              <1> 	; else
  4201                              <1> 	;  vgamem_copy_pl4(cul,i+nblines,i,cols,nbcols,cheight);
  4202 000026E5 E80E000000          <1> 	call	vgamem_copy_pl4
  4203                              <1> vga_g_up_pl1:
  4204 000026EA FEC5                <1> 	inc	ch 
  4205 000026EC 38F5                <1> 	cmp	ch, dh
  4206 000026EE 76E9                <1> 	jna	short vga_g_up_pl0
  4207 000026F0 C3                  <1> 	retn
  4208                              <1> vga_g_up_pl2:
  4209                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  4210 000026F1 E870000000          <1> 	call	vgamem_fill_pl4
  4211 000026F6 EBF2                <1> 	jmp	short vga_g_up_pl1
  4212                              <1> 
  4213                              <1> vgamem_copy_pl4:
  4214                              <1> 	; 08/08/2016
  4215                              <1> 	; 07/08/2016
  4216                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4217                              <1> 	;
  4218                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4219                              <1> 	; vgabios-0.7a (2011)
  4220                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4221                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  4222                              <1> 	;
  4223                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  4224                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  4225                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  4226                              <1> 
  4227                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  4228                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  4229                              <1> 
  4230 000026F8 52                  <1> 	push	edx
  4231 000026F9 50                  <1> 	push	eax
  4232                              <1> 
  4233                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  4234 000026FA 66B80501            <1> 	mov	ax, 0105h
  4235 000026FE 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4236 00002702 66EF                <1> 	out	dx, ax
  4237                              <1> 
  4238                              <1> 	; 07/08/2016
  4239                              <1>  	;mov     ah, [esp+1]
  4240                              <1> 	;movzx	edx, ah ; ysrc
  4241 00002704 0FB6542401          <1> 	movzx	edx, byte [esp+1]
  4242                              <1> 	; 08/08/2016
  4243 00002709 0FB605[CE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4244 00002710 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  4245 00002716 F6E4                <1> 	mul	ah 
  4246                              <1> 	;; 07/08/2016
  4247                              <1> 	;movzx	eax, byte [CRT_COLS]
  4248                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4249 00002718 50                  <1> 	push	eax ; cheight * nbcols
  4250 00002719 F7E2                <1> 	mul	edx ; * ysrc
  4251                              <1> 	; eax = ysrc * cheight * nbcols
  4252                              <1> 	; edx = 0
  4253 0000271B 88CA                <1> 	mov	dl, cl ; edx = xstart	
  4254 0000271D 01D0                <1>  	add	eax, edx
  4255 0000271F 89C6                <1> 	mov	esi, eax ; src
  4256 00002721 88EA                <1> 	mov	dl, ch ; ydest
  4257 00002723 58                  <1> 	pop	eax ; cheight * nbcols
  4258 00002724 F7E2                <1> 	mul	edx
  4259                              <1> 	; eax = ydest * cheight * nbcols
  4260 00002726 88CA                <1> 	mov	dl, cl ; edx = xstart	
  4261 00002728 01D0                <1>  	add	eax, edx
  4262 0000272A 89C7                <1> 	mov	edi, eax ; dest
  4263                              <1> 	; esi = src
  4264                              <1> 	; edi = dest
  4265                              <1> 	; for(i=0;i<cheight;i++)
  4266                              <1>   	; {
  4267                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  4268                              <1>   	; }
  4269 0000272C 51                  <1> 	push	ecx
  4270 0000272D B900000A00          <1> 	mov	ecx, 0A0000h
  4271 00002732 01CE                <1> 	add	esi, ecx
  4272 00002734 01CF                <1> 	add	edi, ecx
  4273                              <1> 	; 08/08/2016
  4274 00002736 8A35[CE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4275                              <1> 	;; 07/08/2016
  4276                              <1> 	;mov	dh, 8 ; 07/08/2016
  4277 0000273C 28D2                <1> 	sub	dl, dl ; i
  4278                              <1> vgamem_copy_pl4_0:
  4279 0000273E 56                  <1> 	push	esi
  4280 0000273F 57                  <1> 	push	edi
  4281 00002740 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  4282 00002747 F6E2                <1> 	mul	dl
  4283                              <1> 	; eax = i * nbcols
  4284 00002749 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4285 0000274B 01C6                <1> 	add	esi, eax
  4286 0000274D 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4287 00002750 F3A4                <1> 	rep	movsb
  4288 00002752 5F                  <1> 	pop	edi
  4289 00002753 5E                  <1> 	pop	esi
  4290 00002754 FECE                <1> 	dec	dh
  4291 00002756 75E6                <1> 	jnz	short vgamem_copy_pl4_0
  4292                              <1> vgamem_copy_pl4_1:
  4293 00002758 59                  <1> 	pop	ecx
  4294                              <1> 
  4295                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4296 00002759 66B80500            <1> 	mov	ax, 0005h
  4297 0000275D 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4298 00002761 66EF                <1> 	out	dx, ax
  4299                              <1> 
  4300 00002763 58                  <1> 	pop	eax
  4301 00002764 5A                  <1> 	pop	edx
  4302                              <1> 
  4303 00002765 C3                  <1> 	retn	
  4304                              <1> 
  4305                              <1> vgamem_fill_pl4:
  4306                              <1> 	; 08/08/2016
  4307                              <1> 	; 07/08/2016
  4308                              <1> 	; 04/08/2016
  4309                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4310                              <1> 	;
  4311                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4312                              <1> 	; vgabios-0.7a (2011)
  4313                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4314                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  4315                              <1> 	;
  4316                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  4317                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  4318                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  4319                              <1> 
  4320                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  4321 00002766 52                  <1> 	push	edx
  4322 00002767 50                  <1> 	push	eax
  4323                              <1> 
  4324                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  4325 00002768 66B80502            <1> 	mov	ax, 0205h
  4326 0000276C 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4327 00002770 66EF                <1> 	out	dx, ax
  4328                              <1> 
  4329                              <1>       	; 08/08/2016
  4330 00002772 0FB605[CE6F0000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  4331 00002779 F6E5                <1> 	mul	ch
  4332                              <1> 	;; 07/08/2016
  4333                              <1> 	;movzx	eax, ch
  4334                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4335 0000277B 0FB615[CC6F0000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  4336 00002782 F7E2                <1> 	mul	edx
  4337                              <1> 	; edx  = 0
  4338 00002784 88CA                <1> 	mov	dl, cl 
  4339 00002786 01D0                <1> 	add	eax, edx
  4340 00002788 89C7                <1> 	mov	edi, eax
  4341                              <1> 	; edi = dest
  4342                              <1> 	; for(i=0;i<cheight;i++)
  4343                              <1>   	; {
  4344                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  4345                              <1>   	; }
  4346 0000278A 81C700000A00        <1> 	add	edi, 0A0000h
  4347 00002790 51                  <1> 	push	ecx
  4348                              <1> 	; 08/08/2016
  4349 00002791 8A35[CE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4350                              <1> 	;; 07/08/2016
  4351                              <1> 	;mov	dh, 8 ; 07/08/2016
  4352 00002797 28D2                <1> 	sub	dl, dl ; i
  4353                              <1> vgamem_fill_pl4_0:
  4354 00002799 57                  <1> 	push	edi
  4355 0000279A 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  4356 000027A1 F6E2                <1> 	mul	dl
  4357                              <1> 	; eax = i * nbcols
  4358 000027A3 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4359 000027A5 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  4360 000027A7 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4361 000027AA F3AA                <1>  	rep	stosb
  4362 000027AC 5F                  <1> 	pop	edi
  4363 000027AD 75EA                <1> 	jnz	short vgamem_fill_pl4_0
  4364                              <1> vgamem_fill_pl4_1:
  4365 000027AF 59                  <1> 	pop	ecx
  4366                              <1> 
  4367                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4368 000027B0 66B80500            <1> 	mov	ax, 0005h
  4369 000027B4 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4370 000027B8 66EF                <1> 	out	dx, ax
  4371                              <1> 
  4372 000027BA 58                  <1> 	pop	eax
  4373 000027BB 5A                  <1> 	pop	edx 
  4374                              <1> 	
  4375 000027BC C3                  <1> 	retn
  4376                              <1> 
  4377                              <1> vgamem_copy_l8:
  4378                              <1> 	; 08/08/2016
  4379                              <1> 	; 07/08/2016
  4380                              <1> 	; 06/08/2016
  4381                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4382                              <1> 	;
  4383                              <1> 	; TEMPORARY
  4384                              <1> 	;
  4385                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4386                              <1> 	; vgabios-0.7a (2011)
  4387                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4388                              <1> 	; 'vgabios.c', 'vgamem_copy_pl4'
  4389                              <1> 	;
  4390                              <1> 	; vgamem_copy_pl4(xstart,ysrc,ydest,cols,nbcols,cheight)
  4391                              <1> 	; cl = xstart, ah = ysrc (i+nblines), ch = ydest (i),
  4392                              <1> 	; bh = cols, [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  4393                              <1> 
  4394                              <1> 	; src=ysrc*cheight*nbcols+xstart;
  4395                              <1> 	; dest=ydest*cheight*nbcols+xstart;
  4396                              <1> 
  4397 000027BD 52                  <1> 	push	edx
  4398 000027BE 50                  <1> 	push	eax
  4399                              <1> 
  4400                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0105)
  4401                              <1> 	;mov	ax, 0105h
  4402                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4403                              <1> 	;out	dx, ax
  4404                              <1> 
  4405                              <1> 	;mov	ah, [esp+1]
  4406                              <1> 
  4407 000027BF 0FB6D4              <1> 	movzx	edx, ah ; ysrc
  4408                              <1> 	; 08/08/2016
  4409 000027C2 0FB605[CE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4410 000027C9 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  4411 000027CF F6E4                <1> 	mul	ah 
  4412                              <1> 	;; 07/08/2016
  4413                              <1> 	;movzx	eax, byte [CRT_COLS]
  4414                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4415 000027D1 50                  <1> 	push	eax ; cheight * nbcols
  4416 000027D2 F7E2                <1> 	mul	edx ; * ysrc
  4417                              <1> 	; eax = ysrc * cheight * nbcols
  4418                              <1> 	; edx = 0
  4419 000027D4 88CA                <1> 	mov	dl, cl ; edx = xstart
  4420 000027D6 01D0                <1>  	add	eax, edx
  4421 000027D8 89C6                <1> 	mov	esi, eax ; src
  4422 000027DA 66C1E603            <1> 	shl	si, 3 ; * 8 ; 06/08/2016
  4423 000027DE 88EA                <1> 	mov	dl, ch ; ydest
  4424 000027E0 58                  <1> 	pop	eax ; cheight * nbcols
  4425 000027E1 F7E2                <1> 	mul	edx
  4426                              <1> 	; eax = ydest * cheight * nbcols
  4427 000027E3 88CA                <1> 	mov	dl, cl ; edx = xstart	
  4428 000027E5 01D0                <1>  	add	eax, edx
  4429 000027E7 89C7                <1> 	mov	edi, eax ; dest
  4430 000027E9 66C1E703            <1> 	shl	di, 3 ; * 8 ; 06/08/2016
  4431                              <1> 	; esi = src
  4432                              <1> 	; edi = dest
  4433                              <1> 	; for(i=0;i<cheight;i++)
  4434                              <1>   	; {
  4435                              <1>    	;  memcpyb(0xa000,dest+i*nbcols,0xa000,src+i*nbcols,cols);
  4436                              <1>   	; }
  4437 000027ED 51                  <1> 	push	ecx
  4438 000027EE B900000A00          <1> 	mov	ecx, 0A0000h
  4439 000027F3 01CE                <1> 	add	esi, ecx
  4440 000027F5 01CF                <1> 	add	edi, ecx
  4441                              <1> 	; 08/08/2016
  4442 000027F7 8A35[CE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4443                              <1> 	;; 07/08/2016
  4444                              <1> 	;mov	dh, 8 ; 07/08/2016
  4445 000027FD 28D2                <1> 	sub	dl, dl ; i
  4446                              <1> vgamem_copy_l8_0:
  4447 000027FF 56                  <1> 	push	esi
  4448 00002800 57                  <1> 	push	edi
  4449 00002801 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  4450 00002808 F6E2                <1> 	mul	dl
  4451                              <1> 	; eax = i * nbcols
  4452 0000280A 66C1E003            <1> 	shl	ax, 3 ; * 8 ; 06/08/2016
  4453 0000280E 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4454 00002810 01C6                <1> 	add	esi, eax
  4455 00002812 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4456 00002815 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 06/08/2016
  4457 00002819 F3A4                <1> 	rep	movsb
  4458 0000281B 5F                  <1> 	pop	edi
  4459 0000281C 5E                  <1> 	pop	esi
  4460 0000281D FEC2                <1> 	inc	dl ; 06/08/2016
  4461 0000281F FECE                <1> 	dec	dh
  4462 00002821 75DC                <1> 	jnz	short vgamem_copy_l8_0
  4463                              <1> vgamem_copy_l8_1:
  4464 00002823 59                  <1> 	pop	ecx
  4465                              <1> 
  4466                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4467                              <1> 	;mov	ax, 0005h
  4468                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4469                              <1> 	;out	dx, ax
  4470                              <1> 
  4471 00002824 58                  <1> 	pop	eax
  4472 00002825 5A                  <1> 	pop	edx
  4473                              <1> 
  4474 00002826 C3                  <1> 	retn
  4475                              <1> 
  4476                              <1> vgamem_fill_l8:
  4477                              <1> 	; 08/08/2016
  4478                              <1> 	; 07/08/2016
  4479                              <1> 	; 06/08/2016
  4480                              <1> 	; 04/08/2016
  4481                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4482                              <1> 	;
  4483                              <1> 	; TEMPORARY
  4484                              <1> 	;
  4485                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4486                              <1> 	; vgabios-0.7a (2011)
  4487                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4488                              <1> 	; 'vgabios.c', 'vgamem_fill_pl4'
  4489                              <1> 	;
  4490                              <1> 	; vgamem_fill_pl4(xstart,ystart,cols,nbcols,cheight,attr)
  4491                              <1> 	; cl = xstart, edi = ch = ystart, bh = cols,
  4492                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight, attr = 0
  4493                              <1> 
  4494                              <1> 	; dest=ystart*cheight*nbcols+xstart;
  4495 00002827 52                  <1> 	push	edx
  4496 00002828 50                  <1> 	push	eax
  4497                              <1> 
  4498                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0205)
  4499                              <1> 	;mov	ax, 0205h
  4500                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4501                              <1> 	;out	dx, ax
  4502                              <1> 
  4503                              <1>         ; 08/08/2016
  4504 00002829 0FB605[CE6F0000]    <1> 	movzx   eax, byte [CHAR_HEIGHT]
  4505 00002830 F6E5                <1> 	mul	ch
  4506                              <1> 	;; 07/08/2016
  4507                              <1> 	;movzx	eax, ch
  4508                              <1> 	;shl	ax, 3 ; * 8 ; * [CHAR_HEIGHT]
  4509 00002832 0FB615[CC6F0000]    <1> 	movzx	edx, byte [CRT_COLS] ; = [VGA_COLS]
  4510 00002839 F7E2                <1> 	mul	edx
  4511                              <1> 	; edx  = 0
  4512 0000283B 88CA                <1> 	mov	dl, cl 
  4513 0000283D 01D0                <1> 	add	eax, edx
  4514 0000283F 89C7                <1> 	mov	edi, eax
  4515 00002841 66C1E703            <1> 	shl	di, 3 ; * 8 ; 06/08/2016
  4516                              <1> 	; edi = dest
  4517                              <1> 	; for(i=0;i<cheight;i++)
  4518                              <1>   	; {
  4519                              <1>    	;  memsetb(0xa000,dest+i*nbcols,attr,cols);
  4520                              <1>   	; }
  4521 00002845 81C700000A00        <1> 	add	edi, 0A0000h
  4522 0000284B 51                  <1> 	push	ecx
  4523                              <1> 	; 08/08/2016
  4524 0000284C 8A35[CE6F0000]      <1> 	mov	dh, [CHAR_HEIGHT]
  4525                              <1> 	;; 07/08/2016
  4526                              <1> 	;mov	dh, 8 ; 07/08/2016
  4527 00002852 28D2                <1> 	sub	dl, dl ; i
  4528                              <1> vgamem_fill_l8_0:
  4529 00002854 57                  <1> 	push	edi
  4530 00002855 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS]
  4531 0000285C F6E2                <1> 	mul	dl
  4532                              <1> 	; eax = i * nbcols
  4533 0000285E 66C1E003            <1> 	shl	ax, 3 ; * 8 ; 06/08/2016
  4534 00002862 01C7                <1> 	add	edi, eax ; dest+i*nbcols
  4535 00002864 88D8                <1> 	mov	al, bl ; attr ; 04/08/2016
  4536 00002866 0FB6CF              <1> 	movzx	ecx, bh ; cols
  4537 00002869 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 06/08/2016
  4538 0000286D F3AA                <1>  	rep	stosb
  4539 0000286F 5F                  <1> 	pop	edi
  4540 00002870 FEC2                <1> 	inc	dl ; 06/08/2016
  4541 00002872 FECE                <1> 	dec	dh
  4542 00002874 75DE                <1> 	jnz	short vgamem_fill_l8_0
  4543                              <1> vgamem_fill_l8_1:
  4544 00002876 59                  <1> 	pop	ecx
  4545                              <1> 
  4546                              <1> 	;; outw(VGAREG_GRDC_ADDRESS, 0x0005);
  4547                              <1> 	;mov	ax, 0005h
  4548                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4549                              <1> 	;out	dx, ax
  4550                              <1> 
  4551 00002877 58                  <1> 	pop	eax
  4552 00002878 5A                  <1> 	pop	edx 
  4553                              <1> 
  4554 00002879 C3                  <1> 	retn
  4555                              <1> 
  4556                              <1> vga_graphics_down:
  4557                              <1> 	; 08/08/2016
  4558                              <1> 	; 07/08/2016
  4559                              <1> 	; 31/07/2016
  4560                              <1> 	; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
  4561                              <1> 	;
  4562                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  4563                              <1> 	; vgabios-0.7a (2011)
  4564                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  4565                              <1> 	; 'vgabios.c', 'biosfn_scroll'
  4566                              <1> 	;
  4567                              <1> 
  4568                              <1> 	; cl = upper left column
  4569                              <1> 	; ch = upper left row
  4570                              <1> 	; dl = lower rigth column
  4571                              <1> 	; dh = lower right row
  4572                              <1> 	;
  4573                              <1> 	; al = line count (AL=0 means blank entire fields)
  4574                              <1> 	; bl = fill value for blanked lines	
  4575                              <1> 	; bh = unused
  4576                              <1> 	;
  4577                              <1> 	; ah = [CRT_MODE], current video mode	
  4578                              <1> 
  4579 0000287A FC                  <1>         cld     ; !!! Clear direction flag !!! 
  4580                              <1> 
  4581 0000287B 88C7                <1> 	mov	bh, al ; 31/07/2016
  4582                              <1> 
  4583 0000287D BE[E66F0000]        <1> 	mov	esi, vga_modes
  4584 00002882 89F7                <1> 	mov	edi, esi
  4585 00002884 83C710              <1> 	add	edi, vga_mode_count
  4586                              <1> vga_g_down_0:
  4587 00002887 AC                  <1> 	lodsb
  4588 00002888 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  4589 0000288A 7405                <1> 	je	short vga_g_down_1
  4590 0000288C 39FE                <1> 	cmp	esi, edi
  4591 0000288E 72F7                <1> 	jb	short vga_g_down_0
  4592                              <1> 	; xor 	bh, bh	; 31/07/2016
  4593 00002890 C3                  <1> 	retn	; nothing to do
  4594                              <1> vga_g_down_1:
  4595 00002891 88F8                <1> 	mov	al, bh ; 31/07/2016
  4596 00002893 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  4597                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  4598                              <1> 	
  4599                              <1> 	; if(rlr>=nbrows)rlr=nbrows-1;
  4600                              <1>  	; if(clr>=nbcols)clr=nbcols-1;
  4601                              <1>  	; if(nblines>nbrows)nblines=0;
  4602                              <1>  	; cols=clr-cul+1;
  4603                              <1> 
  4604 00002896 3A35[D26F0000]      <1> 	cmp	dh, [VGA_ROWS]
  4605 0000289C 7208                <1> 	jb	short vga_g_down_2
  4606 0000289E 8A35[D26F0000]      <1> 	mov	dh, [VGA_ROWS]
  4607 000028A4 FECE                <1> 	dec	dh
  4608                              <1> vga_g_down_2:
  4609 000028A6 3A15[CC6F0000]      <1> 	cmp	dl, [CRT_COLS]  ; = [VGA_COLS]
  4610 000028AC 7208                <1> 	jb	short vga_g_down_3
  4611 000028AE 8A15[CC6F0000]      <1> 	mov	dl, [CRT_COLS]
  4612 000028B4 FECA                <1> 	dec	dl
  4613                              <1> vga_g_down_3:	
  4614 000028B6 3A05[D26F0000]      <1> 	cmp	al, [VGA_ROWS]
  4615 000028BC 7602                <1> 	jna	short vga_g_down_4
  4616 000028BE 28C0                <1> 	sub	al, al ; 0
  4617                              <1> vga_g_down_4:
  4618 000028C0 88F7                <1> 	mov	bh, dh ; clr
  4619 000028C2 28CF                <1> 	sub	bh, cl ; cul
  4620 000028C4 FEC7                <1> 	inc	bh ; cols = clr-cul+1
  4621                              <1> 
  4622 000028C6 20C0                <1> 	and	al, al ; nblines = 0
  4623 000028C8 755B                <1> 	jnz	short vga_g_down_6
  4624 000028CA 20ED                <1> 	and	ch, ch ; rul = 0
  4625 000028CC 7557                <1> 	jnz	short vga_g_down_6
  4626 000028CE 20C9                <1> 	and	cl, cl ; cul = 0
  4627 000028D0 7553                <1> 	jnz	short vga_g_down_6
  4628                              <1> 
  4629 000028D2 6650                <1> 	push	ax
  4630 000028D4 A0[D26F0000]        <1> 	mov	al, [VGA_ROWS]
  4631 000028D9 FEC8                <1> 	dec	al  
  4632 000028DB 38C6                <1> 	cmp	dh, al ; rlr = nbrows-1
  4633 000028DD 7544                <1> 	jne	short vga_g_down_5
  4634 000028DF A0[CC6F0000]        <1>         mov     al, [CRT_COLS]  ; = VGA_COLS
  4635 000028E4 FEC8                <1> 	dec	al 
  4636 000028E6 38C2                <1>  	cmp	dl, al ; clr = nbcols-1
  4637 000028E8 7539                <1> 	jne	short vga_g_down_5
  4638 000028EA 6658                <1> 	pop	ax
  4639                              <1> 
  4640 000028EC 66B80502            <1> 	mov	ax, 0205h
  4641 000028F0 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4642 000028F4 66EF                <1> 	out	dx, ax
  4643 000028F6 A0[D26F0000]        <1> 	mov	al, [VGA_ROWS]
  4644 000028FB 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS] ; = [VGA_COLS]
  4645 00002901 F6E4                <1> 	mul	ah
  4646 00002903 0FB7D0              <1> 	movzx	edx, ax
  4647                              <1> 	; 08/08/2016
  4648 00002906 0FB605[CE6F0000]    <1> 	movzx	eax, byte [CHAR_HEIGHT]
  4649 0000290D F7E2                <1> 	mul	edx
  4650                              <1> 	; eax = byte count	
  4651 0000290F 89C1                <1> 	mov	ecx, eax
  4652                              <1> 	;; 07/08/2016
  4653                              <1> 	;shl	dx, 3 ; * 8 ; * [CHAR_HEIGHT]
  4654                              <1> 	;mov	ecx, edx
  4655 00002911 88D8                <1> 	mov	al, bl ; fill value for blanked lines
  4656 00002913 BF00000A00          <1> 	mov	edi, 0A0000h
  4657 00002918 F3AA                <1> 	rep	stosb			
  4658                              <1> 	
  4659 0000291A B005                <1> 	mov	al, 5
  4660 0000291C 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  4661 00002920 66EF                <1> 	out	dx, ax ; 0005h	
  4662                              <1> 
  4663 00002922 C3                  <1> 	retn
  4664                              <1> 
  4665                              <1> vga_g_down_5:
  4666 00002923 6658                <1> 	pop	ax
  4667                              <1> 
  4668                              <1> vga_g_down_6:
  4669                              <1> 	; [ESI] = VGA memory model number for current video mode
  4670                              <1>         ;
  4671                              <1>         ; LINEAR8 equ 5
  4672                              <1>         ; PLANAR4 equ 4
  4673                              <1>         ; PLANAR1 equ 3
  4674                              <1> 
  4675 00002925 803E04              <1> 	cmp	byte [esi], PLANAR4
  4676 00002928 742C                <1> 	je	short vga_g_down_planar
  4677 0000292A 803E03              <1> 	cmp	byte [esi], PLANAR1
  4678 0000292D 7427                <1> 	je	short vga_g_down_planar
  4679                              <1> vga_g_down_linear8:
  4680                              <1> 	; 07/07/2016 (TEMPORARY)
  4681                              <1> 	;
  4682                              <1> 	; cl = upper left column ; cul
  4683                              <1> 	; ch = upper left row ; rul
  4684                              <1> 	; dl = lower rigth column ; clr
  4685                              <1> 	; dh = lower right row ; rlr
  4686                              <1> 
  4687                              <1> vga_g_down_l0:
  4688                              <1> 	;{for(i=rlr;i>=rul;i--)
  4689                              <1>         ; if((i<rul+nblines)||(nblines==0))
  4690 0000292F 08C0                <1> 	or	al, al
  4691 00002931 741C                <1> 	jz	short vga_g_down_l2
  4692 00002933 88C4                <1> 	mov	ah, al
  4693 00002935 00EC                <1> 	add	ah, ch
  4694                              <1> 	;jc	short vga_g_down_l2	
  4695 00002937 86EE                <1> 	xchg	ch, dh
  4696 00002939 38E5                <1> 	cmp	ch, ah
  4697 0000293B 7212                <1> 	jb	short vga_g_down_l2
  4698 0000293D 88EC                <1> 	mov	ah, ch
  4699 0000293F 28C4                <1> 	sub	ah, al ; ah = i - nblines
  4700                              <1> 	; else
  4701                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  4702 00002941 E877FEFFFF          <1> 	call	vgamem_copy_l8
  4703                              <1> vga_g_down_l1:
  4704 00002946 86F5                <1> 	xchg	dh, ch
  4705 00002948 FECE                <1> 	dec	dh 
  4706 0000294A 38EE                <1> 	cmp	dh, ch
  4707 0000294C 73E1                <1> 	jnb	short vga_g_down_l0
  4708 0000294E C3                  <1> 	retn
  4709                              <1> 
  4710                              <1> vga_g_down_l2:
  4711                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  4712 0000294F E8D3FEFFFF          <1> 	call	vgamem_fill_l8
  4713 00002954 EBF0                <1> 	jmp	short vga_g_down_l1
  4714                              <1> 		 
  4715                              <1> vga_g_down_planar:
  4716                              <1> 	; cl = upper left column ; cul
  4717                              <1> 	; ch = upper left row ; rul
  4718                              <1> 	; dl = lower rigth column ; clr
  4719                              <1> 	; dh = lower right row ; rlr
  4720                              <1> vga_g_down_pl0:
  4721                              <1>  	;{for(i=rlr;i>=rul;i--)
  4722                              <1>         ; if((i<rul+nblines)||(nblines==0))
  4723 00002956 08C0                <1> 	or	al, al
  4724 00002958 741C                <1> 	jz	short vga_g_down_pl2
  4725 0000295A 88C4                <1> 	mov	ah, al
  4726 0000295C 00EC                <1> 	add	ah, ch
  4727                              <1> 	;jc	short vga_g_down_pl2	
  4728 0000295E 86EE                <1> 	xchg	ch, dh
  4729 00002960 38E5                <1> 	cmp	ch, ah
  4730 00002962 7212                <1> 	jb	short vga_g_down_pl2
  4731 00002964 88EC                <1> 	mov	ah, ch
  4732 00002966 28C4                <1> 	sub	ah, al ; ah = i - nblines
  4733                              <1> 	; else
  4734                              <1> 	; vgamem_copy_pl4(cul,i,i-nblines,cols,nbcols,cheight);
  4735 00002968 E88BFDFFFF          <1> 	call	vgamem_copy_pl4
  4736                              <1> vga_g_down_pl1:
  4737 0000296D 86F5                <1> 	xchg	dh, ch
  4738 0000296F FECE                <1> 	dec	dh 
  4739 00002971 38EE                <1> 	cmp	dh, ch
  4740 00002973 73E1                <1> 	jnb	short vga_g_down_pl0
  4741 00002975 C3                  <1> 	retn
  4742                              <1> 
  4743                              <1> vga_g_down_pl2:
  4744                              <1> 	; vgamem_fill_pl4(cul,i,cols,nbcols,cheight,attr);
  4745 00002976 E8EBFDFFFF          <1> 	call	vgamem_fill_pl4
  4746 0000297B EBF0                <1> 	jmp	short vga_g_down_pl1
  4747                              <1> 
  4748                              <1> ; 07/07/2016
  4749                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  4750                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  4751                              <1> ;------------------------------------------------------
  4752                              <1> ; SCROLL DOWN
  4753                              <1> ;  THIS ROUTINE SCROLLS DOWN THE INFORMATION ON THE CRT
  4754                              <1> ; ENTRY --
  4755                              <1> ;  CH,CL = UPPER LEFT CORNER OF REGION TO SCROLL
  4756                              <1> ;  DH,DL = LOWER RIGHT CORNER OF REGION TO SCROLL
  4757                              <1> ;   BOTH OF THE ABOVE ARE IN CHARACTER POSITIONS
  4758                              <1> ;  BH = FILL VALUE FOR BLANKED LINES
  4759                              <1> ;  AL = # LINES TO SCROLL (AL=0 MEANS BLANK THE ENTIRE FIELD)
  4760                              <1> ;  DS = DATA SEGMENT
  4761                              <1> ;  ES = REGEN SEGMENT
  4762                              <1> ; EXIT --
  4763                              <1> ;  NOTHING, THE SCREEN IS SCROLLED
  4764                              <1> ;--------------------------------------------------------
  4765                              <1> 
  4766                              <1> 	; cl = upper left column
  4767                              <1> 	; ch = upper left row
  4768                              <1> 	; dl = lower rigth column
  4769                              <1> 	; dh = lower right row
  4770                              <1> 	;
  4771                              <1> 	; al = line count (AL=0 means blank entire fields)
  4772                              <1> 	; bl = fill value for blanked lines	
  4773                              <1> 	; bh = unused
  4774                              <1> 
  4775                              <1> GRAPHICS_DOWN:
  4776                              <1> 	; 07/07/2016
  4777                              <1> 	;AH = Current video mode, [CRT_MODE]
  4778                              <1> 	;STD				; SET DIRECTION
  4779 0000297D 80FC07              <1> 	cmp	ah, 7
  4780 00002980 0F87F4FEFFFF        <1>         ja      vga_graphics_down
  4781                              <1> 	;je	_n0
  4782                              <1> 
  4783 00002986 88C7                <1> 	MOV	bh, al			; save line count in BH
  4784 00002988 6689D0              <1> 	MOV	AX, DX			; GET LOWER RIGHT POSITION INTO AX REG
  4785                              <1> 
  4786                              <1> ;-----	USE CHARACTER SUBROUTINE FOR POSITIONING
  4787                              <1> ;-----	ADDRESS RETURNED IS MULTIPLIED BY 2 FROM CORRECT VALUE
  4788                              <1> 
  4789 0000298B E8F2010000          <1> 	CALL	GRAPH_POSN
  4790 00002990 0FB7F8              <1> 	MOVzx	eDI, AX			; SAVE RESULT AS DESTINATION ADDRESS
  4791                              <1> 
  4792                              <1> ;-----	DETERMINE SIZE OF WINDOW
  4793                              <1> 
  4794 00002993 6629CA              <1> 	SUB	DX, CX
  4795 00002996 6681C20101          <1>         ADD     DX, 101h                ; ADJUST VALUES
  4796 0000299B C0E602              <1> 	SAL	DH, 2			; MULTIPLY ROWS BY 4 AT 8 VERT DOTS/CHAR
  4797                              <1> 					; AND EVEN/ODD ROWS
  4798                              <1> 
  4799                              <1> ;-----	DETERMINE CRT MODE
  4800                              <1> 
  4801 0000299E 803D[CA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6	; TEST FOR MEDIUM RES
  4802 000029A5 7307                <1>         JNC     short _R12              ; FIND_SOURCE_DOWN
  4803                              <1> 
  4804                              <1> ;-----	MEDIUM RES DOWN
  4805 000029A7 D0E2                <1> 	SAL	DL, 1			; # COLUMNS * 2, SINCE 2 BYTES/CHAR
  4806 000029A9 66D1E7              <1> 	SAL	DI, 1			; OFFSET *2 SINCE 2 BYTES/CHAR
  4807 000029AC 6647                <1> 	INC	DI			; POINT TO LAST BYTE
  4808                              <1> 
  4809                              <1> ;-----	DETERMINE THE SOURCE ADDRESS IN THE BUFFER
  4810                              <1> 
  4811                              <1> _R12:                                   ; FIND_SOURCE_DOWN
  4812 000029AE 81C700800B00        <1> 	add	edi, 0B8000h		
  4813 000029B4 6681C7F000          <1> 	ADD	DI, 240			; POINT TO LAST ROW OF PIXELS
  4814 000029B9 C0E702              <1> 	sal	bh, 2			; multiply number of lines by 4
  4815 000029BC 74(06)              <1> 	JZ	short 6			; IF ZERO, THEN BLANK ENTIRE FIELD
  4816 000029BE B050                <1> 	MOV	AL, 80			; 80 BYTES/ROW
  4817 000029C0 F6E7                <1> 	mul	bh			; determine offset to source
  4818 000029C2 89FE                <1> 	MOV	eSI, eDI		; SET UP SOURCE
  4819 000029C4 6629C6              <1> 	SUB	SI, AX			; SUBTRACT THE OFFSET
  4820 000029C7 88F4                <1> 	MOV	AH, DH			; NUMBER OF ROWS IN FIELD
  4821 000029C9 28FC                <1> 	sub	ah, bh			; determine number to move
  4822                              <1> 
  4823                              <1> ;-----	LOOP THROUGH, MOVING ONE ROW AT A TIME, BOTH EVEN AND ODD FIELDS
  4824                              <1> 
  4825                              <1> _R13:                                   ; ROW_LOOP_DOWN
  4826 000029CB E824000000          <1>         CALL    _R17                    ; MOVE ONE ROW
  4827 000029D0 6681EE5020          <1> 	SUB	SI, 2000h+80		; MOVE TO NEXT ROW
  4828 000029D5 6681EF5020          <1> 	SUB	DI, 2000h+80
  4829 000029DA FECC                <1> 	DEC	AH			; NUMBER OF ROWS TO MOVE
  4830 000029DC 75ED                <1>         JNZ     short _R13              ; CONTINUE TILL ALL MOVED
  4831                              <1> 
  4832                              <1> ;-----	FILL IN THE VACATED LINE(S)
  4833                              <1> _R14:                                   ; CLEAR_ENTRY_DOWN
  4834 000029DE 88D8                <1> 	mov	al, bl			; attribute to fill with
  4835                              <1> _R15_:                                  ; CLEAR_LOOP_DOWN
  4836 000029E0 E82B000000          <1> 	CALL	_R18			; CLEAR A ROW
  4837 000029E5 6681EF5020          <1> 	SUB	DI, 2000h+80		; POINT TO NEXT LINE
  4838 000029EA FECF                <1> 	dec	bh			; number of lines to fill
  4839 000029EC 75F2                <1>         JNZ     short _R15_             ; CLEAR_LOOP_DOWN
  4840                              <1> 	; 18/11/2020
  4841 000029EE FC                  <1> 	CLD				; RESET THE DIRECTION FLAG
  4842                              <1> 	
  4843 000029EF C3                  <1> 	retn				; EVERYTHING DONE
  4844                              <1> 
  4845                              <1> _R16:                                   ; BLANK_FIELD_DOWN
  4846 000029F0 88F7                <1> 	mov	bh, dh			; set blank count to everything in field
  4847 000029F2 EBEA                <1>         JMP     short _R14              ; CLEAR THE FIELD
  4848                              <1> 
  4849                              <1> ; 27/06/2016 - TRDOS 386 (TRDOS v2.0)
  4850                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  4851                              <1> 
  4852                              <1> ;-----	ROUTINE TO MOVE ONE ROW OF INFORMATION
  4853                              <1> 
  4854                              <1> _R17:
  4855 000029F4 0FB6CA              <1> 	MOVzx	ecx, DL			; NUMBER OF BYTES IN THE ROW
  4856 000029F7 56                  <1> 	PUSH	eSI
  4857 000029F8 57                  <1> 	PUSH	eDI			; SAVE POINTERS
  4858 000029F9 F3A4                <1> 	REP	MOVSB			; MOVE THE EVEN FIELD
  4859 000029FB 5F                  <1> 	POP	eDI
  4860 000029FC 5E                  <1> 	POP	eSI
  4861 000029FD 6681C60020          <1> 	ADD	SI, 2000h
  4862 00002A02 6681C70020          <1> 	ADD	DI, 2000h		; POINT TO THE ODD FIELD
  4863 00002A07 56                  <1> 	PUSH	eSI
  4864 00002A08 57                  <1> 	PUSH	eDI			; SAVE THE POINTERS
  4865 00002A09 88D1                <1> 	MOV	CL, DL			; COUNT BACK
  4866 00002A0B F3A4                <1> 	REP	MOVSB			; MOVE THE ODD FIELD
  4867 00002A0D 5F                  <1> 	POP	eDI
  4868 00002A0E 5E                  <1> 	POP	eSI			; POINTERS BACK
  4869 00002A0F C3                  <1> 	RETn				; RETURN TO CALLER
  4870                              <1> 
  4871                              <1> ;-----	CLEAR A SINGLE ROW
  4872                              <1> 
  4873                              <1> _R18:
  4874 00002A10 0FB6CA              <1> 	MOVzx	ecx, DL			; NUMBER OF BYTES IN FIELD
  4875 00002A13 57                  <1> 	PUSH	eDI			; SAVE POINTER
  4876 00002A14 F3AA                <1> 	REP	STOSB			; STORE THE NEW VALUE
  4877 00002A16 5F                  <1> 	POP	eDI			; POINTER BACK
  4878 00002A17 6681C70020          <1> 	ADD	DI, 2000h		; POINT TO ODD FIELD
  4879 00002A1C 57                  <1> 	PUSH	eDI
  4880 00002A1D 88D1                <1> 	MOV	CL, DL
  4881 00002A1F F3AA                <1> 	REP	STOSB			; FILL THE ODD FIELD
  4882 00002A21 5F                  <1> 	POP	eDI
  4883 00002A22 C3                  <1> 	RETn				; RETURN TO CALLER
  4884                              <1> 
  4885                              <1> ; 04/07/2016
  4886                              <1> ; 01/07/2016
  4887                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  4888                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  4889                              <1> ;--------------------------------------------------
  4890                              <1> ; GRAPHICS WRITE
  4891                              <1> ;  THIS ROUTINE WRITES THE ASCII CHARACTER TO THE CURRENT
  4892                              <1> ;  POSITION ON THE SCREEN.
  4893                              <1> ; ENTRY --
  4894                              <1> ;  AL = CHARACTER TO WRITE
  4895                              <1> ;  BL = COLOR ATTRIBUTE TO BE USED FOR FOREGROUND COLOR
  4896                              <1> ;	IF BIT 7 IS SET, THE CHAR IS XOR'D INTO THE REGEN BUFFER
  4897                              <1> ;	(0 IS USED FOR THE BACKGROUND COLOR)
  4898                              <1> ;  CX = NUMBER OF CHARS TO WRITE
  4899                              <1> ;  DS = DATA SEGMENT
  4900                              <1> ;  ES = REGEN SEGMENT
  4901                              <1> ; EXIT --
  4902                              <1> ;  NOTHING IS RETURNED
  4903                              <1> ;
  4904                              <1> ; GRAPHICS READ
  4905                              <1> ;  THIS ROUTINE READS THE ASCII CHARACTER AT THE CURRENT CURSOR
  4906                              <1> ;  POSITION ON THE SCREEN BY MATCHING THE DOTS ON THE SCREEN TO THE
  4907                              <1> ;  CHARACTER GENERATOR CODE POINTS
  4908                              <1> ; ENTRY --
  4909                              <1> ;  NONE (0 IS ASSUMED AS THE BACKGROUND COLOR)
  4910                              <1> ; EXIT --
  4911                              <1> ;  AL = CHARACTER READ AT THAT POSITION (0 RETURNED IF NONE FOUND)
  4912                              <1> ;
  4913                              <1> ; FOR BOTH ROUTINES, THE IMAGES USED TO FORM CHARS ARE CONTAINED IN ROM
  4914                              <1> ;  FOR THE 1ST 128 CHARS.  TO ACCESS CHARS IN THE SECOND HALF, THE USER
  4915                              <1> ;  MUST INITIALIZE THE VECTOR AT INTERRUPT 1FH (LOCATION 0007CH) TO
  4916                              <1> ;  POINT TO THE USER SUPPLIED TABLE OF GRAPHIC IMAGES (8X8 BOXES).
  4917                              <1> ;  FAILURE TO DO SO WILL CAUSE IN STRANGE RESULTS
  4918                              <1> ;-----------------------------------------------------
  4919                              <1> 
  4920                              <1> GRAPHICS_WRITE:
  4921 00002A23 25FF000000          <1> 	and 	eax, 0FFh		; ZERO TO HIGH OF CODE POINT
  4922 00002A28 50                  <1> 	PUSH	eAX			; SAVE CODE POINT VALUE
  4923                              <1> 
  4924                              <1> ;-----	DETERMINE POSITION IN REGEN BUFFER TO PUT CODE POINTS
  4925                              <1> 
  4926 00002A29 E84D010000          <1> 	CALL	S26			; FIND LOCATION IN REGEN BUFFER
  4927 00002A2E 89C7                <1> 	MOV	eDI, eAX		; REGEN POINTER IN DI
  4928                              <1> 
  4929                              <1> ;-----	DETERMINE REGION TO GET CODE POINTS FROM
  4930                              <1> 
  4931 00002A30 58                  <1> 	POP	eAX			; RECOVER CODE POINT
  4932                              <1> 
  4933 00002A31 BE[64600100]        <1> 	MOV	eSI, CRT_CHAR_GEN	; OFFSET OF IMAGES
  4934                              <1> 
  4935                              <1> ;-----	DETERMINE GRAPHICS MODE IN OPERATION
  4936                              <1> 					; DETERMINE_MODE
  4937 00002A36 66C1E003            <1> 	SAL	AX, 3			; MULTIPLY CODE POINT VALUE BY 8
  4938 00002A3A 01C6                <1> 	ADD	eSI, eAX		; SI HAS OFFSET OF DESIRED CODES
  4939                              <1> 	
  4940 00002A3C 803D[CA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6
  4941 00002A43 7231                <1> 	JC	short S6		; TEST FOR MEDIUM RESOLUTION MODE
  4942                              <1> 
  4943                              <1> ;-----	HIGH RESOLUTION MODE
  4944                              <1> 
  4945 00002A45 81C700800B00        <1> 	add	edi, 0B8000h
  4946                              <1> S1:					; HIGH_CHAR
  4947 00002A4B 57                  <1> 	PUSH	eDI			; SAVE REGEN POINTER
  4948 00002A4C 56                  <1> 	PUSH	eSI			; SAVE CODE POINTER
  4949 00002A4D B604                <1> 	MOV	DH, 4			; NUMBER OF TIMES THROUGH LOOP
  4950                              <1> S2:
  4951 00002A4F AC                  <1> 	LODSB				; GET BYTE FROM CODE POINTS
  4952 00002A50 F6C380              <1> 	TEST	BL, 80H			; SHOULD WE USE THE FUNCTION
  4953 00002A53 7515                <1> 	JNZ	short S5		; TO PUT CHAR IN
  4954 00002A55 AA                  <1> 	STOSB				; STORE IN REGEN BUFFER
  4955 00002A56 AC                  <1> 	LODSB
  4956                              <1> S4:
  4957 00002A57 8887FF1F0000        <1> 	MOV	[eDI+2000H-1], AL ; STORE IN SECOND HALF
  4958 00002A5D 83C74F              <1> 	ADD	eDI, 79			; MOVE TO NEXT ROW IN REGEN
  4959 00002A60 FECE                <1> 	DEC	DH			; DONE WITH LOOP
  4960 00002A62 75EB                <1> 	JNZ	short S2
  4961 00002A64 5E                  <1> 	POP	eSI
  4962 00002A65 5F                  <1> 	POP	eDI			; RECOVER REGEN POINTER
  4963 00002A66 47                  <1> 	INC	eDI			; POINT TO NEXT CHAR POSITION
  4964 00002A67 E2E2                <1> 	LOOP	S1			; MORE CHARS TO WRITE
  4965 00002A69 C3                  <1> 	retn
  4966                              <1> 
  4967                              <1> S5:
  4968 00002A6A 3207                <1> 	XOR	AL, [eDI]		; EXCLUSIVE OR WITH CURRENT
  4969 00002A6C AA                  <1> 	STOSB				; STORE THE CODE POINT
  4970 00002A6D AC                  <1> 	LODSB				; AGAIN FOR ODD FIELD
  4971 00002A6E 3287FF1F0000        <1> 	XOR	AL, [eDI+2000H-1]
  4972 00002A74 EBE1                <1> 	JMP	short S4		; BACK TO MAINSTREAM
  4973                              <1> 
  4974                              <1> ;-----	MEDIUM RESOLUTION WRITE
  4975                              <1> S6:					; MED_RES_WRITE
  4976 00002A76 88DA                <1> 	MOV	DL, BL			; SAVE HIGH COLOR BIT
  4977 00002A78 66D1E7              <1> 	SAL	DI, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  4978                              <1> 					; EXPAND BL TO FULL WORD OF COLOR
  4979 00002A7B 80E303              <1> 	AND	BL, 3			; ISOLATE THE COLOR BITS ( LOW 2 BITS )
  4980 00002A7E B055                <1> 	MOV	AL, 055H 		; GET BIT CONVERSION MULTIPLIER
  4981 00002A80 F6E3                <1> 	MUL	BL			; EXPAND 2 COLOR BITS TO 4 REPLICATIONS
  4982 00002A82 88C3                <1> 	MOV	BL, AL			; PLACE BACK IN WORK REGISTER
  4983 00002A84 88C7                <1> 	MOV	BH, AL			; EXPAND TO 8 REPLICATIONS OF COLOR BITS
  4984 00002A86 81C700800B00        <1> 	add	edi, 0B8000h
  4985                              <1> S7:                                     ; MED_CHAR
  4986 00002A8C 57                  <1> 	PUSH	eDI			; SAVE REGEN POINTER
  4987 00002A8D 56                  <1> 	PUSH	eSI			; SAVE THE CODE POINTER
  4988 00002A8E B604                <1> 	MOV	DH, 4			; NUMBER OF LOOPS
  4989                              <1> S8:
  4990 00002A90 AC                  <1> 	LODSB				; GET CODE POINT
  4991 00002A91 E8B3000000          <1> 	CALL	S21			; DOUBLE UP ALL THE BITS
  4992 00002A96 6621D8              <1> 	AND	AX, BX			; CONVERT TO FOREGROUND COLOR ( 0 BACK )
  4993 00002A99 86E0                <1> 	XCHG	AH, AL			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  4994 00002A9B F6C280              <1> 	TEST	DL, 80H			; IS THIS XOR FUNCTION
  4995 00002A9E 7403                <1> 	JZ	short S9		; NO, STORE IT IN AS IS
  4996 00002AA0 663307              <1> 	XOR	AX, [eDI]		; DO FUNCTION WITH LOW/HIGH
  4997                              <1> S9:
  4998 00002AA3 668907              <1> 	MOV	[eDI], AX		; STORE FIRST BYTE HIGH, SECOND LOW
  4999 00002AA6 AC                  <1> 	LODSB				; GET CODE POINT
  5000 00002AA7 E89D000000          <1> 	CALL	S21
  5001 00002AAC 6621D8              <1> 	AND	AX, BX			; CONVERT TO COLOR
  5002 00002AAF 86E0                <1> 	XCHG	AH, AL			; SWAP HIGH/LOW BYTES FOR WORD MOVE
  5003 00002AB1 F6C280              <1> 	TEST	DL, 80H			; AGAIN, IS THIS XOR FUNCTION
  5004 00002AB4 7407                <1> 	JZ	short _S10		; NO, JUST STORE THE VALUES
  5005 00002AB6 66338700200000      <1> 	XOR	AX, [eDI+2000H]		; FUNCTION WITH FIRST HALF LOW
  5006                              <1> _S10:
  5007 00002ABD 66898700200000      <1> 	MOV	[eDI+2000H], AX		; STORE SECOND PORTION HIGH
  5008 00002AC4 6683C750            <1> 	ADD	DI, 80			; POINT TO NEXT LOCATION
  5009 00002AC8 FECE                <1> 	DEC	DH
  5010 00002ACA 75C4                <1> 	JNZ	short S8		; KEEP GOING
  5011 00002ACC 5E                  <1> 	POP	eSI			; RECOVER CODE POINTER
  5012 00002ACD 5F                  <1> 	POP	eDI			; RECOVER REGEN POINTER
  5013 00002ACE 47                  <1> 	INC	eDI			; POINT TO NEXT CHAR POSITION
  5014 00002ACF 47                  <1> 	INC	eDI
  5015 00002AD0 E2BA                <1> 	LOOP	S7			; MORE TO WRITE
  5016 00002AD2 C3                  <1> 	retn
  5017                              <1> 
  5018                              <1> ; 04/07/2016
  5019                              <1> ; 01/07/2016
  5020                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5021                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5022                              <1> ;----------------------------------------
  5023                              <1> ; GRAPHICS READ
  5024                              <1> ;----------------------------------------
  5025                              <1> GRAPHICS_READ:
  5026 00002AD3 E8A3000000          <1> 	CALL	S26			; CONVERTED TO OFFSET IN REGEN
  5027 00002AD8 89C6                <1> 	MOV	eSI, eAX		; SAVE IN SI
  5028 00002ADA 81C600800B00        <1> 	add	esi, 0B8000h		; 01/07/2016
  5029 00002AE0 83EC08              <1> 	SUB	eSP, 8			; ALLOCATE SPACE FOR THE READ CODE POINT
  5030 00002AE3 89E5                <1> 	MOV	eBP, eSP		; POINTER TO SAVE AREA
  5031                              <1> 
  5032                              <1> ;-----	DETERMINE GRAPHICS MODES
  5033 00002AE5 B604                <1> 	mov	dh, 4			; number of passes ; 01/07/2016
  5034 00002AE7 803D[CA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6
  5035 00002AEE 7219                <1> 	JC	short S12		; MEDIUM RESOLUTION
  5036                              <1> 
  5037                              <1> ;-----	HIGH RESOLUTION READ
  5038                              <1> ;-----	GET VALUES FROM REGEN BUFFER AND CONVERT TO CODE POINT
  5039                              <1> 	;MOV	DH,4			; NUMBER OF PASSES
  5040                              <1> S11:
  5041 00002AF0 8A06                <1> 	MOV	AL, [eSI] 		; GET FIRST BYTE
  5042 00002AF2 884500              <1> 	MOV	[eBP], AL 		; SAVE IN STORAGE AREA
  5043 00002AF5 45                  <1> 	INC	eBP			; NEXT LOCATION
  5044 00002AF6 8A8600200000        <1> 	MOV	AL, [eSI+2000H]		; GET LOWER REGION BYTE
  5045 00002AFC 884500              <1> 	MOV	[eBP], AL 		; ADJUST AND STORE
  5046 00002AFF 45                  <1> 	INC	eBP
  5047 00002B00 83C650              <1> 	ADD	eSI, 80			; POINTER INTO REGEN
  5048 00002B03 FECE                <1> 	DEC	DH			; LOOP CONTROL
  5049 00002B05 75E9                <1> 	JNZ	short S11		; DO IT SOME MORE
  5050 00002B07 EB1D                <1> 	JMP	SHORT S14		; GO MATCH THE SAVED CODE POINTS
  5051                              <1> 
  5052                              <1> ;-----	MEDIUM RESOLUTION READ
  5053                              <1> S12:	
  5054 00002B09 66D1E6              <1> 	SAL	SI, 1			; OFFSET*2 SINCE 2 BYTES/CHAR
  5055                              <1> 	;MOV	DH, 4			; NUMBER OF PASSES
  5056                              <1> S13:
  5057 00002B0C E84D000000          <1> 	CALL	S23			; GET BYTES FROM REGEN INTO SINGLE SAVE
  5058 00002B11 81C6FE1F0000        <1> 	ADD	eSI, 2000H-2		; GO TO LOWER REGION
  5059 00002B17 E842000000          <1> 	CALL	S23			; GET THIS PAIR INTO SAVE
  5060 00002B1C 81EEB21F0000        <1> 	SUB	eSI, 2000H-80+2		; ADJUST POINTER BACK INTO UPPER
  5061 00002B22 FECE                <1> 	DEC	DH
  5062 00002B24 75E6                <1> 	JNZ	short S13		; KEEP GOING UNTIL ALL 8 DONE
  5063                              <1> 
  5064                              <1> ;-----	SAVE AREA HAS CHARACTER IN IT, MATCH IT
  5065                              <1> S14:					; FIND_CHAR
  5066 00002B26 BF[64600100]        <1> 	MOV	eDI, CRT_CHAR_GEN	; ESTABLISH ADDRESSING
  5067 00002B2B 83ED08              <1> 	SUB	eBP, 8			; ADJUST POINTER TO START OF SAVE AREA
  5068 00002B2E 89EE                <1> 	MOV	eSI, eBP
  5069                              <1> S15:
  5070 00002B30 66B80001            <1> 	mov	ax, 256			; NUMBER TO TEST AGAINST
  5071                              <1> S16:
  5072 00002B34 56                  <1> 	PUSH	eSI			; SAVE SAVE AREA POINTER
  5073 00002B35 57                  <1> 	PUSH	eDI			; SAVE CODE POINTER
  5074                              <1> 	;MOV	eCX, 4			; NUMBER OF WORDS TO MATCH
  5075                              <1> 	;REPE	CMPSW			; COMPARE THE 8 BYTES AS WORDS
  5076 00002B36 A7                  <1> 	cmpsd				; compare first 4 bytes 
  5077 00002B37 7501                <1> 	jne	short S17		; 
  5078 00002B39 A7                  <1> 	cmpsd				; compare last 4 bytes
  5079                              <1> S17:
  5080 00002B3A 5F                  <1> 	POP	eDI			; RECOVER THE POINTERS
  5081 00002B3B 5E                  <1> 	POP	eSI
  5082                              <1> 	;JZ	short S18		; IF ZERO FLAG SET, THEN MATCH OCCURRED
  5083 00002B3C 7407                <1> 	je	short S18
  5084                              <1> 	;				; NO MATCH, MOVE ON TO NEXT
  5085 00002B3E 83C708              <1> 	ADD	eDI, 8			; NEXT CODE POINT
  5086 00002B41 6648                <1> 	dec	ax			; LOOP CONTROL
  5087 00002B43 75EF                <1> 	JNZ	short S16		; DO ALL OF THEM
  5088                              <1> 
  5089                              <1> ;-----	CHARACTER IS FOUND ( AL=0 IF NOT FOUND )
  5090                              <1> S18:	
  5091 00002B45 83C408              <1> 	ADD	eSP, 8			; READJUST THE STACK, THROW AWAY SAVE
  5092 00002B48 C3                  <1> 	retn				; ALL DONE
  5093                              <1> 
  5094                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5095                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5096                              <1> ;--------------------------------------------
  5097                              <1> ; EXPAND BYTE
  5098                              <1> ;  THIS ROUTINE TAKES THE BYTE IN AL AND DOUBLES ALL
  5099                              <1> ;  OF THE BITS, TURNING THE 8 BITS INTO 16 BITS.
  5100                              <1> ;  THE RESULT IS LEFT IN AX
  5101                              <1> ;--------------------------------------------
  5102                              <1> S21:
  5103 00002B49 6651                <1> 	PUSH	CX			; SAVE REGISTER
  5104                              <1> 	;MOV	CX, 8			; SHIFT COUNT REGISTER FOR ONE BYTE
  5105 00002B4B B108                <1> 	mov	cl, 8
  5106                              <1> S22:
  5107 00002B4D D0C8                <1> 	ROR	AL,1			; SHIFT BITS, LOW BIT INTO CARRY FLAG
  5108 00002B4F 66D1DD              <1> 	RCR	BP,1			; MOVE CARRY FLAG (LOW BIT INTO RESULTS
  5109 00002B52 66D1FD              <1> 	SAR	BP,1			; SIGN EXTEND HIGH BIT (DOUBLE IT)
  5110                              <1> 	;LOOP	S22			; REPEAT FOR ALL 8 BITS
  5111 00002B55 FEC9                <1> 	dec	cl
  5112 00002B57 75F4                <1> 	jnz	short S22
  5113 00002B59 6695                <1> 	XCHG	AX, BP			; MOVE RESULTS TO PARAMETER REGISTER
  5114 00002B5B 6659                <1> 	POP	CX			; RECOVER REGISTER
  5115 00002B5D C3                  <1> 	RETn				; ALL DONE
  5116                              <1> 
  5117                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5118                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5119                              <1> ;--------------------------------------------------
  5120                              <1> ; MED_READ_BYTE
  5121                              <1> ; THIS ROUTINE WILL TAKE 2 BYTES FROM THE REGEN BUFFER,
  5122                              <1> ;  COMPARE AGAINST THE CURRENT FOREGROUND COLOR, AND PLACE
  5123                              <1> ;  THE CORRESPONDING ON/OFF BIT PATTERN INTO THE CURRENT
  5124                              <1> ;  POSITION IN THE SAVE AREA
  5125                              <1> ; ENTRY --
  5126                              <1> ;  SI,DS = POINTER TO REGEN AREA OF INTEREST
  5127                              <1> ;  BX = EXPANDED FOREGROUND COLOR
  5128                              <1> ;  BP = POINTER TO SAVE AREA
  5129                              <1> ; EXIT --
  5130                              <1> ;  SI AND BP ARE INCREMENTED
  5131                              <1> ;----------------------------------------------------
  5132                              <1> S23:
  5133 00002B5E 66AD                <1> 	LODSW				; GET FIRST BYTE AND SECOND BYTES
  5134 00002B60 86C4                <1> 	XCHG	AL, AH			; SWAP FOR COMPARE
  5135 00002B62 66B900C0            <1> 	MOV	CX, 0C000H		; 2 BIT MASK TO TEST THE ENTRIES
  5136 00002B66 B200                <1> 	MOV	DL, 0			; RESULT REGISTER
  5137                              <1> S24:
  5138 00002B68 6685C8              <1> 	TEST	AX, CX			; IS THIS SECTION BACKCROUND?
  5139 00002B6B 7401                <1>         JZ      short S25               ; IF ZERO, IT IS BACKGROUND (CARRY=0)
  5140 00002B6D F9                  <1> 	STC				; WASN'T, SO SET CARRY
  5141                              <1> S25:
  5142 00002B6E D0D2                <1> 	RCL	DL, 1			; MOVE THAT BIT INTO THE RESULT
  5143 00002B70 66C1E902            <1> 	SHR	CX, 2			; MOVE THE MASK TO THE RIGHT BY 2 BITS
  5144 00002B74 73F2                <1> 	JNC	short S24		; DO IT AGAIN IF MASK DIDN'T FALL OUT
  5145 00002B76 885500              <1> 	MOV	[eBP], DL 		; STORE RESULT IN SAVE AREA
  5146 00002B79 45                  <1> 	INC	eBP			; ADJUST POINTER
  5147 00002B7A C3                  <1> 	RETn				; ALL DONE
  5148                              <1> 
  5149                              <1> ; 30/06/2016 - TRDOS 386 (TRDOS v2.0)
  5150                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5151                              <1> ;-----------------------------------------
  5152                              <1> ; V4_POSITION
  5153                              <1> ;  THIS ROUTINE TAKES THE CURSOR POSITION CONTAINED IN
  5154                              <1> ;  THE MEMORY LOCATION, AND CONVERTS IT INTO AN OFFSET
  5155                              <1> ;  INTO THE REGEN BUFFER, ASSUMING ONE BYTE/CHAR.
  5156                              <1> ;  FOR MEDIUM RESOLUTION GRAPHICS, THE NUMBER MUST
  5157                              <1> ;  BE DOUBLED.
  5158                              <1> ; ENTRY -- NO REGISTERS,MEMORY LOCATION @CURSOR_POSN IS USED
  5159                              <1> ; EXIT--
  5160                              <1> ;  AX CONTAINS OFFSET INTO REGEN BUFFER
  5161                              <1> ;-----------------------------------------
  5162                              <1> S26:
  5163 00002B7B 0FB705[EE890100]    <1> 	movzx	eax, word [CURSOR_POSN]	; GET CURRENT CURSOR
  5164                              <1> GRAPH_POSN:
  5165 00002B82 53                  <1> 	PUSH	eBX			; SAVE REGISTER
  5166 00002B83 0FB6D8              <1> 	movzx	ebx, al			; SAVE A COPY OF CURRENT CURSOR
  5167 00002B86 A0[CC6F0000]        <1> 	MOV	AL, [CRT_COLS]		; GET BYTES PER COLUMN
  5168 00002B8B F6E4                <1> 	MUL	AH			; MULTIPLY BY ROWS
  5169 00002B8D 66C1E002            <1> 	SHL	AX, 2			; MULTIPLY * 4 SINCE 4 ROWS/BYTE
  5170 00002B91 01D8                <1> 	ADD	eAX, eBX		; DETERMINE OFFSET
  5171 00002B93 5B                  <1> 	POP	eBX			; RECOVER POINTER
  5172 00002B94 C3                  <1> 	RETn				; ALL DONE
  5173                              <1> 
  5174                              <1> ; 09/07/2016
  5175                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5176                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5177                              <1> ;---------------------------------------------
  5178                              <1> ; SET_COLOR
  5179                              <1> ;	THIS ROUTINE WILL ESTABLISH THE BACKGROUND COLOR, THE OVERSCAN COLOR,
  5180                              <1> ;	AND THE FOREGROUND COLOR SET FOR MEDIUM RESOLUTION GRAPHICS
  5181                              <1> ; INPUT
  5182                              <1> ;	(BH) HAS COLOR ID
  5183                              <1> ;		IF BH=0, THE BACKGROUND COLOR VALUE IS SET
  5184                              <1> ;			FROM THE LOW BITS OF BL (0-31)
  5185                              <1> ;		IF BH=1, THE PALETTE SELECTION IS MADE
  5186                              <1> ;			BASED ON THE LOW BIT OF BL:
  5187                              <1> ;				0 = GREEN, RED, YELLOW FOR COLORS 1,2,3
  5188                              <1> ;				1 = BLUE, CYAN, MAGENTA FOR COLORS 1,2,3
  5189                              <1> ;	(BL) HAS THE COLOR VALUE TO BE USED
  5190                              <1> ; OUTPUT
  5191                              <1> ;	THE COLOR SELECTION IS UPDATED
  5192                              <1> ;----------------------------------------------
  5193                              <1> SET_COLOR:
  5194 00002B95 803D[CA6F0000]07    <1>         cmp     byte [CRT_MODE], 7      ; 09/07/2016
  5195 00002B9C 0F87B5EFFFFF        <1> 	ja	VIDEO_RETURN		; nothing to do for VGA modes	 
  5196                              <1> 
  5197                              <1> 	;MOV	DX, [ADDR_6845]		; I/O PORT FOR PALETTE
  5198                              <1> 	;mov	dx, 3D4h
  5199                              <1> 	;ADD	DX,5			; OVERSCAN PORT
  5200 00002BA2 66BAD903            <1> 	mov	dx, 3D9h
  5201 00002BA6 A0[CD6F0000]        <1> 	MOV	AL, [CRT_PALETTE] 	; GET THE CURRENT PALETTE VALUE
  5202 00002BAB 08FF                <1> 	OR	BH, BH			; IS THIS COLOR 0?
  5203 00002BAD 7512                <1> 	JNZ	short M20		; OUTPUT COLOR 1
  5204                              <1> 
  5205                              <1> ;-----	HANDLE COLOR 0 BY SETTING THE BACKGROUND COLOR
  5206                              <1> 
  5207 00002BAF 24E0                <1> 	AND	AL, 0E0H 		; TURN OFF LOW 5 BITS OF CURRENT
  5208 00002BB1 80E31F              <1> 	AND	BL, 01FH 		; TURN OFF HIGH 3 BITS OF INPUT VALUE
  5209 00002BB4 08D8                <1> 	OR	AL, BL			; PUT VALUE INTO REGISTER
  5210                              <1> M19:					; OUTPUT THE PALETTE
  5211 00002BB6 EE                  <1> 	OUT	DX, AL			; OUTPUT COLOR SELECTION TO 3D9 PORT
  5212 00002BB7 A2[CD6F0000]        <1> 	MOV	[CRT_PALETTE], AL 	; SAVE THE COLOR VALUE
  5213 00002BBC E996EFFFFF          <1> 	JMP	VIDEO_RETURN
  5214                              <1> 
  5215                              <1> ;-----	HANDLE COLOR 1 BY SELECTING THE PALETTE TO BE USED
  5216                              <1> 
  5217                              <1> M20:
  5218 00002BC1 24DF                <1> 	AND	AL, 0DFH 		; TURN OFF PALETTE SELECT BIT
  5219 00002BC3 D0EB                <1> 	SHR	BL, 1			; TEST THE LOW ORDER BIT OF BL
  5220 00002BC5 73EF                <1> 	JNC	short M19		; ALREADY DONE
  5221 00002BC7 0C20                <1> 	OR	AL, 20H			; TURN ON PALETTE SELECT BIT
  5222 00002BC9 EBEB                <1> 	JMP	short M19		; GO DO IT
  5223                              <1> 
  5224                              <1> ; 09/07/2016
  5225                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5226                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5227                              <1> ;--------------------------------------------
  5228                              <1> ; READ DOT -- WRITE DOT
  5229                              <1> ; THESE ROUTINES WILL WRITE A DOT, OR READ THE
  5230                              <1> ;  DOT AT THE INDICATED LOCATION
  5231                              <1> ; ENTRY --
  5232                              <1> ;   DX = ROW (0-199)	(THE ACTUAL VALUE DEPENDS ON THE MODE)
  5233                              <1> ;   CX = COLUMN ( 0-639) ( THE VALUES ARE NOT RANGE CHECKED )
  5234                              <1> ;   AL = DOT VALUE TO WRITE (1,2 OR 4 BITS DEPENDING ON MODE,
  5235                              <1> ;	REQUIRED FOR WRITE DOT ONLY, RIGHT JUSTIFIED)
  5236                              <1> ;	BIT 7 OF AL = 1 INDICATES XOR THE VALUE INTO THE LOCATION
  5237                              <1> ;   DS = DATA SEGMENT
  5238                              <1> ;   ES = REGEN SEGMENT
  5239                              <1> ;
  5240                              <1> ; EXIT
  5241                              <1> ;	AL = DOT VALUE READ, RIGHT JUSTIFIED, READ ONLY
  5242                              <1> ;----------------------------------------------
  5243                              <1> 
  5244                              <1> READ_DOT:
  5245                              <1> 	; 09/07/2016
  5246 00002BCB 8A25[CA6F0000]      <1> 	mov	ah,  [CRT_MODE]
  5247 00002BD1 80FC07              <1> 	cmp	ah, 7 ; 6!?
  5248 00002BD4 760A                <1> 	jna	short read_dot_cga
  5249                              <1> 
  5250 00002BD6 E8D7030000          <1> 	call	vga_read_pixel
  5251                              <1> 	; al = pixel value
  5252 00002BDB E97CEFFFFF          <1> 	jmp	_video_return
  5253                              <1> 
  5254                              <1> read_dot_cga:
  5255                              <1> 	;je	VIDEO_RETURN ; 7	
  5256 00002BE0 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  5257 00002BE3 0F826EEFFFFF        <1> 	jb	VIDEO_RETURN ; no, text mode, nothing to do
  5258                              <1> 
  5259 00002BE9 E855000000          <1> 	CALL	R3			; DETERMINE BYTE POSITION OF DOT
  5260 00002BEE 8A06                <1> 	MOV	AL, [eSI]		; GET THE BYTE
  5261 00002BF0 20E0                <1> 	AND	AL, AH			; MASK OFF THE OTHER BITS IN THE BYTE
  5262 00002BF2 D2E0                <1> 	SHL	AL, CL			; LEFT JUSTIFY THE VALUE
  5263 00002BF4 88F1                <1> 	MOV	CL, DH			; GET NUMBER OF BITS IN RESULT
  5264 00002BF6 D2C0                <1> 	ROL	AL, CL			; RIGHT JUSTIFY THE RESULT
  5265                              <1> 	;JMP	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  5266 00002BF8 0FB6C0              <1> 	movzx	eax, al
  5267 00002BFB E95CEFFFFF          <1> 	jmp	_video_return
  5268                              <1> 
  5269                              <1> ; 09/07/2016
  5270                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5271                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5272                              <1> 
  5273                              <1> WRITE_DOT:
  5274                              <1> 	; 09/07/2016
  5275 00002C00 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE]
  5276 00002C06 80FC07              <1> 	cmp	ah, 7 ; 6!?
  5277 00002C09 760A                <1> 	jna	short write_dot_cga
  5278                              <1> 	
  5279 00002C0B E811030000          <1> 	call	vga_write_pixel
  5280 00002C10 E942EFFFFF          <1> 	jmp	VIDEO_RETURN
  5281                              <1> 
  5282                              <1> write_dot_cga:
  5283                              <1> 	;je	VIDEO_RETURN ; 7	
  5284 00002C15 80FC04              <1> 	cmp	ah, 4 ; graphics ? 
  5285 00002C18 0F8239EFFFFF        <1> 	jb	VIDEO_RETURN ; no, text mode, nothing to do
  5286                              <1> 
  5287                              <1> 	;PUSH	AX			; SAVE DOT VALUE
  5288 00002C1E 6650                <1> 	PUSH	AX			; TWICE
  5289 00002C20 E81E000000          <1> 	CALL	R3			; DETERMINE BYTE POSITION OF THE DOT
  5290 00002C25 D2E8                <1> 	SHR	AL, CL			; SHIFT TO SET UP THE BITS FOR OUTPUT
  5291 00002C27 20E0                <1> 	AND	AL, AH			; STRIP OFF THE OTHER BITS
  5292 00002C29 8A0E                <1> 	MOV	CL, [eSI]		; GET THE CURRENT BYTE
  5293 00002C2B 665B                <1> 	POP	BX			; RECOVER XOR FLAG
  5294 00002C2D F6C380              <1> 	TEST	BL, 80H			; IS IT ON
  5295 00002C30 750D                <1> 	JNZ	short R2		; YES, XOR THE DOT
  5296 00002C32 F6D4                <1> 	NOT	AH			; SET MASK TO REMOVE THE INDICATED BITS
  5297 00002C34 20E1                <1> 	AND	CL, AH
  5298 00002C36 08C8                <1> 	OR	AL, CL			; OR IN THE NEW VALUE OF THOSE BITS
  5299                              <1> R1:					; FINISH_DOT
  5300 00002C38 8806                <1> 	MOV	[eSI], AL		; RESTORE THE BYTE IN MEMORY
  5301                              <1> 	;POP	AX
  5302 00002C3A E918EFFFFF          <1> 	JMP	VIDEO_RETURN		; RETURN FROM VIDEO I/O
  5303                              <1> R2:					; XOR_DOT
  5304 00002C3F 30C8                <1> 	XOR	AL, CL			; EXCLUSIVE OR THE DOTS
  5305 00002C41 EBF5                <1> 	JMP	short R1		; FINISH UP THE WRITING
  5306                              <1> 
  5307                              <1> ; 01/07/2016 - TRDOS 386 (TRDOS v2.0)
  5308                              <1> ; VIDEO1.ASM - 24/03/1985 (IBM PC-AT BIOS source code)
  5309                              <1> 
  5310                              <1> ;----------------------------------------------
  5311                              <1> ; THIS SUBROUTINE DETERMINES THE REGEN BYTE LOCATION OF THE
  5312                              <1> ; INDICATED ROW COLUMN VALUE IN GRAPHICS MODE.
  5313                              <1> ; ENTRY --
  5314                              <1> ;  DX = ROW VALUE (0-199)
  5315                              <1> ;  CX = COLUMN VALUE (0-639)
  5316                              <1> ; EXIT --
  5317                              <1> ;  SI = OFFSET INTO REGEN BUFFER FOR BYTE OF INTEREST
  5318                              <1> ;  AH = MASK TO STRIP OFF THE BITS OF INTEREST
  5319                              <1> ;  CL = BITS TO SHIFT TO RIGHT JUSTIFY THE MASK IN AH
  5320                              <1> ;  DH = # BITS IN RESULT
  5321                              <1> ;  BX = MODIFIED
  5322                              <1> ;-----------------------------------------------
  5323                              <1> R3:
  5324                              <1> 
  5325                              <1> ;-----	DETERMINE 1ST BYTE IN INDICATED ROW BY MULTIPLYING ROW VALUE BY 40
  5326                              <1> ;-----	 ( LOW BIT OF ROW DETERMINES EVEN/ODD, 80 BYTES/ROW )
  5327                              <1> 
  5328 00002C43 0FB7F0              <1> 	movzx	esi, ax			; WILL SAVE AL AND AH DURING OPERATION
  5329 00002C46 B028                <1> 	MOV	AL, 40
  5330 00002C48 F6E2                <1> 	MUL	DL			; AX= ADDRESS OF START OF INDICATED ROW
  5331 00002C4A A808                <1> 	TEST	AL, 08H 		; TEST FOR EVEN/ODD ROW CALCULATED
  5332 00002C4C 7404                <1> 	JZ	short R4		; JUMP IF EVEN ROW
  5333 00002C4E 6605D81F            <1> 	ADD	AX, 2000H-40		; OFFSET TO LOCATION OF ODD ROWS ADJUST
  5334                              <1> R4:					; EVEN_ROW
  5335 00002C52 6696                <1> 	XCHG	SI, AX			; MOVE POINTER TO (SI) AND RECOVER (AX)
  5336 00002C54 81C600800B00        <1> 	add	esi, 0B8000h
  5337 00002C5A 6689CA              <1> 	MOV	DX, CX			; COLUMN VALUE TO DX
  5338                              <1> 
  5339                              <1> ;-----	DETERMINE GRAPHICS MODE CURRENTLY IN EFFECT
  5340                              <1> 
  5341                              <1> ; SET UP THE REGISTERS ACCORDING TO THE MODE
  5342                              <1> ; CH = MASK FOR LOW OF COLUMN ADDRESS ( 7/3 FOR HIGH/MED RES )
  5343                              <1> ; CL = # OF ADDRESS BITS IN COLUMN VALUE ( 3/2 FOR H/M )
  5344                              <1> ; BL = MASK TO SELECT BITS FROM POINTED BYTE ( 80H/C0H FOR H/M )
  5345                              <1> ; BH = NUMBER OF VALID BITS IN POINTED BYTE ( 1/2 FOR H/M )
  5346                              <1> 
  5347 00002C5D 66BBC002            <1> 	MOV	BX, 2C0H
  5348 00002C61 66B90203            <1> 	MOV	CX, 302H 		; SET PARMS FOR MED RES
  5349 00002C65 803D[CA6F0000]06    <1> 	CMP	byte [CRT_MODE], 6
  5350 00002C6C 7208                <1> 	JC	short R5		; HANDLE IF MED RES
  5351 00002C6E 66BB8001            <1> 	MOV	BX, 180H
  5352 00002C72 66B90307            <1> 	MOV	CX, 703H 		; SET PARMS FOR HIGH RES
  5353                              <1> 
  5354                              <1> ;-----	DETERMINE BIT OFFSET IN BYTE FROM COLUMN MASK
  5355                              <1> R5:
  5356 00002C76 20D5                <1> 	AND	CH, DL			; ADDRESS OF PEL WITHIN BYTE TO CH
  5357                              <1> 
  5358                              <1> ;-----	DETERMINE BYTE OFFSET FOR THIS LOCATION IN COLUMN
  5359                              <1> 
  5360 00002C78 66D3EA              <1> 	SHR	DX, CL			; SHIFT BY CORRECT AMOUNT
  5361 00002C7B 6601D6              <1> 	ADD	SI, DX			; INCREMENT THE POINTER
  5362 00002C7E 88FE                <1> 	MOV	DH, BH			; GET THE # OF BITS IN RESULT TO DH
  5363                              <1> 
  5364                              <1> ;-----	MULTIPLY BH (VALID BITS IN BYTE) BY CH (BIT OFFSET)
  5365                              <1> 
  5366 00002C80 28C9                <1> 	SUB	CL, CL			; ZERO INTO STORAGE LOCATION
  5367                              <1> R6:
  5368 00002C82 D0C8                <1> 	ROR	AL, 1			; LEFT JUSTIFY VALUE IN AL (FOR WRITE)
  5369 00002C84 00E9                <1> 	ADD	CL, CH			; ADD IN THE BIT OFFSET VALUE
  5370 00002C86 FECF                <1> 	DEC	BH			; LOOP CONTROL
  5371 00002C88 75F8                <1> 	JNZ	short R6		; ON EXIT, CL HAS COUNT TO RESTORE BITS
  5372 00002C8A 88DC                <1> 	MOV	AH, BL			;  GET MASK TO AH
  5373 00002C8C D2EC                <1> 	SHR	AH, CL			;  MOVE THE MASK TO CORRECT LOCATION
  5374 00002C8E C3                  <1> 	RETn				;  RETURN WITH EVERYTHING SET UP
  5375                              <1> 
  5376                              <1> load_dac_palette:
  5377                              <1> 	; 29/07/2016
  5378                              <1> 	; 23/07/2016
  5379                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  5380                              <1> 	; (set_mode_vga)
  5381                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5382                              <1> 	; vgabios-0.7a (2011)
  5383                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5384                              <1> 	; 'vgabios.c', 'load_dac_palette'
  5385                              <1> 	;
  5386                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  5387                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  5388                              <1> 	;
  5389                              <1> 	; INPUT -> AH = DAC selection number (3, 2 or 1)
  5390                              <1> 	; OUTPUT -> ECX = 0, AX = 0
  5391                              <1> 	; (Modifed registers: EAX, ECX, EDX, ESI)
  5392                              <1> 	;
  5393 00002C8F 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  5394 00002C93 28C0                <1> 	sub	al, al ; 0
  5395 00002C95 EE                  <1> 	out	dx, al ; 0 ; color index, always 0 at the beginning	
  5396 00002C96 6642                <1> 	inc	dx   ; 3C9h ; VGAREG_DAC_DATA
  5397 00002C98 B900010000          <1> 	mov	ecx, 256   ; always 256*3 values
  5398                              <1> 	;push	esi
  5399 00002C9D 88E0                <1> 	mov	al, ah
  5400 00002C9F B43F                <1> 	mov	ah, 3Fh	; 3Fh except DAC selection number 3
  5401 00002CA1 3C02                <1> 	cmp 	al, 2
  5402 00002CA3 7414                <1> 	je	short l_dac_p_2
  5403 00002CA5 7719                <1> 	ja	short l_dac_p_3
  5404 00002CA7 20C0                <1> 	and	al, al
  5405 00002CA9 7507                <1> 	jnz	short l_dac_p_1
  5406                              <1> l_dac_p_0:
  5407 00002CAB BE[245B0100]        <1> 	mov	esi, palette0
  5408 00002CB0 EB15                <1> 	jmp	short l_dac_p_4	
  5409                              <1> l_dac_p_1:
  5410 00002CB2 BE[E45B0100]        <1> 	mov	esi, palette1
  5411 00002CB7 EB0E                <1> 	jmp	short l_dac_p_4
  5412                              <1> l_dac_p_2:
  5413 00002CB9 BE[A45C0100]        <1> 	mov	esi, palette2
  5414 00002CBE EB07                <1> 	jmp	short l_dac_p_4
  5415                              <1> l_dac_p_3:
  5416 00002CC0 B4FF                <1> 	mov	ah, 0FFh ; dac registers
  5417 00002CC2 BE[645D0100]        <1> 	mov	esi, palette3
  5418                              <1> l_dac_p_4:
  5419 00002CC7 AC                  <1> 	lodsb
  5420 00002CC8 EE                  <1> 	out	dx, al  ; Red
  5421 00002CC9 AC                  <1> 	lodsb
  5422 00002CCA EE                  <1> 	out	dx, al	; Green
  5423 00002CCB AC                  <1> 	lodsb
  5424 00002CCC EE                  <1> 	out	dx, al	; Blue
  5425 00002CCD 20E4                <1> 	and	ah, ah
  5426 00002CCF 7405                <1> 	jz	short l_dac_p_5	
  5427 00002CD1 FECC                <1> 	dec	ah
  5428 00002CD3 E2F2                <1> 	loop	l_dac_p_4
  5429                              <1> 	;pop	esi
  5430 00002CD5 C3                  <1> 	retn
  5431                              <1> l_dac_p_5:
  5432                              <1> 	; 29/07/2016
  5433 00002CD6 FEC9                <1> 	dec	cl
  5434 00002CD8 7407                <1> 	jz	short l_dac_p_7
  5435                              <1> 	;
  5436 00002CDA 28C0                <1> 	sub	al, al ; 0
  5437                              <1> l_dac_p_6:
  5438 00002CDC EE                  <1> 	out	dx, al ; outb(VGAREG_DAC_DATA,0);
  5439 00002CDD EE                  <1> 	out	dx, al
  5440 00002CDE EE                  <1> 	out	dx, al
  5441 00002CDF E2FB                <1> 	loop	l_dac_p_6
  5442                              <1> l_dac_p_7:
  5443                              <1> 	;pop	esi
  5444 00002CE1 C3                  <1> 	retn
  5445                              <1> 
  5446                              <1> gray_scale_summing:
  5447                              <1> 	; 03/07/2016 (TRDOS 386 = TRDOS v2.0)
  5448                              <1> 	; (set_mode_vga)
  5449                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5450                              <1> 	; vgabios-0.7a (2011)
  5451                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5452                              <1> 	; 'vgabios.c', 'biosfn_perform_gray_scale_summing'
  5453                              <1> 	;
  5454                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
  5455                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
  5456                              <1> 	;
  5457                              <1> 
  5458                              <1> 	; INPUT -> EBX = Start address (color index <= 255)
  5459                              <1> 	;	   ECX = Count (<= 256)
  5460                              <1> 	; OUTPUT -> (E)CX = 0
  5461                              <1> 	; (Modifed registers: EAX, ECX, EDX, EBX)
  5462                              <1> 
  5463 00002CE2 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  5464 00002CE6 EC                  <1> 	in	al, dx
  5465 00002CE7 30C0                <1> 	xor	al, al ; 0
  5466 00002CE9 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  5467 00002CED EE                  <1> 	out	dx, al	; clear bit 5
  5468                              <1> 			; (while loading palette registers)
  5469                              <1> 	; set read address and switch to read mode
  5470                              <1> g_s_s_1:
  5471 00002CEE 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  5472 00002CF2 88D8                <1> 	mov	al, bl
  5473 00002CF4 EE                  <1> 	out	dx, al
  5474                              <1> 	; get 6-bit wide RGB data values
  5475                              <1>  	; intensity = (0.3*Red)+(0.59*Green)+(0.11*Blue)
  5476                              <1> 	; i = ( ( 77*r + 151*g + 28*b ) + 0x80 ) >> 8;
  5477 00002CF5 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  5478 00002CF9 EC                  <1> 	in	al, dx ; red
  5479 00002CFA B44D                <1> 	mov	ah, 77 ; 0.3* Red
  5480 00002CFC F6E4                <1> 	mul	ah
  5481 00002CFE 6650                <1> 	push	ax
  5482 00002D00 EC                  <1> 	in	al, dx ; green
  5483 00002D01 B497                <1> 	mov	ah, 151  ; 0.59 * Green
  5484 00002D03 F6E4                <1> 	mul	ah
  5485 00002D05 6650                <1> 	push	ax
  5486 00002D07 EC                  <1> 	in	al, dx ; blue
  5487 00002D08 B41C                <1> 	mov	ah, 28 ; 0.11 * Blue
  5488 00002D0A F6E4                <1> 	mul	ah
  5489 00002D0C 665A                <1> 	pop	dx
  5490 00002D0E 6601D0              <1> 	add	ax, dx
  5491 00002D11 665A                <1> 	pop	dx
  5492 00002D13 6601D0              <1> 	add	ax, dx
  5493 00002D16 66058000            <1> 	add	ax, 80h  
  5494 00002D1A B03F                <1> 	mov	al, 3Fh
  5495 00002D1C 38C4                <1> 	cmp	ah, al	; if(i>0x3f)i=0x3f
  5496 00002D1E 7602                <1> 	jna	short g_s_s_2
  5497 00002D20 88C4                <1> 	mov	ah, al
  5498                              <1> g_s_s_2:
  5499 00002D22 66BAC803            <1> 	mov	dx, 3C8h  ; VGAREG_DAC_WRITE_ADDRESS
  5500 00002D26 88D8                <1> 	mov	al, bl ; color index
  5501 00002D28 EE                  <1> 	out	dx, al
  5502 00002D29 88E0                <1> 	mov	al, ah ; intensity
  5503 00002D2B 6642                <1> 	inc	dx ; 3C9h ; VGAREG_DAC_DATA
  5504 00002D2D EE                  <1> 	out	dx, al ; R (R=G=B)
  5505 00002D2E 88E0                <1> 	mov	al, ah ; intensity
  5506 00002D30 EE                  <1> 	out	dx, al ; G (R=G=B)
  5507 00002D31 88E0                <1>  	mov	al, ah ; intensity
  5508 00002D33 EE                  <1> 	out	dx, al ; B (R=G=B)
  5509 00002D34 6649                <1> 	dec	cx
  5510 00002D36 7404                <1> 	jz	short g_s_s_3
  5511 00002D38 FEC3                <1> 	inc	bl    ; next color index value
  5512 00002D3A EBB2                <1> 	jmp	short g_s_s_1
  5513                              <1> g_s_s_3:
  5514 00002D3C 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  5515 00002D40 EC                  <1> 	in	al, dx
  5516 00002D41 B020                <1> 	mov	al, 20h
  5517 00002D43 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  5518 00002D47 EE                  <1> 	out	dx, al ; 20h -> set bit 5
  5519                              <1> 		        ; (after loading palette regs)	
  5520 00002D48 C3                  <1> 	retn
  5521                              <1> 
  5522                              <1> vga_write_char_attr:
  5523                              <1> vga_write_char_only: 
  5524                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  5525                              <1> 	;
  5526                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5527                              <1> 	; vgabios-0.7a (2011)
  5528                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5529                              <1> 	; 'vgabios.c', 'biosfn_write_char_attr'
  5530                              <1> 	; 'biosfn_write_char_only'
  5531                              <1> 
  5532                              <1> 	; INPUT ->
  5533                              <1> 	; [CRT_MODE] = current video mode (>7)
  5534                              <1> 	; CX = Count of characters to write
  5535                              <1> 	; AL = Character to write
  5536                              <1> 	; BL = Color of character
  5537                              <1> 	; OUTPUT ->
  5538                              <1> 	; Regen buffer updated
  5539                              <1>  
  5540 00002D49 8A25[CA6F0000]      <1> 	mov 	ah, [CRT_MODE]
  5541 00002D4F 668B15[EE890100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  5542                              <1> 
  5543 00002D56 BE[E66F0000]        <1> 	mov	esi, vga_modes
  5544 00002D5B 89F7                <1> 	mov	edi, esi
  5545 00002D5D 83C710              <1> 	add	edi, vga_mode_count
  5546                              <1> vga_wca_0:
  5547 00002D60 AC                  <1> 	lodsb
  5548 00002D61 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  5549 00002D63 7405                <1> 	je	short vga_wca_2
  5550 00002D65 39FE                <1> 	cmp	esi, edi
  5551 00002D67 72F7                <1> 	jb	short vga_wca_0
  5552                              <1> vga_wca_1:
  5553 00002D69 C3                  <1> 	retn	; nothing to do
  5554                              <1> vga_wca_2:
  5555 00002D6A 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  5556                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  5557                              <1> 
  5558                              <1> 	; biosfn_write_char_attr (car,page,attr,count) 
  5559                              <1> 	; AL = car, page = 0, BL = attr, CX = count
  5560 00002D6D 803E04              <1> 	cmp	byte [esi], PLANAR4
  5561 00002D70 741D                <1> 	je	short vga_wca_planar
  5562 00002D72 803E03              <1> 	cmp	byte [esi], PLANAR1
  5563 00002D75 7418                <1> 	je	short vga_wca_planar
  5564                              <1> vga_wca_linear8:
  5565                              <1> 	; while((count-->0) && (xcurs<nbcols))
  5566                              <1> 	; CX = count
  5567 00002D77 6621C9              <1> 	and	cx, cx
  5568 00002D7A 74ED                <1> 	jz	short vga_wca_1
  5569 00002D7C 3A15[CC6F0000]      <1> 	cmp	dl, [CRT_COLS]
  5570 00002D82 73E5                <1> 	jnb	short vga_wca_1
  5571                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  5572                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  5573                              <1> 	; [CRT_COLS] = nbcols
  5574 00002D84 E81E000000          <1> 	call	write_gfx_char_lin	 
  5575 00002D89 6649                <1> 	dec	cx ; count
  5576 00002D8B FEC2                <1> 	inc	dl ; xcurs
  5577 00002D8D EBE8                <1> 	jmp	short vga_wca_linear8
  5578                              <1> vga_wca_planar:
  5579                              <1> 	; while((count-->0) && (xcurs<nbcols))
  5580                              <1> 	; CX = count
  5581 00002D8F 6621C9              <1> 	and	cx, cx
  5582 00002D92 74D5                <1> 	jz	short vga_wca_1
  5583 00002D94 3A15[CC6F0000]      <1> 	cmp	dl, [CRT_COLS]
  5584 00002D9A 73CD                <1> 	jnb	short vga_wca_1
  5585                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  5586                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  5587                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  5588 00002D9C E8A9000000          <1> 	call	write_gfx_char_pl4
  5589 00002DA1 6649                <1> 	dec	cx ; count
  5590 00002DA3 FEC2                <1> 	inc	dl ; xcurs
  5591 00002DA5 EBE8                <1> 	jmp	short vga_wca_planar
  5592                              <1> 
  5593                              <1> write_gfx_char_lin:
  5594                              <1> 	; 08/01/2021
  5595                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  5596                              <1> 	; 08/08/2016
  5597                              <1> 	; 31/07/2016
  5598                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  5599                              <1> 	;
  5600                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5601                              <1> 	; vgabios-0.7a (2011)
  5602                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5603                              <1> 	; 'vgabios.c', 'write_gfx_char_lin'
  5604                              <1> 
  5605                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols)
  5606                              <1> 	; INPUT ->
  5607                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  5608                              <1> 	; [CRT_COLS] = nbcols
  5609                              <1> 	; OUTPUT ->
  5610                              <1> 	; Regen buffer updated
  5611                              <1> 
  5612 00002DA7 51                  <1> 	push	ecx
  5613 00002DA8 53                  <1> 	push	ebx
  5614 00002DA9 52                  <1> 	push	edx
  5615 00002DAA 50                  <1> 	push	eax
  5616                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  5617                              <1> 	; 08/08/2016
  5618 00002DAB 0FB6F0              <1> 	movzx	esi, al ; car
  5619                              <1> 	; 08/01/2021
  5620                              <1> 	;movzx	eax, dh ; ycurs
  5621                              <1> 	;mov	ah, [CRT_COLS] ; nbcols
  5622                              <1> 	;mul	ah
  5623 00002DAE A0[CC6F0000]        <1> 	mov	al, [CRT_COLS]
  5624 00002DB3 F6E6                <1> 	mul	dh
  5625                              <1> 	;shl	ax, 6 ; * 64
  5626 00002DB5 66C1E003            <1>  	shl	ax, 3 ; 8 * ycurs * [CRT_COLS]
  5627                              <1> 	;sub	dh, dh
  5628                              <1> 	;shl	dx, 3 ; xcurs * 8
  5629                              <1> 	;movzx	edi, dx
  5630 00002DB9 BF00000A00          <1> 	mov	edi, 0A0000h
  5631 00002DBE 30F6                <1> 	xor	dh, dh
  5632 00002DC0 6689D7              <1> 	mov	di, dx
  5633                              <1> 	;movzx	edi, dl
  5634 00002DC3 66C1E703            <1> 	shl	di, 3 ; xcurs * 8
  5635                              <1> 	;xor	dh, dh
  5636 00002DC7 8A15[CE6F0000]      <1> 	mov	dl, [CHAR_HEIGHT]
  5637 00002DCD 66F7E2              <1> 	mul	dx
  5638                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
  5639                              <1> 	;add	edi, eax ; addr
  5640                              <1> 	;add	edi, 0A0000h
  5641 00002DD0 6601C7              <1> 	add	di, ax
  5642                              <1> 	;shl	si, 3 ; car * 8
  5643 00002DD3 30E4                <1> 	xor	ah, ah
  5644 00002DD5 A0[CE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  5645 00002DDA 66F7E6              <1> 	mul	si
  5646 00002DDD 6689C6              <1> 	mov	si, ax
  5647                              <1> 	;; esi = src = car * 8
  5648                              <1> 	; esi = src = car * [CHAR_HEIGHT]
  5649                              <1> 	; i = 0
  5650                              <1> 	;add	esi, vgafont8 ; fdata [src+i]
  5651                              <1> 	; 08/08/2016
  5652 00002DE0 A1[7A960100]        <1> 	mov	eax, [VGA_INT43H]
  5653 00002DE5 09C0                <1> 	or	eax, eax ; 0 ?
  5654 00002DE7 743F                <1> 	jz	short wfxl_7 ; yes, default font
  5655                              <1> 	;cmp	eax, vgafont16
  5656                              <1>         ;je	short wgfxl_0
  5657                              <1> 	;cmp	eax, vgafont14
  5658                              <1> 	;je	short wgfxl_0
  5659                              <1> 	;cmp	eax, vgafont8
  5660                              <1> 	;je	short wgfxl_0
  5661                              <1> 	;; 05/01/2021 (TRDOS 386 v2.0.3)
  5662                              <1> 	;; user font  
  5663                              <1> 	;mov	eax, VGAFONTUSR ; 8x16 or 8x8 or 8x14 font
  5664                              <1> 	;			; (256 characters)
  5665                              <1> wgfxl_0:
  5666 00002DE9 01C6                <1> 	add	esi, eax
  5667                              <1> wgfxl_1:
  5668 00002DEB 28FF                <1> 	sub	bh, bh ; i = 0
  5669                              <1> wgfxl_2:
  5670                              <1> 	; for(i=0;i<8;i++)
  5671 00002DED 57                  <1> 	push	edi ; addr
  5672 00002DEE 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  5673 00002DF5 F6E7                <1> 	mul	bh ; nbcols*i
  5674 00002DF7 66C1E003            <1> 	shl	ax, 3 ; i*nbcols*8
  5675                              <1>  	; dest=addr+i*nbcols*8;
  5676 00002DFB 01C7                <1> 	add	edi, eax ; dest + j ; j = 0
  5677 00002DFD B180                <1> 	mov	cl, 80h ; mask = 0x80;
  5678                              <1> 	; esi = fdata + src + i
  5679                              <1> 	; for(j=0;j<8;j++)
  5680 00002DFF 29D2                <1> 	sub	edx, edx ; j = 0
  5681                              <1> wgfxl_3:
  5682 00002E01 8A06                <1> 	mov	al, [esi] ; al = fdata[src+i]
  5683 00002E03 20C8                <1> 	and	al, cl ; if (fdata[src+i] & mask)
  5684 00002E05 7402                <1> 	jz	short wgfxl_4  ; data = 0, zf = 1
  5685 00002E07 88D8                <1> 	mov	al, bl ; data = attr;
  5686                              <1> wgfxl_4:
  5687                              <1> 	; write_byte(0xa000,dest+j,data);		
  5688 00002E09 AA                  <1> 	stosb  ; dest + j (+ 0A0000h)
  5689                              <1> 	;inc	dl ; j++
  5690                              <1> 	;cmp	dl, 8
  5691 00002E0A 80FA07              <1> 	cmp	dl, 7
  5692 00002E0D 720E                <1> 	jb	short wgfxl_5
  5693 00002E0F 5F                  <1> 	pop	edi
  5694                              <1> 	; 08/08/2016
  5695                              <1> 	;cmp	bh, 7
  5696                              <1> 	;jnb	short wgfxl_6
  5697 00002E10 FEC7                <1> 	inc	bh ; i++
  5698 00002E12 3A3D[CE6F0000]      <1> 	cmp	bh, [CHAR_HEIGHT]
  5699 00002E18 7309                <1> 	jnb	short wgfxl_6
  5700 00002E1A 46                  <1> 	inc	esi
  5701 00002E1B EBD0                <1> 	jmp	short wgfxl_2
  5702                              <1> wgfxl_5:
  5703 00002E1D D0E9                <1> 	shr	cl, 1 ; mask >>= 1;
  5704 00002E1F FEC2                <1> 	inc	dl ; j++
  5705 00002E21 EBDE                <1>         jmp     short wgfxl_3
  5706                              <1> wgfxl_6:
  5707 00002E23 58                  <1> 	pop	eax
  5708 00002E24 5A                  <1> 	pop	edx
  5709 00002E25 5B                  <1> 	pop	ebx
  5710 00002E26 59                  <1> 	pop	ecx
  5711 00002E27 C3                  <1> 	retn
  5712                              <1> wfxl_7:
  5713                              <1> 	; 08/01/2021
  5714                              <1> 	; 05/01/2021
  5715                              <1> 	; Default font (8x8 or 8x14 or 8x16)
  5716 00002E28 A0[CE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  5717 00002E2D 3C08                <1> 	cmp	al, 8
  5718 00002E2F 7507                <1> 	jne	short wfxl_8
  5719 00002E31 B8[64600100]        <1> 	mov	eax, vgafont8
  5720 00002E36 EBB1                <1> 	jmp	short wgfxl_0
  5721                              <1> wfxl_8:
  5722 00002E38 3C0E                <1> 	cmp	al, 14
  5723 00002E3A 7507                <1> 	jne	short wfxl_9
  5724 00002E3C B8[64680100]        <1> 	mov	eax, vgafont14
  5725 00002E41 EBA6                <1> 	jmp	short wgfxl_0
  5726                              <1> wfxl_9:
  5727 00002E43 B8[64760100]        <1> 	mov	eax, vgafont16
  5728 00002E48 EB9F                <1> 	jmp	short wgfxl_0
  5729                              <1> 
  5730                              <1> write_gfx_char_pl4:
  5731                              <1> 	; 08/08/2016
  5732                              <1> 	; 08/07/2016 (TRDOS 386 = TRDOS v2.0)
  5733                              <1> 	;
  5734                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5735                              <1> 	; vgabios-0.7a (2011)
  5736                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5737                              <1> 	; 'vgabios.c', 'write_gfx_char_pl4'
  5738                              <1> 
  5739                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight)
  5740                              <1> 	; INPUT ->
  5741                              <1> 	; AL = car, BL = attr, DL = xcurs, DH = ycurs, 
  5742                              <1> 	; [CRT_COLS] = nbcols, [CHAR_HEIGHT] = cheight
  5743                              <1> 	; OUTPUT ->
  5744                              <1> 	; Regen buffer updated
  5745                              <1> 
  5746 00002E4A 51                  <1> 	push	ecx
  5747 00002E4B 53                  <1> 	push	ebx
  5748 00002E4C 52                  <1> 	push	edx
  5749 00002E4D 50                  <1> 	push	eax
  5750                              <1> wgfxpl_f0:
  5751                              <1> 	; switch(cheight)
  5752 00002E4E 8A25[CE6F0000]      <1> 	mov	ah, [CHAR_HEIGHT]
  5753 00002E54 80FC10              <1> 	cmp	ah, 16 ; case 16:
  5754 00002E57 7507                <1> 	jne	short wgfxpl_f1
  5755                              <1> 	; fdata = &vgafont16;
  5756 00002E59 BE[64760100]        <1> 	mov	esi, vgafont16
  5757 00002E5E EB13                <1> 	jmp	short wgfxpl_f3
  5758                              <1> wgfxpl_f1:
  5759 00002E60 80FC0E              <1> 	cmp	ah, 14 ; case 14:
  5760 00002E63 7507                <1> 	jne	short wgfxpl_f2
  5761 00002E65 BE[64680100]        <1> 	mov	esi, vgafont14
  5762 00002E6A EB07                <1> 	jmp	short wgfxpl_f3
  5763                              <1> wgfxpl_f2:
  5764                              <1> 	; default:
  5765                              <1> 	;  fdata = &vgafont8;
  5766 00002E6C BE[64600100]        <1> 	mov	esi, vgafont8
  5767 00002E71 B408                <1> 	mov	ah, 8	
  5768                              <1> wgfxpl_f3:
  5769                              <1> 	; al = car
  5770 00002E73 F6E4                <1> 	mul	ah ; ah = cheight
  5771 00002E75 25FFFF0000          <1> 	and	eax, 0FFFFh ; car * cheight
  5772                              <1> 	; src = car * cheight;
  5773 00002E7A 01C6                <1> 	add	esi, eax ; esi = fdata[src+i]
  5774                              <1> 	; addr=xcurs*8+ycurs*nbcols*64;
  5775 00002E7C 88F0                <1> 	mov	al, dh ; ycurs
  5776 00002E7E 8A25[CC6F0000]      <1> 	mov	ah, [CRT_COLS] ; nbcols
  5777 00002E84 F6E4                <1> 	mul	ah
  5778                              <1> 	; 08/08/2016
  5779                              <1> 	;shl	ax, 6 ; * 64
  5780 00002E86 66C1E003            <1> 	shl	ax, 3 ; * 8
  5781                              <1> 	;sub	dh, dh ; 0
  5782                              <1> 	;shl	dx, 3 ; xcurs * 8
  5783                              <1> 	;movzx	edi, dx
  5784 00002E8A 0FB6FA              <1> 	movzx	edi, dl
  5785 00002E8D 66C1E703            <1> 	shl	di, 3 ; xcurs * 8
  5786 00002E91 30F6                <1> 	xor	dh, dh
  5787 00002E93 8A15[CE6F0000]      <1> 	mov	dl, [CHAR_HEIGHT]
  5788 00002E99 66F7E2              <1> 	mul	dx
  5789                              <1> 	; eax = ycurs*nbcols*8*[CHAR_HEIGHT]
  5790 00002E9C 01C7                <1> 	add	edi, eax ; addr
  5791 00002E9E 81C700000A00        <1> 	add	edi, 0A0000h
  5792                              <1> 	;
  5793                              <1> 	; outw(VGAREG_SEQU_ADDRESS, 0x0f02);
  5794                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  5795 00002EA4 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  5796 00002EA8 66B8020F            <1> 	mov	ax, 0F02h
  5797 00002EAC 66EF                <1> 	out	dx, ax
  5798 00002EAE 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5799 00002EB2 66B80502            <1> 	mov	ax, 0205h
  5800 00002EB6 66EF                <1> 	out	dx, ax
  5801                              <1> 	;
  5802 00002EB8 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5803 00002EBC F6C380              <1> 	test	bl, 80h ; if(attr&0x80)
  5804 00002EBF 7406                <1> 	jz	short wgfxpl_f4 ; else
  5805                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x1803);
  5806 00002EC1 66B80318            <1> 	mov	ax, 1803h
  5807 00002EC5 EB04                <1> 	jmp	short wgfxpl_f5
  5808                              <1> wgfxpl_f4:
  5809                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0003);
  5810 00002EC7 66B80300            <1> 	mov	ax, 0003h	
  5811                              <1> wgfxpl_f5:
  5812 00002ECB 66EF                <1> 	out	dx, ax
  5813                              <1> 	;	
  5814 00002ECD 28FF                <1> 	sub	bh, bh ; i = 0
  5815                              <1> wgfxpl_0:
  5816                              <1> 	; for(i=0;i<cheight;i++)
  5817 00002ECF 57                  <1> 	push	edi ; addr
  5818 00002ED0 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; nbcols
  5819 00002ED7 F6E7                <1> 	mul	bh ; nbcols*i
  5820                              <1> 	; dest=addr+i*nbcols
  5821 00002ED9 01C7                <1> 	add	edi, eax ; dest
  5822 00002EDB B580                <1> 	mov	ch, 80h ; mask = 0x80;
  5823                              <1> 	; for(j=0;j<8;j++)
  5824 00002EDD 28C9                <1> 	sub	cl, cl ; j = 0
  5825                              <1> wgfxpl_1:
  5826 00002EDF D2ED                <1> 	shr	ch, cl ; mask=0x80>>j;
  5827                              <1> 	;
  5828                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  5829                              <1>      	; read_byte(0xa000,dest);
  5830                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5831 00002EE1 88EC                <1> 	mov	ah, ch
  5832 00002EE3 B008                <1> 	mov	al, 8
  5833 00002EE5 66EF                <1> 	out	dx, ax
  5834 00002EE7 8A07                <1> 	mov	al, [edi] ; ? (io delay?)
  5835                              <1> 	;
  5836 00002EE9 28C0                <1> 	sub	al, al ; attr = 0
  5837                              <1> 	; if (fdata[src+i] & mask)
  5838 00002EEB 842E                <1> 	test	byte [esi], ch
  5839 00002EED 7404                <1> 	jz	short wgfxpl_2  ; zf = 1
  5840                              <1> 	; write_byte(0xa000,dest,attr&0x0f);
  5841 00002EEF 88D8                <1> 	mov	al, bl ; attr;
  5842 00002EF1 240F                <1> 	and	al, 0Fh	; attr&0x0f
  5843                              <1> wgfxpl_2:
  5844                              <1> 	; write_byte(0xa000,dest,0x00);		
  5845 00002EF3 8807                <1> 	mov	[edi], al ; dest (+ 0A0000h)
  5846 00002EF5 FEC1                <1> 	inc	cl ; j++
  5847 00002EF7 80F908              <1> 	cmp	cl, 8
  5848 00002EFA 72E3                <1> 	jb	short wgfxpl_1
  5849 00002EFC 5F                  <1> 	pop	edi
  5850                              <1> 	; 08/08/2016
  5851                              <1> 	;cmp	bh, 7
  5852                              <1> 	;jnb	short wgfxpl_3
  5853 00002EFD FEC7                <1> 	inc	bh ; i++
  5854 00002EFF 3A3D[CE6F0000]      <1> 	cmp	bh, [CHAR_HEIGHT]
  5855 00002F05 7303                <1> 	jnb	short wgfxpl_3
  5856 00002F07 46                  <1> 	inc	esi
  5857 00002F08 EBC5                <1> 	jmp	short wgfxpl_0
  5858                              <1> wgfxpl_3:
  5859                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5860 00002F0A 66B808FF            <1>   	mov	ax, 0FF08h
  5861 00002F0E 66EF                <1> 	out	dx, ax
  5862 00002F10 66B80500            <1> 	mov	ax, 0005h
  5863 00002F14 66EF                <1> 	out	dx, ax
  5864 00002F16 66B80300            <1> 	mov	ax, 0003h
  5865 00002F1A 66EF                <1> 	out	dx, ax
  5866                              <1> 	;
  5867 00002F1C 58                  <1> 	pop	eax
  5868 00002F1D 5A                  <1> 	pop	edx
  5869 00002F1E 5B                  <1> 	pop	ebx
  5870 00002F1F 59                  <1> 	pop	ecx
  5871 00002F20 C3                  <1> 	retn
  5872                              <1> 
  5873                              <1> vga_write_pixel: 
  5874                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  5875                              <1> 	;
  5876                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5877                              <1> 	; vgabios-0.7a (2011)
  5878                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5879                              <1> 	; 'vgabios.c', 'biosfn_write_pixel'
  5880                              <1> 
  5881                              <1> 	; INPUT ->
  5882                              <1> 	; 	DX = row (0-239)
  5883                              <1> 	; 	CX = column (0-799)
  5884                              <1> 	; 	AL = pixel value
  5885                              <1> 	;	(AH = [CRT_MODE])
  5886                              <1> 	; OUTPUT ->
  5887                              <1> 	; 	none
  5888                              <1>  
  5889 00002F21 88C3                <1> 	mov	bl, al ; pixel value
  5890                              <1> 	;mov 	ah, [CRT_MODE]
  5891 00002F23 BE[E66F0000]        <1> 	mov	esi, vga_modes
  5892 00002F28 89F7                <1> 	mov	edi, esi
  5893 00002F2A 83C710              <1> 	add	edi, vga_mode_count
  5894                              <1> vga_wp_0:
  5895 00002F2D AC                  <1> 	lodsb
  5896 00002F2E 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  5897 00002F30 7405                <1> 	je	short vga_wp_1
  5898 00002F32 39FE                <1> 	cmp	esi, edi
  5899 00002F34 72F7                <1> 	jb	short vga_wp_0
  5900 00002F36 C3                  <1> 	retn	; nothing to do
  5901                              <1> vga_wp_1:
  5902 00002F37 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  5903                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  5904 00002F3A BF00000A00          <1> 	mov	edi, 0A0000h
  5905                              <1> 	;
  5906 00002F3F 803E04              <1> 	cmp	byte [esi], PLANAR4
  5907 00002F42 741D                <1> 	je	short vga_wp_planar
  5908 00002F44 803E03              <1> 	cmp	byte [esi], PLANAR1
  5909 00002F47 7418                <1> 	je	short vga_wp_planar
  5910                              <1> vga_wp_linear8:
  5911                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  5912 00002F49 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  5913 00002F50 66C1E003            <1>      	shl	ax, 3 ; * 8
  5914 00002F54 66F7E2              <1> 	mul	dx
  5915 00002F57 50                  <1> 	push	eax
  5916                              <1> 	;mov	edi, 0A0000h
  5917 00002F58 6601CF              <1> 	add	di, cx
  5918 00002F5B 58                  <1> 	pop	eax
  5919 00002F5C 01C7                <1> 	add	edi, eax ; addr
  5920                              <1> 	; write_byte(0xa000,addr,AL);
  5921 00002F5E 881F                <1> 	mov	[edi], bl
  5922 00002F60 C3                  <1> 	retn    
  5923                              <1> vga_wp_planar:
  5924                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  5925 00002F61 0FB7C1              <1> 	movzx	eax, cx
  5926 00002F64 66C1E803            <1> 	shr	ax, 3 ; CX/8
  5927 00002F68 50                  <1> 	push	eax
  5928 00002F69 28E4                <1> 	sub	ah, ah ; 0
  5929 00002F6B A0[CC6F0000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  5930 00002F70 66F7E2              <1> 	mul	dx
  5931                              <1> 	;mov	edi, 0A0000h
  5932 00002F73 6601C7              <1>         add     di, ax
  5933 00002F76 58                  <1> 	pop	eax
  5934 00002F77 01C7                <1> 	add	edi, eax ; addr
  5935 00002F79 80E107              <1> 	and	cl, 7
  5936 00002F7C B580                <1> 	mov	ch, 80h ; mask
  5937 00002F7E D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  5938                              <1> 	
  5939                              <1> 	; outw(VGAREG_GRDC_ADDRESS, (mask << 8) | 0x08);
  5940 00002F80 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5941 00002F84 88EC                <1> 	mov	ah, ch
  5942 00002F86 B008                <1> 	mov	al, 8
  5943 00002F88 66EF                <1> 	out	dx, ax
  5944                              <1> 	; outw(VGAREG_GRDC_ADDRESS, 0x0205);
  5945 00002F8A 66B80502            <1> 	mov	ax, 0205h
  5946 00002F8E 66EF                <1> 	out	dx, ax
  5947                              <1> 	; data = read_byte(0xa000,addr);
  5948 00002F90 8A07                <1> 	mov	al, [edi] ; (delay?)	
  5949                              <1> 	; if (AL & 0x80)
  5950                              <1> 	; {
  5951                              <1> 	;  outw(VGAREG_GRDC_ADDRESS, 0x1803);
  5952                              <1> 	; }
  5953 00002F92 F6C380              <1> 	test	bl, 80h
  5954 00002F95 7406                <1> 	jz	short vga_wp_2
  5955 00002F97 66B80318            <1> 	mov	ax, 1803h
  5956 00002F9B 66EF                <1> 	out	dx, ax
  5957                              <1> vga_wp_2:	
  5958                              <1> 	; write_byte(0xa000,addr,AL);
  5959 00002F9D 881F                <1> 	mov	[edi], bl
  5960                              <1> 	;
  5961                              <1> 	;mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  5962 00002F9F 66B808FF            <1>   	mov	ax, 0FF08h
  5963 00002FA3 66EF                <1> 	out	dx, ax
  5964 00002FA5 66B80500            <1> 	mov	ax, 0005h
  5965 00002FA9 66EF                <1> 	out	dx, ax
  5966 00002FAB 66B80300            <1> 	mov	ax, 0003h
  5967 00002FAF 66EF                <1> 	out	dx, ax
  5968                              <1> 	;
  5969 00002FB1 C3                  <1> 	retn
  5970                              <1> 
  5971                              <1> vga_read_pixel: 
  5972                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  5973                              <1> 	;
  5974                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  5975                              <1> 	; vgabios-0.7a (2011)
  5976                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  5977                              <1> 	; 'vgabios.c', 'biosfn_read_pixel'
  5978                              <1> 
  5979                              <1> 	; INPUT ->
  5980                              <1> 	; 	DX = row (0-239)
  5981                              <1> 	; 	CX = column (0-799)
  5982                              <1> 	;	(AH = [CRT_MODE])
  5983                              <1> 	; OUTPUT ->
  5984                              <1> 	; 	AL = pixel value
  5985                              <1> 	 
  5986                              <1> 	;mov 	ah, [CRT_MODE]
  5987 00002FB2 BE[E66F0000]        <1> 	mov	esi, vga_modes
  5988 00002FB7 89F7                <1> 	mov	edi, esi
  5989 00002FB9 83C710              <1> 	add	edi, vga_mode_count
  5990                              <1> vga_rp_0:
  5991 00002FBC AC                  <1> 	lodsb
  5992 00002FBD 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  5993 00002FBF 7405                <1> 	je	short vga_rp_1
  5994 00002FC1 39FE                <1> 	cmp	esi, edi
  5995 00002FC3 72F7                <1> 	jb	short vga_rp_0
  5996 00002FC5 C3                  <1> 	retn	; nothing to do
  5997                              <1> vga_rp_1:
  5998 00002FC6 83C64F              <1> 	add	esi, vga_memmodel - (vga_modes + 1)  
  5999                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  6000 00002FC9 BF00000A00          <1> 	mov	edi, 0A0000h
  6001                              <1> 	;
  6002 00002FCE 803E04              <1> 	cmp	byte [esi], PLANAR4
  6003 00002FD1 741D                <1> 	je	short vga_rp_planar
  6004 00002FD3 803E03              <1> 	cmp	byte [esi], PLANAR1
  6005 00002FD6 7418                <1> 	je	short vga_rp_planar
  6006                              <1> vga_rp_linear8:
  6007                              <1> 	; addr=CX+DX*(read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)*8);
  6008 00002FD8 0FB605[CC6F0000]    <1> 	movzx	eax, byte [CRT_COLS] ; = [VGA_COLS] ; nbcols
  6009 00002FDF 66C1E003            <1>      	shl	ax, 3 ; * 8
  6010 00002FE3 66F7E2              <1> 	mul	dx
  6011 00002FE6 50                  <1> 	push	eax
  6012                              <1> 	;mov	edi, 0A0000h
  6013 00002FE7 6601CF              <1> 	add	di, cx
  6014 00002FEA 58                  <1> 	pop	eax
  6015 00002FEB 01C7                <1> 	add	edi, eax ; addr
  6016                              <1> 	; attr=read_byte(0xa000,addr);
  6017 00002FED 8A07                <1> 	mov	al, [edi] ; pixel value
  6018 00002FEF C3                  <1> 	retn    
  6019                              <1> vga_rp_planar:
  6020                              <1> 	; addr = CX/8+DX*read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS);
  6021 00002FF0 0FB7C1              <1> 	movzx	eax, cx
  6022 00002FF3 66C1E803            <1> 	shr	ax, 3 ; CX/8
  6023 00002FF7 50                  <1> 	push	eax
  6024 00002FF8 28E4                <1> 	sub	ah, ah ; 0
  6025 00002FFA A0[CC6F0000]        <1> 	mov	al, [CRT_COLS] ; = [VGA_COLS] ; nbcols
  6026 00002FFF 66F7E2              <1> 	mul	dx
  6027                              <1> 	;mov	edi, 0A0000h
  6028 00003002 6601C7              <1>         add     di, ax
  6029 00003005 58                  <1> 	pop	eax
  6030 00003006 01C7                <1> 	add	edi, eax ; addr
  6031 00003008 80E107              <1> 	and	cl, 7
  6032 0000300B B580                <1> 	mov	ch, 80h ; mask
  6033 0000300D D2ED                <1> 	shr	ch, cl 	; mask = 0x80 >> (CX & 0x07);
  6034                              <1> 	; attr = 0x00;
  6035 0000300F 30DB                <1> 	xor	bl, bl ; attr = bl = 0, 
  6036 00003011 30C9                <1> 	xor	cl, cl ; i = cl = 0
  6037                              <1> 	; for(i=0;i<4;i++)
  6038                              <1>       	; {
  6039                              <1>        	;  outw(VGAREG_GRDC_ADDRESS, (i << 8) | 0x04);
  6040                              <1>        	;  data = read_byte(0xa000,addr) & mask;
  6041                              <1>        	;  if (data > 0) attr |= (0x01 << i);
  6042                              <1>       	; }
  6043                              <1> vga_rp_2:
  6044 00003013 88CC                <1> 	mov	ah, cl ; i << 8
  6045 00003015 B004                <1> 	mov	al, 4  ; | 0x04
  6046 00003017 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6047 0000301B 66EF                <1> 	out	dx, ax
  6048                              <1> 	; data = read_byte(0xa000,addr) & mask;
  6049 0000301D 8A07                <1> 	mov	al, [edi]
  6050 0000301F 20E8                <1> 	and	al, ch ; & mask
  6051                              <1> 	; if (data > 0) attr |= (0x01 << i);
  6052 00003021 08C0                <1> 	or	al, al
  6053 00003023 7408                <1> 	jz	short vga_rp_3 ; al = 0 
  6054 00003025 B701                <1> 	mov	bh, 1
  6055 00003027 D2E7                <1> 	shl	bh, cl ; (0x01 << i)
  6056 00003029 08FB                <1> 	or	bl, bh ; attr |= (0x01 << i)
  6057 0000302B 88D8                <1> 	mov	al, bl ; pixel value	
  6058                              <1> vga_rp_3:	
  6059 0000302D C3                  <1> 	retn
  6060                              <1> 
  6061                              <1> vga_beeper:
  6062                              <1> 	; 04/08/2016  (TRDOS 386 = TRDOS v2.0)
  6063 0000302E FB                  <1> 	sti
  6064                              <1> 	;mov	bh, [ACTIVE_PAGE]
  6065 0000302F E9BEF3FFFF          <1>         jmp     beeper_gfx
  6066                              <1> 
  6067                              <1> vga_write_teletype:
  6068                              <1> 	; 09/12/2017
  6069                              <1> 	; 06/08/2016
  6070                              <1> 	; 04/08/2016
  6071                              <1> 	; 01/08/2016
  6072                              <1> 	; 31/07/2016
  6073                              <1> 	; 09/07/2016 (TRDOS 386 = TRDOS v2.0)
  6074                              <1> 	;
  6075                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6076                              <1> 	; vgabios-0.7a (2011)
  6077                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6078                              <1> 	; 'vgabios.c', 'biosfn_write_teletype'
  6079                              <1> 	; 'biosfn_write_char_only'
  6080                              <1> 
  6081                              <1> 	; INPUT ->
  6082                              <1> 	; [CRT_MODE] = current video mode (>7)
  6083                              <1> 	; AL = Character to write
  6084                              <1> 	; BL = Color of character
  6085                              <1> 	; OUTPUT ->
  6086                              <1> 	; Regen buffer updated
  6087                              <1> 
  6088                              <1> 	; biosfn_write_teletype (car, page, attr, flag) 
  6089                              <1> 	; car = character (AL)
  6090                              <1> 	; page = 0
  6091                              <1> 	; attr = color (BL)
  6092                              <1> 	; 'flag' not used
  6093                              <1> 
  6094 00003034 8A25[CA6F0000]      <1> 	mov 	ah, [CRT_MODE]
  6095 0000303A 88C7                <1> 	mov	bh, al ; character
  6096 0000303C 668B15[EE890100]    <1> 	mov	dx, [CURSOR_POSN] ; cursor pos for page 0
  6097                              <1> 
  6098 00003043 BE[EE6F0000]        <1> 	mov	esi, vga_g_modes
  6099 00003048 89F7                <1> 	mov	edi, esi
  6100 0000304A 83C708              <1> 	add	edi, vga_g_mode_count
  6101                              <1> vga_wtty_0:
  6102 0000304D AC                  <1> 	lodsb
  6103 0000304E 38E0                <1> 	cmp	al, ah ; [CRT_MODE]
  6104 00003050 7405                <1> 	je	short vga_wtty_2
  6105 00003052 39FE                <1> 	cmp	esi, edi
  6106 00003054 72F7                <1> 	jb	short vga_wtty_0
  6107                              <1> vga_wtty_1:
  6108 00003056 C3                  <1> 	retn	; nothing to do
  6109                              <1> vga_wtty_2:
  6110 00003057 80FF07              <1> 	cmp	bh, 07h ; bell (beep)
  6111 0000305A 74D2                <1> 	je	short vga_beeper  ; u11
  6112 0000305C 80FF08              <1> 	cmp	bh, 08h ; backspace
  6113 0000305F 7508                <1> 	jne	short vga_wtty_3
  6114                              <1> 	; if(xcurs>0)xcurs--;
  6115 00003061 08D2                <1> 	or	dl, dl ; xcurs (column)
  6116 00003063 74F1                <1> 	jz	short vga_wtty_1
  6117 00003065 FECA                <1> 	dec	dl ; xcurs--;
  6118 00003067 EB59                <1>         jmp     short vga_wtty_12 
  6119                              <1> vga_wtty_3:			
  6120 00003069 80FF0D              <1> 	cmp	bh, 0Dh ; carriage return (\r)
  6121 0000306C 7504                <1> 	jne	short vga_wtty_4
  6122                              <1> 	; xcurs=0;
  6123 0000306E 28D2                <1> 	sub	dl, dl ; 0
  6124 00003070 EB50                <1>         jmp     short vga_wtty_12 
  6125                              <1> vga_wtty_4:	
  6126 00003072 80FF0A              <1> 	cmp	bh, 0Ah ; new line (\n)
  6127 00003075 7504                <1> 	jne	short vga_wtty_5
  6128                              <1> 	; ycurs++;
  6129 00003077 FEC6                <1> 	inc	dh ; next row
  6130 00003079 EB62                <1>         jmp     short vga_wtty_11
  6131                              <1> vga_wtty_5:
  6132 0000307B 80FF09              <1> 	cmp 	bh, 09h ; tab stop
  6133 0000307E 7527                <1> 	jne	short vga_wtty_8
  6134 00003080 88D0                <1> 	mov	al, dl
  6135                              <1> 	;cbw
  6136 00003082 30E4                <1> 	xor	ah, ah ; 09/12/2017
  6137 00003084 B108                <1> 	mov	cl, 8
  6138 00003086 F6F1                <1> 	div	cl
  6139 00003088 28E1                <1> 	sub	cl, ah
  6140                              <1> 	;
  6141 0000308A B720                <1> 	mov	bh, 20h ; space
  6142                              <1> vga_wtty_6: ; tab stop loop
  6143 0000308C 6651                <1> 	push	cx
  6144 0000308E 6653                <1> 	push	bx
  6145 00003090 E812000000          <1> 	call	vga_wtty_8
  6146 00003095 665B                <1> 	pop	bx  ; bh = character, bl = color
  6147 00003097 6659                <1> 	pop	cx
  6148 00003099 FEC9                <1> 	dec	cl
  6149 0000309B 7409                <1> 	jz	short vga_wtty_7
  6150 0000309D 668B15[EE890100]    <1> 	mov	dx, [CURSOR_POSN] ; new cursor position (pg 0)
  6151 000030A4 EBE6                <1> 	jmp	short vga_wtty_6
  6152                              <1> vga_wtty_7:
  6153 000030A6 C3                  <1> 	retn
  6154                              <1> 	;
  6155                              <1> vga_wtty_8:
  6156 000030A7 83C64F              <1> 	add	esi, vga_g_memmodel - (vga_g_modes + 1)  
  6157                              <1> 	; [ESI] = VGA memory model number (LINEAR8, PLANAR4, PLANAR1)
  6158 000030AA BF00000A00          <1> 	mov	edi, 0A0000h
  6159                              <1> 	;
  6160 000030AF 88F8                <1> 	mov	al, bh ; character
  6161                              <1> 	;
  6162 000030B1 803E04              <1> 	cmp	byte [esi], PLANAR4
  6163 000030B4 7414                <1> 	je	short vga_wtty_planar
  6164 000030B6 803E03              <1> 	cmp	byte [esi], PLANAR1
  6165 000030B9 740F                <1> 	je	short vga_wtty_planar
  6166                              <1> vga_wtty_linear8:
  6167                              <1> 	; write_gfx_char_lin(car,attr,xcurs,ycurs,nbcols);
  6168                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  6169                              <1> 	; [CRT_COLS] = nbcols
  6170 000030BB E8E7FCFFFF          <1> 	call	write_gfx_char_lin
  6171 000030C0 EB0D                <1> 	jmp	short vga_wtty_9
  6172                              <1> 
  6173                              <1> vga_wtty_12:
  6174                              <1> 	; 09/07/2016
  6175                              <1> 	; set cursor position
  6176                              <1> 	; NOTE: Hardware cursor position will not be set
  6177                              <1> 	;   in any VGA modes (>7)
  6178                              <1> 	;   But, cursor position will be saved into
  6179                              <1> 	;   [CURSOR_POSN].
  6180                              <1> 	;   TRDOS 386 (TRDOS v2.0) uses only one page
  6181                              <1> 	;   (page 0) for all graphics modes.
  6182                              <1> 
  6183 000030C2 668915[EE890100]    <1> 	mov	[CURSOR_POSN], dx ; save cursor pos for pg 0
  6184                              <1> 	; 04/08/2016
  6185                              <1> 	;mov	bh, [ACTIVE_PAGE] ; = 0
  6186                              <1> 	;call	_set_cpos
  6187 000030C9 C3                  <1> 	retn
  6188                              <1> 
  6189                              <1> vga_wtty_planar:
  6190                              <1> 	; write_gfx_char_pl4(car,attr,xcurs,ycurs,nbcols,cheight);
  6191                              <1> 	; AL = car, BL = attr (color), DL = xcurs, DH = ycurs, 
  6192                              <1> 	; [CRT_COLS]= nbcols, [CHAR_HEIGHT] = cheight
  6193 000030CA E87BFDFFFF          <1> 	call	write_gfx_char_pl4
  6194                              <1> vga_wtty_9:
  6195 000030CF FEC2                <1> 	inc	dl ; xcurs++;
  6196                              <1> vga_wtty_10:
  6197                              <1> 	; Do we need to wrap ?
  6198                              <1> 	; if(xcurs==nbcols)
  6199 000030D1 3A15[CC6F0000]      <1> 	cmp	dl, [CRT_COLS] ; [VGA_COLS]
  6200 000030D7 7204                <1> 	jb	short vga_wtty_11 ; no
  6201 000030D9 28D2                <1> 	sub	dl, dl ; xcurs=0;
  6202 000030DB FEC6                <1> 	inc	dh ;  ycurs++;
  6203                              <1> vga_wtty_11:
  6204                              <1> 	; Do we need to scroll ?
  6205                              <1> 	; if(ycurs==nbrows)
  6206 000030DD 3A35[D26F0000]      <1> 	cmp	dh, [VGA_ROWS]
  6207 000030E3 72DD                <1> 	jb	short vga_wtty_12 ; no
  6208                              <1> 	;
  6209                              <1> 	; biosfn_scroll (nblines,attr,rul,cul,rlr,clr,page,dir)
  6210                              <1> 	; al = nblines = 1, bl = attr (color) = 0
  6211                              <1> 	; ch = rul, cl = cul, dh = rlr, dl = clr, page = 0
  6212                              <1> 	; dir = SCROLL_UP
  6213                              <1> 	
  6214 000030E5 B001                <1> 	mov	al, 1
  6215 000030E7 28DB                <1> 	sub	bl, bl ; 0 ; blank/black line (attr=0) will be used
  6216 000030E9 6629C9              <1> 	sub	cx, cx ; 0,0
  6217                              <1> 
  6218                              <1> 	; 06/08/2016
  6219 000030EC 8A35[D26F0000]      <1> 	mov	dh, [VGA_ROWS]
  6220 000030F2 FECE                <1> 	dec	dh ; nbrows -1
  6221                              <1> 
  6222 000030F4 6652                <1> 	push	dx 	; 04/08/2016
  6223 000030F6 8A15[CC6F0000]      <1> 	mov	dl, [CRT_COLS]
  6224 000030FC FECA                <1> 	dec	dl ; nbcols -1
  6225                              <1> 	
  6226 000030FE 8A25[CA6F0000]      <1> 	mov	ah, [CRT_MODE]
  6227                              <1> 	
  6228                              <1> 	; biosfn_scroll(0x01,0x00,0,0,nbrows-1,nbcols-1,page,SCROLL_UP);
  6229 00003104 E8FBF4FFFF          <1> 	call	vga_graphics_up
  6230                              <1> 	; 04/08/2016
  6231 00003109 665A                <1> 	pop	dx
  6232                              <1> 	;dec	dh ; ycurs-=1
  6233 0000310B EBB5                <1> 	jmp	short vga_wtty_12 
  6234                              <1> 
  6235                              <1> font_setup:
  6236                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
  6237                              <1> 	; 09/07/2016
  6238                              <1> 	; character generator (font loading) functions
  6239                              <1> 	;
  6240                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6241                              <1> 	; vgabios-0.7a (2011)
  6242                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6243                              <1> 	; 'vgabios.c', 'int10_func'
  6244                              <1> 
  6245                              <1> 	; AX = 1100H ; Load User-Defined Font (EGA/VGA)
  6246                              <1> 	;
  6247                              <1>         ; BH    height of each character (bytes per character definition)
  6248                              <1>         ; (BL   font block to load (EGA: 0-3; VGA: 0-7))
  6249                              <1> 	; CX    number of characters to redefine (<=256)
  6250                              <1>         ; DX    ASCII code of the first character defined at ES:BP
  6251                              <1>         ; EBP	address of font-definition information
  6252                              <1> 	;	(in user's memory space)
  6253                              <1> 
  6254                              <1> 	; case 0x11:
  6255                              <1>      	; switch(GET_AL())
  6256                              <1>       	; {
  6257                              <1> 	; case 0x00:
  6258                              <1>         ; case 0x10:
  6259                              <1>         ; biosfn_load_text_user_pat(GET_AL(),ES,BP,CX,DX,GET_BL(),GET_BH());
  6260                              <1>         ; break;
  6261                              <1> 
  6262                              <1> 	; AX = 1110H ; Load and Activate User-Defined Font (EGA/VGA)
  6263 0000310D 08C0                <1> 	or	al, al ; 0
  6264 0000310F 7404                <1> 	jz	short font_setup_0
  6265 00003111 3C10                <1> 	cmp	al, 10h
  6266 00003113 7511                <1> 	jne	short font_setup_1	
  6267                              <1> font_setup_0:
  6268 00003115 E8CE000000          <1> 	call	transfer_user_fonts
  6269 0000311A 721C                <1> 	jc	short font_setup_error
  6270 0000311C E8B2010000          <1> 	call	load_text_user_pat
  6271 00003121 E931EAFFFF          <1>         jmp     VIDEO_RETURN 
  6272                              <1> font_setup_1:
  6273                              <1> 	; AX = 1101H ; Load ROM 8x14 Character Set (EGA/VGA)
  6274                              <1> 	; case 0x01:
  6275                              <1>         ; case 0x11:
  6276                              <1>         ; biosfn_load_text_8_14_pat(GET_AL(),GET_BL());
  6277                              <1>         ; break;
  6278 00003126 3C01                <1> 	cmp	al, 1
  6279 00003128 7404                <1> 	je	short font_setup_2
  6280 0000312A 3C11                <1> 	cmp	al, 11h
  6281 0000312C 7511                <1> 	jne	short font_setup_3	
  6282                              <1> font_setup_2:
  6283                              <1> 	; AX = 1111H ; Load and Activate ROM 8x14 Character Set (EGA/VGA)
  6284                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6285 0000312E E8DC020000          <1> 	call	load_text_8_14_pat
  6286 00003133 E91FEAFFFF          <1>         jmp     VIDEO_RETURN
  6287                              <1> font_setup_error:
  6288 00003138 29C0                <1> 	sub	eax, eax ; 0 -> fonts could not be loaded
  6289 0000313A E91DEAFFFF          <1> 	jmp	_video_return
  6290                              <1> font_setup_3:
  6291                              <1> 	; AX = 1102H ; Load ROM 8x8 Character Set (EGA/VGA)
  6292                              <1> 	; case 0x02:
  6293                              <1>         ; case 0x12:
  6294                              <1>         ; biosfn_load_text_8_8_pat(GET_AL(),GET_BL());
  6295                              <1>         ; break;
  6296 0000313F 3C02                <1> 	cmp	al, 2
  6297 00003141 7404                <1> 	je	short font_setup_4
  6298 00003143 3C12                <1> 	cmp	al, 12h
  6299 00003145 750A                <1> 	jne	short font_setup_5	
  6300                              <1> font_setup_4:
  6301                              <1> 	; AX = 1112H ; Load and Activate ROM 8x8 Character Set (EGA/VGA)
  6302                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6303 00003147 E8F3020000          <1> 	call	load_text_8_8_pat
  6304 0000314C E906EAFFFF          <1>         jmp     VIDEO_RETURN
  6305                              <1> font_setup_5:
  6306                              <1> 	; AX = 1104H ; Load ROM 8x16 Character Set (EGA/VGA)
  6307                              <1> 	; case 0x04:
  6308                              <1>         ; case 0x14:
  6309                              <1>         ; biosfn_load_text_8_16_pat(GET_AL(),GET_BL());
  6310                              <1>         ; break;
  6311 00003151 3C04                <1> 	cmp	al, 4
  6312 00003153 7404                <1> 	je	short font_setup_6
  6313 00003155 3C14                <1> 	cmp	al, 14h
  6314 00003157 750A                <1> 	jne	short font_setup_7	
  6315                              <1> font_setup_6:
  6316                              <1> 	; AX = 1114H ; Load and Activate ROM 8x16 Character Set (EGA/VGA)
  6317                              <1> 	; (BL = font block to load (EGA: 0-3; VGA: 0-7))
  6318 00003159 E82A030000          <1> 	call	load_text_8_16_pat
  6319 0000315E E9F4E9FFFF          <1>         jmp     VIDEO_RETURN
  6320                              <1> font_setup_7:
  6321                              <1> 	; Note: AX=1120h (Setup INT 1Fh, EXT_PTR) is not needed
  6322                              <1> 	; for TRDOS 386 (TRDOS v2.0) video functionality;
  6323                              <1> 	; because, originally EXT_PTR (font address) was used for
  6324                              <1> 	; chars 80h to 0FFh (after the first 128 ASCII char fonts), for
  6325                              <1> 	; CGA graphics mode; currenty, 'vgafont8' address has 256 chars!
  6326                              <1> 	; 
  6327                              <1> 	; case 0x20:
  6328                              <1>         ; biosfn_load_gfx_8_8_chars(ES,BP);
  6329                              <1>         ; break; 
  6330                              <1> 	; case 0x21:
  6331                              <1>         ; biosfn_load_gfx_user_chars(ES,BP,CX,GET_BL(),GET_DL());
  6332                              <1>         ; break;
  6333                              <1> 	; AX = 1121H ; Setup User-Defined Font for Graphics Mode (VGA)
  6334                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  6335                              <1>         ;                        01H = 14 rows
  6336                              <1>         ;                        02H = 25 rows
  6337                              <1>         ;                        03H = 43 rows
  6338                              <1>         ; CX   bytes per character definition
  6339                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  6340                              <1>         ; EBP  address of font-definition information (user's mem space)
  6341                              <1> 
  6342 00003163 3C21                <1> 	cmp	al, 21h
  6343 00003165 7531                <1> 	jne	short font_setup_9
  6344                              <1> 
  6345                              <1> 	; TRDOS 386 modification !
  6346                              <1> 	; dh = 0 -> 256 characters
  6347                              <1> 	; dh = 80h -> second 128 characters
  6348                              <1> 	; dh = 0FFh -> first 128 characters
  6349                              <1> 
  6350                              <1> 	; 09/01/2021 (TRDOS 386 v2.0.3)
  6351                              <1> 	;push	ebx
  6352 00003167 51                  <1> 	push	ecx
  6353 00003168 52                  <1> 	push	edx
  6354 00003169 30D2                <1> 	xor	dl, dl
  6355 0000316B 88CF                <1> 	mov	bh, cl ; character height
  6356 0000316D 66B90001            <1> 	mov	cx, 100h ; 256
  6357 00003171 08F6                <1> 	or	dh, dh ; 0
  6358 00003173 7410                <1> 	jz	short  font_setup_8
  6359 00003175 FECD                <1> 	dec	ch ; cx = 0
  6360 00003177 80FEFF              <1> 	cmp	dh, 0FFh
  6361 0000317A 7409                <1> 	je	short font_setup_8 ; 1st 128 chars
  6362                              <1> 	; 2nd 128 chars
  6363 0000317C 80FE80              <1> 	cmp	dh, 80h
  6364 0000317F 75B7                <1> 	jne	short font_setup_error ; invalid !
  6365 00003181 88F1                <1> 	mov	cl, dh
  6366 00003183 86D6                <1> 	xchg	dl, dh
  6367                              <1> 	; number of chars, cx = 80h 
  6368                              <1> 	; start char, dl = 80h
  6369                              <1> font_setup_8:	
  6370 00003185 E85E000000          <1> 	call	transfer_user_fonts
  6371 0000318A 5A                  <1> 	pop	edx
  6372 0000318B 59                  <1> 	pop	ecx
  6373                              <1> 	;pop	ebx
  6374 0000318C 72AA                <1> 	jc	short font_setup_error
  6375                              <1> 	; ebp = user's font data address in system's memory space
  6376 0000318E E83F030000          <1> 	call	load_gfx_user_chars
  6377 00003193 E9BFE9FFFF          <1>         jmp     VIDEO_RETURN 
  6378                              <1> font_setup_9:
  6379                              <1> 	; case 0x22:
  6380                              <1>         ; biosfn_load_gfx_8_14_chars(GET_BL());
  6381                              <1>         ; break;
  6382 00003198 3C22                <1> 	cmp	al, 22h
  6383 0000319A 750A                <1> 	jne	short font_setup_10
  6384 0000319C E86D030000          <1> 	call	load_gfx_8_14_chars	
  6385 000031A1 E9B1E9FFFF          <1>         jmp     VIDEO_RETURN 
  6386                              <1> font_setup_10:	
  6387                              <1> 	; case 0x23:
  6388                              <1>         ; biosfn_load_gfx_8_8_dd_chars(GET_BL());
  6389                              <1>         ; break;
  6390 000031A6 3C23                <1> 	cmp	al, 23h
  6391 000031A8 750A                <1> 	jne	short font_setup_11
  6392 000031AA E8A0030000          <1> 	call	load_gfx_8_8_chars	
  6393 000031AF E9A3E9FFFF          <1>         jmp     VIDEO_RETURN 
  6394                              <1> font_setup_11:	
  6395                              <1> 	; case 0x24:
  6396                              <1>         ; biosfn_load_gfx_8_16_chars(GET_BL());
  6397                              <1>         ; break;
  6398 000031B4 3C24                <1> 	cmp	al, 24h
  6399 000031B6 750A                <1> 	jne	short font_setup_12
  6400 000031B8 E8D3030000          <1> 	call	load_gfx_8_16_chars	
  6401 000031BD E995E9FFFF          <1>         jmp     VIDEO_RETURN 
  6402                              <1> font_setup_12:
  6403                              <1>  	; case 0x30:
  6404                              <1>         ; biosfn_get_font_info(GET_BH(),&ES,&BP,&CX,&DX);
  6405                              <1>         ; break;
  6406 000031C2 3C30                <1> 	cmp	al, 30h
  6407 000031C4 750A                <1> 	jne	short font_setup_13			
  6408 000031C6 E806040000          <1> 	call	get_font_info
  6409                              <1> 	; eax = return value (info: 4 bytes for 4 parms)
  6410                              <1> 	; eax = 0 -> invalid function (input)
  6411 000031CB E98CE9FFFF          <1>         jmp     _video_return
  6412                              <1> font_setup_13:
  6413 000031D0 3C03                <1> 	cmp	al, 03h ; AX = 1103h	
  6414 000031D2 750D                <1> 	jne	short font_setup_14
  6415                              <1> 	; biosfn_set_text_block_specifier:
  6416                              <1> 	; BL = font block selector code	
  6417                              <1> 	; NOTE: TRDOS 386 only uses and sets font block 0
  6418                              <1> 	; (It is as BL = 0 for TRDOS 386)
  6419 000031D4 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6420                              <1> 	;mov	ah, bl
  6421 000031D8 28E4                <1> 	sub	ah, ah ; 0
  6422                              <1> 	;mov	al, 03h
  6423 000031DA 66EF                <1> 	out	dx, ax
  6424 000031DC E976E9FFFF          <1> 	jmp     VIDEO_RETURN 
  6425                              <1> 	
  6426                              <1> font_setup_14:
  6427 000031E1 29C0                <1> 	sub	eax, eax ; 0 = invalid function
  6428 000031E3 E974E9FFFF          <1>         jmp     _video_return
  6429                              <1> 
  6430                              <1> transfer_user_fonts:
  6431                              <1> 	; 19/01/2021
  6432                              <1> 	; 09/01/2021
  6433                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  6434                              <1> 
  6435                              <1> 	; BH    height of each character (bytes per character)
  6436                              <1> 	; CX    number of characters to redefine (<=256)
  6437                              <1>         ; DX    ASCII code of the first character defined at EBP
  6438                              <1>         ; EBP	address of font-definition information
  6439                              <1> 	;	(in user's memory space)
  6440                              <1> 
  6441                              <1> 	; Modified registers: eax, edx, ecx, esi, edi, ebp
  6442                              <1> 	;
  6443                              <1> 	; output:
  6444                              <1> 	;	ebp = user font data address in system memory
  6445                              <1> 
  6446 000031E8 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  6447 000031EE 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  6448 000031F4 7537                <1> 	jnz	short transfer_user_fonts_5
  6449                              <1> 
  6450 000031F6 09D2                <1> 	or	edx, edx
  6451 000031F8 7531                <1> 	jnz	short transfer_user_fonts_4
  6452 000031FA 09ED                <1> 	or	ebp, ebp
  6453 000031FC 752D                <1> 	jnz	short transfer_user_fonts_4
  6454                              <1> 
  6455                              <1> 	; cx = 0, dx = 0, ebp = 0
  6456                              <1> 	; copy system font to user font
  6457                              <1> 
  6458 000031FE B140                <1> 	mov	cl, 64 ; 64 dwords
  6459                              <1> 	
  6460 00003200 80FF10              <1> 	cmp	bh, 16
  6461 00003203 7417                <1> 	je	short transfer_user_fonts_2
  6462 00003205 80FF08              <1> 	cmp	bh, 8
  6463 00003208 7406                <1> 	je	short transfer_user_fonts_1
  6464                              <1> 
  6465 0000320A BD[64680100]        <1> 	mov	ebp, vgafont14
  6466 0000320F C3                  <1> 	retn 
  6467                              <1> 
  6468                              <1> transfer_user_fonts_1:
  6469 00003210 BF00500900          <1> 	mov	edi, VGAFONT8USER
  6470 00003215 BE[64600100]        <1> 	mov	esi, vgafont8
  6471 0000321A EB0A                <1> 	jmp	short transfer_user_fonts_3
  6472                              <1> 
  6473                              <1> transfer_user_fonts_2:
  6474 0000321C BF00400900          <1> 	mov	edi, VGAFONT16USER
  6475 00003221 BE[64760100]        <1> 	mov	esi, vgafont16
  6476                              <1> transfer_user_fonts_3:
  6477 00003226 89FD                <1> 	mov	ebp, edi
  6478 00003228 F3A5                <1> 	rep	movsd
  6479 0000322A C3                  <1> 	retn
  6480                              <1> 
  6481                              <1> transfer_user_fonts_4:
  6482 0000322B F9                  <1> 	stc	
  6483 0000322C C3                  <1> 	retn
  6484                              <1> 	
  6485                              <1> transfer_user_fonts_5:
  6486 0000322D 09ED                <1> 	or	ebp, ebp
  6487 0000322F 74FA                <1> 	jz	short transfer_user_fonts_4 ; invalid address !
  6488                              <1> 
  6489 00003231 6681F90001          <1> 	cmp	cx, 256
  6490 00003236 77F3                <1> 	ja	short transfer_user_fonts_4
  6491 00003238 29D1                <1> 	sub	ecx, edx
  6492 0000323A 76EF                <1> 	jna	short transfer_user_fonts_4
  6493                              <1> 
  6494 0000323C 80FF0E              <1> 	cmp	bh, 14 ; 8x14 font
  6495                              <1> 		       ; (there is not an alternative buffer)
  6496 0000323F 7525                <1> 	jne	short transfer_user_fonts_6
  6497                              <1> 	
  6498                              <1> 	; use system's 8x14 font space if permission flag is 1
  6499 00003241 F605[7E120300]80    <1> 	test	byte [ufont], 80h
  6500 00003248 74E1                <1> 	jz	short transfer_user_fonts_4 ; not allowed	
  6501                              <1> 
  6502                              <1> 	; permission is given (for vgafont14 location etc.)
  6503                              <1> 	; (for permanent font modification)
  6504                              <1> 	;
  6505                              <1> 	; 19/01/2021
  6506                              <1> 	; Note: Permission flag can be set by 'root' while
  6507                              <1> 	;	system is not in multi tasking/user mode
  6508                              <1> 	;	while [multi_tasking] = 0 and [u.uid] = 0
  6509                              <1> 
  6510 0000324A 52                  <1> 	push	edx	
  6511 0000324B 30E4                <1> 	xor	ah, ah
  6512 0000324D 88F8                <1> 	mov	al, bh ; mov al, 14 
  6513 0000324F 66F7E1              <1> 	mul	cx 
  6514                              <1> 		; ecx = byte count 
  6515 00003252 89C1                <1> 	mov	ecx, eax
  6516 00003254 5A                  <1> 	pop	edx	
  6517 00003255 30E4                <1> 	xor	ah, ah
  6518 00003257 88F8                <1> 	mov	al, bh ; mov ax, 14 ; bytes per character
  6519 00003259 66F7E2              <1> 	mul	dx
  6520 0000325C 6689C2              <1> 	mov	dx, ax ; char offset
  6521 0000325F BF[64680100]        <1> 	mov	edi, vgafont14
  6522 00003264 EB4C                <1> 	jmp	short transfer_user_fonts_8			
  6523                              <1> transfer_user_fonts_6:
  6524 00003266 80FF08              <1> 	cmp	bh, 8 ; 8x8 font
  6525 00003269 7522                <1> 	jne	short transfer_user_fonts_7 ; 8x16 font
  6526 0000326B 66C1E203            <1> 	shl	dx, 3 ; * 8
  6527 0000326F 66C1E103            <1> 	shl	cx, 3 ; * 8
  6528                              <1> 	; 09/01/2021
  6529 00003273 BF00500900          <1> 	mov	edi, VGAFONT8USER
  6530 00003278 F605[7E120300]08    <1> 	test	byte [ufont], 8  ; already loaded ?	
  6531 0000327F 7531                <1> 	jnz	short transfer_user_fonts_8 ; yes
  6532 00003281 BE[64600100]        <1> 	mov	esi, vgafont8
  6533 00003286 E83B000000          <1> 	call	transfer_user_fonts_10
  6534 0000328B EB25                <1> 	jmp	short transfer_user_fonts_8
  6535                              <1> transfer_user_fonts_7:
  6536 0000328D 80FF10              <1> 	cmp	bh, 16 ; 8x16 font
  6537 00003290 7599                <1> 	jne	short transfer_user_fonts_4  ; invalid !
  6538 00003292 66C1E204            <1> 	shl	dx, 4 ; * 16
  6539 00003296 66C1E104            <1> 	shl	cx, 4 ; * 16 
  6540 0000329A BF00400900          <1> 	mov	edi, VGAFONT16USER
  6541 0000329F F605[7E120300]10    <1> 	test	byte [ufont], 16  ; already loaded ?	
  6542 000032A6 750A                <1> 	jnz	short transfer_user_fonts_8 ; yes
  6543 000032A8 BE[64760100]        <1> 	mov	esi, vgafont16
  6544 000032AD E814000000          <1> 	call	transfer_user_fonts_10
  6545                              <1> transfer_user_fonts_8:
  6546 000032B2 01D7                <1> 	add	edi, edx ; char offset
  6547                              <1> 	; 09/07/2016
  6548                              <1> 	;and	ecx, 0FFFFh
  6549                              <1> 	; ECX = byte count
  6550                              <1> 	;push	ecx
  6551 000032B4 89EE                <1> 	mov	esi, ebp ; user's font buffer
  6552                              <1> 	; 09/01/2021
  6553 000032B6 89FD                <1> 	mov	ebp, edi ; system addr for user's font
  6554                              <1> 	; 05/01/2021
  6555                              <1> 	;mov	edi, Cluster_Buffer  ; system buffer
  6556 000032B8 E891E80000          <1> 	call	transfer_from_user_buffer
  6557                              <1> 	;pop	ecx
  6558                              <1> 	; ecx = transfer (byte) count = character count
  6559 000032BD 7206                <1> 	jc	short transfer_user_fonts_9
  6560                              <1> 	; 05/01/2021
  6561                              <1> 	;mov	ebp, Cluster_Buffer
  6562                              <1> 	
  6563 000032BF 083D[7E120300]      <1> 	or	byte [ufont], bh 
  6564                              <1> 			; 8x8 or 8x16 user font ready 
  6565                              <1> transfer_user_fonts_9:
  6566 000032C5 C3                  <1> 	retn
  6567                              <1> 
  6568                              <1> transfer_user_fonts_10:
  6569                              <1> 	; 09/01/2021
  6570 000032C6 56                  <1> 	push	esi
  6571 000032C7 57                  <1> 	push	edi
  6572 000032C8 51                  <1> 	push	ecx
  6573 000032C9 66B94000            <1> 	mov	cx, 64
  6574 000032CD F3A5                <1> 	rep	movsd
  6575 000032CF 59                  <1> 	pop	ecx
  6576 000032D0 5F                  <1> 	pop	edi
  6577 000032D1 5E                  <1> 	pop	esi
  6578 000032D2 C3                  <1> 	retn
  6579                              <1> 
  6580                              <1> load_text_user_pat:
  6581                              <1> 	; 26/07/2016
  6582                              <1> 	; 09/07/2016
  6583                              <1> 	; load user defined (EGA/VGA) text fonts
  6584                              <1> 	;
  6585                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6586                              <1> 	; vgabios-0.7a (2011)
  6587                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6588                              <1> 	; 'vgabios.c', 'biosfn_load_text_user_pat'
  6589                              <1> 
  6590                              <1> 	; biosfn_load_text_user_pat (AL,ES,BP,CX,DX,BL,BH)
  6591                              <1> 
  6592                              <1> 	; get_font_access();
  6593                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6594                              <1> 	; for(i=0;i<CX;i++)
  6595                              <1> 	; {
  6596                              <1> 	;  src = BP + i * BH;
  6597                              <1> 	;  dest = blockaddr + (DX + i) * 32;
  6598                              <1> 	;  memcpyb(0xA000, dest, ES, src, BH);
  6599                              <1> 	; }
  6600                              <1> 	; release_font_access();
  6601                              <1> 	; if(AL>=0x10)
  6602                              <1> 	; {
  6603                              <1> 	; set_scan_lines(BH);
  6604                              <1> 	; }
  6605                              <1> 
  6606 000032D3 50                  <1> 	push	eax
  6607 000032D4 E83C000000          <1> 	call	get_font_access
  6608 000032D9 28DB                <1> 	sub	bl, bl ; i = 0	
  6609                              <1> ltup_1:
  6610 000032DB 88D8                <1> 	mov	al, bl
  6611 000032DD F6E7                <1> 	mul	bh
  6612 000032DF 0FB7F0              <1> 	movzx	esi, ax
  6613 000032E2 01EE                <1> 	add	esi, ebp
  6614 000032E4 88D8                <1> 	mov	al, bl
  6615 000032E6 28E4                <1> 	sub	ah, ah
  6616 000032E8 6601D0              <1> 	add	ax, dx ; (DX + i)
  6617 000032EB 66C1E005            <1> 	shl	ax, 5  ; * 32
  6618 000032EF 0FB7F8              <1> 	movzx	edi, ax
  6619 000032F2 81C700000A00        <1> 	add	edi, 0A0000h
  6620 000032F8 51                  <1> 	push	ecx
  6621 000032F9 0FB6CF              <1> 	movzx	ecx, bh 		
  6622 000032FC F3A4                <1> 	rep	movsb
  6623 000032FE 59                  <1> 	pop	ecx	
  6624 000032FF FEC3                <1> 	inc	bl
  6625 00003301 38CB                <1> 	cmp	bl, cl
  6626 00003303 75D6                <1> 	jne	short ltup_1	
  6627                              <1> 	;
  6628 00003305 E840000000          <1> 	call	release_font_access
  6629                              <1> 	;
  6630 0000330A 58                  <1> 	pop	eax
  6631                              <1> 	; if(AL>=0x10)
  6632 0000330B 3C10                <1> 	cmp	al, 10h
  6633 0000330D 7205                <1> 	jb	short ltup_2
  6634                              <1>    	; set_scan_lines(BH);
  6635 0000330F E875000000          <1> 	call	set_scan_lines
  6636                              <1> ltup_2:
  6637 00003314 C3                  <1> 	retn
  6638                              <1> 
  6639                              <1> get_font_access:
  6640                              <1> 	; 09/07/2016
  6641                              <1> 	;
  6642                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6643                              <1> 	; vgabios-0.7a (2011)
  6644                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6645                              <1> 	; 'vgabios.c', 'get_font_access'
  6646                              <1> 
  6647                              <1> 	; get_font_access()
  6648 00003315 52                  <1> 	push	edx
  6649 00003316 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6650 0000331A 66B80001            <1> 	mov	ax, 0100h
  6651 0000331E 66EF                <1> 	out	dx, ax
  6652 00003320 66B80204            <1> 	mov	ax, 0402h
  6653 00003324 66EF                <1> 	out	dx, ax
  6654 00003326 66B80407            <1> 	mov	ax, 0704h
  6655 0000332A 66EF                <1> 	out	dx, ax
  6656 0000332C 66B80003            <1> 	mov	ax, 0300h
  6657 00003330 66EF                <1> 	out	dx, ax
  6658 00003332 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6659 00003336 66B80402            <1> 	mov	ax, 0204h
  6660 0000333A 66EF                <1> 	out	dx, ax
  6661 0000333C 66B80500            <1> 	mov	ax, 0005h
  6662 00003340 66EF                <1> 	out	dx, ax
  6663 00003342 66B80604            <1> 	mov	ax, 0406h
  6664 00003346 66EF                <1> 	out	dx, ax
  6665 00003348 5A                  <1> 	pop	edx
  6666 00003349 C3                  <1> 	retn
  6667                              <1> 
  6668                              <1> release_font_access:
  6669                              <1> 	; 29/07/2016
  6670                              <1> 	; 09/07/2016
  6671                              <1> 	;
  6672                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6673                              <1> 	; vgabios-0.7a (2011)
  6674                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6675                              <1> 	; 'vgabios.c', 'release_font_access'
  6676                              <1> 
  6677 0000334A 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
  6678 0000334E 66B80001            <1> 	mov	ax, 0100h
  6679 00003352 66EF                <1> 	out	dx, ax
  6680 00003354 66B80203            <1> 	mov	ax, 0302h
  6681 00003358 66EF                <1> 	out	dx, ax
  6682 0000335A 66B80403            <1> 	mov	ax, 0304h
  6683 0000335E 66EF                <1> 	out	dx, ax
  6684 00003360 66B80003            <1> 	mov	ax, 0300h
  6685 00003364 66EF                <1> 	out	dx, ax
  6686 00003366 66BACC03            <1> 	mov	dx, 3CCh ; VGAREG_READ_MISC_OUTPUT
  6687 0000336A EC                  <1>  	in	al, dx
  6688 0000336B 2401                <1> 	and	al, 01h
  6689 0000336D C0E002              <1> 	shl	al, 2
  6690 00003370 0C0A                <1> 	or	al, 0Ah
  6691 00003372 88C4                <1> 	mov	ah, al
  6692 00003374 B006                <1> 	mov	al, 06h
  6693 00003376 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
  6694 0000337A 66EF                <1> 	out	dx, ax
  6695 0000337C 66B80400            <1> 	mov	ax, 0004h
  6696 00003380 66EF                <1> 	out	dx, ax
  6697 00003382 66B80510            <1> 	mov	ax, 1005h
  6698 00003386 66EF                <1> 	out	dx, ax
  6699 00003388 C3                  <1> 	retn
  6700                              <1> 
  6701                              <1> set_scan_lines:
  6702                              <1> 	; 09/07/2016
  6703                              <1> 	;
  6704                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6705                              <1> 	; vgabios-0.7a (2011)
  6706                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6707                              <1> 	; 'vgabios.c', 'set_scan_lines'
  6708                              <1> 
  6709                              <1> 	; set_scan_lines(lines)
  6710                              <1> 	; BH = lines
  6711                              <1> 
  6712                              <1> 	; outb(crtc_addr, 0x09);
  6713 00003389 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS = 3D4h (always)
  6714 0000338D B009                <1> 	mov	al, 09h
  6715 0000338F EE                  <1> 	out	dx, al
  6716                              <1> 	; crtc_r9 = inb(crtc_addr+1);
  6717 00003390 6642                <1> 	inc	dx ; 3D5h
  6718 00003392 EC                  <1> 	in	al, dx
  6719                              <1> 	; crtc_r9 = (crtc_r9 & 0xe0) | (lines - 1);
  6720 00003393 24E0                <1> 	and	al, 0E0h
  6721 00003395 FECF                <1> 	dec	bh ; lines - 1
  6722 00003397 08F8                <1> 	or	al, bh
  6723                              <1> 	; outb(crtc_addr+1, crtc_r9);
  6724 00003399 EE                  <1> 	out	dx, al
  6725                              <1> 	;inc	bh 
  6726                              <1> 	; if(lines==8)
  6727                              <1> 	;cmp	bh, 8
  6728 0000339A 80FF07              <1> 	cmp	bh, 7
  6729 0000339D 7506                <1> 	jne	short ssl_1
  6730                              <1> 	; biosfn_set_cursor_shape(0x06,0x07);
  6731 0000339F 66B90706            <1> 	mov	cx, 0607h
  6732 000033A3 EB06                <1> 	jmp	short ssl_2
  6733                              <1> ssl_1:
  6734                              <1> 	; biosfn_set_cursor_shape(lines-4,lines-3);
  6735 000033A5 88F9                <1> 	mov	cl, bh ; lines - 1
  6736 000033A7 88CD                <1> 	mov	ch, cl ; lines - 1 (16 -> 15)
  6737 000033A9 FECD                <1> 	dec	ch  ; lines - 2 (16 -> 14)
  6738                              <1> ssl_2:
  6739                              <1> 	; CH = start line, CL = stop line
  6740 000033AB B40A                <1> 	mov	ah, 10	; 6845 register for cursor set
  6741 000033AD 66890D[E36F0000]    <1> 	mov	[CURSOR_MODE], cx ; save in data area
  6742 000033B4 E809F0FFFF          <1> 	call	m16	; output cx register
  6743                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, lines);
  6744 000033B9 FEC7                <1> 	inc	bh ; lines
  6745 000033BB 883D[CE6F0000]      <1> 	mov	[CHAR_HEIGHT], bh
  6746                              <1> 	;  outb(crtc_addr, 0x12);
  6747 000033C1 66BAD403            <1> 	mov	dx, 3D4h ; CRTC_ADDRESS
  6748 000033C5 B012                <1> 	mov	al, 12h
  6749 000033C7 EE                  <1> 	out	dx, al
  6750                              <1> 	; vde = inb(crtc_addr+1);
  6751 000033C8 6642                <1> 	inc	dx
  6752 000033CA EC                  <1> 	in	al, dx
  6753 000033CB 88C4                <1> 	mov	ah, al
  6754                              <1> 	; outb(crtc_addr, 0x07);
  6755 000033CD 664A                <1> 	dec	dx
  6756 000033CF B007                <1> 	mov	al, 07h
  6757 000033D1 EE                  <1> 	out	dx, al
  6758                              <1> 	; ovl = inb(crtc_addr+1);
  6759 000033D2 6642                <1> 	inc	dx
  6760 000033D4 EC                  <1> 	in	al, dx
  6761                              <1> 	; vde += (((ovl & 0x02) << 7) + ((ovl & 0x40) << 3) + 1);
  6762 000033D5 88E2                <1> 	mov	dl, ah ; vde
  6763 000033D7 88C6                <1> 	mov	dh, al ; ovl
  6764 000033D9 6683E002            <1> 	and	ax, 02h
  6765 000033DD 66C1E007            <1> 	shl	ax, 7
  6766 000033E1 6689C1              <1> 	mov	cx, ax ; (ovl & 0x02) << 7)	
  6767 000033E4 88F0                <1> 	mov	al, dh ; ovl
  6768 000033E6 6683E040            <1> 	and	ax, 40h			
  6769 000033EA 66C1E003            <1> 	shl	ax, 3  ; (ovl & 0x40) << 3)
  6770 000033EE 6640                <1> 	inc	ax ; + 1 
  6771 000033F0 6601C8              <1> 	add	ax, cx
  6772 000033F3 30F6                <1> 	xor	dh, dh
  6773 000033F5 6601D0              <1> 	add	ax, dx ; + vde
  6774                              <1> 	; rows = vde / lines;
  6775 000033F8 F6F7                <1> 	div	bh
  6776                              <1> 	;dec	al ; rows -1
  6777                              <1> 	; write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, rows-1);
  6778 000033FA A2[D26F0000]        <1> 	mov	[VGA_ROWS], al ; rows (not 'rows-1' !)
  6779                              <1> 	; write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, rows * cols * 2);
  6780                              <1> 	;mov	ah, [CRT_COLS]
  6781                              <1> 	;mul	ah
  6782                              <1> 	; 17/11/2020
  6783 000033FF F625[CC6F0000]      <1> 	mul	byte [CRT_COLS]
  6784 00003405 66D1E0              <1> 	shl	ax, 1
  6785 00003408 66A3[68960100]      <1> 	mov 	[CRT_LEN], ax	
  6786 0000340E C3                  <1> 	retn
  6787                              <1> 
  6788                              <1> load_text_8_14_pat:
  6789                              <1> 	; 26/07/2016
  6790                              <1> 	; 25/07/2016
  6791                              <1> 	; 23/07/2016
  6792                              <1> 	; 09/07/2016
  6793                              <1> 	; load user defined (EGA/VGA) text fonts
  6794                              <1> 	;
  6795                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6796                              <1> 	; vgabios-0.7a (2011)
  6797                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6798                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_14_pat'
  6799                              <1> 
  6800                              <1> 	; biosfn_load_text_8_14_pat (AL,BL)
  6801                              <1> 
  6802                              <1> 	; get_font_access();
  6803                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6804                              <1> 	; for(i=0;i<0x100;i++)
  6805                              <1> 	; {
  6806                              <1> 	;  src = i * 14;
  6807                              <1> 	;  dest = blockaddr + i * 32;
  6808                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont14+src, 14);
  6809                              <1> 	; }
  6810                              <1> 	; release_font_access();
  6811                              <1> 	; if(AL>=0x10)
  6812                              <1> 	; {
  6813                              <1> 	; set_scan_lines(14);
  6814                              <1> 	; }
  6815                              <1> 
  6816 0000340F 50                  <1> 	push	eax
  6817 00003410 E800FFFFFF          <1> 	call	get_font_access
  6818                              <1> 
  6819                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6820                              <1> 	;mov	dl, bl
  6821                              <1> 	;and	dl, 3
  6822                              <1> 	;shl	dx, 14
  6823                              <1> 	;xchg	dx, bx
  6824                              <1> 	;and	dl, 4
  6825                              <1> 	;shl	dx, 11
  6826                              <1> 	;add	dx, bx 	
  6827                              <1>  
  6828                              <1> 	;xor	dx, dx  ; blockaddr = 0
  6829                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  6830                              <1> 
  6831 00003415 28DB                <1> 	sub	bl, bl ; i = 0
  6832 00003417 B70E                <1> 	mov	bh, 14
  6833 00003419 BE[64680100]        <1> 	mov	esi, vgafont14
  6834 0000341E BF00000A00          <1> 	mov	edi, 0A0000h		
  6835                              <1> lt8_14_1:
  6836                              <1> 	;mov	al, bl
  6837                              <1> 	;mul	bh
  6838                              <1> 	;movzx	esi, ax
  6839                              <1> 	;add	esi, vgafont14
  6840                              <1> 	;mov	al, bl
  6841                              <1> 	;sub	ah, ah
  6842                              <1> 	;shl	ax, 5 ; * 32
  6843                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  6844                              <1> 	;movzx	edi, ax ; dest
  6845                              <1> 	;add	edi, 0A0000h
  6846 00003423 0FB6CF              <1> 	movzx	ecx, bh 		
  6847 00003426 F3A4                <1> 	rep	movsb
  6848 00003428 83C712              <1> 	add	edi, 18 ; 32 - 14
  6849 0000342B FEC3                <1> 	inc	bl
  6850 0000342D 75F4                <1> 	jnz	short lt8_14_1	
  6851                              <1> 	;
  6852 0000342F E816FFFFFF          <1> 	call	release_font_access
  6853                              <1> 	;
  6854 00003434 58                  <1> 	pop	eax
  6855                              <1> 	; if(AL>=0x10)
  6856 00003435 3C10                <1> 	cmp	al, 10h
  6857 00003437 7205                <1> 	jb	short lt8_14_4
  6858                              <1> 	; BH = 14
  6859                              <1>    	; set_scan_lines(14);
  6860 00003439 E84BFFFFFF          <1> 	call	set_scan_lines
  6861                              <1> lt8_14_4:
  6862 0000343E C3                  <1> 	retn
  6863                              <1> 
  6864                              <1> load_text_8_8_pat:
  6865                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  6866                              <1> 	; 26/07/2016
  6867                              <1> 	; 25/07/2016
  6868                              <1> 	; 23/07/2016
  6869                              <1> 	; 09/07/2016
  6870                              <1> 	; load user defined (EGA/VGA) text fonts
  6871                              <1> 	;
  6872                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6873                              <1> 	; vgabios-0.7a (2011)
  6874                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6875                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_8_pat'
  6876                              <1> 
  6877                              <1> 	; biosfn_load_text_8_8_pat (AL,BL)
  6878                              <1> 
  6879                              <1> 	; get_font_access();
  6880                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6881                              <1> 	; for(i=0;i<0x100;i++)
  6882                              <1> 	; {
  6883                              <1> 	;  src = i * 8;
  6884                              <1> 	;  dest = blockaddr + i * 32;
  6885                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont8+src, 8);
  6886                              <1> 	; }
  6887                              <1> 	; release_font_access();
  6888                              <1> 	; if(AL>=0x10)
  6889                              <1> 	; {
  6890                              <1> 	; set_scan_lines(8);
  6891                              <1> 	; }
  6892                              <1> 
  6893 0000343F 50                  <1> 	push	eax
  6894 00003440 E8D0FEFFFF          <1> 	call	get_font_access
  6895                              <1> 
  6896                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6897                              <1> 	;mov	dl, bl
  6898                              <1> 	;and	dl, 3
  6899                              <1> 	;shl	dx, 14
  6900                              <1> 	;xchg	dx, bx
  6901                              <1> 	;and	dl, 4
  6902                              <1> 	;shl	dx, 11
  6903                              <1> 	;add	dx, bx 	
  6904                              <1>  
  6905                              <1> 	;xor	dx, dx  ; blockaddr = 0
  6906                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  6907                              <1> 
  6908 00003445 28DB                <1> 	sub	bl, bl ; i = 0
  6909 00003447 B708                <1> 	mov	bh, 8
  6910                              <1> 	;mov	esi, vgafont8
  6911 00003449 BF00000A00          <1> 	mov	edi, 0A0000h
  6912                              <1> 
  6913                              <1> 	; 05/01/2021
  6914 0000344E F605[7E120300]80    <1> 	test	byte [ufont], 80h
  6915 00003455 7410                <1> 	jz	short lt8_8_0
  6916                              <1> 		; user font permission (after set mode)
  6917 00003457 F605[7E120300]08    <1>  	test	byte [ufont], 8
  6918 0000345E 7407                <1> 	jz	short lt8_8_0
  6919 00003460 BE00500900          <1> 	mov	esi, VGAFONT8USER
  6920 00003465 EB05                <1> 	jmp	short lt8_8_1
  6921                              <1> lt8_8_0:
  6922 00003467 BE[64600100]        <1> 	mov	esi, vgafont8	
  6923                              <1> lt8_8_1:
  6924                              <1> 	;mov	al, bl
  6925                              <1> 	;mul	bh
  6926                              <1> 	;movzx	esi, ax
  6927                              <1> 	;add	esi, vgafont8
  6928                              <1> 	;mov	al, bl
  6929                              <1> 	;sub	ah, ah
  6930                              <1> 	;shl	ax, 5 ; * 32
  6931                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  6932                              <1> 	;movzx	edi, ax ; dest
  6933                              <1> 	;add	edi, 0A0000h
  6934 0000346C 0FB6CF              <1> 	movzx	ecx, bh 		
  6935 0000346F F3A4                <1> 	rep	movsb
  6936 00003471 83C718              <1> 	add	edi, 24 ; 32 - 8
  6937 00003474 FEC3                <1> 	inc	bl
  6938 00003476 75F4                <1> 	jnz	short lt8_8_1
  6939                              <1> 	;
  6940 00003478 E8CDFEFFFF          <1> 	call	release_font_access
  6941                              <1> 	;
  6942 0000347D 58                  <1> 	pop	eax
  6943                              <1> 	; if(AL>=0x10)
  6944 0000347E 3C10                <1> 	cmp	al, 10h
  6945 00003480 7205                <1> 	jb	short lt8_8_2
  6946                              <1> 	; BH = 8
  6947                              <1>    	; set_scan_lines(8);
  6948 00003482 E802FFFFFF          <1> 	call	set_scan_lines
  6949                              <1> lt8_8_2:
  6950 00003487 C3                  <1> 	retn
  6951                              <1> 
  6952                              <1> load_text_8_16_pat:
  6953                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  6954                              <1> 	; 26/07/2016
  6955                              <1> 	; 25/07/2016
  6956                              <1> 	; 23/07/2016
  6957                              <1> 	; 09/07/2016
  6958                              <1> 	; load user defined (EGA/VGA) text fonts
  6959                              <1> 	;
  6960                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  6961                              <1> 	; vgabios-0.7a (2011)
  6962                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  6963                              <1> 	; 'vgabios.c', 'biosfn_load_text_8_16_pat'
  6964                              <1> 
  6965                              <1> 	; biosfn_load_text_8_16_pat (AL,BL)
  6966                              <1> 
  6967                              <1> 	; get_font_access();
  6968                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6969                              <1> 	; for(i=0;i<0x100;i++)
  6970                              <1> 	; {
  6971                              <1> 	;  src = i * 16;
  6972                              <1> 	;  dest = blockaddr + i * 32;
  6973                              <1> 	;  memcpyb(0xA000, dest, 0xC000, vgafont16+src, 16);
  6974                              <1> 	; }
  6975                              <1> 	; release_font_access();
  6976                              <1> 	; if(AL>=0x10)
  6977                              <1> 	; {
  6978                              <1> 	; set_scan_lines(16);
  6979                              <1> 	; }
  6980                              <1> 
  6981 00003488 50                  <1> 	push	eax
  6982 00003489 E887FEFFFF          <1> 	call	get_font_access
  6983                              <1> 
  6984                              <1> 	; blockaddr = ((BL & 0x03) << 14) + ((BL & 0x04) << 11);
  6985                              <1> 	;mov	dl, bl
  6986                              <1> 	;and	dl, 3
  6987                              <1> 	;shl	dx, 14
  6988                              <1> 	;xchg	dx, bx
  6989                              <1> 	;and	dl, 4
  6990                              <1> 	;shl	dx, 11
  6991                              <1> 	;add	dx, bx 	
  6992                              <1>  
  6993                              <1> 	;xor	dx, dx  ; blockaddr = 0
  6994                              <1> 	; Always block 0 for TRDOS 386 ! (blockaddr=0)
  6995                              <1> 
  6996 0000348E 28DB                <1> 	sub	bl, bl ; i = 0
  6997 00003490 B710                <1> 	mov	bh, 16
  6998                              <1> 	;mov	esi, vgafont16
  6999 00003492 BF00000A00          <1> 	mov	edi, 0A0000h
  7000 00003497 0FB6C7              <1> 	movzx	eax, bh
  7001                              <1> 
  7002                              <1> 	; 05/01/2021
  7003 0000349A F605[7E120300]80    <1> 	test	byte [ufont], 80h
  7004 000034A1 7410                <1> 	jz	short lt8_16_0
  7005                              <1> 		; user font permission (after set mode)
  7006 000034A3 F605[7E120300]10    <1>  	test	byte [ufont], 16
  7007 000034AA 7407                <1> 	jz	short lt8_16_0
  7008 000034AC BE00400900          <1> 	mov	esi, VGAFONT16USER
  7009 000034B1 EB05                <1> 	jmp	short lt8_16_1
  7010                              <1> lt8_16_0:
  7011 000034B3 BE[64760100]        <1> 	mov	esi, vgafont16
  7012                              <1> lt8_16_1:
  7013                              <1> 	;mov	al, bl
  7014                              <1> 	;mul	bh
  7015                              <1> 	;movzx	esi, ax
  7016                              <1> 	;add	esi, vgafont16
  7017                              <1> 	;mov	al, bl ; i
  7018                              <1> 	;sub	ah, ah
  7019                              <1> 	;shl	ax, 5 ; * 32
  7020                              <1> 	;;add	ax, dx ; blockaddr + i * 32;
  7021                              <1> 	;movzx	edi, ax ; dest
  7022                              <1> 	;add	edi, 0A0000h
  7023                              <1> 	;movzx	ecx, bh
  7024 000034B8 89C1                <1> 	mov	ecx, eax ; 16	
  7025 000034BA F3A4                <1> 	rep	movsb
  7026 000034BC 01C7                <1> 	add	edi, eax ; add edi, 16
  7027 000034BE FEC3                <1> 	inc	bl
  7028 000034C0 75F6                <1> 	jnz	short lt8_16_1
  7029                              <1> 	;
  7030 000034C2 E883FEFFFF          <1> 	call	release_font_access
  7031                              <1> 	;
  7032 000034C7 58                  <1> 	pop	eax
  7033                              <1> 	; if(AL>=0x10)
  7034 000034C8 3C10                <1> 	cmp	al, 10h
  7035 000034CA 7205                <1> 	jb	short lt8_16_2
  7036                              <1> 	; BH = 16
  7037                              <1>    	; set_scan_lines(16);
  7038 000034CC E8B8FEFFFF          <1> 	call	set_scan_lines
  7039                              <1> lt8_16_2:
  7040 000034D1 C3                  <1> 	retn
  7041                              <1> 
  7042                              <1> load_gfx_user_chars:
  7043                              <1> 	; 08/01/2021
  7044                              <1> 	; 05/01/2021 (TRDOS 386 v2.0.3)
  7045                              <1> 	; 08/08/2016
  7046                              <1> 	; 10/07/2016
  7047                              <1> 	; Setup User-Defined Font for Graphics Mode (VGA)
  7048                              <1> 	;
  7049                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7050                              <1> 	; vgabios-0.7a (2011)
  7051                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7052                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_user_chars'
  7053                              <1> 
  7054                              <1> 	; biosfn_load_gfx_user_chars (ES,BP,CX,BL,DL)
  7055                              <1> 	; /* set 0x43 INT pointer */
  7056                              <1>     	; write_word(0x0, 0x43*4, BP);
  7057                              <1>     	; write_word(0x0, 0x43*4+2, ES);
  7058                              <1> 	
  7059                              <1> 	; 08/01/2021
  7060                              <1> 		
  7061                              <1> 	; BL   screen rows code: 00H = user-specified (in DL)
  7062                              <1>         ;                        01H = 14 rows
  7063                              <1>         ;                        02H = 25 rows
  7064                              <1>         ;                        03H = 43 rows
  7065                              <1>         ; CX   bytes per character definition
  7066                              <1>         ; DL   (when BL=0) custom number of character rows on screen
  7067                              <1>         ; EBP  address of font-definition information (user's mem space)
  7068                              <1> 
  7069                              <1> 	; 05/01/2021
  7070                              <1> 	;xor	eax, eax
  7071                              <1> 	;dec	eax ; 0FFFFFFFFh (user defined fonts)
  7072                              <1> 	;mov	[VGA_INT43H], eax
  7073                              <1> 
  7074                              <1> 	; 08/01/2021
  7075                              <1> 	; ebp = video font data (buffer) address
  7076 000034D2 892D[7A960100]      <1> 	mov	[VGA_INT43H], ebp
  7077                              <1> 
  7078                              <1> 	; switch (BL) {
  7079                              <1> 	; case 0:
  7080                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7081                              <1> 	;    break;
  7082 000034D8 20DB                <1> 	and	bl, bl
  7083 000034DA 7508                <1> 	jnz	short l_gfx_uc_1
  7084 000034DC 8815[D26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7085 000034E2 EB23                <1> 	jmp	short l_gfx_uc_4 	
  7086                              <1> l_gfx_uc_1:
  7087                              <1> 	; case 1:
  7088                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7089                              <1> 	;    break;
  7090 000034E4 FECB                <1> 	dec	bl
  7091 000034E6 7509                <1> 	jnz	short l_gfx_uc_2
  7092                              <1> 	; bl = 1
  7093 000034E8 C605[D26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7094 000034EF EB16                <1> 	jmp	short l_gfx_uc_4 	
  7095                              <1> l_gfx_uc_2:
  7096 000034F1 FECB                <1> 	dec	bl
  7097 000034F3 740B                <1> 	jz	short l_gfx_uc_3 ; bl = 2
  7098 000034F5 FECB                <1> 	dec	bl
  7099 000034F7 750E                <1> 	jnz	short l_gfx_uc_4 ; bl > 3
  7100                              <1> 	; bl = 3
  7101                              <1> 	; case 3:
  7102                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7103                              <1> 	;    break;
  7104 000034F9 C605[D26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7105                              <1> l_gfx_uc_3:
  7106                              <1>     	; case 2:
  7107                              <1>     	; default:
  7108                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7109                              <1> 	;    break;
  7110                              <1> 	; bl = 2 or bl > 3
  7111 00003500 C605[D26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7112                              <1>     	; }
  7113                              <1> l_gfx_uc_4:
  7114                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, CX);
  7115 00003507 880D[CE6F0000]      <1> 	mov	[CHAR_HEIGHT], cl
  7116                              <1> 	; }
  7117 0000350D C3                  <1> 	retn
  7118                              <1> 
  7119                              <1> load_gfx_8_14_chars:
  7120                              <1> 	; 08/08/2016
  7121                              <1> 	; 10/07/2016
  7122                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  7123                              <1> 	;
  7124                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7125                              <1> 	; vgabios-0.7a (2011)
  7126                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7127                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_14_chars'
  7128                              <1> 
  7129                              <1> 	; biosfn_load_gfx_8_14_chars (BL)
  7130                              <1> 	; /* set 0x43 INT pointer */
  7131                              <1>     	; write_word(0x0, 0x43*4, &vgafont14);
  7132                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  7133 0000350E C705[7A960100]-     <1> 	mov	dword [VGA_INT43H], vgafont14
  7133 00003514 [64680100]          <1>
  7134                              <1> 		
  7135                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  7136                              <1>         ;                         01H = 14 rows
  7137                              <1>         ;                         02H = 25 rows
  7138                              <1>         ;                         03H = 43 rows
  7139                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  7140                              <1> 
  7141                              <1> 	; switch (BL) {
  7142                              <1> 	; case 0:
  7143                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7144                              <1> 	;    break;
  7145 00003518 20DB                <1> 	and	bl, bl
  7146 0000351A 7508                <1> 	jnz	short l_gfx_8_14c_1
  7147 0000351C 8815[D26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7148 00003522 EB23                <1> 	jmp	short l_gfx_8_14c_4 	
  7149                              <1> l_gfx_8_14c_1:
  7150                              <1> 	; case 1:
  7151                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7152                              <1> 	;    break;
  7153 00003524 FECB                <1> 	dec	bl
  7154 00003526 7509                <1> 	jnz	short l_gfx_8_14c_2
  7155                              <1> 	; bl = 1
  7156 00003528 C605[D26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7157 0000352F EB16                <1> 	jmp	short l_gfx_8_14c_4 	
  7158                              <1> l_gfx_8_14c_2:
  7159 00003531 FECB                <1> 	dec	bl
  7160 00003533 740B                <1> 	jz	short l_gfx_8_14c_3 ; bl = 2
  7161 00003535 FECB                <1> 	dec	bl
  7162 00003537 750E                <1> 	jnz	short l_gfx_8_14c_4 ; bl > 3
  7163                              <1> 	; bl = 3
  7164                              <1> 	; case 3:
  7165                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7166                              <1> 	;    break;
  7167 00003539 C605[D26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7168                              <1> l_gfx_8_14c_3:
  7169                              <1>     	; case 2:
  7170                              <1>     	; default:
  7171                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7172                              <1> 	;    break;
  7173                              <1> 	; bl = 2 or bl > 3
  7174 00003540 C605[D26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7175                              <1>     	; }
  7176                              <1> l_gfx_8_14c_4:
  7177                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 14);
  7178 00003547 C605[CE6F0000]0E    <1>         mov     byte [CHAR_HEIGHT], 14
  7179                              <1> 	; }
  7180 0000354E C3                  <1> 	retn	
  7181                              <1> 
  7182                              <1> load_gfx_8_8_chars:
  7183                              <1> 	; 08/08/2016
  7184                              <1> 	; 10/07/2016
  7185                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  7186                              <1> 	;
  7187                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7188                              <1> 	; vgabios-0.7a (2011)
  7189                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7190                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_8_dd_chars'
  7191                              <1> 
  7192                              <1> 	; biosfn_load_gfx_8_8_dd_chars (BL)
  7193                              <1> 	; /* set 0x43 INT pointer */
  7194                              <1>     	; write_word(0x0, 0x43*4, &vgafont8);
  7195                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  7196 0000354F C705[7A960100]-     <1> 	mov	dword [VGA_INT43H], vgafont8
  7196 00003555 [64600100]          <1>
  7197                              <1> 		
  7198                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  7199                              <1>         ;                         01H = 14 rows
  7200                              <1>         ;                         02H = 25 rows
  7201                              <1>         ;                         03H = 43 rows
  7202                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  7203                              <1> 
  7204                              <1> 	; switch (BL) {
  7205                              <1> 	; case 0:
  7206                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7207                              <1> 	;    break;
  7208 00003559 20DB                <1> 	and	bl, bl
  7209 0000355B 7508                <1> 	jnz	short l_gfx_8_8c_1
  7210 0000355D 8815[D26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7211 00003563 EB23                <1> 	jmp	short l_gfx_8_8c_4 	
  7212                              <1> l_gfx_8_8c_1:
  7213                              <1> 	; case 1:
  7214                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7215                              <1> 	;    break;
  7216 00003565 FECB                <1> 	dec	bl
  7217 00003567 7509                <1> 	jnz	short l_gfx_8_8c_2
  7218                              <1> 	; bl = 1
  7219 00003569 C605[D26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7220 00003570 EB16                <1> 	jmp	short l_gfx_8_8c_4 	
  7221                              <1> l_gfx_8_8c_2:
  7222 00003572 FECB                <1> 	dec	bl
  7223 00003574 740B                <1> 	jz	short l_gfx_8_8c_3 ; bl = 2
  7224 00003576 FECB                <1> 	dec	bl
  7225 00003578 750E                <1> 	jnz	short l_gfx_8_8c_4 ; bl > 3
  7226                              <1> 	; bl = 3
  7227                              <1> 	; case 3:
  7228                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7229                              <1> 	;    break;
  7230 0000357A C605[D26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7231                              <1> l_gfx_8_8c_3:
  7232                              <1>     	; case 2:
  7233                              <1>     	; default:
  7234                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7235                              <1> 	;    break;
  7236                              <1> 	; bl = 2 or bl > 3
  7237 00003581 C605[D26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7238                              <1>     	; }
  7239                              <1> l_gfx_8_8c_4:
  7240                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 8);
  7241 00003588 C605[CE6F0000]08    <1>         mov     byte [CHAR_HEIGHT], 8
  7242                              <1> 	; }
  7243 0000358F C3                  <1> 	retn
  7244                              <1> 
  7245                              <1> load_gfx_8_16_chars:
  7246                              <1> 	; 08/08/2016
  7247                              <1> 	; 10/07/2016
  7248                              <1> 	; Setup ROM 8x14 Font for Graphics Mode (VGA)
  7249                              <1> 	;
  7250                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7251                              <1> 	; vgabios-0.7a (2011)
  7252                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7253                              <1> 	; 'vgabios.c', 'biosfn_load_gfx_8_16_chars'
  7254                              <1> 
  7255                              <1> 	; biosfn_load_gfx_8_16_chars (BL)
  7256                              <1> 	; /* set 0x43 INT pointer */
  7257                              <1>     	; write_word(0x0, 0x43*4, &vgafont16);
  7258                              <1>     	; write_word(0x0, 0x43*4+2, 0xC000);
  7259 00003590 C705[7A960100]-     <1> 	mov	dword [VGA_INT43H], vgafont16
  7259 00003596 [64760100]          <1>
  7260                              <1> 		
  7261                              <1> 	; BL    screen rows code: 00H = user-specified (in DL)
  7262                              <1>         ;                         01H = 14 rows
  7263                              <1>         ;                         02H = 25 rows
  7264                              <1>         ;                         03H = 43 rows
  7265                              <1>         ; DL    (when BL=0) custom number of char rows on screen
  7266                              <1> 
  7267                              <1> 	; switch (BL) {
  7268                              <1> 	; case 0:
  7269                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, DL-1);
  7270                              <1> 	;    break;
  7271 0000359A 20DB                <1> 	and	bl, bl
  7272 0000359C 7508                <1> 	jnz	short l_gfx_8_16c_1
  7273 0000359E 8815[D26F0000]      <1> 	mov	[VGA_ROWS], dl  ; not DL-1 !
  7274 000035A4 EB23                <1> 	jmp	short l_gfx_8_16c_4 	
  7275                              <1> l_gfx_8_16c_1:
  7276                              <1> 	; case 1:
  7277                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 13);
  7278                              <1> 	;    break;
  7279 000035A6 FECB                <1> 	dec	bl
  7280 000035A8 7509                <1> 	jnz	short l_gfx_8_16c_2
  7281                              <1> 	; bl = 1
  7282 000035AA C605[D26F0000]0E    <1> 	mov	byte [VGA_ROWS], 14  ; not 13 !
  7283 000035B1 EB16                <1> 	jmp	short l_gfx_8_16c_4 	
  7284                              <1> l_gfx_8_16c_2:
  7285 000035B3 FECB                <1> 	dec	bl
  7286 000035B5 740B                <1> 	jz	short l_gfx_8_16c_3 ; bl = 2
  7287 000035B7 FECB                <1> 	dec	bl
  7288 000035B9 750E                <1> 	jnz	short l_gfx_8_16c_4 ; bl > 3
  7289                              <1> 	; bl = 3
  7290                              <1> 	; case 3:
  7291                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 42);
  7292                              <1> 	;    break;
  7293 000035BB C605[D26F0000]2B    <1> 	mov	byte [VGA_ROWS], 43  ; not 42 !
  7294                              <1> l_gfx_8_16c_3:
  7295                              <1>     	; case 2:
  7296                              <1>     	; default:
  7297                              <1> 	;    write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, 24);
  7298                              <1> 	;    break;
  7299                              <1> 	; bl = 2 or bl > 3
  7300 000035C2 C605[D26F0000]19    <1> 	mov	byte [VGA_ROWS], 25  ; not 24 !	
  7301                              <1>     	; }
  7302                              <1> l_gfx_8_16c_4:
  7303                              <1>     	; write_byte(BIOSMEM_SEG, BIOSMEM_CHAR_HEIGHT, 16);
  7304 000035C9 C605[CE6F0000]10    <1>         mov     byte [CHAR_HEIGHT], 16
  7305                              <1> 	; }
  7306 000035D0 C3                  <1> 	retn
  7307                              <1> 			
  7308                              <1> get_font_info:
  7309                              <1> 	; 08/01/2021 (TRDOS 386 v2.0.3)
  7310                              <1> 	; 19/09/2016
  7311                              <1> 	; 08/08/2016
  7312                              <1> 	; 10/07/2016
  7313                              <1> 	; Get Current Character Generator Info (VGA)
  7314                              <1> 	;
  7315                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7316                              <1> 	; vgabios-0.7a (2011)
  7317                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7318                              <1> 	; 'vgabios.c', 'biosfn_get_font_info'
  7319                              <1> 
  7320                              <1> 	; Modified for TRDOS 386 !
  7321                              <1> 	;
  7322                              <1> 	; INPUT ->
  7323                              <1> 	;    AX = 1130h
  7324                              <1> 	;    BL = 0 -> Get info for current VGA font
  7325                              <1> 	;	       (BH = unused)
  7326                              <1> 	;    19/09/2016
  7327                              <1> 	;    BL > 0 -> Get requested character font data
  7328                              <1> 	;	 BL = 1 -> vgafont8
  7329                              <1> 	;        BL = 2 -> vgafont14
  7330                              <1> 	;	 BL = 3 -> vgafont16   
  7331                              <1> 	;	;08/01/2021
  7332                              <1> 	;	 BL = 4 -> user defined 8x8 font
  7333                              <1> 	;	 BL = 5 -> user defined 8x14 font
  7334                              <1> 	;	 BL = 6 -> user defined 8x16 font
  7335                              <1> 	;	 BL > 6 -> Invalid function (for now!)
  7336                              <1> 	;	 BH = ASCII code of the first character
  7337                              <1> 	;	 ECX = Number of characters from the 1st char
  7338                              <1> 	;	 ECX >= 256 -> All (256-BH) characters
  7339                              <1> 	;	 ECX = 0 -> All characters (BH = unused)	
  7340                              <1> 	;        EDX = User's Buffer Address	
  7341                              <1> 	; OUTPUT ->
  7342                              <1> 	;    AL = height (scanlines), bytes per character
  7343                              <1> 	;    AH = screen rows
  7344                              <1> 	;    Byte 16-23 of EAX = number of columns
  7345                              <1> 	;    Byte 24-31 of EAX = 
  7346                              <1> 	;	  0 -> default font (not configured yet)
  7347                              <1> 	;	  0FFh -> user defined font
  7348                              <1> 	;	  14 = vgafont14
  7349                              <1> 	;	   8 = vgafont8
  7350                              <1> 	;	  16 = vgafont16
  7351                              <1> 	;   If BL input > 0 -> 
  7352                              <1> 	;       EAX = Actual transfer count
  7353                              <1> 	;
  7354 000035D1 20DB                <1> 	and	bl, bl
  7355 000035D3 740F                <1> 	jz	short gfi_1
  7356                              <1> 	; invalid function (input)
  7357                              <1> 	; 08/01/2021
  7358 000035D5 80FB04              <1> 	cmp	bl, 4
  7359 000035D8 7263                <1> 	jb	short gfi_5
  7360 000035DA 7441                <1> 	je	short gfi_3	
  7361 000035DC 80FB06              <1> 	cmp	bl, 6
  7362 000035DF 744C                <1> 	je	short gfi_4
  7363                              <1> 	; bh = 5 or bh > 6
  7364                              <1> gfi_0:
  7365 000035E1 31C0                <1> 	xor	eax, eax ; 0
  7366 000035E3 C3                  <1> 	retn
  7367                              <1> gfi_1:
  7368 000035E4 A0[CE6F0000]        <1> 	mov	al, [CHAR_HEIGHT]
  7369 000035E9 8A25[D26F0000]      <1> 	mov	ah, [VGA_ROWS]
  7370 000035EF C1E010              <1> 	shl	eax, 16
  7371 000035F2 A0[CC6F0000]        <1> 	mov	al, [CRT_COLS]
  7372 000035F7 8B0D[7A960100]      <1> 	mov	ecx, [VGA_INT43H]
  7373 000035FD 21C9                <1> 	and	ecx, ecx
  7374 000035FF 7418                <1> 	jz	short gfi_2 ; 0 = default font
  7375                              <1> 	; 08/01/2021
  7376 00003601 FECC                <1> 	dec	ah ; 0FFh
  7377 00003603 81F900400900        <1> 	cmp	ecx, VGAFONT16USER
  7378 00003609 740E                <1> 	je	short gfi_2
  7379 0000360B 81F900500900        <1> 	cmp	ecx, VGAFONT8USER
  7380 00003611 7406                <1> 	je	short gfi_2	
  7381 00003613 8A25[CE6F0000]      <1> 	mov	ah, [CHAR_HEIGHT] ; font size = height
  7382                              <1> gfi_2:
  7383 00003619 C1C010              <1> 	rol	eax, 16
  7384 0000361C C3                  <1> 	retn
  7385                              <1> gfi_3:
  7386                              <1> 	; 08/01/2021
  7387 0000361D F605[7E120300]08    <1> 	test	byte [ufont], 08h ; 8x8 user font
  7388 00003624 74BB                <1> 	jz	short gfi_0 ; not loaded !
  7389 00003626 BE00500900          <1> 	mov	esi, VGAFONT8USER ; *
  7390                              <1> 	;mov	bl, 8
  7391                              <1> 	;jmp	short gfi_8
  7392 0000362B EB4D                <1> 	jmp	short gfi_10
  7393                              <1> gfi_4:
  7394                              <1> 	; 08/01/2021
  7395 0000362D F605[7E120300]10    <1> 	test	byte [ufont], 10h ; 8x16 user font
  7396 00003634 74AB                <1> 	jz	short gfi_0 ; not loaded !
  7397 00003636 BE00400900          <1> 	mov	esi, VGAFONT16USER ; *
  7398 0000363B EB15                <1> 	jmp	short gfi_7
  7399                              <1> gfi_5:
  7400 0000363D 80FB02              <1> 	cmp	bl, 2
  7401 00003640 7233                <1> 	jb	short gfi_9
  7402 00003642 7709                <1> 	ja	short gfi_6
  7403                              <1> 	;BL = 2 -> vgafont14
  7404 00003644 BE[64680100]        <1> 	mov	esi, vgafont14 ; *
  7405 00003649 B30E                <1> 	mov	bl, 14
  7406 0000364B EB07                <1> 	jmp	short gfi_8 
  7407                              <1> gfi_6:
  7408                              <1> 	;BL = 3 -> vgafont16
  7409 0000364D BE[64760100]        <1> 	mov	esi, vgafont16 ; *
  7410                              <1> gfi_7:
  7411 00003652 B310                <1> 	mov	bl, 16
  7412                              <1> gfi_8:
  7413 00003654 89D7                <1> 	mov	edi, edx ; **
  7414 00003656 09C9                <1> 	or	ecx, ecx
  7415 00003658 7424                <1> 	jz	short gfi_11 ; all chars from the 00h
  7416 0000365A 88F8                <1> 	mov	al, bh ; character index
  7417 0000365C F6E3                <1> 	mul	bl ; char index * char height/size
  7418 0000365E 0FB7D0              <1> 	movzx	edx, ax
  7419 00003661 01D6                <1> 	add	esi, edx ; *
  7420 00003663 66BAFF00            <1> 	mov	dx, 255
  7421 00003667 28FA                <1> 	sub	dl, bh
  7422 00003669 6642                <1> 	inc	dx	
  7423 0000366B 39D1                <1> 	cmp	ecx, edx
  7424 0000366D 770F                <1> 	ja	short gfi_11
  7425 0000366F 7412                <1> 	je	short gfi_12
  7426 00003671 89D1                <1> 	mov	ecx, edx
  7427 00003673 EB0E                <1> 	jmp	short gfi_12
  7428                              <1> gfi_9:
  7429                              <1> 	;BL = 1 -> vgafont8
  7430 00003675 BE[64600100]        <1> 	mov	esi, vgafont8 ; *
  7431                              <1> gfi_10:
  7432 0000367A B308                <1> 	mov	bl, 8
  7433 0000367C EBD6                <1> 	jmp	short gfi_8
  7434                              <1> gfi_11:
  7435 0000367E B900010000          <1> 	mov	ecx, 256
  7436                              <1> gfi_12:
  7437                              <1> 	; 08/01/2021
  7438 00003683 89C8                <1> 	mov	eax, ecx ; character count
  7439 00003685 30FF                <1> 	xor	bh, bh
  7440 00003687 66F7E3              <1> 	mul	bx ; char count * char height/size	
  7441 0000368A 89C1                <1>  	mov	ecx, eax
  7442                              <1> 
  7443                              <1> 	; ESI = source address in system space
  7444                              <1> 	; EDI = user's buffer address
  7445                              <1> 	; ECX = transfer (byte) count
  7446 0000368C E873E40000          <1> 	call	transfer_to_user_buffer
  7447 00003691 89C8                <1> 	mov	eax, ecx ; actual transfer count
  7448 00003693 C3                  <1> 	retn
  7449                              <1> 	
  7450                              <1> vga_pal_funcs:
  7451                              <1> 	; 10/08/2016
  7452                              <1> 	; VGA Palette functions
  7453                              <1> 	;
  7454                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
  7455                              <1> 	; vgabios-0.7a (2011)
  7456                              <1> 	; by the LGPL VGABios developers Team (2001-2008)
  7457                              <1> 	; 'vgabios.c', 'vgarom.asm'
  7458                              <1> 
  7459 00003694 3C00                <1> 	cmp	al, 0
  7460 00003696 0F848F000000        <1>         je      set_single_palette_reg
  7461                              <1> vga_palf_1001:
  7462 0000369C 3C01                <1> 	cmp	al, 1
  7463 0000369E 0F84B4000000        <1>         je      set_overscan_border_color
  7464                              <1> vga_palf_1002:
  7465 000036A4 3C02                <1> 	cmp	al, 2
  7466 000036A6 0F84B0000000        <1>         je      set_all_palette_reg
  7467                              <1> vga_palf_1003:
  7468 000036AC 3C03                <1> 	cmp	al, 3
  7469 000036AE 0F84E8000000        <1>         je      toggle_intensity
  7470                              <1> vga_palf_1007:
  7471 000036B4 3C07                <1> 	cmp	al, 7
  7472 000036B6 0F840D010000        <1>         je      get_single_palette_reg
  7473 000036BC 7266                <1> 	jb	short vga_palf_unknown
  7474                              <1> vga_palf_1008:
  7475 000036BE 3C08                <1> 	cmp	al, 8
  7476 000036C0 0F8437010000        <1>         je      read_overscan_border_color
  7477                              <1> vga_palf_1009:
  7478 000036C6 3C09                <1> 	cmp	al, 9
  7479 000036C8 0F8433010000        <1> 	je	get_all_palette_reg
  7480                              <1> vga_palf_1010:
  7481 000036CE 3C10                <1> 	cmp	al, 10h
  7482 000036D0 0F8487010000        <1> 	je 	set_single_dac_reg
  7483 000036D6 724C                <1> 	jb	short vga_palf_unknown
  7484                              <1> vga_palf_1012:
  7485 000036D8 3C12                <1> 	cmp	al, 12h
  7486 000036DA 0F8498010000        <1>         je      set_all_dac_reg
  7487 000036E0 7242                <1> 	jb	short vga_palf_unknown
  7488                              <1> vga_palf_1013:
  7489 000036E2 3C13                <1> 	cmp	al, 13h
  7490 000036E4 0F84CC010000        <1>         je      select_video_dac_color_page
  7491                              <1> vga_palf_1015:
  7492 000036EA 3C15                <1> 	cmp	al, 15h
  7493 000036EC 0F8412020000        <1> 	je	read_single_dac_reg
  7494 000036F2 7230                <1> 	jb	short vga_palf_unknown
  7495                              <1> vga_palf_1017:
  7496 000036F4 3C17                <1> 	cmp	al, 17h
  7497 000036F6 0F8428020000        <1>         je      read_all_dac_reg
  7498 000036FC 7226                <1> 	jb	short vga_palf_unknown
  7499                              <1> vga_palf_1018:
  7500 000036FE 3C18                <1> 	cmp	al, 18h
  7501 00003700 0F845E020000        <1>         je      set_pel_mask
  7502                              <1> vga_palf_1019:
  7503 00003706 3C19                <1> 	cmp	al, 19h
  7504 00003708 0F8462020000        <1>         je      read_pel_mask
  7505                              <1> vga_palf_101A:
  7506 0000370E 3C1A                <1> 	cmp	al, 1Ah
  7507 00003710 0F8468020000        <1>         je      read_video_dac_state
  7508                              <1> vga_palf_101B:
  7509 00003716 3C1B                <1> 	cmp	al, 1Bh
  7510                              <1> 	;jne	short vga_palf_unknown
  7511 00003718 770A                <1> 	ja	short vga_palf_unknown
  7512                              <1>  
  7513 0000371A E8C3F5FFFF          <1> 	call	gray_scale_summing
  7514 0000371F E933E4FFFF          <1>         jmp     VIDEO_RETURN 	
  7515                              <1> 
  7516                              <1> vga_palf_unknown:
  7517 00003724 29C0                <1> 	sub	eax, eax ; 0 = invalid function
  7518 00003726 E931E4FFFF          <1>         jmp     _video_return
  7519                              <1> 
  7520                              <1> set_single_palette_reg:
  7521                              <1> 	; 10/08/2016
  7522                              <1> 	; Set One Palette Register
  7523                              <1> 	; BL = register number to set
  7524                              <1> 	;     (a 4-bit attribute nibble: 00h-0Fh)
  7525                              <1> 	; BH = 6-bit RGB color to display 
  7526                              <1> 	;      for that attribute
  7527                              <1> 
  7528 0000372B 80FB14              <1> 	cmp	bl, 14h
  7529                              <1> 	;ja	short no_actl_reg1
  7530 0000372E 0F8723E4FFFF        <1> 	ja	VIDEO_RETURN
  7531 00003734 6650                <1> 	push	ax
  7532 00003736 6652                <1> 	push	dx
  7533 00003738 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7534 0000373C EC                  <1> 	in	al, dx
  7535 0000373D 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7536 00003741 88D8                <1> 	mov	al, bl
  7537 00003743 EE                  <1> 	out	dx, al
  7538 00003744 88F8                <1> 	mov	al, bh
  7539 00003746 EE                  <1> 	out	dx, al
  7540 00003747 B020                <1> 	mov	al, 20h
  7541 00003749 EE                  <1> 	out	dx, al
  7542                              <1> 	; ifdef VBOX
  7543 0000374A 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7544 0000374E EC                  <1> 	in	al, dx
  7545                              <1> 	; endif ; VBOX
  7546 0000374F 665A                <1> 	pop	dx
  7547 00003751 6658                <1> 	pop	ax
  7548                              <1> ;no_actl_reg1:
  7549 00003753 E9FFE3FFFF          <1> 	jmp	VIDEO_RETURN
  7550                              <1> 
  7551                              <1> set_overscan_border_color:
  7552                              <1> 	; 10/08/2016
  7553                              <1> 	; Set Overscan/Border Color Register
  7554                              <1> 	; BH = 6-bit RGB color to display 
  7555                              <1> 	;      for that attribute
  7556                              <1> 	
  7557 00003758 B311                <1> 	mov	bl, 11h
  7558 0000375A EBCF                <1>   	jmp	short set_single_palette_reg
  7559                              <1> 
  7560                              <1> set_all_palette_reg:
  7561                              <1> 	; 10/08/2016
  7562                              <1> 	; Set All Palette Registers and Overscan
  7563                              <1> 	; EDX = Address of 17 bytes; 
  7564                              <1> 	; an rgbRGB value for each of 16 palette
  7565                              <1> 	; registers plus one for the border.
  7566                              <1> 
  7567 0000375C 89D6                <1> 	mov	esi, edx ; user buffer
  7568 0000375E B911000000          <1> 	mov	ecx, 17
  7569 00003763 89E7                <1> 	mov	edi, esp
  7570 00003765 83EC14              <1> 	sub	esp, 20	 	 
  7571 00003768 E8E1E30000          <1> 	call	transfer_from_user_buffer
  7572                              <1> 	;jc	VIDEO_RETURN
  7573                              <1> 
  7574 0000376D 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7575 00003771 EC                  <1> 	in	al, dx
  7576 00003772 B100                <1> 	mov	cl, 0
  7577 00003774 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7578                              <1> set_palette_loop:
  7579 00003778 88C8                <1> 	mov	al, cl
  7580 0000377A EE                  <1> 	out	dx, al
  7581 0000377B 8A07                <1> 	mov	al, [edi]
  7582 0000377D EE                  <1> 	out	dx, al
  7583 0000377E 47                  <1> 	inc	edi
  7584 0000377F FEC1                <1> 	inc	cl
  7585 00003781 80F910              <1> 	cmp	cl, 10h
  7586 00003784 75F2                <1> 	jne	short set_palette_loop
  7587 00003786 B011                <1> 	mov	al, 11h
  7588 00003788 EE                  <1> 	out	dx, al
  7589 00003789 8A07                <1> 	mov	al, [edi]
  7590 0000378B EE                  <1> 	out	dx, al
  7591 0000378C B020                <1> 	mov	al, 20h
  7592 0000378E EE                  <1> 	out	dx, al
  7593                              <1> 	; ifdef VBOX
  7594 0000378F 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7595 00003793 EC                  <1> 	in	al, dx
  7596                              <1> 	; endif ; VBOX
  7597 00003794 83C414              <1> 	add	esp, 20
  7598 00003797 E9BBE3FFFF          <1> 	jmp	VIDEO_RETURN
  7599                              <1> 
  7600                              <1> toggle_intensity:
  7601                              <1> 	; 10/08/2016
  7602                              <1> 	; Select Foreground Blink or Bold Background
  7603                              <1> 	; BL = 00h = enable bold backgrounds
  7604                              <1> 	;	    (16 background colors)
  7605                              <1>         ;      01h = enable blinking foreground
  7606                              <1> 	;	    (8 background colors)
  7607                              <1> 
  7608 0000379C 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7609 000037A0 EC                  <1> 	in	al, dx
  7610 000037A1 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7611 000037A5 B010                <1> 	mov	al, 10h
  7612 000037A7 EE                  <1> 	out	dx, al
  7613 000037A8 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7614 000037AC EC                  <1> 	in	al, dx
  7615 000037AD 24F7                <1> 	and	al, 0F7h
  7616 000037AF 80E301              <1> 	and	bl, 01h
  7617 000037B2 C0E303              <1> 	shl	bl, 3
  7618 000037B5 08D8                <1> 	or	al, bl
  7619 000037B7 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7620 000037BB EE                  <1> 	out	dx, al
  7621 000037BC B020                <1> 	mov	al, 20h
  7622 000037BE EE                  <1> 	out	dx, al
  7623                              <1> 	; ifdef VBOX
  7624 000037BF 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7625 000037C3 EC                  <1> 	in	al, dx
  7626                              <1> 	; endif ; VBOX
  7627 000037C4 E98EE3FFFF          <1> 	jmp	VIDEO_RETURN
  7628                              <1> 
  7629                              <1> get_single_palette_reg:
  7630                              <1> 	; 10/08/2016
  7631                              <1> 	; Read One Palette Register
  7632                              <1>         ; INPUT:
  7633                              <1> 	; BL = Palette register to read (00h-0Fh)
  7634                              <1> 	; OUTPUT:
  7635                              <1> 	; BH = Current rgbRGB value of specified register
  7636                              <1> 	;      for that attribute
  7637                              <1> 
  7638 000037C9 80FB14              <1> 	cmp	bl, 14h
  7639                              <1> 	;ja	short no_actl_reg2
  7640 000037CC 0F8785E3FFFF        <1> 	ja	VIDEO_RETURN
  7641                              <1> 
  7642 000037D2 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7643 000037D6 EC                  <1> 	in	al, dx
  7644 000037D7 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7645 000037DB 88D8                <1> 	mov	al, bl
  7646 000037DD EE                  <1> 	out	dx, al
  7647 000037DE 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7648 000037E2 EC                  <1> 	in	al, dx
  7649 000037E3 8844240D            <1> 	mov	[esp+13], al ; bh
  7650 000037E7 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7651 000037EB EC                  <1> 	in	al, dx
  7652 000037EC 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7653 000037F0 B020                <1> 	mov	al, 20h
  7654 000037F2 EE                  <1> 	out	dx, al
  7655                              <1> 	; ifdef VBOX
  7656 000037F3 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7657 000037F7 EC                  <1> 	in	al, dx
  7658                              <1> 	; endif ; VBOX
  7659 000037F8 E95AE3FFFF          <1> 	jmp	VIDEO_RETURN
  7660                              <1> 
  7661                              <1> read_overscan_border_color:
  7662                              <1> 	; 10/08/2016
  7663                              <1> 	; Read Overscan Register
  7664                              <1> 	; OUTPUT:
  7665                              <1> 	; BH = current rgbRGB value 
  7666                              <1> 	;      of the overscan/border register
  7667                              <1> 
  7668 000037FD B311                <1> 	mov	bl, 11h
  7669 000037FF EBC8                <1> 	jmp	short get_single_palette_reg
  7670                              <1> 
  7671                              <1> get_all_palette_reg:
  7672                              <1> 	; 10/08/2016
  7673                              <1> 	; Read All Palette Registers
  7674                              <1> 	; EDX = Address of 17-byte buffer 
  7675                              <1> 	;	to receive data
  7676                              <1> 	
  7677 00003801 89D7                <1> 	mov	edi, edx
  7678 00003803 89E3                <1> 	mov	ebx, esp
  7679 00003805 89DE                <1> 	mov	esi, ebx
  7680 00003807 83EC14              <1> 	sub	esp, 20	 
  7681                              <1> 
  7682 0000380A B100                <1> 	mov	cl, 0
  7683                              <1> get_palette_loop:
  7684 0000380C 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7685 00003810 EC                  <1> 	in	al, dx
  7686 00003811 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7687 00003815 88C8                <1> 	mov	al, cl
  7688 00003817 EE                  <1> 	out	dx, al
  7689 00003818 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7690 0000381C EC                  <1> 	in	al, dx
  7691 0000381D 8803                <1> 	mov	[ebx], al
  7692 0000381F 43                  <1> 	inc	ebx
  7693 00003820 FEC1                <1> 	inc	cl
  7694 00003822 80F910              <1> 	cmp	cl, 10h
  7695 00003825 75E5                <1> 	jne	short get_palette_loop
  7696 00003827 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7697 0000382B EC                  <1> 	in	al, dx
  7698 0000382C 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7699 00003830 B011                <1> 	mov	al, 11h
  7700 00003832 EE                  <1> 	out	dx, al
  7701 00003833 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7702 00003837 EC                  <1> 	in	al, dx
  7703 00003838 8803                <1> 	mov	[ebx], al
  7704 0000383A 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7705 0000383E EC                  <1> 	in	al, dx
  7706 0000383F 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7707 00003843 B020                <1> 	mov	al, 20h
  7708 00003845 EE                  <1> 	out	dx, al
  7709                              <1> 	; ifdef VBOX
  7710 00003846 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7711 0000384A EC                  <1> 	in	al, dx
  7712                              <1> 	; endif ; VBOX
  7713                              <1> 
  7714 0000384B B911000000          <1> 	mov	ecx, 17 ; transfer (byte) count
  7715                              <1> 	; ESI = source address in system space
  7716                              <1> 	; EDI = user's buffer address
  7717 00003850 E8AFE20000          <1> 	call	transfer_to_user_buffer
  7718                              <1> 
  7719 00003855 83C414              <1> 	add	esp, 20
  7720 00003858 E9FAE2FFFF          <1> 	jmp	VIDEO_RETURN
  7721                              <1> 
  7722                              <1> set_single_dac_reg:
  7723                              <1> 	; 10/08/2016
  7724                              <1> 	; Set One DAC Color Register
  7725                              <1> 	; BX = color register to set (0-255)
  7726                              <1>         ; CH = green value (00h-3Fh)
  7727                              <1>         ; CL = blue value  (00h-3Fh)
  7728                              <1>         ; DH = red value   (00h-3Fh)
  7729                              <1> 
  7730 0000385D 6652                <1> 	push	dx
  7731 0000385F 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  7732 00003863 88D8                <1> 	mov	al, bl
  7733 00003865 EE                  <1> 	out	dx, al
  7734                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  7735 00003866 6642                <1> 	inc	dx
  7736 00003868 6658                <1> 	pop	ax
  7737 0000386A 88E0                <1> 	mov	al, ah
  7738 0000386C EE                  <1> 	out	dx, al
  7739 0000386D 88E8                <1> 	mov	al, ch
  7740 0000386F EE                  <1> 	out	dx, al
  7741 00003870 88C8                <1> 	mov	al, cl
  7742 00003872 EE                  <1> 	out	dx, al
  7743 00003873 E9DFE2FFFF          <1> 	jmp	VIDEO_RETURN
  7744                              <1> 
  7745                              <1> set_all_dac_reg:
  7746                              <1> 	; 12/08/2016
  7747                              <1> 	; 11/08/2016
  7748                              <1> 	; 10/08/2016
  7749                              <1> 	; Set a Block of DAC Color Register
  7750                              <1> 	; BX = first DAC register to set (0-00FFh)
  7751                              <1> 	; ECX = number of registers to set (0-00FFh)
  7752                              <1> 	; EDX = addr of a table of R,G,B values 
  7753                              <1> 	;	(it will be CX*3 bytes long)
  7754                              <1> 
  7755 00003878 89D6                <1> 	mov	esi, edx ; user buffer
  7756 0000387A 89CA                <1> 	mov	edx, ecx
  7757 0000387C 66D1E1              <1> 	shl	cx, 1 ; *2
  7758 0000387F 01D1                <1> 	add	ecx, edx ; ecx = 3*ecx
  7759 00003881 89E5                <1> 	mov	ebp, esp
  7760 00003883 89EF                <1> 	mov	edi, ebp
  7761 00003885 29CF                <1> 	sub	edi, ecx
  7762 00003887 6683E7FC            <1> 	and	di, 0FFFCh ; (dword alignment)
  7763 0000388B 89FC                <1> 	mov	esp, edi
  7764 0000388D E8BCE20000          <1> 	call	transfer_from_user_buffer
  7765                              <1> 	;jc	VIDEO_RETURN
  7766                              <1> 
  7767 00003892 89D1                <1> 	mov	ecx, edx
  7768 00003894 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  7769 00003898 88D8                <1> 	mov	al, bl
  7770 0000389A EE                  <1> 	out	dx, al
  7771 0000389B 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  7772                              <1> set_dac_loop:
  7773 0000389F 8A07                <1> 	mov	al, [edi]
  7774 000038A1 EE                  <1> 	out	dx, al
  7775 000038A2 47                  <1> 	inc	edi
  7776 000038A3 8A07                <1> 	mov	al, [edi]
  7777 000038A5 EE                  <1> 	out	dx, al
  7778 000038A6 47                  <1> 	inc	edi
  7779 000038A7 8A07                <1> 	mov	al, [edi]
  7780 000038A9 EE                  <1> 	out	dx, al
  7781 000038AA 47                  <1> 	inc	edi
  7782 000038AB 6649                <1> 	dec	cx
  7783 000038AD 75F0                <1> 	jnz	short set_dac_loop
  7784 000038AF 89EC                <1> 	mov	esp, ebp
  7785 000038B1 E9A1E2FFFF          <1> 	jmp	VIDEO_RETURN
  7786                              <1> 
  7787                              <1> select_video_dac_color_page:
  7788                              <1> 	; 10/08/2016
  7789                              <1> 	; DAC Color Paging Functions
  7790                              <1> 	; BL = 00H = select color paging mode
  7791                              <1>         ;       BH = paging mode
  7792                              <1>         ;            00h = 4 blocks of 64 registers
  7793                              <1>         ;            01h = 16 blocks of 16 registers
  7794                              <1> 	; BL = 01H = activate color page
  7795                              <1>         ;       BH = DAC color page number
  7796                              <1>         ;            00h-03h (4-page/64-reg mode)
  7797                              <1>         ;            00h-0Fh (16-page/16-reg mode)
  7798                              <1> 
  7799 000038B6 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7800 000038BA EC                  <1> 	in	al, dx
  7801 000038BB 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7802 000038BF B010                <1> 	mov	al, 10h
  7803 000038C1 EE                  <1> 	out	dx, al
  7804 000038C2 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7805 000038C6 EC                  <1> 	in	al, dx
  7806 000038C7 80E301              <1> 	and	bl, 01h
  7807 000038CA 750E                <1> 	jnz	short set_dac_page
  7808 000038CC 247F                <1> 	and	al, 07Fh
  7809 000038CE C0E707              <1> 	shl	bh, 7
  7810 000038D1 08F8                <1> 	or	al, bh
  7811 000038D3 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7812 000038D7 EE                  <1> 	out	dx, al
  7813 000038D8 EB1D                <1> 	jmp	short set_actl_normal
  7814                              <1> set_dac_page:
  7815 000038DA 6650                <1> 	push	ax
  7816 000038DC 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7817 000038E0 EC                  <1> 	in	al, dx
  7818 000038E1 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7819 000038E5 B014                <1> 	mov	al, 14h
  7820 000038E7 EE                  <1> 	out	dx, al
  7821 000038E8 6658                <1> 	pop	ax
  7822 000038EA 2480                <1> 	and	al, 80h
  7823 000038EC 7503                <1> 	jnz	short set_dac_16_page
  7824 000038EE C0E702              <1> 	shl	bh, 2
  7825                              <1> set_dac_16_page:
  7826 000038F1 80E70F              <1> 	and	bh, 0Fh
  7827 000038F4 88F8                <1> 	mov	al, bh
  7828 000038F6 EE                  <1> 	out	dx, al
  7829                              <1> set_actl_normal:
  7830 000038F7 B020                <1> 	mov	al, 20h
  7831 000038F9 EE                  <1> 	out	dx, al
  7832                              <1> 	; ifdef VBOX
  7833 000038FA 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7834 000038FE EC                  <1> 	in	al, dx
  7835                              <1> 	; endif ; VBOX
  7836 000038FF E953E2FFFF          <1> 	jmp	VIDEO_RETURN	
  7837                              <1> 
  7838                              <1> read_single_dac_reg:
  7839                              <1> 	; 10/08/2016
  7840                              <1> 	; Read One DAC Color Register
  7841                              <1> 	; INPUT:
  7842                              <1> 	; BX = color register to read (0-255)
  7843                              <1> 	; OUTPUT:
  7844                              <1> 	; CH = green value (00h-3Fh)
  7845                              <1>         ; CL = blue value  (00h-3Fh)
  7846                              <1>         ; DH = red value   (00h-3Fh)
  7847                              <1> 
  7848 00003904 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  7849 00003908 88D8                <1> 	mov	al, bl
  7850 0000390A EE                  <1> 	out	dx, al
  7851 0000390B 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  7852 0000390F EC                  <1> 	in	al, dx
  7853 00003910 88442415            <1> 	mov	[esp+21], al ; dh
  7854 00003914 EC                  <1> 	in	al, dx
  7855 00003915 88C5                <1> 	mov	ch, al
  7856 00003917 EC                  <1> 	in	al, dx
  7857 00003918 88C1                <1> 	mov	cl, al
  7858 0000391A 66894C2410          <1> 	mov	[esp+16], cx ; cx
  7859 0000391F E933E2FFFF          <1> 	jmp	VIDEO_RETURN	
  7860                              <1> 
  7861                              <1> read_all_dac_reg:
  7862                              <1> 	; 12/08/2016
  7863                              <1> 	; 11/08/2016
  7864                              <1> 	; 10/08/2016
  7865                              <1> 	; Read a Block of DAC Color Registers
  7866                              <1>         ; BX = first DAC register to read (0-00FFh)
  7867                              <1>         ; ECX = number of registers to read (0-00FFh)
  7868                              <1>         ; EDX = addr of a buffer to hold R,G,B values
  7869                              <1> 	;	(CX*3 bytes long)
  7870                              <1> 
  7871 00003924 89D7                <1> 	mov	edi, edx ; user buffer
  7872 00003926 89CA                <1> 	mov	edx, ecx
  7873 00003928 66D1E2              <1> 	shl	dx, 1 ; *2
  7874 0000392B 01CA                <1> 	add	edx, ecx ; edx = 3*ecx
  7875 0000392D 89E5                <1> 	mov	ebp, esp
  7876 0000392F 89EE                <1> 	mov	esi, ebp
  7877 00003931 29D6                <1> 	sub	esi, edx
  7878 00003933 6683E6FC            <1> 	and	si, 0FFFCh ; (dword alignment)
  7879 00003937 89F4                <1> 	mov	esp, esi
  7880 00003939 52                  <1> 	push	edx ; 3*ecx
  7881 0000393A 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  7882 0000393E 88D8                <1> 	mov	al, bl
  7883 00003940 EE                  <1> 	out	dx, al
  7884 00003941 66BAC903            <1> 	mov	dx, 3C9h ; VGAREG_DAC_DATA
  7885 00003945 89F3                <1> 	mov	ebx, esi
  7886                              <1> read_dac_loop:
  7887 00003947 EC                  <1> 	in	al, dx
  7888 00003948 8803                <1> 	mov	[ebx], al
  7889 0000394A 43                  <1> 	inc	ebx
  7890 0000394B EC                  <1> 	in	al, dx
  7891 0000394C 8803                <1> 	mov	[ebx], al
  7892 0000394E 43                  <1> 	inc	ebx
  7893 0000394F EC                  <1> 	in	al, dx
  7894 00003950 8803                <1> 	mov	[ebx], al
  7895 00003952 43                  <1> 	inc	ebx
  7896 00003953 6649                <1> 	dec	cx
  7897 00003955 75F0                <1> 	jnz	short read_dac_loop
  7898 00003957 59                  <1> 	pop	ecx ; 3*ecx
  7899                              <1> 	; ECX = transfer (byte) count
  7900                              <1> 	; ESI = source address in system space
  7901                              <1> 	; EDI = user's buffer address
  7902 00003958 E8A7E10000          <1> 	call	transfer_to_user_buffer
  7903 0000395D 89EC                <1> 	mov	esp, ebp
  7904 0000395F E9F3E1FFFF          <1> 	jmp	VIDEO_RETURN
  7905                              <1> 
  7906                              <1> set_pel_mask:
  7907                              <1> 	; 10/08/2016
  7908                              <1> 	; BL = mask value
  7909 00003964 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
  7910 00003968 88D8                <1> 	mov	al, bl
  7911 0000396A EE                  <1> 	out	dx, al
  7912 0000396B E9E7E1FFFF          <1> 	jmp	VIDEO_RETURN
  7913                              <1> 
  7914                              <1> read_pel_mask:
  7915                              <1> 	; 10/08/2016
  7916                              <1> 	; Output: BL = mask value 
  7917 00003970 66BAC603            <1> 	mov	dx, 3C6h ; VGAREG_PEL_MASK
  7918 00003974 EC                  <1> 	in	al, dx
  7919 00003975 8844240C            <1> 	mov	[esp+12], al ; bl
  7920 00003979 E9D9E1FFFF          <1> 	jmp	VIDEO_RETURN
  7921                              <1> 
  7922                              <1> read_video_dac_state:
  7923                              <1> 	; 10/08/2016
  7924                              <1> 	; Query DAC Color Paging State
  7925                              <1> 	; Output:
  7926                              <1> 	; BH = current active DAC color page
  7927                              <1>         ; BL = current active DAC paging mode
  7928                              <1> 
  7929 0000397E 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7930 00003982 EC                  <1> 	in	al, dx
  7931 00003983 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7932 00003987 B010                <1> 	mov	al, 10h
  7933 00003989 EE                  <1> 	out	dx, al
  7934 0000398A 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7935 0000398E EC                  <1> 	in	al, dx
  7936 0000398F 88C3                <1> 	mov	bl, al
  7937 00003991 C0EB07              <1> 	shr	bl, 7
  7938 00003994 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7939 00003998 EC                  <1> 	in	al, dx
  7940 00003999 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7941 0000399D B014                <1> 	mov	al, 14h
  7942 0000399F EE                  <1> 	out	dx, al
  7943 000039A0 66BAC103            <1> 	mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
  7944 000039A4 EC                  <1> 	in	al, dx
  7945 000039A5 88C7                <1> 	mov	bh, al
  7946 000039A7 80E70F              <1> 	and	bh, 0Fh
  7947 000039AA F6C301              <1> 	test	bl, 01
  7948 000039AD 7503                <1> 	jnz	short get_dac_16_page
  7949 000039AF C0EF02              <1> 	shr	bh, 2
  7950                              <1> get_dac_16_page:
  7951 000039B2 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7952 000039B6 EC                  <1> 	in	al, dx
  7953 000039B7 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
  7954 000039BB B020                <1> 	mov	al, 20h
  7955 000039BD EE                  <1> 	out	dx, al
  7956                              <1> 	; ifdef VBOX
  7957 000039BE 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  7958 000039C2 EC                  <1> 	in	al, dx
  7959                              <1> 	; endif ; VBOX 
  7960 000039C3 66895C240C          <1> 	mov	[esp+12], bx ; bx
  7961 000039C8 E98AE1FFFF          <1> 	jmp	VIDEO_RETURN
  7962                              <1> 
  7963                              <1> ; 23/11/2020 - TRDOS 386 v2.0.3
  7964                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
  7965                              <1> ;	for TRDOS 386 v2 kernel (video bios)  
  7966                              <1> 
  7967                              <1> ; BOCH/QEMU VBE2 VGA BIOS code 
  7968                              <1> ;	by Jeroen Janssen (2002)
  7969                              <1> ;	by Volker Rupper (2003-2020)
  7970                              <1> ; vbe.c (02/01/2020) 
  7971                              <1> 
  7972                              <1> ; vbe.h (02/01/2020)
  7973                              <1> 
  7974                              <1> VBE_DISPI_BANK_ADDRESS	equ	0A0000h
  7975                              <1> VBE_DISPI_BANK_SIZE_KB	equ	64
  7976                              <1> 
  7977                              <1> VBE_DISPI_MAX_XRES	equ	2560
  7978                              <1> VBE_DISPI_MAX_YRES	equ	1600
  7979                              <1> 
  7980                              <1> VBE_DISPI_IOPORT_INDEX	equ	01CEh
  7981                              <1> VBE_DISPI_IOPORT_DATA	equ	01CFh
  7982                              <1> 
  7983                              <1> VBE_DISPI_INDEX_ID	equ	00h
  7984                              <1> VBE_DISPI_INDEX_XRES	equ	01h
  7985                              <1> VBE_DISPI_INDEX_YRES	equ	02h
  7986                              <1> VBE_DISPI_INDEX_BPP	equ	03h
  7987                              <1> VBE_DISPI_INDEX_ENABLE	equ	04h
  7988                              <1> VBE_DISPI_INDEX_BANK	equ	05h
  7989                              <1> VBE_DISPI_INDEX_VIRT_WIDTH equ	06h
  7990                              <1> VBE_DISPI_INDEX_VIRT_HEIGHT equ	07h
  7991                              <1> VBE_DISPI_INDEX_X_OFFSET equ	08h
  7992                              <1> VBE_DISPI_INDEX_Y_OFFSET equ	09h
  7993                              <1> VBE_DISPI_INDEX_VIDEO_MEMORY_64K equ 0Ah
  7994                              <1> VBE_DISPI_INDEX_DDC	equ	0Bh
  7995                              <1> 
  7996                              <1> VBE_DISPI_ID0		equ	0B0C0h
  7997                              <1> VBE_DISPI_ID1		equ	0B0C1h
  7998                              <1> VBE_DISPI_ID2		equ	0B0C2h
  7999                              <1> VBE_DISPI_ID3		equ	0B0C3h
  8000                              <1> VBE_DISPI_ID4		equ	0B0C4h
  8001                              <1> VBE_DISPI_ID5		equ	0B0C5h
  8002                              <1> 
  8003                              <1> VBE_DISPI_DISABLED	equ	00h
  8004                              <1> VBE_DISPI_ENABLED	equ	01h
  8005                              <1> VBE_DISPI_GETCAPS	equ	02h
  8006                              <1> VBE_DISPI_8BIT_DAC	equ	20h
  8007                              <1> VBE_DISPI_LFB_ENABLED	equ	40h
  8008                              <1> VBE_DISPI_NOCLEARMEM	equ	80h
  8009                              <1> 
  8010                              <1> VBE_DISPI_LFB_PHYSICAL_ADDRESS equ 0E0000000h
  8011                              <1> 
  8012                              <1> ; ***
  8013                              <1> 
  8014                              <1> ;// VBE Return Status Info
  8015                              <1> ;// AL
  8016                              <1> VBE_RETURN_STATUS_SUPPORTED	equ	4Fh
  8017                              <1> VBE_RETURN_STATUS_UNSUPPORTED	equ	00h
  8018                              <1> ;// AH
  8019                              <1> VBE_RETURN_STATUS_SUCCESSFULL	equ	00h
  8020                              <1> VBE_RETURN_STATUS_FAILED	equ	01h
  8021                              <1> VBE_RETURN_STATUS_NOT_SUPPORTED	equ	02h
  8022                              <1> VBE_RETURN_STATUS_INVALID	equ	03h
  8023                              <1> 
  8024                              <1> ;// VBE Mode Numbers
  8025                              <1> 
  8026                              <1> VBE_MODE_VESA_DEFINED		equ	0100h
  8027                              <1> VBE_MODE_REFRESH_RATE_USE_CRTC	equ	0800h
  8028                              <1> VBE_MODE_LINEAR_FRAME_BUFFER	equ	4000h
  8029                              <1> VBE_MODE_PRESERVE_DISPLAY_MEMORY equ	8000h
  8030                              <1> 
  8031                              <1> ;// Mode Attributes
  8032                              <1> 
  8033                              <1> VBE_MODE_ATTRIBUTE_SUPPORTED		   equ	0001h
  8034                              <1> VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE equ	0002h
  8035                              <1> VBE_MODE_ATTRIBUTE_COLOR_MODE		   equ	0008h
  8036                              <1> VBE_MODE_ATTRIBUTE_GRAPHICS_MODE	   equ	0010h
  8037                              <1> VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE equ	0080h
  8038                              <1> VBE_MODE_ATTRIBUTE_DOUBLE_SCAN_MODE	   equ	0100h
  8039                              <1> VBE_MODE_ATTRIBUTE_INTERLACE_MODE	   equ	0200h
  8040                              <1> 
  8041                              <1> ;// Window attributes
  8042                              <1> 
  8043                              <1> VBE_WINDOW_ATTRIBUTE_RELOCATABLE equ	01h
  8044                              <1> VBE_WINDOW_ATTRIBUTE_READABLE	 equ	02h
  8045                              <1> VBE_WINDOW_ATTRIBUTE_WRITEABLE	 equ	04h
  8046                              <1> 
  8047                              <1> ;/* Video memory */
  8048                              <1> VGAMEM_GRAPH equ 0A000h
  8049                              <1> VGAMEM_CTEXT equ 0B800h
  8050                              <1> ;VGAMEM_MTEXT equ 0B000h
  8051                              <1> 
  8052                              <1> ;// Memory model
  8053                              <1> 
  8054                              <1> ;VBE_MEMORYMODEL_TEXT_MODE	equ	00h
  8055                              <1> ;VBE_MEMORYMODEL_CGA_GRAPHICS	equ	01h
  8056                              <1> ;VBE_MEMORYMODEL_PLANAR		equ	03h
  8057                              <1> VBE_MEMORYMODEL_PACKED_PIXEL	equ	04h
  8058                              <1> ;VBE_MEMORYMODEL_NON_CHAIN_4_256 equ	05h
  8059                              <1> VBE_MEMORYMODEL_DIRECT_COLOR	equ	06h
  8060                              <1> ;VBE_MEMORYMODEL_YUV		equ	07h
  8061                              <1> 
  8062                              <1> ;// DirectColorModeInfo
  8063                              <1> 
  8064                              <1> ;VBE_DIRECTCOLOR_COLOR_RAMP_PROGRAMMABLE equ 01h
  8065                              <1> VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE equ 02h
  8066                              <1> 
  8067                              <1> VBE_DISPI_TOTAL_VIDEO_MEMORY_MB	equ 16
  8068                              <1> 
  8069                              <1> ; 24/11/2020
  8070                              <1> ; vbe.c
  8071                              <1> 
  8072                              <1> %if 1
  8073                              <1> 
  8074                              <1> _vbe_biosfn_return_mode_info:
  8075                              <1> 	; 15/12/2020
  8076                              <1> 	; 12/12/2020
  8077                              <1> 	; Return VBE Mode Information	
  8078                              <1> 	; (call from 'sysvideo')
  8079                              <1> 	;
  8080                              <1> 	; Input:
  8081                              <1> 	;	cx = video (bios) mode
  8082                              <1> 	; Output:
  8083                              <1> 	;	cf = 0 -> (successful)
  8084                              <1> 	;	   MODE_INFO_LIST addr contains MODEINFO
  8085                              <1> 	;	cf = 1 -> error
  8086                              <1> 	;
  8087                              <1> 	; Modified registers: eax, edx, edi
  8088                              <1> 	;
  8089                              <1> 
  8090                              <1> 	; pushes for subroutine stack pops compatibility
  8091                              <1> 	
  8092                              <1> 	;push	ds  ; *
  8093                              <1> 	;push	es  ; **
  8094                              <1> 
  8095 000039CD 55                  <1> 	push	ebp ; ***
  8096 000039CE 56                  <1> 	push	esi ; **** 
  8097                              <1> 	
  8098 000039CF 31FF                <1> 	xor	edi, edi  ; mov edi, 0
  8099                              <1> 
  8100 000039D1 803D[54090000]03    <1> 	cmp	byte [vbe3], 3
  8101 000039D8 7221                <1> 	jb	short _vbe_rmi_1
  8102                              <1> 
  8103                              <1> 	;sub	edi, edi  ; 0 = kernel call (sign)
  8104                              <1> 	;	; no transfer to user's buffer
  8105                              <1> 	
  8106                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
  8107                              <1> 
  8108 000039DA 66B8014F            <1> 	mov	ax, 4F01h
  8109                              <1> 
  8110 000039DE E820DFFFFF          <1> 	call	_vbe3_pmfn_return_mode_info
  8111                              <1> 
  8112 000039E3 6683F84F            <1> 	cmp	ax, 004Fh
  8113 000039E7 7533                <1> 	jne	short _vbe_rmi_2 ; fail
  8114                              <1> 
  8115                              <1> 	; 15/12/2020
  8116                              <1> 	; cx = vbe video mode
  8117 000039E9 80E501              <1> 	and	ch, 01h ; clear LFB flag
  8118 000039EC BEFE7B0900          <1> 	mov	esi, VBE3MODEINFOBLOCK - 2
  8119 000039F1 66890E              <1> 	mov	[esi], cx ; MODEINFO.mode
  8120 000039F4 E8A6000000          <1> 	call	set_lfbinfo_table
  8121 000039F9 EB22                <1> 	jmp	short _vbe_rmi_3  ; cf = 0 
  8122                              <1> _vbe_rmi_1:
  8123 000039FB 803D[54090000]02    <1> 	cmp	byte [vbe3], 2
  8124 00003A02 7219                <1> 	jb	short _vbe_rmi_3 ; cf = 1
  8125 00003A04 A0[55090000]        <1> 	mov	al, [vbe2bios] ; 0C0h-0C5h for emu (*)
  8126 00003A09 3CC0                <1> 	cmp	al, 0C0h ; BOCHS/QEMU/VIRTUALBOX (*) ? 
  8127 00003A0B 7210                <1> 	jb	short _vbe_rmi_3  ; cf = 1
  8128 00003A0D 3CC5                <1> 	cmp	al, 0C5h ; (*)
  8129 00003A0F 770B                <1> 	ja	short _vbe_rmi_2 ; unknown vbios !? 
  8130                              <1> 	
  8131                              <1> 	;xor	edi, edi  ; 0 = kernel call (sign)
  8132                              <1> 	;	; no transfer to user's buffer
  8133                              <1> 
  8134                              <1> 	;mov	ax, 4F01h
  8135                              <1> 
  8136                              <1> 	; cx = Video mode (for 4F01h, with LFB flag)
  8137                              <1> 
  8138 00003A11 E80A000000          <1> 	call	vbe_biosfn_return_mode_info
  8139 00003A16 6683F84F            <1> 	cmp	ax, 004Fh ; successful ?
  8140 00003A1A 7401                <1> 	je	short _vbe_rmi_3  ; cf = 0
  8141                              <1> _vbe_rmi_2:
  8142 00003A1C F9                  <1> 	stc
  8143                              <1> 	; cf = 1	
  8144                              <1> _vbe_rmi_3:
  8145 00003A1D 5E                  <1> 	pop	esi ; ****
  8146 00003A1E 5D                  <1> 	pop	ebp ; ***
  8147                              <1> 	
  8148                              <1> 	;pop	es  ; **
  8149                              <1> 	;pop	ss  ; *
  8150                              <1> 	
  8151 00003A1F C3                  <1> 	retn
  8152                              <1> 
  8153                              <1> 
  8154                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  8155                              <1> ; * ---------------------------------------------------------
  8156                              <1> ; * Function 01h - Return VBE Mode Information
  8157                              <1> ; * ---------------------------------------------------------
  8158                              <1> ; * Input:
  8159                              <1> ; *		AX = 4F01h
  8160                              <1> ; *		CX = Mode number
  8161                              <1> ; *    (ES:DI) EDI = Pointer to ModeInfoBlock structure	
  8162                              <1> ; * Output:
  8163                              <1> ; *		AX = VBE Return Status
  8164                              <1> ; * 
  8165                              <1> ; *----------------------------------------------------------
  8166                              <1> ; *
  8167                              <1> 
  8168                              <1> vbe_biosfn_return_mode_info:
  8169                              <1> 	; 15/12/2020 
  8170                              <1> 	; 14/12/2020
  8171                              <1> 	; 12/12/2020
  8172                              <1> 	; 11/12/2020 (TRDOS 386 v2.0.3)
  8173                              <1> 	;
  8174                              <1> 	; Input:
  8175                              <1> 	;	cx = video (bios) mode
  8176                              <1> 	;      edi = ModeInfoBlock buffer address
  8177                              <1> 	;	     (in user's memory space)		
  8178                              <1> 	;      (ax = 4F01h)
  8179                              <1> 	; Output:
  8180                              <1> 	;	ax = 004Fh (successful)
  8181                              <1> 	;	ah > 0 -> error
  8182                              <1> 	;
  8183                              <1> 	; Modified registers: esi
  8184                              <1> 
  8185                              <1> 	;;push	ds  ; *
  8186                              <1> 	;;push	es  ; **
  8187                              <1> 	;;push	ebp ; ***
  8188                              <1> 	;;push	esi ; **** 
  8189                              <1> 
  8190 00003A20 F6C501              <1> 	test	ch, 1
  8191 00003A23 7505                <1> 	jnz	short vbe_rmi_1
  8192                              <1> 
  8193                              <1> 	; mode number < 100h
  8194                              <1> 	; CGA/VGA mode is not proper this VBE function 
  8195                              <1> 
  8196 00003A25 29C0                <1> 	sub	eax, eax
  8197                              <1> vbe_rmi_0:	
  8198                              <1> 	;mov	ax, 0100h  ; Function is not supported
  8199 00003A27 B401                <1> 	mov	ah, 1
  8200 00003A29 C3                  <1> 	retn
  8201                              <1> vbe_rmi_1:
  8202 00003A2A 52                  <1> 	push	edx ; *****
  8203 00003A2B 51                  <1> 	push	ecx ; ******
  8204 00003A2C 53                  <1> 	push	ebx ; *******	
  8205 00003A2D 57                  <1> 	push	edi ; ********
  8206                              <1> 	
  8207                              <1> 	; 14/12/2020
  8208 00003A2E 89CB                <1> 	mov	ebx, ecx
  8209                              <1>  			
  8210                              <1> 	;xor	eax, eax
  8211 00003A30 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
  8212 00003A33 883D[1D120300]      <1> 	mov	[vbe_mode_x], bh
  8213                              <1> 	;and	bx, 1FFh
  8214 00003A39 80E701              <1> 	and	bh, 1
  8215                              <1> 	;mov	bh, 1
  8216                              <1> 
  8217                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
  8218 00003A3C E88A060000          <1> 	call	set_mode_info_list ; (alternative 2)
  8219                              <1> 
  8220                              <1> 	; eax = 0	
  8221                              <1> 
  8222                              <1> 	;mov	bx, [esi] ; mode
  8223                              <1> 
  8224                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
  8225                              <1> 	;call	mode_info_find_mode ; (alternative 1)
  8226                              <1> 
  8227 00003A41 09F6                <1> 	or	esi, esi
  8228                              <1> 	; 14/12/2020
  8229 00003A43 744D                <1> 	jz	short vbe_rmi_4	; VBE mode number is wrong
  8230                              <1> 				; or it is not supported
  8231                              <1> 
  8232                              <1> 	; 15/12/2020
  8233                              <1> 	;mov	bx, [esi] ; mode
  8234                              <1> 
  8235                              <1> 	; 12/12/2020
  8236                              <1> 	;call	set_lfbinfo_table
  8237                              <1> 
  8238 00003A45 F605[1D120300]40    <1> 	test	byte [vbe_mode_x], 40h ; LFB model ?
  8239 00003A4C 7404                <1> 	jz	short vbe_rmi_2
  8240                              <1> 	
  8241 00003A4E C6461C01            <1> 	mov	byte [esi+MODEINFO.NumberOfBanks], 1
  8242                              <1> vbe_rmi_2:
  8243                              <1> 	; (vbe.c, 02/01/2020, vruppert)
  8244                              <1> 	; 11/12/2020 (Erdogan Tan, video.s) 
  8245                              <1> 	; Bochs Graphics Adapter
  8246                              <1> 	; vendor_id: 1111h, device id: 1234h
  8247                              <1> 
  8248 00003A52 E855070000          <1> 	call	pci_get_lfb_addr
  8249                              <1> 	;or	eax, eax
  8250 00003A57 7404                <1> 	jz	short vbe_rmi_3
  8251                              <1> 	; zf = 0, ax > 0 (high word of LFB address)
  8252                              <1> 	; set/change LFB address in MODEINFO structure
  8253 00003A59 6689462C            <1> 	mov	[esi+MODEINFO.PhysBasePtr+2], ax
  8254                              <1> 	; 12/12/2020
  8255                              <1> 	;mov	[edi+LFBINFO.LFB_addr+2], ax
  8256                              <1> vbe_rmi_3:
  8257                              <1> 	;test	byte [esi+MODEINFO.WinAAttributes], 1 
  8258                              <1> 	;		; VBE_WINDOW_ATTRIBUTE_RELOCATABLE = 1
  8259                              <1>         ;jz	short vbe_rmi_4
  8260                              <1> 	;; 11/12/2020
  8261                              <1> 	;; In fact, this is far call address in (Bochs/BGA) Video Bios
  8262                              <1> 	;; Direct user access to kernel subroutines is not possible 
  8263                              <1> 	;; in TRDOS 386. Also, TRDOS 386 kernel will support only LFB.
  8264                              <1> 	;; Bank select may be a seperate sysvideo function in future
  8265                              <1> 	;; (if it will be required).
  8266                              <1> 	;mov	dword [esi+MODEINFO.WinFuncPtr], dispi_set_bank_farcall
  8267                              <1> ;vbe_rmi_4:
  8268                              <1> 	; 12/12/2020
  8269 00003A5D E83D000000          <1> 	call	set_lfbinfo_table
  8270                              <1> 
  8271                              <1> 	; 11/12/2020
  8272                              <1> 	; copy 68 bytes of MODE_INFO_LIST to user
  8273                              <1> 
  8274 00003A62 8B3C24              <1> 	mov	edi, [esp]  ; user's buffer address
  8275                              <1> 	; 12/12/2020
  8276 00003A65 09FF                <1> 	or	edi, edi ; 0 = kernel call 
  8277                              <1> 			 ; (call from '_vbe_biosfn_return_mode_info')
  8278 00003A67 7432                <1> 	jz	short vbe_rmi_6
  8279                              <1> 
  8280                              <1> 	; 15/12/2020
  8281                              <1> 	; prepare 256 bytes MODEINFO buffer at VBE3MODEINFOBLOCK
  8282                              <1> 	; and then, copy buffer conttent to user's buffer
  8283 00003A69 57                  <1> 	push	edi
  8284 00003A6A BE[3C120300]        <1> 	mov	esi, MODE_INFO_LIST + 2	; MODEINFO.ModeAttributes
  8285 00003A6F BF007C0900          <1> 	mov	edi, VBE3MODEINFOBLOCK
  8286 00003A74 B910000000          <1> 	mov	ecx, 66/4  ; 66 bytes
  8287 00003A79 F3A5                <1> 	rep	movsd
  8288 00003A7B 31C0                <1> 	xor	eax, eax
  8289 00003A7D B12F                <1> 	mov	cl, (256-68)/4 ; 188 bytes
  8290 00003A7F F3AB                <1> 	rep	stosd
  8291 00003A81 66AB                <1> 	stosw	; 2 bytes
  8292 00003A83 5F                  <1> 	pop	edi
  8293 00003A84 BE007C0900          <1> 	mov	esi, VBE3MODEINFOBLOCK
  8294                              <1> 	;mov	cx, 256 
  8295 00003A89 FEC5                <1> 	inc	ch ; cx = 256
  8296 00003A8B E874E00000          <1> 	call	transfer_to_user_buffer
  8297 00003A90 7309                <1> 	jnc	short vbe_rmi_5
  8298                              <1> vbe_rmi_4:
  8299                              <1> 	;mov	eax, 014Fh ; fail/error
  8300 00003A92 31C0                <1> 	xor	eax, eax
  8301 00003A94 B401                <1> 	mov	ah, 01h
  8302                              <1> 	;jmp	short vbe_rmi_6
  8303 00003A96 E981000000          <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
  8304                              <1> vbe_rmi_5:
  8305                              <1> 	; 256 bytes of MODEINFO have been transferred to user
  8306                              <1> 	;mov	eax, 4Fh ; succesfull
  8307                              <1> vbe_rmi_6: ; 12/12/2020
  8308 00003A9B 31C0                <1> 	xor	eax, eax
  8309                              <1> ;vbe_rmi_6:
  8310 00003A9D EB7D                <1> 	jmp	vbe_sm_ret1 ; 11/12/2020
  8311                              <1> 
  8312                              <1> 	;pop	edi ; ********
  8313                              <1> 	;pop	ebx ; *******
  8314                              <1> 	;pop	ecx ; ******
  8315                              <1> 	;pop	edx ; *****	
  8316                              <1> 	
  8317                              <1> 	;;pop	esi ; ****
  8318                              <1> 	;;pop	ebp ; ***
  8319                              <1> 	;;pop	es  ; **
  8320                              <1> 	;;pop	ds  ; * 
  8321                              <1> 
  8322                              <1> 	;retn
  8323                              <1> 
  8324                              <1> set_lfbinfo_table:
  8325                              <1> 	; 19/12/2020
  8326                              <1> 	; 11/12/2020
  8327                              <1> 	; Set/Fill LFBINFO structure/table
  8328                              <1> 	;
  8329                              <1> 	; Input:
  8330                              <1> 	;	esi = Mode info list address 
  8331                              <1> 	; Output:
  8332                              <1> 	;	LFB_Info address is filled with LFBINFO
  8333                              <1> 	;	edi = LFB_Info address
  8334                              <1> 	;
  8335                              <1> 	; Modified registers: eax, edx (=0), edi
  8336                              <1> 
  8337 00003A9F BF[2A120300]        <1> 	mov	edi, LFB_Info
  8338 00003AA4 8B462A              <1> 	mov	eax, [esi+MODEINFO.PhysBasePtr]
  8339 00003AA7 894702              <1> 	mov	[edi+LFBINFO.LFB_addr], eax ; LFB address
  8340                              <1> 	;mov	ax, [esi+MODEINFO.mode]
  8341 00003AAA 668B06              <1> 	mov	ax, [esi]
  8342 00003AAD 668907              <1> 	mov	[edi+LFBINFO.mode],ax
  8343 00003AB0 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
  8344 00003AB3 88470E              <1> 	mov	[edi+LFBINFO.bpp], al
  8345 00003AB6 29C0                <1> 	sub	eax, eax
  8346 00003AB8 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
  8347 00003ABC 6689470A            <1> 	mov	[edi+LFBINFO.X_res], ax
  8348 00003AC0 89C2                <1> 	mov	edx, eax ; 19/12/2020
  8349 00003AC2 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
  8350 00003AC6 6689470C            <1> 	mov	[edi+LFBINFO.Y_res], ax
  8351                              <1> 	; eax = Y_res ; screen height
  8352                              <1> 	; 19/12/2020	
  8353 00003ACA F7E2                <1> 	mul	edx ; X_res*Y_res
  8354                              <1> 	; edx = 0
  8355 00003ACC 8A570E              <1> 	mov	dl, [edi+LFBINFO.bpp]
  8356                              <1> 	; Note:
  8357                              <1> 	; Bits per pixel may be 8,16,24,32 for TRDOS 386 v2.
  8358                              <1> 	; (4 bits for pixel is not used for VESA modes here)
  8359 00003ACF C0EA03              <1> 	shr	dl, 3 ; convert bits to byte
  8360 00003AD2 F7E2                <1> 	mul	edx
  8361                              <1> 	; eax = screen/page/buffer size in bytes
  8362 00003AD4 894706              <1> 	mov	[edi+LFBINFO.LFB_size], eax
  8363                              <1> 	; edx = 0
  8364                              <1> 	; clear reserved byte in LFBINFO structure/table
  8365 00003AD7 88570F              <1> 	mov	[edi+LFBINFO.reserved], dl ; not necessary
  8366 00003ADA C3                  <1> 	retn
  8367                              <1> 
  8368                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  8369                              <1> ; * ---------------------------------------------------------
  8370                              <1> ; * Function 02h - Set VBE Mode
  8371                              <1> ; * ---------------------------------------------------------
  8372                              <1> ; * Input:
  8373                              <1> ; *		AX = 4F02h
  8374                              <1> ; *		BX = Desired Mode to set
  8375                              <1> ; * Output:
  8376                              <1> ; *		AX = VBE Return Status
  8377                              <1> ; * 
  8378                              <1> ; *----------------------------------------------------------
  8379                              <1> ; *
  8380                              <1> 
  8381                              <1> vbe_biosfn_set_mode:
  8382                              <1> 	; 12/12/2020
  8383                              <1> 	; 11/12/2020 (LFBINFO table for VESA VBE modes)
  8384                              <1> 	; 27/11/2020
  8385                              <1> 	; 25/11/2020
  8386                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  8387                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
  8388                              <1> 	;
  8389                              <1> 	; Input:
  8390                              <1> 	;	bx = video (bios) mode
  8391                              <1> 	;	ax = 4F02h
  8392                              <1> 	; Output:
  8393                              <1> 	;	ax = 004Fh (successful)
  8394                              <1> 	;	ah > 0 -> error
  8395                              <1> 	;
  8396                              <1> 	; Modified registers: esi
  8397                              <1> 
  8398                              <1> 	; 27/11/2020
  8399                              <1> 
  8400                              <1> 	;;push	ds  ; *
  8401                              <1> 	;;push	es  ; **
  8402                              <1> 	;;push	ebp ; ***
  8403                              <1> 	;;push	esi ; **** 
  8404                              <1> 	
  8405                              <1> 	; 11/12/2020 			
  8406 00003ADB 52                  <1> 	push	edx ; *****
  8407 00003ADC 51                  <1> 	push	ecx ; ******
  8408 00003ADD 53                  <1> 	push	ebx ; *******	
  8409 00003ADE 57                  <1> 	push	edi ; ********
  8410                              <1> 
  8411                              <1> 	;xor	eax, eax
  8412 00003ADF 80E7C1              <1> 	and	bh, 0C1h ; use bit 15, 14, 8 only (for bh)
  8413 00003AE2 883D[1D120300]      <1> 	mov	[vbe_mode_x], bh
  8414 00003AE8 80E701              <1> 	and	bh, 1
  8415 00003AEB 753C                <1> 	jnz	short vbe_sm_3  ; VESA VBE mode
  8416                              <1> 
  8417                              <1>  	;;test	bx, 4000h ; VBE_MODE_LINEAR_FRAME_BUFFER
  8418                              <1> 	;test	bh, 40h
  8419                              <1> 	;jz	short vbe_sm_0
  8420                              <1> 	;; lfb_flag
  8421                              <1> 	;mov	al, 40h	; VBE_DISPI_LFB_ENABLED
  8422                              <1> vbe_sm_0:
  8423                              <1> 	; 27/11/2020
  8424 00003AED B080                <1> 	mov	al, 80h
  8425                              <1> 	;test	bh, 80h ; VBE_MODE_PRESERVE_DISPLAY_MEMORY 	
  8426                              <1> 	;jnz	short vbe_sm_1 ; no_clear
  8427                              <1> 	;; clear
  8428                              <1> 	;sub	al, al ; 0
  8429 00003AEF 8405[1D120300]      <1> 	test	[vbe_mode_x], al ; 80h
  8430 00003AF5 7402                <1> 	jz	short vbe_sm_1 ; clear display memory
  8431                              <1> 	; no_clear
  8432 00003AF7 08C3                <1> 	or	bl, al ; VBE_MODE_PRESERVE_DISPLAY_MEMORY
  8433                              <1> vbe_sm_1:
  8434                              <1> 	; check non vesa mode
  8435                              <1> 	;;cmp	bx, 100h ; VBE_MODE_VESA_DEFINED
  8436                              <1> 	;;jna	short vbe_sm_2
  8437                              <1> 	;and	bh, 1
  8438                              <1> 	;jnz	short vbe_sm_3 
  8439                              <1> 
  8440                              <1> 	; BX <= 1FFh
  8441                              <1> 
  8442                              <1> 	; 27/11/2020
  8443                              <1> 	;or	bl, al	; al = 80h if no_clear option is set 
  8444                              <1> 	;		; al = 0 if no_clear option is not set 
  8445                              <1> 
  8446                              <1> 	; 25/11/2020
  8447                              <1> 	; VBE DISPI will be disabled in 'biosfn_set_video_mode'
  8448                              <1>  
  8449                              <1> 	;xor	al, al ; 0 ; VBE_DISPI_DISABLED
  8450                              <1> 	;call	dispi_set_enable
  8451                              <1> 
  8452                              <1> 	; call the vgabios in order to set the video mode
  8453                              <1> 	; this allows for going back to textmode with a VBE call
  8454                              <1> 	; (some applications expect that to work)
  8455                              <1> 
  8456                              <1> 	;and	bx, 0FFh
  8457                              <1> 	
  8458                              <1> 	; 27/11/2020
  8459                              <1> biosfn_set_video_mode:
  8460                              <1> 	; _call: call subroutine
  8461                              <1> 	; 26/11/2020 (TRDOS 386 v2.0.3)
  8462                              <1> 	; (ref: vgabios.c, 02/01/2020, vruppert)
  8463                              <1> 	; Input:
  8464                              <1> 	;	bl = VGA video (bios) mode
  8465                              <1> 	; Output:
  8466                              <1> 	;	cf = 1 -> error
  8467                              <1> 	;	cf = 0 -> ok
  8468                              <1> 	;
  8469                              <1> 	; Modified registers: esi
  8470                              <1> 
  8471                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'
  8472                              <1> 	
  8473                              <1> 	;mov	ax, 0 ; VBE_DISPI_DISABLED 
  8474 00003AF9 31C0                <1> 	xor	eax, eax ; 0 
  8475 00003AFB E8A3040000          <1> 	call	dispi_set_enable
  8476                              <1> 	
  8477 00003B00 88D8                <1> 	mov	al, bl
  8478                              <1> 	;jmp	_set_mode ; (in 'biosfn_set_video_mode' sub)
  8479 00003B02 E861E0FFFF          <1> 	call	_set_mode ; will return with cf=1 only if
  8480                              <1> 			; desired mode is not implemented
  8481                              <1> 	; _retn: return from subroutine
  8482 00003B07 721A                <1> 	jc	short vbe_sm_2 ; 25/11/2020
  8483                              <1> 
  8484                              <1> 	; 26/11/2020
  8485 00003B09 31C0                <1> 	xor	eax, eax 
  8486 00003B0B A0[CA6F0000]        <1> 	mov	al, [CRT_MODE]
  8487                              <1> 	; 27/11/2020
  8488 00003B10 8A25[67960100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
  8489                              <1> 	;and	ah 80h
  8490 00003B16 66A3[1E120300]      <1> 	mov	[video_mode], ax ; bit 15 = no_clear flag
  8491                              <1> 				 ; bit 14 = 0 (not LFB model)
  8492                              <1> vbe_sm_ret1:
  8493                              <1> 	; 11/12/2020
  8494                              <1> 	; (vbe_rmi_4 and vbe_rmi_6 jump here)
  8495                              <1> 	; 27/11/2020
  8496 00003B1C B04F                <1> 	mov	al, 4Fh ; Function call successful
  8497                              <1> 	; eax = 004Fh
  8498                              <1> vbe_sm_ret2:
  8499                              <1> 	; 11/12/2020
  8500 00003B1E 5F                  <1> 	pop	edi ; ********
  8501 00003B1F 5B                  <1> 	pop	ebx ; *******
  8502 00003B20 59                  <1> 	pop	ecx ; ******
  8503 00003B21 5A                  <1> 	pop	edx ; *****
  8504                              <1> 
  8505                              <1> 	;;pop	esi ; ****
  8506                              <1> 	;;pop	ebp ; ***
  8507                              <1> 	;;pop	es  ; **
  8508                              <1> 	;;pop	ds  ; * 
  8509                              <1> 
  8510 00003B22 C3                  <1> 	retn
  8511                              <1> 
  8512                              <1> vbe_sm_2:
  8513                              <1> 	;mov	ax, 0100h ; Function is not supported
  8514                              <1> 	; 27/11/2020
  8515 00003B23 31C0                <1> 	xor	eax, eax
  8516 00003B25 B401                <1> 	mov	ah, 01h
  8517                              <1> 	; eax = 0100h
  8518                              <1> 	;retn
  8519 00003B27 EBF5                <1> 	jmp	short vbe_sm_ret2
  8520                              <1> 
  8521                              <1> vbe_sm_3:
  8522                              <1> 	; 12/12/2020
  8523                              <1> 	; check current mode, if it is 03h
  8524                              <1> 	; save page contents and cursor positions
  8525 00003B29 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 03h
  8526 00003B30 75BB                <1> 	jne	short vbe_sm_0
  8527 00003B32 E8E6E2FFFF          <1> 	call	save_mode3_multiscreen
  8528                              <1> 	; set current mode to extended (SVGA) mode
  8529                              <1> 	;mov	byte [CRT_MODE], 0FFh ; VESA VBE mode
  8530                              <1> vbe_sm_4:
  8531                              <1> 	; 27/11/2020
  8532                              <1> 	; bx = mode (bit 0 to 8)
  8533                              <1> 
  8534                              <1> 	; 25/11/2020
  8535                              <1> 
  8536                              <1> 	; Alternative 2 (instead of 'Mode_info_find_mode')
  8537                              <1> 	;push	edi
  8538 00003B37 E88F050000          <1> 	call	set_mode_info_list ; (alternative 2)	
  8539                              <1> 	;pop	edi
  8540                              <1> 
  8541                              <1> 	;mov	bx, [esi] ; mode
  8542                              <1> 
  8543                              <1> 	; Alternative 1 (instead of 'set_mode_info_list')
  8544                              <1> 	;call	mode_info_find_mode ; (alternative 1)
  8545                              <1> 
  8546 00003B3C 09F6                <1> 	or	esi, esi
  8547 00003B3E 74E3                <1> 	jz	short vbe_sm_2 ; VBE mode number is wrong
  8548                              <1> 			       ; or it is not supported
  8549                              <1> 
  8550                              <1> 	; 11/12/2020
  8551 00003B40 668B1E              <1> 	mov	bx, [esi] ; mode
  8552                              <1> 
  8553                              <1> 	; 27/11/2020
  8554 00003B43 0A3D[1D120300]      <1> 	or	bh, [vbe_mode_x]
  8555                              <1> 
  8556                              <1> 	; save VESA VBE mode
  8557 00003B49 66891D[1E120300]    <1> 	mov	[video_mode], bx
  8558                              <1> 		; 27/11/2020
  8559                              <1> 		; bit 0 to 8 = VESA VBE mode
  8560                              <1> 		; bit 9 to 13 = 0 (bit 0 to 13 = mode)
  8561                              <1> 		; bit 14 = Linear/Flat Frame Buffer flag
  8562                              <1> 		; bit 15 = 'memory not cleared
  8563                              <1> 		;	   at last mode set' flag
  8564                              <1> 
  8565                              <1> 	; first disable current mode
  8566                              <1> 	; (when switching between vesa modes)
  8567                              <1> 	; 'dispi_set_enable(VBE_DISPI_DISABLED);'        
  8568                              <1> 
  8569                              <1> 	;mov	ax, VBE_DISPI_DISABLED ; 0
  8570 00003B50 29C0                <1> 	sub	eax, eax ; 0
  8571                              <1> 
  8572 00003B52 E84C040000          <1> 	call	dispi_set_enable
  8573                              <1> 
  8574                              <1> 	; 11/12/2020
  8575 00003B57 8A461B              <1> 	mov	al, [esi+MODEINFO.BitsPerPixel]
  8576                              <1> 	; ah = 0
  8577                              <1> 
  8578                              <1> 	;cmp	byte [esi+MODEINFO.BitsPerPixel], 8
  8579 00003B5A 3C08                <1> 	cmp	al, 8
  8580 00003B5C 750B                <1> 	jne	short vbe_sm_5
  8581                              <1> 
  8582                              <1> 	; 11/12/2020
  8583                              <1> 	;push	edi
  8584 00003B5E 50                  <1> 	push	eax
  8585                              <1> 	; 'load_dac_palette(3);'
  8586 00003B5F 56                  <1> 	push	esi
  8587 00003B60 B403                <1> 	mov	ah, 3  ; palette3, 256 colors
  8588 00003B62 E828F1FFFF          <1> 	call	load_dac_palette
  8589 00003B67 5E                  <1> 	pop	esi
  8590                              <1> 	; 11/12/2020
  8591 00003B68 58                  <1> 	pop	eax
  8592                              <1> 	;pop	edi
  8593                              <1> vbe_sm_5:	
  8594                              <1>   	;'dispi_set_bpp(cur_info->info.BitsPerPixel);'
  8595                              <1> 	; 11/12/2020 (al = bits per pixel, ah = 0)
  8596                              <1> 	;xor	ah, ah
  8597                              <1> 	;mov	al, [esi+MODEINFO.BitsPerPixel]
  8598 00003B69 E849040000          <1> 	call	dispi_set_bpp
  8599                              <1>         ;'dispi_set_xres(cur_info->info.XResolution);'
  8600 00003B6E 668B4614            <1> 	mov	ax, [esi+MODEINFO.XResolution]
  8601 00003B72 E846040000          <1> 	call	dispi_set_xres
  8602                              <1>         ;'dispi_set_yres(cur_info->info.YResolution);'
  8603 00003B77 668B4616            <1> 	mov	ax, [esi+MODEINFO.YResolution]
  8604 00003B7B E843040000          <1> 	call	dispi_set_yres
  8605                              <1> 
  8606                              <1> 	;'dispi_set_bank(0);'
  8607                              <1> 	;xor	ax, ax
  8608 00003B80 31C0                <1> 	xor	eax, eax ; 0
  8609 00003B82 E842040000          <1> 	call	dispi_set_bank
  8610                              <1>         ;'dispi_set_enable(VBE_DISPI_ENABLED|no_clear|lfb_flag);'
  8611                              <1> 	;mov	ax, di
  8612                              <1> 	; ah = 0 ; 27/11/2020
  8613 00003B87 A0[1D120300]        <1> 	mov	al, [vbe_mode_x] ; restore VBE mode bit 14 & 15
  8614 00003B8C 0C01                <1> 	or	al, 1 ; VBE_DISPI_ENABLED
  8615 00003B8E E810040000          <1> 	call	dispi_set_enable
  8616                              <1> 
  8617                              <1>         ; 'vga_compat_setup();'
  8618 00003B93 E846040000          <1> 	call	vga_compat_setup
  8619                              <1> 
  8620                              <1> 	; 11/12/2020
  8621 00003B98 E802FFFFFF          <1> 	call	set_lfbinfo_table
  8622                              <1> 
  8623                              <1> 	; 26/11/2020
  8624 00003B9D 31C0                <1> 	xor	eax, eax
  8625 00003B9F FEC8                <1> 	dec	al 
  8626 00003BA1 A2[CA6F0000]        <1> 	mov	[CRT_MODE], al ; 0FFh = VESA VBE mode sign
  8627                              <1> 
  8628                              <1> 	; 27/11/2020
  8629 00003BA6 E971FFFFFF          <1> 	jmp	vbe_sm_ret1 ; Function call successful
  8630                              <1> 	
  8631                              <1> 	; 27/11/2020
  8632                              <1> 	;mov	al, 4Fh
  8633                              <1> 	;	; eax = 004Fh = Function call successful
  8634                              <1> 	;jmp	short vbe_sm_ret2
  8635                              <1> 
  8636                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  8637                              <1> ; * ---------------------------------------------------------
  8638                              <1> ; * Function 03h - Return Current VBE Mode
  8639                              <1> ; * ---------------------------------------------------------
  8640                              <1> ; * Input:
  8641                              <1> ; *		AX = 4F03h
  8642                              <1> ; * Output:
  8643                              <1> ; *		AX = VBE Return Status
  8644                              <1> ; *		BX = Current VBE Mode
  8645                              <1> ; * 
  8646                              <1> ; *----------------------------------------------------------
  8647                              <1> ; *
  8648                              <1> 
  8649                              <1> vbe_biosfn_return_current_mode:
  8650                              <1> 	; 11/12/2020
  8651                              <1> 	; 27/11/2020 (TRDOS 386 v2.0.3)
  8652                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
  8653                              <1> 	;
  8654                              <1> 	; Input:
  8655                              <1> 	;	none
  8656                              <1> 	; Output:
  8657                              <1> 	;	ax = 004Fh (successful)
  8658                              <1> 	;	ah > 0 -> error
  8659                              <1> 	;	bx = current video (bios) mode (if ah = 0)
  8660                              <1> 	;
  8661                              <1> 	; Modified registers: eax, ebx
  8662                              <1> 
  8663                              <1> 	; 27/11/2020
  8664                              <1> 
  8665                              <1> 	;;push	ds  ; *
  8666                              <1> 	;;push	es  ; **
  8667                              <1> 	;;push	ebp ; ***
  8668                              <1> 	;;push	esi ; **** 
  8669                              <1> 	 			
  8670                              <1> 	;push	edx ; *****
  8671                              <1> 
  8672                              <1> 	; (vbe.c)
  8673                              <1> 	;call	dispi_get_enable
  8674                              <1> 	;	; ax = vbe display interface status
  8675                              <1> 	;and	al, 1 ; VBE_DISPI_ENABLED
  8676                              <1> 	;jnz	short vbe_gm_1  ; VBE graphics mode
  8677                              <1> 
  8678 00003BAB A0[CA6F0000]        <1> 	mov	al, [CRT_MODE] ; current cga/vga mode
  8679 00003BB0 3CFF                <1> 	cmp	al, 0FFh ; VBE extension signature
  8680 00003BB2 720E                <1> 	jb	short vbe_gm_1 ; get CGA/VGA mode
  8681                              <1> 
  8682                              <1> 	; get VBE mode
  8683                              <1> vbe_gm_0:
  8684 00003BB4 66A1[1E120300]      <1> 	mov	ax, [video_mode]
  8685                              <1> 		; BX bits:
  8686                              <1> 		; bit 0 to 8 = VESA VBE video mode
  8687                              <1> 		; bit 9 to 13 = 0 
  8688                              <1> 		; bit 14 = last mode set LFB option
  8689                              <1> 		;	   1 - linear/flat frame buffer
  8690                              <1> 		;	   0 - windowed frame buffer
  8691                              <1> 		; bit 15 = last mode set no_clear option		
  8692                              <1> 		;	   0 - video memory cleared
  8693                              <1> 		;	   1 - video memory not cleared
  8694                              <1> 	
  8695                              <1> vbe_gm_return:
  8696                              <1> 	;pop	edx ; ******
  8697 00003BBA 0FB7D8              <1> 	movzx	ebx, ax
  8698                              <1> ;vbe_srs_retn:
  8699 00003BBD 31C0                <1> 	xor	eax, eax ; 0
  8700 00003BBF B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
  8701 00003BC1 C3                  <1> 	retn	
  8702                              <1> 
  8703                              <1> vbe_gm_1:
  8704                              <1> 	; legacy (old, standard) CGA/VGA bios video mode
  8705 00003BC2 8A25[67960100]      <1> 	mov	ah, [noclearmem] ; 80h or 0
  8706                              <1> 		; BX bits: 
  8707                              <1> 		; bit 0 to 7 = video mode
  8708                              <1> 		; bit 8 to 13 = 0 
  8709                              <1> 		; bit 14 = 0 (not LFB mode) CGA/VGA
  8710                              <1> 		; bit 15 = 1 if [noclearmem] = 80h
  8711                              <1> 		;	   0 if [noclearmem] = 0
  8712 00003BC8 EBF0                <1> 	jmp	short vbe_gm_return
  8713                              <1> 
  8714                              <1> ; * (TRDOS 386, INT 31h, VESA Video Bios functions) 
  8715                              <1> ; * ---------------------------------------------------------
  8716                              <1> ; * Function 04h - Save/Restore State
  8717                              <1> ; * ---------------------------------------------------------
  8718                              <1> ; * Input:
  8719                              <1> ; *		AX = 4F04h
  8720                              <1> ; *             DL = 00h Return Save/Restore State buff size
  8721                              <1> ; *                  01h Save State
  8722                              <1> ; *                  02h Restore State
  8723                              <1> ; *             CX = Requested states
  8724                              <1> ; *		     bit 0 - controller hardware state
  8725                              <1> ; *		     bit 1 - BIOS data state
  8726                              <1> ; *		     bit 2 - DAC state
  8727                              <1> ; *		     bit 3 - register state
  8728                              <1> ; *    (ES:BX) EBX = Pointer to buffer (if DL <> 00h)
  8729                              <1> ; * Output:
  8730                              <1> ; *		AX = VBE Return Status
  8731                              <1> ; *		BX = Number of 64-byte blocks 
  8732                              <1> ; *		     to hold the state buffer (if DL=00h)
  8733                              <1> ; * 
  8734                              <1> ; *----------------------------------------------------------
  8735                              <1> ; *
  8736                              <1> 
  8737                              <1> vbe_biosfn_save_restore_state:
  8738                              <1> 	; 23/01/2021
  8739                              <1> 	; 16/01/2021
  8740                              <1> 	; 14/01/2021
  8741                              <1> 	; 13/01/2021
  8742                              <1> 	; 12/01/2021
  8743                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
  8744                              <1> 	; (ref: vbe.c, 02/01/2020, vruppert)
  8745                              <1> 	;
  8746                              <1> 	; Input:
  8747                              <1> 	;	dl = sub function
  8748                              <1> 	;	cl = requested state
  8749                              <1> 	;      ebx = pointer to buffer (if dl<>00h) 
  8750                              <1> 	; Output:
  8751                              <1> 	;	ax = 004Fh (successful)
  8752                              <1> 	;	ah > 0 -> error
  8753                              <1> 	;	bx = Number of 64-byte blocks 
  8754                              <1> 	;	     to hold the state buffer (if DL=00h)
  8755                              <1> 
  8756                              <1> 	; Modified registers: eax, ebx, edi
  8757                              <1> 	
  8758                              <1> 	; 14/01/2021
  8759 00003BCA 09DB                <1> 	or	ebx, ebx ; user's buffer address
  8760 00003BCC 750A                <1> 	jnz	short _vbe_biosfn_save_restore_state
  8761                              <1> 
  8762 00003BCE 20D2                <1> 	and	dl, dl
  8763 00003BD0 7406                <1> 	jz	short _vbe_biosfn_save_restore_state
  8764                              <1> 
  8765                              <1> 	; function failed
  8766                              <1> 	;mov	eax, 0100h
  8767                              <1> 	;xor	eax, eax
  8768                              <1> 	;inc	ah  ; eax = 0100h
  8769                              <1> 	; 16/01/2021
  8770 00003BD2 B84F010000          <1> 	mov	eax, 014Fh
  8771 00003BD7 C3                  <1> 	retn
  8772                              <1> 
  8773                              <1> _vbe_biosfn_save_restore_state:
  8774                              <1> 	; 23/01/2021
  8775                              <1> 	; 14/01/2021
  8776                              <1> 	; ebx = 0 if the caller is kernel ('sysvideo')
  8777                              <1> 
  8778                              <1> 	; 13/01/2021
  8779 00003BD8 57                  <1> 	push	edi
  8780 00003BD9 52                  <1> 	push	edx
  8781 00003BDA 51                  <1> 	push	ecx
  8782                              <1> 
  8783                              <1> 	; 23/01/2021
  8784                              <1> 	; 12/01/2021
  8785 00003BDB 80FA02              <1> 	cmp	dl, 2
  8786 00003BDE 7757                <1> 	ja	short vbe_srs_7 ; 23/01/2021
  8787                              <1> 			; invalid sub function
  8788 00003BE0 83F90F              <1> 	cmp	ecx, 0Fh
  8789 00003BE3 7752                <1> 	ja	short vbe_srs_7 ; invalid !
  8790                              <1> 	
  8791 00003BE5 20D2                <1> 	and	dl, dl
  8792 00003BE7 7515                <1> 	jnz	short vbe_srs_4
  8793                              <1> 
  8794                              <1> 	; DL = 0
  8795                              <1> 	; Return Save/Restore State buffer size
  8796                              <1> 
  8797                              <1> 	;mov	ebx, ecx
  8798                              <1> 	;shl	bl, 1
  8799                              <1> 	;mov	bx, [ebx+vbestatebufsize]
  8800 00003BE9 E881000000          <1> 	call	vbe_srs_gbs
  8801                              <1> 
  8802                              <1> ;	; 11/01/2021
  8803                              <1> ;	test	cl, 8
  8804                              <1> ;	jz	short vbe_srs_3
  8805                              <1> ;	; vbe_biosfn_read_video_state_size();
  8806                              <1> ;	; return 9 * 2;
  8807                              <1> ;	mov	bl, 18 ; register state size
  8808                              <1> ;vbe_srs_0:
  8809                              <1> ;	test	cl, 1
  8810                              <1> ;	jz	short vbe_srs_1
  8811                              <1> ;	; size += 0x46;
  8812                              <1> ;	add	bl, 70	; controller state size
  8813                              <1> ;vbe_srs_1:
  8814                              <1> ;	test	cl, 2
  8815                              <1> ;	jz	short vbe_srs_2
  8816                              <1> ;	; size += (5 + 8 + 5) * 2 + 6;
  8817                              <1> ;	;add	bl, 42 ; BIOS data state size ; Bochs/Plex86
  8818                              <1> ;	; 12/01/2021
  8819                              <1> ;	add	bl, 40 ; TRDOS 386 v2 VBIOS data state size
  8820                              <1> ;vbe_srs_2:
  8821                              <1> ;	test	cl, 4
  8822                              <1> ;	jz	short vbe_srs_3
  8823                              <1> ;	; size += 3 + 256 * 3 + 1;
  8824                              <1> ;	add	bx, 772 ; DAC state size
  8825                              <1> 
  8826                              <1> vbe_srs_3:
  8827 00003BEE 6683C33F            <1> 	add	bx, 63
  8828 00003BF2 66C1EB06            <1> 	shr	bx, 6 ; / 64
  8829                              <1> 
  8830                              <1> vbe_srs_retn:
  8831 00003BF6 31C0                <1> 	xor	eax, eax ; 0
  8832                              <1> vbe_srs_0:  ; 16/01/2021
  8833 00003BF8 B04F                <1> 	mov	al, 4Fh ; ax = 004Fh (successful)
  8834                              <1> ;vbe_srs_0:
  8835                              <1> 	; 13/01/2021
  8836 00003BFA 59                  <1> 	pop	ecx
  8837 00003BFB 5A                  <1> 	pop	edx
  8838 00003BFC 5F                  <1> 	pop	edi	
  8839                              <1> 
  8840 00003BFD C3                  <1> 	retn
  8841                              <1> 
  8842                              <1> 	; 23/01/2021
  8843                              <1> ;vbe_srs_10:
  8844                              <1> 	;; 14/01/2021
  8845                              <1> 	; return to 'sysvideo'
  8846                              <1> 	;mov	ebx, ecx ; transfer count
  8847                              <1> 	;	; (byte count for saving current video state)
  8848                              <1> 	;jmp	short vbe_srs_retn 
  8849                              <1> 
  8850                              <1> vbe_srs_4:
  8851                              <1> 	; 23/01/2021
  8852 00003BFE 80E10F              <1> 	and	cl, 0Fh ; 8, 4, 2, 1
  8853 00003C01 7434                <1> 	jz	short vbe_srs_7 ; cx = 0 -> invalid !
  8854                              <1> 
  8855 00003C03 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
  8856                              <1> 
  8857 00003C08 80FA01              <1> 	cmp	dl, 1
  8858 00003C0B 7730                <1> 	ja	short vbe_srs_8
  8859                              <1> 
  8860                              <1> 	; save video state
  8861                              <1> 
  8862 00003C0D F6C107              <1> 	test	cl, 07h ; 4, 2, 1
  8863 00003C10 740A                <1> 	jz	short vbe_srs_5  ; vbe dispi regs state
  8864                              <1> 
  8865 00003C12 E884000000          <1> 	call	biosfn_save_video_state
  8866                              <1> 	; edi = current position
  8867                              <1> 	;	in VBE3SAVERESTOREBLOCK
  8868                              <1> 	; 	(VGA save_state offset)
  8869                              <1> 	; modified regs: edi, eax, edx, ch
  8870 00003C17 F6C108              <1> 	test	cl, 8
  8871 00003C1A 7405                <1> 	jz	short vbe_srs_6
  8872                              <1> vbe_srs_5:
  8873 00003C1C E8AC010000          <1> 	call	vbe_biosfn_save_video_state
  8874                              <1> 	; edi = end position
  8875                              <1> 	;	in VBE3SAVERESTOREBLOCK
  8876                              <1> 	; 	(VGA save_state offset)
  8877                              <1> 	; modified regs: edi, eax, edx, ch
  8878                              <1> vbe_srs_6:
  8879                              <1> 	; 23/01/2021
  8880 00003C21 21DB                <1> 	and	ebx, ebx 
  8881 00003C23 74D1                <1> 	jz	short vbe_srs_retn ; the caller is kernel
  8882                              <1> 	
  8883 00003C25 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
  8884 00003C2A 29F7                <1> 	sub	edi, esi
  8885 00003C2C 89F9                <1> 	mov	ecx, edi ; transfer count in bytes
  8886                              <1> 
  8887                              <1> 	;; 14/01/2021
  8888                              <1> 	;and	ebx, ebx 
  8889                              <1> 	;jz	short vbe_srs_10 ; the caller is kernel
  8890                              <1> 
  8891 00003C2E 89DF                <1> 	mov	edi, ebx ; user's buffer address
  8892 00003C30 E8CFDE0000          <1> 	call	transfer_to_user_buffer
  8893 00003C35 73BF                <1> 	jnc	short vbe_srs_retn
  8894                              <1> vbe_srs_7:
  8895                              <1> 	; // function failed
  8896                              <1> 	;mov	eax, 0100h
  8897 00003C37 31C0                <1> 	xor	eax, eax
  8898 00003C39 FEC4                <1> 	inc	ah  ; eax = 0100h
  8899                              <1> 	; 16/01/2021
  8900                              <1> 	; ax = 0014Fh
  8901                              <1> 	;retn
  8902                              <1> 	; 13/01/2021
  8903 00003C3B EBBB                <1> 	jmp	short vbe_srs_0
  8904                              <1> vbe_srs_8:
  8905                              <1> 	;cmp	dl, 2
  8906                              <1> 	;jne	short vbe_srs_7
  8907                              <1> 	;		; invalid sub function
  8908                              <1> 
  8909                              <1> 	; 14/01/2021
  8910 00003C3D 09DB                <1> 	or	ebx, ebx ; user's buffer address
  8911                              <1> 	;jnz	short vbe_srs_11
  8912                              <1> 
  8913                              <1> 	; the caller is kernel ('sysvideo')
  8914                              <1> 	;jmp	short vbe_srs_12
  8915                              <1> 	; 23/01/2021
  8916 00003C3F 7414                <1> 	jz	short vbe_srs_12 ; 'sysvideo' call
  8917                              <1> vbe_srs_11:
  8918 00003C41 89DE                <1> 	mov	esi, ebx ; user's buffer address
  8919                              <1> 	; 23/01/2021
  8920                              <1> 	;push	ebx
  8921                              <1> 	
  8922 00003C43 E827000000          <1> 	call	vbe_srs_gbs
  8923                              <1> 	
  8924                              <1> 	; restore video state
  8925                              <1> 
  8926                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
  8927 00003C48 51                  <1> 	push	ecx
  8928 00003C49 89D9                <1> 	mov	ecx, ebx ; transfer count in bytes
  8929 00003C4B E8FEDE0000          <1> 	call	transfer_from_user_buffer
  8930 00003C50 59                  <1> 	pop	ecx
  8931                              <1> 	; 23/01/2021
  8932                              <1> 	;pop	ebx
  8933 00003C51 89F3                <1> 	mov	ebx, esi
  8934 00003C53 72E2                <1> 	jc	short vbe_srs_7
  8935                              <1> 
  8936                              <1> vbe_srs_12:
  8937                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
  8938 00003C55 89FE                <1> 	mov	esi, edi
  8939                              <1> 
  8940 00003C57 F6C107              <1> 	test	cl, 07h ; 4, 2, 1
  8941 00003C5A 740C                <1> 	jz	short vbe_srs_9	; vbe dispi regs state
  8942                              <1> 
  8943 00003C5C E8A8010000          <1> 	call	biosfn_restore_video_state
  8944 00003C61 72D4                <1> 	jc	short vbe_srs_7 ; invalid buffer content !
  8945                              <1> 	; esi = current position
  8946                              <1> 	;	in VBE3SAVERESTOREBLOCK
  8947                              <1> 	; 	(VGA save_state offset)
  8948                              <1> 	; modified regs: esi, eax, edx, ch
  8949 00003C63 F6C108              <1> 	test	cl, 8
  8950                              <1> 	;jz	short vbe_srs_10
  8951                              <1> 	; 23/01/2020
  8952 00003C66 EB8E                <1> 	jmp	short vbe_srs_retn
  8953                              <1> vbe_srs_9:
  8954 00003C68 E8F8020000          <1> 	call	vbe_biosfn_restore_video_state
  8955                              <1> 
  8956                              <1> 	; modified regs: esi, eax, edx, ch
  8957                              <1> 
  8958 00003C6D EB87                <1> 	jmp	short vbe_srs_retn
  8959                              <1> 
  8960                              <1> ;vbe_srs_10:
  8961                              <1> ;	; successful
  8962                              <1> ;	xor	eax, eax ; 0
  8963                              <1> ;	mov	al, 4Fh ; ax = 004Fh (successful)
  8964                              <1> ;	retn
  8965                              <1> 
  8966                              <1> vbe_srs_gbs:
  8967                              <1> 	; return buffer size according to flags
  8968 00003C6F 89CB                <1> 	mov	ebx, ecx ; options/flags
  8969 00003C71 D0E3                <1> 	shl	bl, 1
  8970 00003C73 668B9B[7B3C0000]    <1> 	mov	bx, [ebx+vbestatebufsize]
  8971 00003C7A C3                  <1> 	retn
  8972                              <1> 
  8973                              <1> vbestatebufsize:
  8974                              <1> 	; ----------------------------------------
  8975                              <1> 	; CL =	0  1   2    3    4    5    6    7
  8976                              <1> 	; ----------------------------------------
  8977 00003C7B 0000460028006E0004- <1> 	dw	0, 70, 40, 110, 772, 842, 812, 882
  8977 00003C84 034A032C037203      <1>
  8978                              <1> 	; ----------------------------------------
  8979                              <1> 	; CL =	8   9   10  11   12   13   14   15
  8980                              <1> 	; ----------------------------------------
  8981 00003C8B 120058003A00800016- <1> 	dw	18, 88, 58, 128, 790, 860, 830, 900
  8981 00003C94 035C033E038403      <1>
  8982                              <1> 
  8983                              <1> ; 11/01/2021
  8984                              <1> VGAREG_ACTL_ADDRESS	equ 3C0h
  8985                              <1> VGAREG_ACTL_WRITE_DATA	equ 3C0h
  8986                              <1> VGAREG_ACTL_READ_DATA	equ 3C1h
  8987                              <1> 
  8988                              <1> VGAREG_INPUT_STATUS	equ 3C2h
  8989                              <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h
  8990                              <1> VGAREG_VIDEO_ENABLE	equ 3C3h
  8991                              <1> VGAREG_SEQU_ADDRESS	equ 3C4h
  8992                              <1> VGAREG_SEQU_DATA	equ 3C5h
  8993                              <1> 
  8994                              <1> VGAREG_PEL_MASK		equ 3C6h
  8995                              <1> VGAREG_DAC_STATE	equ 3C7h
  8996                              <1> VGAREG_DAC_READ_ADDRESS	equ 3C7h
  8997                              <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h
  8998                              <1> VGAREG_DAC_DATA		equ 3C9h
  8999                              <1> 
  9000                              <1> VGAREG_READ_FEATURE_CTL	equ 3CAh
  9001                              <1> VGAREG_READ_MISC_OUTPUT	equ 3CCh
  9002                              <1> 
  9003                              <1> VGAREG_GRDC_ADDRESS	equ 3CEh
  9004                              <1> VGAREG_GRDC_DATA	equ 3CFh
  9005                              <1> 
  9006                              <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h
  9007                              <1> ;VGAREG_MDA_CRTC_DATA	equ 3B5h
  9008                              <1> VGAREG_VGA_CRTC_ADDRESS	equ 3D4h
  9009                              <1> VGAREG_VGA_CRTC_DATA	equ 3D5h
  9010                              <1> 
  9011                              <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh
  9012                              <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh
  9013                              <1> VGAREG_ACTL_RESET	equ 3DAh
  9014                              <1> 
  9015                              <1> ;VGAREG_MDA_MODECTL	equ 3B8h
  9016                              <1> VGAREG_CGA_MODECTL	equ 3D8h
  9017                              <1> VGAREG_CGA_PALETTE	equ 3D9h
  9018                              <1> 
  9019                              <1> biosfn_save_video_state:
  9020                              <1> 	; 22/01/2021
  9021                              <1> 	; 12/01/2021
  9022                              <1> 	; 11/01/2021 (TRDOS 386 v2.0.3)
  9023                              <1> 	; (vgabios.c)
  9024                              <1> 
  9025                              <1> 	; modified registers: eax, edx, edi, ch
  9026                              <1> 
  9027                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
  9028                              <1> 
  9029                              <1> 	; input: edi = state buffer address
  9030                              <1> 
  9031 00003C9B F6C101              <1> 	test	cl, 1
  9032 00003C9E 0F8485000000        <1> 	jz	bfn_svs_4
  9033                              <1> 
  9034 00003CA4 66BAC403            <1> 	mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
  9035 00003CA8 EC                  <1> 	in	al, dx
  9036 00003CA9 AA                  <1> 	stosb
  9037                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9038 00003CAA B2D4                <1> 	mov	dl, 0D4h
  9039 00003CAC EC                  <1> 	in	al, dx
  9040 00003CAD AA                  <1> 	stosb
  9041                              <1>   	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
  9042 00003CAE B2CE                <1>         mov	dl, 0CEh
  9043 00003CB0 EC                  <1> 	in	al, dx
  9044 00003CB1 AA                  <1> 	stosb
  9045                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9046 00003CB2 B2DA                <1> 	mov	dl, 0DAh
  9047 00003CB4 EC                  <1> 	in	al, dx
  9048                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
  9049 00003CB5 B2C0                <1> 	mov	dl, 0C0h
  9050 00003CB7 EC                  <1> 	in	al, dx
  9051 00003CB8 AA                  <1> 	stosb
  9052 00003CB9 88C4                <1> 	mov	ah, al ; ar_index
  9053                              <1> 	;mov	dx, VGAREG_READ_FEATURE_CTL ; 3CAh
  9054 00003CBB B2CA                <1> 	mov	dl, 0CAh
  9055 00003CBD EC                  <1> 	in	al, dx
  9056 00003CBE AA                  <1> 	stosb
  9057                              <1> 	; (5 bytes are writen above)
  9058                              <1> 
  9059                              <1> 	; for(i=1;i<=4;i++){
  9060 00003CBF B001                <1> 	mov	al, 1
  9061                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9062                              <1> 	;mov	dl, 0C4h
  9063 00003CC1 B504                <1> 	mov	ch, 4
  9064                              <1> bfn_svs_0:
  9065                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
  9066                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9067 00003CC3 B2C4                <1> 	mov	dl, 0C4h
  9068 00003CC5 EE                  <1> 	out	dx, al
  9069                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
  9070 00003CC6 FEC2                <1> 	inc	dl  ; dx = 3C5h
  9071                              <1> 	; inb(VGAREG_SEQU_DATA)
  9072 00003CC8 50                  <1> 	push	eax
  9073 00003CC9 EC                  <1> 	in	al, dx
  9074 00003CCA AA                  <1> 	stosb	; (4 bytes in loop)
  9075 00003CCB 58                  <1> 	pop	eax
  9076                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9077                              <1> 	;dec	dl	
  9078 00003CCC FEC0                <1> 	inc	al  ; i++
  9079 00003CCE FECD                <1> 	dec	ch
  9080 00003CD0 75F1                <1> 	jnz	short bfn_svs_0
  9081                              <1> 
  9082                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
  9083 00003CD2 28C0                <1> 	sub	al, al ; 0
  9084 00003CD4 EE                  <1> 	out	dx, al
  9085                              <1> 	; inb(VGAREG_SEQU_DATA)
  9086                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
  9087 00003CD5 FEC2                <1> 	inc	dl  ; dx = 3C5h
  9088 00003CD7 EC                  <1> 	in	al, dx
  9089 00003CD8 AA                  <1> 	stosb	; (+1 byte)
  9090                              <1> 
  9091                              <1>         ; for(i=0;i<=0x18;i++) {
  9092 00003CD9 28C0                <1> 	sub	al, al ; 0
  9093                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9094                              <1> 	;mov	dl, 0D4h
  9095 00003CDB B519                <1> 	mov	ch, 25
  9096                              <1> bfn_svs_1:
  9097                              <1>         ; outb(crtc_addr,i);
  9098                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9099 00003CDD B2D4                <1> 	mov	dl, 0D4h
  9100 00003CDF EE                  <1> 	out	dx, al
  9101                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
  9102 00003CE0 FEC2                <1> 	inc	dl  ; dx = 3D5h
  9103                              <1> 	; inb(crtc_addr+1)
  9104 00003CE2 50                  <1> 	push	eax
  9105 00003CE3 EC                  <1> 	in	al, dx
  9106 00003CE4 AA                  <1> 	stosb	; (25 bytes in loop)
  9107 00003CE5 58                  <1> 	pop	eax
  9108                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9109                              <1> 	;dec	dl	
  9110 00003CE6 FEC0                <1> 	inc	al  ; i++
  9111 00003CE8 FECD                <1> 	dec	ch
  9112 00003CEA 75F1                <1> 	jnz	short bfn_svs_1
  9113                              <1> 
  9114 00003CEC 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
  9115                              <1>         ; for(i=0;i<=0x13;i++) {
  9116 00003CEF 28C0                <1> 	sub	al, al ; 0
  9117 00003CF1 B514                <1> 	mov	ch, 20
  9118                              <1> bfn_svs_2:
  9119                              <1> 	; inb(VGAREG_ACTL_RESET);
  9120                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9121 00003CF3 B2DA                <1> 	mov	dl, 0DAh
  9122 00003CF5 50                  <1> 	push	eax
  9123 00003CF6 EC                  <1> 	in	al, dx
  9124 00003CF7 8A0424              <1> 	mov	al, [esp]
  9125                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
  9126 00003CFA 08E0                <1> 	or	al, ah
  9127                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
  9128 00003CFC B2C0                <1> 	mov	dl, 0C0h
  9129 00003CFE EE                  <1> 	out	dx, al
  9130                              <1> 	;mov	dx, VGAREG_ACTL_READ_DATA ; 3C1h
  9131                              <1> 	;mov	dl, 0C1h
  9132 00003CFF FEC2                <1> 	inc	dl
  9133 00003D01 EC                  <1> 	in	al, dx
  9134 00003D02 AA                  <1> 	stosb	; (20 bytes in loop)
  9135 00003D03 58                  <1> 	pop	eax
  9136 00003D04 FEC0                <1> 	inc	al  ; i++
  9137 00003D06 FECD                <1> 	dec	ch
  9138 00003D08 75E9                <1> 	jnz	short bfn_svs_2
  9139                              <1> 
  9140                              <1> 	; inb(VGAREG_ACTL_RESET);
  9141                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9142 00003D0A B2DA                <1> 	mov	dl, 0DAh
  9143 00003D0C EC                  <1> 	in	al, dx
  9144                              <1> 
  9145                              <1>         ; for(i=0;i<=8;i++) {
  9146 00003D0D 28C0                <1> 	sub	al, al ; 0
  9147                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
  9148                              <1> 	;mov	dl, 0CEh
  9149 00003D0F B509                <1> 	mov	ch, 9
  9150                              <1> bfn_svs_3:
  9151                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
  9152                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
  9153 00003D11 B2CE                <1> 	mov	dl, 0CEh
  9154 00003D13 EE                  <1> 	out	dx, al
  9155                              <1> 	; inb(VGAREG_ACTL_READ_DATA)
  9156 00003D14 50                  <1> 	push	eax
  9157                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
  9158                              <1> 	;mov	dl, 0CFh
  9159 00003D15 FEC2                <1> 	inc	dl
  9160 00003D17 EC                  <1> 	in	al, dx
  9161 00003D18 AA                  <1> 	stosb	; (9 bytes in loop)
  9162 00003D19 58                  <1> 	pop	eax
  9163                              <1> 	;dec	dl
  9164 00003D1A FEC0                <1> 	inc	al  ; i++
  9165 00003D1C FECD                <1> 	dec	ch
  9166 00003D1E 75F1                <1> 	jnz	short bfn_svs_3
  9167                              <1> 
  9168                              <1> 	; write_word(ES, BX, crtc_addr); BX+= 2;
  9169                              <1> 	; (offset 64)
  9170 00003D20 66B8D403            <1> 	mov	ax, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
  9171 00003D24 66AB                <1> 	stosw	; (2 bytes (1 word))
  9172                              <1> 
  9173                              <1>         ; /* XXX: read plane latches */
  9174 00003D26 31C0                <1> 	xor	eax, eax  ; 0
  9175 00003D28 AB                  <1>        	stosd	; (4 bytes)
  9176                              <1> 
  9177                              <1> 	; (total 70 bytes are written above as controller hardware state)
  9178                              <1> 
  9179                              <1> bfn_svs_4:		
  9180                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
  9181 00003D29 F6C102              <1> 	test	cl, 2
  9182 00003D2C 7476                <1> 	jz	short bfn_svs_6
  9183                              <1> 
  9184                              <1> 	; VIDEO BIOS DATA
  9185                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
  9186                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
  9187                              <1>   
  9188                              <1>     	; if (CX & 2) {
  9189                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE)); BX++;
  9190                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_NB_COLS)); BX += 2;
  9191                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE)); BX += 2;
  9192                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS)); BX += 2;
  9193                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS)); BX++;
  9194                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT)); BX += 2;
  9195                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL)); BX++;
  9196                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES)); BX++;
  9197                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL)); BX++;
  9198                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE)); BX += 2;
  9199                              <1>         ;for(i=0;i<8;i++) {
  9200                              <1>         ;   write_word(ES, BX, read_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i));
  9201                              <1>         ;   BX += 2;
  9202                              <1>         ;}
  9203                              <1>         ;write_word(ES, BX, read_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START)); BX += 2;
  9204                              <1>         ;write_byte(ES, BX, read_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE)); BX++;
  9205                              <1>         ;/* current font */
  9206                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4)); BX += 2;
  9207                              <1>         ;write_word(ES, BX, read_word(0, 0x1f * 4 + 2)); BX += 2;
  9208                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4)); BX += 2;
  9209                              <1>         ;write_word(ES, BX, read_word(0, 0x43 * 4 + 2)); BX += 2;
  9210                              <1> 
  9211                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
  9212                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
  9213                              <1> 
  9214 00003D2E 66B8D403            <1> 	mov	ax, 3D4h ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
  9215 00003D32 66AB                <1> 	stosw
  9216 00003D34 A0[CA6F0000]        <1> 	mov	al, [CRT_MODE] ; Current video mode (0FFh for VESA VBE modes) 
  9217 00003D39 AA                  <1> 	stosb
  9218 00003D3A A0[CB6F0000]        <1> 	mov	al, [CRT_MODE_SET] ; 29h for mode 03h ; TRDOS 386 feature only !
  9219 00003D3F AA                  <1> 	stosb	
  9220 00003D40 66A1[1E120300]      <1>  	mov	ax, [video_mode] ; Current VESA VBE (SVGA, extended VGA) mode 
  9221 00003D46 66AB                <1> 	stosw			 ; (valid if [CRT_MODE] = 0FFh)	
  9222 00003D48 66A1[68960100]      <1> 	mov	ax, [CRT_LEN] ; page size (in bytes)
  9223 00003D4E 66AB                <1> 	stosw
  9224 00003D50 66A1[EC890100]      <1> 	mov	ax, [CRT_START] ; video page start offset
  9225 00003D56 66AB                <1>  	stosw
  9226 00003D58 A0[CC6F0000]        <1> 	mov	al, [CRT_COLS] ; nbcols, characters per row	
  9227 00003D5D AA                  <1> 	stosb
  9228 00003D5E A0[D26F0000]        <1> 	mov	al, [VGA_ROWS] ; nbrows, (character) rows per page (not rows-1)
  9229 00003D63 AA                  <1> 	stosb
  9230 00003D64 A0[CE6F0000]        <1> 	mov	al, [CHAR_HEIGHT] ; character font height (8 or 16 or 14)
  9231 00003D69 AA                  <1> 	stosb
  9232 00003D6A A0[CF6F0000]        <1> 	mov	al, [VGA_VIDEO_CTL] ; ROM BIOS DATA AREA Offset 87h
  9233 00003D6F AA                  <1> 	stosb
  9234 00003D70 A0[D06F0000]        <1> 	mov	al, [VGA_SWITCHES] ; feature bit switches
  9235 00003D75 AA                  <1> 	stosb
  9236 00003D76 A0[D16F0000]        <1> 	mov	al, [VGA_MODESET_CTL] ; basic mode set options
  9237 00003D7B AA                  <1> 	stosb
  9238                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
  9239                              <1> 	; (bochs/plex86 does not use and return those)
  9240 00003D7C A0[CD6F0000]        <1> 	mov	al, [CRT_PALETTE] ; current color palette ; TRDOS 386 feature only !
  9241 00003D81 AA                  <1> 	stosb
  9242 00003D82 A0[FE890100]        <1> 	mov	al, [ACTIVE_PAGE] ; current video page 
  9243 00003D87 AA                  <1> 	stosb
  9244 00003D88 66A1[E36F0000]      <1> 	mov	ax, [CURSOR_MODE] ; cursor type
  9245 00003D8E 66AB                <1> 	stosw
  9246                              <1> 	;mov	eax, [CURSOR_POSN] ; cursor position for video page 0 and 1 
  9247                              <1> 	;stosd
  9248                              <1> 	;mov	eax, [CURSOR_POSN+4] ; cursor position for video page 2 and 3 
  9249                              <1> 	;stosd
  9250                              <1> 	;mov	eax, [CURSOR_POSN+8] ; cursor position for video page 4 and 5 
  9251                              <1> 	;stosd
  9252                              <1> 	;mov	eax, [CURSOR_POSN+12] ; cursor position for video page 6 and 7 
  9253                              <1> 	;stosd
  9254 00003D90 56                  <1> 	push	esi
  9255 00003D91 B504                <1> 	mov	ch, 4
  9256 00003D93 BE[EE890100]        <1> 	mov	esi, CURSOR_POSN
  9257                              <1> bfn_svs_5:
  9258 00003D98 A5                  <1> 	movsd
  9259 00003D99 FECD                <1> 	dec	ch
  9260 00003D9B 75FB                <1> 	jnz	short bfn_svs_5
  9261 00003D9D 5E                  <1> 	pop	esi
  9262                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
  9263                              <1> 	; (not accessable/meaningful address value by user)
  9264 00003D9E A1[7A960100]        <1> 	mov	eax, [VGA_INT43H] ; VGA current (default) font address
  9265 00003DA3 AB                  <1> 	stosd
  9266                              <1> 	
  9267                              <1> 	; (total 40 bytes are written above as BIOS data state)
  9268                              <1> 
  9269                              <1> bfn_svs_6:
  9270                              <1> 	; 12/01/2021
  9271 00003DA4 F6C104              <1> 	test	cl, 4
  9272 00003DA7 7423                <1> 	jz	short bfn_svs_8
  9273                              <1> 
  9274                              <1>   	;/* XXX: check this */
  9275                              <1> 		; /* read/write mode dac */
  9276                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_STATE)); BX++;
  9277                              <1> 	;	; /* pix address */
  9278                              <1>         ;write_byte(ES, BX, inb(VGAREG_DAC_WRITE_ADDRESS)); BX++;
  9279                              <1>         ;write_byte(ES, BX, inb(VGAREG_PEL_MASK)); BX++;
  9280                              <1>         ;// Set the whole dac always, from 0
  9281                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
  9282                              <1>         ;for(i=0;i<256*3;i++) {
  9283                              <1>         ;   write_byte(ES, BX, inb(VGAREG_DAC_DATA)); BX++;
  9284                              <1>         ;}
  9285                              <1>         ;write_byte(ES, BX, 0); BX++; /* color select register */
  9286                              <1> 
  9287                              <1> 	; /* read/write mode dac */
  9288 00003DA9 66BAC703            <1>     	mov	dx, 3C7h ; VGAREG_DAC_STATE
  9289 00003DAD EC                  <1> 	in	al, dx
  9290 00003DAE AA                  <1> 	stosb
  9291                              <1> 	; /* pix address */
  9292                              <1>     	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
  9293                              <1> 	;mov	dl, 0C8h
  9294 00003DAF FEC2                <1> 	inc	dl
  9295 00003DB1 EC                  <1> 	in	al, dx
  9296 00003DB2 AA                  <1> 	stosb
  9297                              <1>     	;mov	dx, VGAREG_PEL_MASK  ; 3C6h
  9298 00003DB3 B2C6                <1> 	mov	dl, 0C6h
  9299 00003DB5 EC                  <1> 	in	al, dx
  9300 00003DB6 AA                  <1> 	stosb
  9301                              <1> 	;// Set the whole dac always, from 0
  9302 00003DB7 30C0                <1> 	xor	al, al ; 0
  9303                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
  9304 00003DB9 B2C8                <1> 	mov	dl, 0C8h
  9305 00003DBB EE                  <1> 	out	dx, al
  9306                              <1> 
  9307 00003DBC 51                  <1> 	push	ecx ; 22/01/2021
  9308                              <1> 	;for(i=0;i<256*3;i++) {
  9309 00003DBD B900030000          <1> 	mov	ecx, 256*3 ; 768 bytes
  9310                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
  9311                              <1> 	;mov	dl, 0C9h
  9312 00003DC2 FEC2                <1> 	inc	dl ; dx = 3C9h
  9313                              <1> bfn_svs_7:
  9314 00003DC4 EC                  <1> 	in	al, dx
  9315 00003DC5 AA                  <1> 	stosb
  9316 00003DC6 E2FC                <1> 	loop	bfn_svs_7
  9317 00003DC8 59                  <1> 	pop	ecx ; 22/01/2021
  9318                              <1> 
  9319                              <1> 	; /* color select register */
  9320 00003DC9 28C0                <1> 	sub	al, al ; 0
  9321 00003DCB AA                  <1> 	stosb
  9322                              <1> 
  9323                              <1> 	; (total 772 bytes are written above as DAC state)
  9324                              <1> bfn_svs_8:
  9325 00003DCC C3                  <1> 	retn
  9326                              <1> 
  9327                              <1> vbe_biosfn_save_video_state:
  9328                              <1> 	; 23/01/2021
  9329                              <1> 	; 13/01/2021
  9330                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
  9331                              <1> 	; (vbe.c)
  9332                              <1> 
  9333                              <1> 	; modified registers: eax, edx, edi, ch
  9334                              <1> 	
  9335                              <1> 	; input: edi = state buffer address
  9336                              <1> 	; output: 
  9337                              <1> 	;	 VBE DISPI register contents will be saved
  9338                              <1> 	;	 (18 bytes, 9 words)
  9339                              <1> 
  9340                              <1> 	; outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
  9341                              <1> 	; enable = inw(VBE_DISPI_IOPORT_DATA);
  9342                              <1>   	; write_word(ES, BX, enable);
  9343                              <1>  	; BX += 2;
  9344                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) 
  9345                              <1> 	;	return;
  9346                              <1> 	; for(i = VBE_DISPI_INDEX_XRES;
  9347                              <1> 	;		 i <= VBE_DISPI_INDEX_Y_OFFSET; i++) {
  9348                              <1> 	;    if (i != VBE_DISPI_INDEX_ENABLE) {
  9349                              <1> 	;        outw(VBE_DISPI_IOPORT_INDEX, i);
  9350                              <1> 	;        write_word(ES, BX, inw(VBE_DISPI_IOPORT_DATA));
  9351                              <1>         ;    BX += 2;
  9352                              <1> 	;        }
  9353                              <1> 	; }
  9354                              <1> 
  9355 00003DCD 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9356 00003DD1 B804000000          <1> 	mov	eax, 04h  ; VBE_DISPI_INDEX_ENABLE
  9357 00003DD6 66EF                <1> 	out	dx, ax
  9358                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA	
  9359 00003DD8 FEC2                <1> 	inc	dl
  9360 00003DDA 66ED                <1> 	in	ax, dx ; enable (status)
  9361 00003DDC 66AB                <1> 	stosw 
  9362 00003DDE 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
  9363 00003DE2 7505                <1> 	jnz	short vbe_bfn_svs_0
  9364                              <1> 	; 23/01/2021
  9365                              <1> 	; ax = 0
  9366                              <1> 	; VBE_DISPI_DISABLED
  9367                              <1> 	; 13/01/2021
  9368                              <1> 	; clear remain 8 bytes 
  9369                              <1> 	;xor	eax, eax
  9370 00003DE4 AB                  <1> 	stosd	; 2
  9371 00003DE5 AB                  <1> 	stosd	; 2
  9372 00003DE6 AB                  <1> 	stosd	; 2
  9373 00003DE7 AB                  <1> 	stosd	; 2
  9374 00003DE8 C3                  <1> 	retn
  9375                              <1> vbe_bfn_svs_0:
  9376                              <1> 	; VBE_DISPI_ENABLED
  9377                              <1> 
  9378                              <1> 	;sub	eax, eax
  9379 00003DE9 28C0                <1> 	sub	al, al ; eax = 0
  9380                              <1> 	
  9381                              <1> 	; from VBE_DISPI_INDEX_XRES
  9382                              <1> 	;   to VBE_DISPI_INDEX_BPP	
  9383                              <1> 
  9384 00003DEB B503                <1>  	mov	ch, 3
  9385                              <1> 	; al = 0 ; VBE_DISPI_INDEX_XRES - 1
  9386                              <1> 
  9387 00003DED E804000000          <1> 	call	vbe_bfn_svs_1
  9388                              <1> 
  9389                              <1> 	; from VBE_DISPI_INDEX_BANK
  9390                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
  9391                              <1> 
  9392 00003DF2 FEC0                <1> 	inc	al 
  9393                              <1> 	; al = 4 ; VBE_DISPI_INDEX_BANK - 1
  9394                              <1> 
  9395 00003DF4 B505                <1> 	mov	ch, 5
  9396                              <1> vbe_bfn_svs_1:
  9397 00003DF6 FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
  9398                              <1> 		   ;   to VBE_DISPI_INDEX_BPP	
  9399                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9400 00003DF8 FECA                <1> 	dec	dl ; 1CEh
  9401 00003DFA 66EF                <1> 	out	dx, ax
  9402 00003DFC 50                  <1> 	push	eax
  9403                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
  9404 00003DFD FEC2                <1> 	inc	dl ; 1CFh
  9405 00003DFF 66ED                <1> 	in	ax, dx
  9406 00003E01 66AB                <1> 	stosw
  9407 00003E03 58                  <1> 	pop	eax
  9408 00003E04 FECD                <1> 	dec	ch
  9409 00003E06 75EE                <1> 	jnz	short vbe_bfn_svs_1		
  9410 00003E08 C3                  <1> 	retn
  9411                              <1> 
  9412                              <1> ; 11/01/2021
  9413                              <1> VGAREG_ACTL_ADDRESS	equ 3C0h
  9414                              <1> VGAREG_ACTL_WRITE_DATA	equ 3C0h
  9415                              <1> VGAREG_ACTL_READ_DATA	equ 3C1h
  9416                              <1> 
  9417                              <1> VGAREG_INPUT_STATUS	equ 3C2h
  9418                              <1> VGAREG_WRITE_MISC_OUTPUT equ 3C2h
  9419                              <1> VGAREG_VIDEO_ENABLE	equ 3C3h
  9420                              <1> VGAREG_SEQU_ADDRESS	equ 3C4h
  9421                              <1> VGAREG_SEQU_DATA	equ 3C5h
  9422                              <1> 
  9423                              <1> VGAREG_PEL_MASK		equ 3C6h
  9424                              <1> VGAREG_DAC_STATE	equ 3C7h
  9425                              <1> VGAREG_DAC_READ_ADDRESS	equ 3C7h
  9426                              <1> VGAREG_DAC_WRITE_ADDRESS equ 3C8h
  9427                              <1> VGAREG_DAC_DATA		equ 3C9h
  9428                              <1> 
  9429                              <1> VGAREG_READ_FEATURE_CTL	equ 3CAh
  9430                              <1> VGAREG_READ_MISC_OUTPUT	equ 3CCh
  9431                              <1> 
  9432                              <1> VGAREG_GRDC_ADDRESS	equ 3CEh
  9433                              <1> VGAREG_GRDC_DATA	equ 3CFh
  9434                              <1> 
  9435                              <1> ;VGAREG_MDA_CRTC_ADDRESS equ 3B4h
  9436                              <1> ;VGAREG_MDA_CRTC_DATA	equ 3B5h
  9437                              <1> VGAREG_VGA_CRTC_ADDRESS	equ 3D4h
  9438                              <1> VGAREG_VGA_CRTC_DATA	equ 3D5h
  9439                              <1> 
  9440                              <1> ;VGAREG_MDA_WRITE_FEATURE_CTL equ 3BAh
  9441                              <1> VGAREG_VGA_WRITE_FEATURE_CTL equ 3DAh
  9442                              <1> VGAREG_ACTL_RESET	equ 3DAh
  9443                              <1> 
  9444                              <1> ;VGAREG_MDA_MODECTL	equ 3B8h
  9445                              <1> VGAREG_CGA_MODECTL	equ 3D8h
  9446                              <1> VGAREG_CGA_PALETTE	equ 3D9h
  9447                              <1> 
  9448                              <1> biosfn_restore_video_state:
  9449                              <1> 	; 22/01/2021
  9450                              <1> 	; 13/01/2021
  9451                              <1> 	; 12/01/2021 (TRDOS 386 v2.0.3)
  9452                              <1> 	; (vgabios.c)
  9453                              <1> 
  9454                              <1> 	; modified registers: eax, edx, esi, edi, ch
  9455                              <1> 
  9456                              <1> 	;mov	esi, VBE3SAVERESTOREBLOCK
  9457                              <1> 
  9458                              <1> 	; input: esi = state buffer address
  9459                              <1> 
  9460 00003E09 F6C101              <1> 	test	cl, 1
  9461 00003E0C 0F84A9000000        <1> 	jz	bfn_rvs_6
  9462                              <1> 
  9463 00003E12 66817E40D403        <1> 	cmp	word [esi+64], 3D4h ; must be 3D4h
  9464 00003E18 7402                <1> 	je	short bfn_rvs_0  
  9465                              <1> 			; it is seen as valid buffer
  9466 00003E1A F9                  <1> 	stc
  9467 00003E1B C3                  <1> 	retn
  9468                              <1> 
  9469                              <1> bfn_rvs_0:
  9470 00003E1C 89F7                <1> 	mov	edi, esi ; addr1
  9471 00003E1E 83C605              <1> 	add	esi, 5 ; skip 1st 5 bytes for now
  9472                              <1> 
  9473                              <1> 	; // Reset Attribute Ctl flip-flop
  9474                              <1>         ; inb(VGAREG_ACTL_RESET);
  9475 00003E21 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
  9476 00003E25 EC                  <1> 	in	al, dx
  9477                              <1> 
  9478                              <1> 	; for(i=1;i<=4;i++){
  9479 00003E26 B001                <1> 	mov	al, 1
  9480                              <1> 	;;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9481                              <1> 	;mov	dl, 0C4h
  9482 00003E28 B504                <1> 	mov	ch, 4
  9483                              <1> bfn_rvs_1:
  9484                              <1> 	; outb(VGAREG_SEQU_ADDRESS, i);
  9485                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9486 00003E2A B2C4                <1> 	mov	dl, 0C4h
  9487 00003E2C EE                  <1> 	out	dx, al
  9488                              <1> 	;mov	dx, VGAREG_SEQU_DATA  ; 3C5h
  9489 00003E2D FEC2                <1> 	inc	dl  ; dx = 3C5h
  9490                              <1> 	; outb(VGAREG_SEQU_DATA)
  9491 00003E2F 50                  <1> 	push	eax
  9492 00003E30 AC                  <1> 	lodsb	; (4 bytes in loop)
  9493 00003E31 EE                  <1> 	out	dx, al
  9494 00003E32 58                  <1> 	pop	eax
  9495                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C4h
  9496                              <1> 	;dec	dl	
  9497 00003E33 FEC0                <1> 	inc	al  ; i++
  9498 00003E35 FECD                <1> 	dec	ch
  9499 00003E37 75F1                <1> 	jnz	short bfn_rvs_1
  9500                              <1> 
  9501                              <1> 	; outb(VGAREG_SEQU_ADDRESS, 0);
  9502 00003E39 28C0                <1> 	sub	al, al ; 0
  9503 00003E3B EE                  <1> 	out	dx, al
  9504                              <1> 	; outb(VGAREG_SEQU_DATA)
  9505                              <1> 	;mov	dx, VGAREG_SEQU_DATA ; 3C5h
  9506 00003E3C FEC2                <1> 	inc	dl  ; dx = 3C5h
  9507 00003E3E AC                  <1> 	lodsb	; (+1 byte)
  9508 00003E3F EE                  <1> 	out	dx, al
  9509                              <1> 
  9510                              <1> 	; // Disable CRTC write protection
  9511                              <1> 	; outw(crtc_addr,0x0011);
  9512                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9513 00003E40 B2D4                <1> 	mov	dl, 0D4h
  9514 00003E42 66B81100            <1> 	mov	ax, 11h
  9515 00003E46 66EF                <1> 	out	dx, ax
  9516                              <1> 
  9517                              <1> 	; // Set CRTC regs
  9518                              <1>        
  9519                              <1> 	; for(i=0;i<=0x18;i++) {
  9520                              <1>         ;   if (i != 0x11) {
  9521 00003E48 28C0                <1> 	sub	al, al ; 0
  9522                              <1> 	;;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9523                              <1> 	;mov	dl, 0D4h
  9524 00003E4A B519                <1> 	mov	ch, 25
  9525                              <1> bfn_rvs_2:
  9526                              <1>         ; outb(crtc_addr,i);
  9527                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9528 00003E4C B2D4                <1> 	mov	dl, 0D4h
  9529 00003E4E EE                  <1> 	out	dx, al
  9530                              <1> 	;mov	dx, VGAREG_VGA_CRTC_DATA ; 3D5h
  9531 00003E4F FEC2                <1> 	inc	dl  ; dx = 3D5h
  9532                              <1> 	; inb(crtc_addr+1)
  9533 00003E51 50                  <1> 	push	eax
  9534 00003E52 AC                  <1> 	lodsb	; (25 bytes in loop)
  9535 00003E53 EE                  <1> 	out	dx, al
  9536 00003E54 58                  <1> 	pop	eax
  9537                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9538                              <1> 	;dec	dl
  9539 00003E55 FEC0                <1> 	inc	al  ; i++
  9540 00003E57 3C11                <1> 	cmp	al, 17 ; 11h
  9541 00003E59 7505                <1> 	jne	short bfn_rvs_3
  9542 00003E5B AC                  <1> 	lodsb
  9543 00003E5C 88C4                <1> 	mov	ah, al ; *
  9544 00003E5E B012                <1> 	mov	al, 18 
  9545                              <1> bfn_rvs_3:
  9546 00003E60 FECD                <1> 	dec	ch
  9547 00003E62 75E8                <1> 	jnz	short bfn_rvs_2
  9548                              <1> 
  9549                              <1> 	; // select crtc base address
  9550                              <1>         ; v = inb(VGAREG_READ_MISC_OUTPUT) & ~0x01;
  9551                              <1> 	;if (crtc_addr = 0x3d4)
  9552                              <1> 	;   v |= 0x01;
  9553                              <1> 	; outb(VGAREG_WRITE_MISC_OUTPUT, v);
  9554                              <1> 
  9555                              <1> 	;;mov	dx, VGAREG_READ_MISC_OUTPUT ; 3CCh
  9556                              <1> 	;mov	dl, 0CCh
  9557                              <1> 	;in	al, dl
  9558                              <1> 	;and	al, 1
  9559                              <1> 	;;mov	dx, VGAREG_WRITE_MISC_OUTPUT ; 3C2h
  9560                              <1> 	;mov	dl, 0C2h
  9561                              <1> 	;or	al, 1
  9562                              <1> 	;out	dx, al
  9563                              <1> 
  9564                              <1> 	; // enable write protection if needed
  9565                              <1> 	;outb(crtc_addr, 0x11);
  9566                              <1>         ;outb(crtc_addr+1, read_byte(ES, BX - 0x18 + 0x11));
  9567                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9568 00003E64 B2D4                <1> 	mov	dl, 0D4h
  9569 00003E66 B011                <1> 	mov	al, 11h
  9570 00003E68 EE                  <1> 	out	dx, al
  9571 00003E69 88E0                <1> 	mov	al, ah ; *
  9572 00003E6B FEC2                <1> 	inc	dl ; dx = 3D5h
  9573 00003E6D EE                  <1> 	out	dx, al
  9574                              <1> 
  9575                              <1> 	; // Set Attribute Ctl
  9576 00003E6E 8A6703              <1> 	mov	ah, [edi+3] ; addr1+3, ah = ar_index
  9577 00003E71 80E420              <1> 	and	ah, 20h  ; (ar_index & 0x20)
  9578                              <1> 
  9579                              <1>         ; inb(VGAREG_ACTL_RESET);
  9580                              <1> 	;mov	dx, 3DAh ; VGAREG_ACTL_RESET
  9581 00003E74 B2DA                <1> 	mov	dl, 0DAh
  9582 00003E76 EC                  <1> 	in	al, dx
  9583                              <1> 
  9584                              <1>         ; for(i=0;i<=0x13;i++) {
  9585 00003E77 28C0                <1> 	sub	al, al ; 0
  9586 00003E79 B514                <1> 	mov	ch, 20
  9587                              <1> bfn_rvs_4:
  9588                              <1>  	; outb(VGAREG_ACTL_ADDRESS, i | (ar_index & 0x20));
  9589 00003E7B 50                  <1> 	push	eax
  9590 00003E7C 08E0                <1> 	or	al, ah
  9591                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
  9592 00003E7E B2C0                <1> 	mov	dl, 0C0h
  9593 00003E80 EE                  <1> 	out	dx, al
  9594                              <1> 	;mov	dx, VGAREG_ACTL_WRITE_DATA ; 3C0h
  9595                              <1> 	;mov	dl, 0C0h
  9596 00003E81 AC                  <1> 	lodsb	; (20 bytes in loop)
  9597 00003E82 EE                  <1> 	out	dx, al
  9598 00003E83 58                  <1> 	pop	eax
  9599 00003E84 FEC0                <1> 	inc	al  ; i++
  9600 00003E86 FECD                <1> 	dec	ch
  9601 00003E88 75F1                <1> 	jnz	short bfn_rvs_4
  9602                              <1> 
  9603                              <1> 	; outb(VGAREG_ACTL_ADDRESS, ar_index);
  9604                              <1> 	;mov	dx, VGAREG_ACTL_ADDRESS ; 3C0h
  9605                              <1> 	;mov	dl, 0C0h
  9606 00003E8A 88E0                <1> 	mov	al, ah ; ar_index
  9607 00003E8C EE                  <1> 	out	dx, al
  9608                              <1> 
  9609                              <1> 	; inb(VGAREG_ACTL_RESET);
  9610                              <1> 	;mov	dx, VGAREG_ACTL_RESET ; 3DAh
  9611 00003E8D B2DA                <1> 	mov	dl, 0DAh
  9612 00003E8F EC                  <1> 	in	al, dx
  9613                              <1> 
  9614                              <1>         ; for(i=0;i<=8;i++) {
  9615 00003E90 28C0                <1> 	sub	al, al ; 0
  9616                              <1> 	;;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
  9617                              <1> 	;mov	dl, 0CEh
  9618 00003E92 B509                <1> 	mov	ch, 9
  9619                              <1> bfn_rvs_5:
  9620                              <1> 	; outb(VGAREG_GRDC_ADDRESS,i)
  9621                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh
  9622 00003E94 B2CE                <1> 	mov	dl, 0CEh
  9623 00003E96 EE                  <1> 	out	dx, al
  9624                              <1> 	; outb(VGAREG_ACTL_READ_DATA)
  9625 00003E97 50                  <1> 	push	eax
  9626                              <1> 	;mov	dx, VGAREG_GRDC_DATA ; 3CFh
  9627                              <1> 	;mov	dl, 0CFh
  9628 00003E98 FEC2                <1> 	inc	dl
  9629 00003E9A AC                  <1> 	lodsb	; (9 bytes in loop)
  9630 00003E9B EE                  <1> 	out	dx, al
  9631 00003E9C 58                  <1> 	pop	eax
  9632                              <1> 	;dec	dl
  9633 00003E9D FEC0                <1> 	inc	al  ; i++
  9634 00003E9F FECD                <1> 	dec	ch
  9635 00003EA1 75F1                <1> 	jnz	short bfn_rvs_5
  9636                              <1> 
  9637                              <1> 	; BX += 2; /* crtc_addr */     ; 3D4h
  9638                              <1>         ; BX += 4; /* plane latches */ ; 0
  9639 00003EA3 83C606              <1> 	add	esi, 6	      
  9640 00003EA6 56                  <1> 	push	esi ; *	
  9641                              <1> 
  9642                              <1> 	;outb(VGAREG_SEQU_ADDRESS, read_byte(ES, addr1)); addr1++;
  9643                              <1>         ;outb(crtc_addr, read_byte(ES, addr1)); addr1++;
  9644                              <1>         ;outb(VGAREG_GRDC_ADDRESS, read_byte(ES, addr1)); addr1++;
  9645                              <1>         ;addr1++;
  9646                              <1>         ;outb(crtc_addr - 0x4 + 0xa, read_byte(ES, addr1)); addr1++;
  9647                              <1> 
  9648 00003EA7 89FE                <1> 	mov	esi, edi ; start of state buffer
  9649                              <1> 
  9650                              <1> 	;mov	dx, VGAREG_SEQU_ADDRESS ; 3C7h
  9651 00003EA9 B2C7                <1> 	mov	dl, 0C7h 
  9652 00003EAB AC                  <1> 	lodsb
  9653 00003EAC EE                  <1> 	out	dx, al
  9654                              <1> 	;mov	dx, VGAREG_VGA_CRTC_ADDRESS ; 3D4h
  9655 00003EAD B2D4                <1> 	mov	dl, 0D4h
  9656 00003EAF AC                  <1> 	lodsb
  9657 00003EB0 EE                  <1> 	out	dx, al
  9658                              <1> 	;mov	dx, VGAREG_GRDC_ADDRESS ; 3CEh 
  9659 00003EB1 B2CE                <1>         mov	dl, 0CEh
  9660 00003EB3 AC                  <1> 	lodsb
  9661 00003EB4 EE                  <1> 	out	dx, al
  9662 00003EB5 AC                  <1> 	lodsb	; addr1++
  9663                              <1> 	;mov	dx, VGAREG_VGA_WRITE_FEATURE_CTL ; 3DAh
  9664 00003EB6 B2DA                <1> 	mov	dl, 0DAh
  9665 00003EB8 AC                  <1> 	lodsb
  9666 00003EB9 EE                  <1> 	out	dx, al
  9667                              <1> 
  9668 00003EBA 5E                  <1> 	pop	esi ; *
  9669                              <1> 
  9670                              <1> 	; (total 70 bytes are read above as controller hardware state)
  9671                              <1> 
  9672                              <1> bfn_rvs_6:		
  9673                              <1> 	; 13/01/2021
  9674 00003EBB F6C102              <1> 	test	cl, 2
  9675 00003EBE 747D                <1> 	jz	short bfn_rvs_9
  9676                              <1> 
  9677                              <1> 	; VIDEO BIOS DATA
  9678                              <1> 	; !!! this data is valid for TRDOS 386 v2 kernel only !!!
  9679                              <1> 	; (this is not same with BOCHS/PLEX86 video bios, BIOS data)  
  9680                              <1>   
  9681                              <1>     	; if (CX & 2) {
  9682                              <1> 	;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_MODE, read_byte(ES, BX)); BX++;
  9683                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_NB_COLS, read_word(ES, BX)); BX += 2;
  9684                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_PAGE_SIZE, read_word(ES, BX)); BX += 2;
  9685                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CRTC_ADDRESS, read_word(ES, BX)); BX += 2;
  9686                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_NB_ROWS, read_byte(ES, BX)); BX++;
  9687                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CHAR_HEIGHT, read_word(ES, BX)); BX += 2;
  9688                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_VIDEO_CTL, read_byte(ES, BX)); BX++;
  9689                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_SWITCHES, read_byte(ES, BX)); BX++;
  9690                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_MODESET_CTL, read_byte(ES, BX)); BX++;
  9691                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURSOR_TYPE, read_word(ES, BX)); BX += 2;
  9692                              <1>         ;for(i=0;i<8;i++) {
  9693                              <1>         ;   write_word(BIOSMEM_SEG, BIOSMEM_CURSOR_POS+2*i, read_word(ES, BX));
  9694                              <1>         ;   BX += 2;
  9695                              <1>         ;}
  9696                              <1>         ;write_word(BIOSMEM_SEG,BIOSMEM_CURRENT_START, read_word(ES, BX)); BX += 2;
  9697                              <1>         ;write_byte(BIOSMEM_SEG,BIOSMEM_CURRENT_PAGE, read_byte(ES, BX)); BX++;
  9698                              <1>         ;/* current font */
  9699                              <1>         ;write_word(0, 0x1f * 4, read_word(ES, BX)); BX += 2;
  9700                              <1>         ;write_word(0, 0x1f * 4 + 2, read_word(ES, BX)); BX += 2;
  9701                              <1>         ;write_word(0, 0x43 * 4, read_word(ES, BX)); BX += 2;
  9702                              <1>         ;write_word(0, 0x43 * 4 + 2, read_word(ES, BX)); BX += 2;
  9703                              <1> 
  9704                              <1> 	; !!! save TRDOS 386 v2 kernel spesific video bios data !!!
  9705                              <1> 	; (which is/are used by 'SET_MODE' function and/or it's sub functions)
  9706                              <1> 
  9707 00003EC0 66AD                <1> 	lodsw	 ; CRTC_ADDR, always 3D4h (color VGA) for TRDOS 386 v2
  9708                              <1> 	; skip 3D4h check if it is already checked
  9709 00003EC2 F6C101              <1> 	test	cl, 1
  9710 00003EC5 7508                <1> 	jnz	short bfn_rvs_7
  9711 00003EC7 663DD403            <1> 	cmp	ax, 3D4h
  9712 00003ECB 7402                <1> 	je	short bfn_rvs_7
  9713 00003ECD F9                  <1> 	stc
  9714 00003ECE C3                  <1> 	retn
  9715                              <1> bfn_rvs_7:
  9716 00003ECF AC                  <1> 	lodsb
  9717 00003ED0 A2[CA6F0000]        <1> 	mov	[CRT_MODE], al ; Current video mode (0FFh for VESA VBE modes) 
  9718 00003ED5 AC                  <1> 	lodsb
  9719 00003ED6 A2[CB6F0000]        <1> 	mov	[CRT_MODE_SET], al ; 29h for mode 03h ; TRDOS 386 feature only !
  9720 00003EDB 66AD                <1> 	lodsw	
  9721 00003EDD 66A3[1E120300]      <1>  	mov	[video_mode], ax ; Current VESA VBE (SVGA, extended VGA) mode 
  9722 00003EE3 66AD                <1> 	lodsw		 ; (valid if [CRT_MODE] = 0FFh)	
  9723 00003EE5 66A3[68960100]      <1> 	mov	[CRT_LEN], ax ; page size (in bytes)
  9724 00003EEB 66AD                <1> 	lodsw
  9725 00003EED 66A3[EC890100]      <1> 	mov	[CRT_START], ax ; video page start offset
  9726 00003EF3 AC                  <1>  	lodsb
  9727 00003EF4 A2[CC6F0000]        <1> 	mov	[CRT_COLS], al ; nbcols, characters per row	
  9728 00003EF9 AC                  <1> 	lodsb
  9729 00003EFA A2[D26F0000]        <1> 	mov	[VGA_ROWS], al ; nbrows, (character) rows per page (not rows-1)
  9730 00003EFF AC                  <1> 	lodsb
  9731 00003F00 A2[CE6F0000]        <1> 	mov	[CHAR_HEIGHT], al ; character font height (8 or 16 or 14)
  9732 00003F05 AC                  <1> 	lodsb
  9733 00003F06 A2[CF6F0000]        <1> 	mov	[VGA_VIDEO_CTL], al ; ROM BIOS DATA AREA Offset 87h
  9734 00003F0B AC                  <1> 	lodsb
  9735 00003F0C A2[D06F0000]        <1> 	mov	[VGA_SWITCHES], al ; feature bit switches
  9736 00003F11 AC                  <1> 	lodsb
  9737 00003F12 A2[D16F0000]        <1> 	mov	[VGA_MODESET_CTL], al ; basic mode set options
  9738                              <1> 	; followings are only used by TRDOS 386 v2 (IBM PC/AT ROMBIOS) code 
  9739                              <1> 	; (bochs/plex86 does not use and return those)
  9740 00003F17 AC                  <1> 	lodsb
  9741 00003F18 A2[CD6F0000]        <1> 	mov	[CRT_PALETTE], al ; current color palette ; TRDOS 386 feature only !
  9742 00003F1D AC                  <1> 	lodsb
  9743 00003F1E A2[FE890100]        <1> 	mov	[ACTIVE_PAGE], al ; current video page 
  9744 00003F23 66AD                <1> 	lodsw
  9745 00003F25 66A3[E36F0000]      <1> 	mov	[CURSOR_MODE], ax ; cursor type
  9746                              <1> 	;lodsd
  9747                              <1> 	;mov	[CURSOR_POSN], eax ; cursor position for video page 0 and 1 
  9748                              <1> 	;lodsd
  9749                              <1> 	;mov	[CURSOR_POSN+4], eax ; cursor position for video page 2 and 3 
  9750                              <1> 	;lodsd
  9751                              <1> 	;mov	[CURSOR_POSN+8], eax ; cursor position for video page 4 and 5 
  9752                              <1> 	;lodsd
  9753                              <1> 	;mov	[CURSOR_POSN+12], eax ; cursor position for video page 6 and 7 
  9754 00003F2B B504                <1> 	mov	ch, 4
  9755 00003F2D BF[EE890100]        <1> 	mov	edi, CURSOR_POSN
  9756                              <1> bfn_rvs_8:
  9757 00003F32 A5                  <1> 	movsd
  9758 00003F33 FECD                <1> 	dec	ch
  9759 00003F35 75FB                <1> 	jnz	short bfn_rvs_8
  9760                              <1> 	; (font addr) protected mode address in kernel's/system memory space 
  9761                              <1> 	; (not accessable/meaningful address value by user)
  9762 00003F37 AD                  <1> 	lodsd
  9763 00003F38 A3[7A960100]        <1> 	mov	[VGA_INT43H], eax ; VGA current (default) font address
  9764                              <1> 
  9765                              <1> 	; (total 40 bytes are read&written above as BIOS data state)
  9766                              <1> bfn_rvs_9:
  9767                              <1> 	; 13/01/2021
  9768 00003F3D F6C104              <1> 	test	cl, 4
  9769 00003F40 7422                <1> 	jz	short bfn_rvs_11
  9770                              <1> 
  9771                              <1> 	;BX++;
  9772                              <1>         ;v = read_byte(ES, BX); BX++;
  9773                              <1>         ;outb(VGAREG_PEL_MASK, read_byte(ES, BX)); BX++;
  9774                              <1>         ;// Set the whole dac always, from 0
  9775                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS,0x00);
  9776                              <1>         ;for(i=0;i<256*3;i++) {
  9777                              <1>         ;   outb(VGAREG_DAC_DATA, read_byte(ES, BX)); BX++;
  9778                              <1>         ;}
  9779                              <1>         ;BX++;
  9780                              <1>         ;outb(VGAREG_DAC_WRITE_ADDRESS, v);
  9781                              <1> 
  9782                              <1> 	; /* read/write mode dac */
  9783 00003F42 AC                  <1> 	lodsb	; skip ; VGAREG_DAC_STATE
  9784 00003F43 AC                  <1> 	lodsb
  9785 00003F44 88C4                <1> 	mov	ah, al ; * ; v
  9786 00003F46 AC                  <1> 	lodsb
  9787 00003F47 66BAC603            <1> 	mov	dx, VGAREG_PEL_MASK  ; 3C6h
  9788 00003F4B EE                  <1> 	out	dx, al
  9789                              <1> 	;// Set the whole dac always, from 0
  9790 00003F4C 30C0                <1> 	xor	al, al ; 0
  9791                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
  9792 00003F4E B2C8                <1> 	mov	dl, 0C8h
  9793 00003F50 EE                  <1> 	out	dx, al
  9794                              <1> 
  9795 00003F51 51                  <1> 	push	ecx ; 22/01/2021
  9796                              <1> 	;for(i=0;i<256*3;i++) {
  9797 00003F52 B900030000          <1> 	mov	ecx, 256*3 ; 768 bytes
  9798                              <1> 	;mov	dx, VGAREG_DAC_DATA ; 3C9h
  9799                              <1> 	;mov	dl, 0C9h
  9800 00003F57 FEC2                <1> 	inc	dl ; dx = 3C9h
  9801                              <1> bfn_rvs_10:
  9802 00003F59 AC                  <1> 	lodsb
  9803 00003F5A EE                  <1> 	out	dx, al
  9804 00003F5B E2FC                <1> 	loop	bfn_rvs_10
  9805 00003F5D 59                  <1> 	pop	ecx ; 22/01/2021
  9806                              <1> 
  9807                              <1> 	; /* color select register */
  9808 00003F5E AC                  <1> 	lodsb	 ; skip 
  9809                              <1> 	
  9810 00003F5F 88E0                <1> 	mov	al, ah ; * ; v
  9811                              <1> 
  9812                              <1> 	;mov	dx, VGAREG_DAC_WRITE_ADDRESS ; 3C8h
  9813                              <1> 	;mov	dl, 0C8h
  9814 00003F61 FECA                <1> 	dec	dl ; dx  = 3C8h
  9815 00003F63 EE                  <1> 	out	dx, al ; * ; v
  9816                              <1> 	
  9817                              <1> 	; (total 772 bytes are read above as DAC state)
  9818                              <1> bfn_rvs_11:
  9819 00003F64 C3                  <1> 	retn
  9820                              <1> 
  9821                              <1> vbe_biosfn_restore_video_state:
  9822                              <1> 	; 23/01/2021
  9823                              <1> 	; 13/01/2021 (TRDOS 386 v2.0.3)
  9824                              <1> 	; (vbe.c)
  9825                              <1> 
  9826                              <1> 	; modified registers: eax, edx, esi, ch
  9827                              <1> 	
  9828                              <1> 	; input: esi = state buffer address
  9829                              <1> 	; output: 
  9830                              <1> 	;	 VBE DISPI register contents will be restored
  9831                              <1> 	;	 (18 bytes, 9 words)
  9832                              <1> 
  9833                              <1>  	; enable = read_word(ES, BX);
  9834                              <1> 	; BX += 2;
  9835                              <1> 	;
  9836                              <1> 	; if (!(enable & VBE_DISPI_ENABLED)) {
  9837                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
  9838                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
  9839                              <1> 	; } else {
  9840                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_XRES);
  9841                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
  9842                              <1>         ;   BX += 2;
  9843                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_YRES);
  9844                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
  9845                              <1>         ;   BX += 2;
  9846                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_BPP);
  9847                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
  9848                              <1>         ;   BX += 2;
  9849                              <1>         ;   outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
  9850                              <1>         ;   outw(VBE_DISPI_IOPORT_DATA, enable);
  9851                              <1> 	;
  9852                              <1>         ;  for(i = VBE_DISPI_INDEX_BANK; i <= VBE_DISPI_INDEX_Y_OFFSET; i++)
  9853                              <1> 	;    {
  9854                              <1>         ;     outw(VBE_DISPI_IOPORT_INDEX, i);
  9855                              <1>         ;     outw(VBE_DISPI_IOPORT_DATA, read_word(ES, BX));
  9856                              <1>         ;     BX += 2;
  9857                              <1>         ;    }
  9858                              <1>         ; }
  9859                              <1> 
  9860 00003F65 66AD                <1> 	lodsw	; enable (status, enabled=1, disabled=0)
  9861 00003F67 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9862                              <1> 	; 23/01/2021
  9863 00003F6B 6683E001            <1> 	and	ax, 1 ; VBE_DISPI_ENABLED
  9864 00003F6F 750B                <1> 	jnz	short vbe_bfn_rvs_1
  9865                              <1> 	; ax = 0
  9866                              <1> 	; VBE_DISPI_DISABLED
  9867                              <1> vbe_bfn_rvs_0:
  9868                              <1> 	; enable (disable) dispi
  9869                              <1> 	; dx = 01CEh ; VBE_DISPI_IOPORT_INDEX
  9870                              <1> 	; ah = 0
  9871 00003F71 50                  <1> 	push	eax
  9872 00003F72 B004                <1> 	mov	al, 04h	; VBE_DISPI_INDEX_ENABLE
  9873 00003F74 66EF                <1> 	out	dx, ax
  9874                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA	
  9875 00003F76 FEC2                <1> 	inc	dl
  9876 00003F78 58                  <1> 	pop	eax
  9877 00003F79 66EF                <1> 	out	dx, ax ; enable (or disable)
  9878 00003F7B C3                  <1> 	retn
  9879                              <1> vbe_bfn_rvs_1:
  9880                              <1> 	; VBE_DISPI_ENABLED
  9881                              <1> 
  9882                              <1> 	; from VBE_DISPI_INDEX_XRES
  9883                              <1> 	;   to VBE_DISPI_INDEX_BPP	
  9884                              <1> 
  9885 00003F7C B503                <1>  	mov	ch, 3
  9886 00003F7E 28C0                <1> 	sub	al, al ; 0 ; VBE_DISPI_INDEX_XRES - 1
  9887                              <1> 	; ax = 0
  9888                              <1> 
  9889 00003F80 E80B000000          <1> 	call	vbe_bfn_rvs_2
  9890                              <1> 
  9891                              <1>         ;outw(VBE_DISPI_IOPORT_INDEX,VBE_DISPI_INDEX_ENABLE);
  9892                              <1> 	;outw(VBE_DISPI_IOPORT_DATA, enable);
  9893                              <1> 
  9894                              <1> 	; 23/01/2021
  9895 00003F85 B001                <1> 	mov	al, 1 ; VBE_DISPI_ENABLED
  9896                              <1> 	; ax = 1
  9897 00003F87 E8E5FFFFFF          <1> 	call	vbe_bfn_rvs_0
  9898                              <1> 
  9899                              <1> 	; from VBE_DISPI_INDEX_BANK
  9900                              <1> 	;   to VBE_DISPI_INDEX_Y_OFFSET
  9901                              <1> 
  9902 00003F8C B505                <1> 	mov	ch, 5
  9903                              <1> 	; 23/01/2021
  9904 00003F8E B004                <1> 	mov	al, 4  ; VBE_DISPI_INDEX_BANK - 1
  9905                              <1> 	; ax = 4
  9906                              <1> vbe_bfn_rvs_2:
  9907 00003F90 FEC0                <1> 	inc	al ; from VBE_DISPI_INDEX_XRES
  9908                              <1> 		     ; to VBE_DISPI_INDEX_BPP	
  9909                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9910                              <1> 	;mov	dl, 0CEh
  9911 00003F92 66EF                <1> 	out	dx, ax
  9912 00003F94 50                  <1> 	push	eax
  9913                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
  9914 00003F95 FEC2                <1> 	inc	dl ; 1CFh
  9915 00003F97 66AD                <1> 	lodsw
  9916 00003F99 66EF                <1> 	out	dx, ax
  9917 00003F9B 58                  <1> 	pop	eax
  9918 00003F9C FECA                <1> 	dec	dl ; 1CEh
  9919 00003F9E FECD                <1> 	dec	ch
  9920 00003FA0 75EE                <1> 	jnz	short vbe_bfn_rvs_2		
  9921 00003FA2 C3                  <1> 	retn
  9922                              <1> 
  9923                              <1> ; ---------------------------------------------------------
  9924                              <1>  
  9925                              <1> dispi_set_enable:
  9926                              <1> 	; 23/11/2020
  9927                              <1> 	; Input:
  9928                              <1> 	;	ax = VBE_DISPI_ENABLED = 1
  9929                              <1> 	;	     or VBE_DISPI_DISABLED = 0
  9930                              <1> 	;
  9931                              <1> 	; Modified registers: none
  9932                              <1> 	
  9933                              <1> 	;push	edx
  9934                              <1> 	;push	eax
  9935                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9936                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
  9937                              <1> 	;out	dx, ax
  9938                              <1> 	;pop	eax
  9939                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
  9940                              <1> 	;;mov	dl, 0CFh
  9941                              <1> 	;inc	dl
  9942                              <1> 	;out	dx, ax
  9943                              <1> 	;pop	edx
  9944                              <1> 	;retn
  9945                              <1> 
  9946                              <1> 	; 25/11/2020
  9947                              <1> 	; Modified registers: edx
  9948                              <1> 	;push	edx
  9949 00003FA3 66BA0400            <1> 	mov	dx, 04h ; VBE_DISPI_INDEX_ENABLE
  9950                              <1> 	;call	dispi_set_parms
  9951                              <1> 	;pop	edx
  9952                              <1> 	;retn
  9953                              <1> 	;;jmp	short dispi_set_parms
  9954                              <1> 
  9955                              <1> dispi_set_parms:
  9956                              <1> 	; 25/11/2020
  9957                              <1> 	; Input:
  9958                              <1> 	;	ax = data
  9959                              <1> 	;	dx = vbe dispi register index
  9960                              <1> 	;
  9961                              <1> 	; Modified registers: edx
  9962                              <1> 
  9963 00003FA7 50                  <1> 	push	eax
  9964 00003FA8 6689D0              <1> 	mov	ax, dx
  9965 00003FAB 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9966 00003FAF 66EF                <1> 	out	dx, ax
  9967 00003FB1 58                  <1> 	pop	eax
  9968                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
  9969                              <1> 	;mov	dl, 0CFh
  9970 00003FB2 FEC2                <1> 	inc	dl
  9971 00003FB4 66EF                <1> 	out	dx, ax
  9972 00003FB6 C3                  <1> 	retn
  9973                              <1> 
  9974                              <1> dispi_set_bpp:
  9975                              <1> 	; 25/11/2020
  9976                              <1> 	; Input:
  9977                              <1> 	;	ax = Bits per pixel value
  9978                              <1> 	;	     (8,16,24,32)
  9979                              <1> 	;
  9980                              <1> 	; Modified registers: none
  9981                              <1> 
  9982                              <1> 	;push	edx
  9983                              <1> 	;push	eax
  9984                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
  9985                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
  9986                              <1> 	;out	dx, ax
  9987                              <1> 	;pop	eax
  9988                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
  9989                              <1> 	;;mov	dl, 0CFh
  9990                              <1> 	;inc	dl
  9991                              <1> 	;out	dx, ax
  9992                              <1> 	;pop	edx
  9993                              <1> 	;retn
  9994                              <1> 
  9995                              <1> 	; 25/11/2020
  9996                              <1> 	; Modified registers: edx
  9997                              <1> 	;push	edx
  9998 00003FB7 66BA0300            <1> 	mov	dx, 03h ; VBE_DISPI_INDEX_BPP
  9999                              <1> 	;call	dispi_set_parms
 10000                              <1> 	;pop	edx
 10001                              <1> 	;retn
 10002 00003FBB EBEA                <1> 	jmp	short dispi_set_parms
 10003                              <1> 
 10004                              <1> dispi_set_xres:
 10005                              <1> 	; 25/11/2020
 10006                              <1> 	; Input:
 10007                              <1> 	;	ax = X resolution (screen witdh)
 10008                              <1> 	;	     (320,640,800,1024,1280,1920)
 10009                              <1> 	;
 10010                              <1> 	; Modified registers: none
 10011                              <1> 
 10012                              <1> 	;push	edx
 10013                              <1> 	;push	eax
 10014                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10015                              <1> 	;mov	ax, 01h	  ; VBE_DISPI_INDEX_XRES
 10016                              <1> 	;out	dx, ax
 10017                              <1> 	;pop	eax
 10018                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10019                              <1> 	;;mov	dl, 0CFh
 10020                              <1> 	;inc	dl
 10021                              <1> 	;out	dx, ax
 10022                              <1> 	;pop	edx
 10023                              <1> 	;retn
 10024                              <1> 
 10025                              <1> 	; 25/11/2020
 10026                              <1> 	; Modified registers: edx
 10027                              <1> 	;push	edx
 10028 00003FBD 66BA0100            <1> 	mov	dx, 01h ; VBE_DISPI_INDEX_XRES
 10029                              <1> 	;call	dispi_set_parms
 10030                              <1> 	;pop	edx
 10031                              <1> 	;retn
 10032 00003FC1 EBE4                <1> 	jmp	short dispi_set_parms
 10033                              <1> 
 10034                              <1> dispi_set_yres:
 10035                              <1> 	; 25/11/2020
 10036                              <1> 	; Input:
 10037                              <1> 	;	ax = Y resolution (screen height)
 10038                              <1> 	;	     (200,400,600,720,768,1080)
 10039                              <1> 	;
 10040                              <1> 	; Modified registers: none
 10041                              <1> 
 10042                              <1> 	;push	edx
 10043                              <1> 	;push	eax
 10044                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10045                              <1> 	;mov	ax, 02h	  ; VBE_DISPI_INDEX_YRES
 10046                              <1> 	;out	dx, ax
 10047                              <1> 	;pop	eax
 10048                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10049                              <1> 	;;mov	dl, 0CFh
 10050                              <1> 	;inc	dl
 10051                              <1> 	;out	dx, ax
 10052                              <1> 	;pop	edx
 10053                              <1> 	;retn
 10054                              <1> 
 10055                              <1> 	; 25/11/2020
 10056                              <1> 	; Modified registers: edx
 10057                              <1> 	;push	edx
 10058 00003FC3 66BA0200            <1> 	mov	dx, 02h  ; VBE_DISPI_INDEX_YRES
 10059                              <1> 	;call	dispi_set_parms
 10060                              <1> 	;pop	edx
 10061                              <1> 	;retn
 10062 00003FC7 EBDE                <1> 	jmp	short dispi_set_parms
 10063                              <1> 
 10064                              <1> dispi_set_bank:
 10065                              <1> 	; 25/11/2020
 10066                              <1> 	; Input:
 10067                              <1> 	;	ax = video memory bank number
 10068                              <1> 	;
 10069                              <1> 	; Modified registers: none
 10070                              <1> 
 10071                              <1> 	;push	edx
 10072                              <1> 	;push	eax
 10073                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10074                              <1> 	;mov	ax, 05h	  ; VBE_DISPI_INDEX_BANK
 10075                              <1> 	;out	dx, ax
 10076                              <1> 	;pop	eax
 10077                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10078                              <1> 	;;mov	dl, 0CFh
 10079                              <1> 	;inc	dl
 10080                              <1> 	;out	dx, ax
 10081                              <1> 	;pop	edx
 10082                              <1> 	;retn
 10083                              <1> 	
 10084                              <1> 	; 25/11/2020
 10085                              <1> 	; Modified registers: edx
 10086                              <1> 	;push	edx
 10087 00003FC9 66BA0500            <1> 	mov	dx, 05h  ; VBE_DISPI_INDEX_BANK
 10088                              <1> 	;call	dispi_set_parms
 10089                              <1> 	;pop	edx
 10090                              <1> 	;retn
 10091 00003FCD EBD8                <1> 	jmp	short dispi_set_parms
 10092                              <1> 
 10093                              <1> dispi_get_enable:
 10094                              <1> 	; 27/11/2020
 10095                              <1> 	; Input:
 10096                              <1> 	;	none
 10097                              <1> 	; Output:
 10098                              <1> 	;	ax = vbe dispi status
 10099                              <1> 	;
 10100                              <1> 	; Modified registers: eax
 10101                              <1> 	
 10102                              <1> 	;push	edx
 10103                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10104                              <1> 	;mov	ax, 04h	  ; VBE_DISPI_INDEX_ENABLE
 10105                              <1> 	;out	dx, ax
 10106                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10107                              <1> 	;;mov	dl, 0CFh
 10108                              <1> 	;inc	dl
 10109                              <1> 	;in	ax, dx
 10110                              <1> 	;pop	edx
 10111                              <1> 	;retn
 10112                              <1> 
 10113                              <1> 	; 27/11/2020
 10114                              <1> 	; Modified registers: eax, edx
 10115                              <1> 	;push	edx
 10116 00003FCF 66B80400            <1> 	mov	ax, 04h ; VBE_DISPI_INDEX_ENABLE
 10117                              <1> 	;call	dispi_get_parms
 10118                              <1> 	;pop	edx
 10119                              <1> 	;retn
 10120                              <1> 	;;jmp	short dispi_get_parms
 10121                              <1> 
 10122                              <1> dispi_get_parms:
 10123                              <1> 	; 25/11/2020
 10124                              <1> 	; Input:
 10125                              <1> 	;	ax = vbe dispi register index
 10126                              <1> 	; output:
 10127                              <1> 	;	ax = data
 10128                              <1> 	;
 10129                              <1> 	; Modified registers: eax, edx
 10130                              <1> 
 10131 00003FD3 66BACE01            <1> 	mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10132 00003FD7 66EF                <1> 	out	dx, ax
 10133                              <1> 	;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10134                              <1> 	;mov	dl, 0CFh
 10135 00003FD9 FEC2                <1> 	inc	dl
 10136 00003FDB 66ED                <1> 	in	ax, dx
 10137 00003FDD C3                  <1> 	retn
 10138                              <1> 
 10139                              <1> vga_compat_setup:
 10140                              <1> 	; 26/11/2020
 10141                              <1> 	; 25/11/2020
 10142                              <1> 	; VGA compatibility setup
 10143                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 10144                              <1> 	;
 10145                              <1> 	; Input:
 10146                              <1> 	;	none
 10147                              <1> 	;
 10148                              <1> 	; Modified registers: eax, edx
 10149                              <1> 	
 10150                              <1> 	; 26/11/2020
 10151                              <1>   	;push	eax
 10152                              <1>   	;push	edx
 10153                              <1> 
 10154                              <1>   	; set CRT X resolution
 10155 00003FDE 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 10156 00003FE2 66B80100            <1>   	mov	ax, 01h  ; VBE_DISPI_INDEX_XRES
 10157 00003FE6 66EF                <1>   	out	dx, ax
 10158                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 10159 00003FE8 FEC2                <1>   	inc	dl
 10160 00003FEA 66ED                <1> 	in	ax, dx
 10161 00003FEC 50                  <1> 	push	eax
 10162 00003FED 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10163 00003FF1 66B81100            <1>   	mov	ax, 0011h ; Vertical retrace end register
 10164 00003FF5 66EF                <1>   	out	dx, ax
 10165                              <1>   	;pop	eax
 10166                              <1>   	;push	eax
 10167 00003FF7 8B0424              <1>   	mov	eax, [esp]
 10168 00003FFA 66C1E803            <1> 	shr	ax, 3 ; / 8 for pixel to character
 10169 00003FFE 6648                <1>   	dec	ax  ; - 1 (EGA or VGA?)
 10170 00004000 88C4                <1>   	mov	ah, al
 10171 00004002 B001                <1>   	mov	al, 01h ; Horizontal display end register
 10172 00004004 66EF                <1>   	out	dx, ax
 10173 00004006 58                  <1>   	pop	eax
 10174                              <1> 
 10175 00004007 E8B0000000          <1> 	call	vga_set_virt_width
 10176                              <1> 
 10177                              <1>   	; set CRT Y resolution
 10178 0000400C 66BACE01            <1>   	mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 10179 00004010 66B80200            <1>   	mov	ax, 02h  ; VBE_DISPI_INDEX_YRES
 10180 00004014 66EF                <1>   	out	dx, ax
 10181                              <1>   	;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 10182 00004016 FEC2                <1>   	inc	dl
 10183 00004018 66ED                <1> 	in	ax, dx
 10184 0000401A 50                  <1> 	push	eax
 10185 0000401B 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10186 0000401F 88C4                <1>   	mov	ah, al
 10187 00004021 B012                <1> 	mov	al, 12h ; Vertical display end register
 10188 00004023 66EF                <1>   	out	dx, ax
 10189 00004025 58                  <1>   	pop	eax
 10190 00004026 B007                <1>   	mov	al, 07h	; Overflow register
 10191 00004028 EE                  <1>   	out	dx, al
 10192 00004029 6642                <1>   	inc	dx
 10193 0000402B EC                  <1>   	in	al, dx ; read overflow register
 10194 0000402C 24BD                <1>   	and	al, 0BDh ; clear VDE 9th and 10th bits	
 10195 0000402E F6C401              <1>   	test	ah, 01h
 10196 00004031 7402                <1>   	jz	short bit8_clear
 10197 00004033 0C02                <1>   	or	al, 02h ; VDE 9th bit (bit 8) in bit 1
 10198                              <1> bit8_clear:
 10199 00004035 F6C402              <1>   	test	ah, 02h
 10200 00004038 7402                <1>   	jz	short bit9_clear
 10201 0000403A 0C40                <1>   	or	al, 40h ; VDE 10th bit (bit 9) in bit 6
 10202                              <1> bit9_clear:
 10203 0000403C EE                  <1>   	out	dx, al
 10204                              <1> 
 10205                              <1>   	; other settings
 10206 0000403D 66BAD403            <1>  	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10207 00004041 66B80900            <1>   	mov	ax, 0009h ; Maximum scan line register
 10208 00004045 66EF                <1>   	out	dx, ax	; Reset
 10209 00004047 B017                <1>   	mov	al, 17h ; Mode control register		
 10210 00004049 EE                  <1>   	out	dx, al
 10211                              <1>  	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 10212 0000404A FEC2                <1>   	inc	dl
 10213 0000404C EC                  <1> 	in	al, dx	; Read mode control register
 10214 0000404D 0C03                <1>   	or	al, 03h ; Set SRS and CMS bits
 10215 0000404F EE                  <1>   	out	dx, al 
 10216 00004050 66BADA03            <1>   	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10217 00004054 EC                  <1>   	in	al, dx	 ; clear flip-flop
 10218 00004055 66BAC003            <1>   	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10219 00004059 B010                <1>   	mov	al, 10h	; Mode control register
 10220 0000405B EE                  <1>   	out	dx, al
 10221                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10222 0000405C FEC2                <1> 	inc	dl
 10223 0000405E EC                  <1> 	in	al, dx
 10224 0000405F 0C01                <1> 	or	al, 01h ; select graphics mode
 10225                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10226 00004061 FECA                <1> 	dec	dl
 10227 00004063 EE                  <1> 	out	dx, al ; Write to mode control register
 10228 00004064 B020                <1> 	mov	al, 20h ; Palette RAM <-> display memory
 10229 00004066 EE                  <1> 	out	dx, al ; Write to attribute addr register
 10230 00004067 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 10231 0000406B 66B80605            <1> 	mov	ax, 0506h ; Misc. register, graph, mm 1
 10232 0000406F 66EF                <1> 	out	dx, ax
 10233 00004071 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 10234 00004075 66B8020F            <1> 	mov	ax, 0F02h ; Map mask register, all planes
 10235 00004079 66EF                <1> 	out	dx, ax
 10236                              <1> 
 10237                              <1>   	; settings for >= 8bpp
 10238                              <1> 
 10239                              <1> 	;mov	dx, 1CEh ; VBE_DISPI_IOPORT_INDEX
 10240                              <1> 	;mov	ax, 03h ; VBE_DISPI_INDEX_BPP
 10241                              <1> 	;out	dx, ax
 10242                              <1> 	;;mov	dx, 1CFh ; VBE_DISPI_IOPORT_DATA
 10243                              <1> 	;inc	dl
 10244                              <1> 	;in	ax, dx
 10245                              <1> 	;cmp	al, 08h  ; < 8 bits per pixel
 10246                              <1> 	;jb	short vga_compat_end
 10247                              <1> 
 10248 0000407B 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10249 0000407F B014                <1> 	mov	al, 14h  ; Underline location register
 10250 00004081 EE                  <1> 	out	dx, al
 10251                              <1> 	;mov	dx, 3D5h ; VGAREG_VGA_CRTC_DATA
 10252 00004082 FEC2                <1> 	inc	dl
 10253 00004084 EC                  <1> 	in	al, dx	
 10254 00004085 0C40                <1> 	or	al, 40h	 ; enable double word mode
 10255 00004087 EE                  <1> 	out	dx, al
 10256 00004088 66BADA03            <1> 	mov	dx, 3DAh ; VGAREG_ACTL_RESET
 10257 0000408C EC                  <1> 	in	al, dx	 ; clear flip-flop
 10258 0000408D 66BAC003            <1> 	mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10259 00004091 B010                <1> 	mov	al, 10h	 ; Mode control register
 10260 00004093 EE                  <1> 	out	dx, al
 10261                              <1> 	;mov	dx, 3C1h ; VGAREG_ACTL_READ_DATA
 10262 00004094 FEC2                <1> 	inc	dl
 10263 00004096 EC                  <1> 	in	al, dx
 10264 00004097 0C40                <1> 	or	al, 40h  ; Pixel clock select is 1 	
 10265                              <1> 	;mov	dx, 3C0h ; VGAREG_ACTL_ADDRESS
 10266 00004099 FECA                <1> 	dec	dl
 10267 0000409B EE                  <1> 	out	dx, al	 ; update mode control reggister
 10268 0000409C B020                <1> 	mov	al, 20h	 ; select display memory as PAS	
 10269 0000409E EE                  <1> 	out	dx, al
 10270 0000409F 66BAC403            <1> 	mov	dx, 3C4h ; VGAREG_SEQU_ADDRESS
 10271 000040A3 B004                <1> 	mov	al, 04h	; Memory mode register
 10272 000040A5 EE                  <1> 	out	dx, al
 10273                              <1> 	;mov	dx, 3C5h ; VGAREG_SEQU_DATA
 10274 000040A6 FEC2                <1> 	inc	dl
 10275 000040A8 EC                  <1> 	in	al, dx
 10276 000040A9 0C08                <1> 	or	al, 08h	; enable chain four
 10277 000040AB EE                  <1> 	out	dx, al
 10278 000040AC 66BACE03            <1> 	mov	dx, 3CEh ; VGAREG_GRDC_ADDRESS
 10279 000040B0 B005                <1> 	mov	al, 05h	 ; Mode register	
 10280 000040B2 EE                  <1> 	out	dx, al
 10281                              <1> 	;mov	dx, 3CFh ; VGAREG_GRDC_DATA
 10282 000040B3 FEC2                <1> 	inc	dl
 10283 000040B5 EC                  <1> 	in	al, dx	
 10284 000040B6 249F                <1> 	and	al, 9Fh	 ; clear shift register 
 10285 000040B8 0C40                <1> 	or	al, 40h  ; set shift register to 2
 10286 000040BA EE                  <1> 	out	dx, al
 10287                              <1> 
 10288                              <1> vga_compat_end:
 10289                              <1>   	;pop	edx
 10290                              <1>   	;pop	eax
 10291 000040BB C3                  <1> 	retn
 10292                              <1> 
 10293                              <1> vga_set_virt_width:
 10294                              <1> 	; 27/11/2020
 10295                              <1> 	; 25/11/2020
 10296                              <1> 	; (vbe.c, 02/01/2020, vruppert)
 10297                              <1> 	;
 10298                              <1> 	; Input:
 10299                              <1> 	;	AX = resolution (screen width)
 10300                              <1> 	;
 10301                              <1> 	; Modified registers: eax, edx
 10302                              <1> 
 10303                              <1>   	;;push	ebx
 10304                              <1>   	;push	edx
 10305                              <1> 	;push	eax
 10306                              <1>   	;mov	ebx, eax
 10307                              <1>   	;call	dispi_get_bpp ; bits per pixel
 10308                              <1> 	;cmp	al, 4
 10309                              <1> 	;ja	short set_width_svga  ; 8, 16, 24, 32 
 10310                              <1> 	;shr	bx, 1
 10311                              <1> ;set_width_svga:
 10312                              <1> 	;shr	bx, 3
 10313                              <1> 	;mov	eax, [esp]
 10314 000040BC 66C1E803            <1> 	shr	ax, 3	; / 8, bytes per row
 10315 000040C0 66BAD403            <1> 	mov	dx, 3D4h ; VGAREG_VGA_CRTC_ADDRESS
 10316                              <1> 	;mov	ah, bl	; 
 10317 000040C4 88C4                <1> 	mov	ah, al	; width in bytes
 10318 000040C6 B013                <1> 	mov	al, 13h	; offset register
 10319 000040C8 66EF                <1> 	out	dx, ax	; index (3D4h) and data (3D5h)
 10320                              <1> 	;pop	eax
 10321                              <1> 	;pop  	edx
 10322                              <1> 	;;pop	ebx
 10323 000040CA C3                  <1> 	retn
 10324                              <1> 
 10325                              <1> ; 24/11/2020
 10326                              <1> 
 10327                              <1> struc bmi ; BOCHS/PLEX86 MODE INFO structure/table 
 10328 00000000 <res 00000002>      <1>  .mode:	  resw 1
 10329 00000002 <res 00000002>      <1>  .width:  resw 1
 10330 00000004 <res 00000002>      <1>  .height: resw 1
 10331 00000006 <res 00000002>      <1>  .depth:  resw 1
 10332                              <1>  .size:	
 10333                              <1> endstruc
 10334                              <1> 
 10335                              <1> ; 24/11/2020
 10336                              <1> struc MODEINFO
 10337 00000000 <res 00000002>      <1>  .mode:			resw 1  ; 1XXh
 10338 00000002 <res 00000002>      <1>  .ModeAttributes:	resw 1
 10339 00000004 <res 00000001>      <1>  .WinAAttributes:	resb 1
 10340 00000005 <res 00000001>      <1>  .WinBAttributes:	resb 1	; = 0
 10341 00000006 <res 00000002>      <1>  .WinGranularity:	resw 1
 10342 00000008 <res 00000002>      <1>  .WinSize:		resw 1
 10343 0000000A <res 00000002>      <1>  .WinASegment:		resw 1
 10344 0000000C <res 00000002>      <1>  .WinBSegment:		resw 1	; = 0
 10345 0000000E <res 00000004>      <1>  .WinFuncPtr:		resd 1	; = 0
 10346 00000012 <res 00000002>      <1>  .BytesPerScanLine:	resw 1
 10347 00000014 <res 00000002>      <1>  .XResolution:		resw 1
 10348 00000016 <res 00000002>      <1>  .YResolution:		resw 1
 10349 00000018 <res 00000001>      <1>  .XCharSize:		resb 1
 10350 00000019 <res 00000001>      <1>  .YCharSize:		resb 1
 10351 0000001A <res 00000001>      <1>  .NumberOfPlanes: 	resb 1
 10352 0000001B <res 00000001>      <1>  .BitsPerPixel:		resb 1
 10353 0000001C <res 00000001>      <1>  .NumberOfBanks:	resb 1
 10354 0000001D <res 00000001>      <1>  .MemoryModel:		resb 1
 10355 0000001E <res 00000001>      <1>  .BankSize:		resb 1	; = 0
 10356 0000001F <res 00000001>      <1>  .NumberOfImagePages: 	resb 1
 10357 00000020 <res 00000001>      <1>  .Reserved_page:	resb 1	; = 0
 10358 00000021 <res 00000001>      <1>  .RedMaskSize:		resb 1
 10359 00000022 <res 00000001>      <1>  .RedFieldPosition: 	resb 1
 10360 00000023 <res 00000001>      <1>  .GreenMaskSize:	resb 1
 10361 00000024 <res 00000001>      <1>  .GreenFieldPosition: 	resb 1
 10362 00000025 <res 00000001>      <1>  .BlueMaskSize:		resb 1
 10363 00000026 <res 00000001>      <1>  .BlueFieldPosition: 	resb 1
 10364 00000027 <res 00000001>      <1>  .RsvdMaskSize:		resb 1
 10365 00000028 <res 00000001>      <1>  .RsvdFieldPosition: 	resb 1
 10366 00000029 <res 00000001>      <1>  .DirectColorModeInfo: 	resb 1
 10367 0000002A <res 00000004>      <1>  .PhysBasePtr:		resd 1
 10368 0000002E <res 00000004>      <1>  .OffScreenMemOffset: 	resd 1	; = 0
 10369 00000032 <res 00000002>      <1>  .OffScreenMemSize: 	resw 1	; = 0
 10370 00000034 <res 00000002>      <1>  .LinBytesPerScanLine: 	resw 1
 10371 00000036 <res 00000001>      <1>  .BnkNumberOfPages: 	resb 1
 10372 00000037 <res 00000001>      <1>  .LinNumberOfPages: 	resb 1
 10373 00000038 <res 00000001>      <1>  .LinRedMaskSize:	resb 1
 10374 00000039 <res 00000001>      <1>  .LinRedFieldPosition1: resb 1
 10375 0000003A <res 00000001>      <1>  .LinGreenMaskSize1: 	resb 1
 10376 0000003B <res 00000001>      <1>  .LinGreenFieldPosition:resb 1
 10377 0000003C <res 00000001>      <1>  .LinBlueMaskSize: 	resb 1
 10378 0000003D <res 00000001>      <1>  .LinBlueFieldPosition:	resb 1
 10379 0000003E <res 00000001>      <1>  .LinRsvdMaskSize: 	resb 1
 10380 0000003F <res 00000001>      <1>  .LinRsvdFieldPosition:	resb 1
 10381 00000040 <res 00000004>      <1>  .MaxPixelClock:	resd 1	; = 0
 10382                              <1> .size:
 10383                              <1> endstruc
 10384                              <1> 
 10385                              <1> ; 10/12/2020
 10386                              <1> struc LFBINFO
 10387 00000000 <res 00000002>      <1>  .mode:			resw 1  ; 1XXh
 10388 00000002 <res 00000004>      <1>  .LFB_addr:		resd 1
 10389 00000006 <res 00000004>      <1>  .LFB_size:		resd 1
 10390 0000000A <res 00000002>      <1>  .X_res:		resw 1
 10391 0000000C <res 00000002>      <1>  .Y_res:		resw 1
 10392 0000000E <res 00000001>      <1>  .bpp:			resb 1
 10393 0000000F <res 00000001>      <1>  .reserved:		resb 1
 10394                              <1> .size:	; 16 bytes
 10395                              <1> endstruc
 10396                              <1> 
 10397                              <1> set_mode_info_list:
 10398                              <1> 	; 14/12/2020
 10399                              <1> 	; 11/12/2020
 10400                              <1> 	; 24/11/2020
 10401                              <1> 	; (vbetables-gen.c)
 10402                              <1> 	; Input:
 10403                              <1> 	;	BX = VBE mode (including bochs special modes) 
 10404                              <1> 	; Output:
 10405                              <1> 	;	;;EAX = MODE_INFO_LIST address
 10406                              <1> 	;	EAX = 0 ; 11/12/2020
 10407                              <1> 	;	ESI = MODE_INFO_LIST address ; 11/12/2020
 10408                              <1> 	;	(if mode is not found, ESI = 0)
 10409                              <1> 	;
 10410                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi 
 10411                              <1> 
 10412 000040CB BE[56730000]        <1> 	mov	esi, b_vbe_modes ; bochs mode info base table	
 10413 000040D0 BF[3A120300]        <1> 	mov	edi, MODE_INFO_LIST ; mode info list (4F01h)
 10414                              <1> sml_0:
 10415 000040D5 66AD                <1> 	lodsw	
 10416 000040D7 6639D8              <1> 	cmp	ax, bx ; is mode number same ?
 10417 000040DA 7410                <1> 	je	short sml_1 ; yes
 10418 000040DC AD                  <1> 	lodsd
 10419 000040DD 66AD                <1> 	lodsw	
 10420 000040DF 81FE[16740000]      <1> 	cmp	esi, end_of_b_vbe_modes
 10421 000040E5 72EE                <1> 	jb	short sml_0
 10422                              <1> 	; not found
 10423 000040E7 31C0                <1> 	xor	eax, eax ; 0
 10424                              <1> 	; 11/12/2020
 10425 000040E9 31F6                <1> 	xor	esi, esi
 10426 000040EB C3                  <1> 	retn
 10427                              <1> sml_1:
 10428 000040EC 66AB                <1> 	stosw	; mode
 10429 000040EE AD                  <1> 	lodsd	; width, height
 10430                              <1> 	; 14/12/2020
 10431 000040EF 89C1                <1> 	mov	ecx, eax
 10432 000040F1 50                  <1> 	push	eax ; ***
 10433 000040F2 29C0                <1> 	sub	eax, eax ; clear high word of eax
 10434 000040F4 66AD                <1> 	lodsw	; depth
 10435 000040F6 50                  <1> 	push	eax ; **
 10436                              <1> 
 10437                              <1> 	;add	al, 7 ; only for 15 bit colors (not used here)
 10438 000040F7 C0E803              <1> 	shr	al, 3 ; / 8
 10439                              <1> 	; 14/12/2020
 10440 000040FA 66F7E1              <1> 	mul	cx  ; pitch = width * ((depth+7)/8)
 10441                              <1> 		; ax = pitch
 10442 000040FD 50                  <1> 	push	eax ; * ; high word of eax = 0
 10443 000040FE C1E910              <1> 	shr	ecx, 16
 10444                              <1> 	;mul	cx
 10445                              <1> 	;mov	cx, ax
 10446 00004101 31D2                <1> 	xor	edx, edx  ; clear high word of edx
 10447 00004103 F7E1                <1> 	mul	ecx ; height * pitch
 10448 00004105 89C1                <1> 	mov	ecx, eax
 10449 00004107 B800000001          <1> 	mov	eax, VBE_DISPI_TOTAL_VIDEO_MEMORY_MB * 1024 * 1024
 10450 0000410C F7F1                <1> 	div	ecx
 10451                              <1> 		; eax = pages = vram_size / (height*pitch)
 10452                              <1> 	
 10453                              <1> 	;mov	cx, ax
 10454 0000410E 89C1                <1> 	mov	ecx, eax ; pages 
 10455                              <1> 		
 10456 00004110 66B89B00            <1> 	mov	ax, MODE_ATTRIBUTES
 10457 00004114 66AB                <1> 	stosw	; ModeAttributes
 10458 00004116 B007                <1> 	mov	al, WINA_ATTRIBUTES
 10459 00004118 AA                  <1> 	stosb	; WinAAttributes
 10460 00004119 30C0                <1> 	xor	al, al ; WinBAttributes = 0
 10461 0000411B AA                  <1> 	stosb
 10462 0000411C 66B84000            <1> 	mov	ax, VBE_DISPI_BANK_SIZE_KB
 10463 00004120 66AB                <1> 	stosw	; WinGranularity
 10464 00004122 66AB                <1> 	stosw	; WinSize
 10465 00004124 66B800A0            <1> 	mov	ax, VGAMEM_GRAPH
 10466 00004128 66AB                <1> 	stosw	; WinASegment
 10467 0000412A 29C0                <1> 	sub	eax, eax
 10468 0000412C 66AB                <1> 	stosw	; WinBSegment = 0
 10469 0000412E AB                  <1> 	stosd	; WinFuncPtr = 0
 10470                              <1> 
 10471 0000412F 58                  <1> 	pop	eax ; * ; pitch
 10472 00004130 89C3                <1> 	mov	ebx, eax  ; high word of ebx = 0 ; 14/12/2020
 10473 00004132 66AB                <1> 	stosw	; BytesPerScanLine
 10474                              <1> 
 10475 00004134 5A                  <1> 	pop	edx ; ** ; depth (bits per pixel)
 10476 00004135 58                  <1> 	pop	eax ; *** width, height
 10477                              <1> 
 10478                              <1>  	; // Mandatory information for VBE 1.2 and above
 10479                              <1> 
 10480 00004136 66AB                <1> 	stosw	; XResolution (width)
 10481 00004138 C1E810              <1> 	shr	eax, 16
 10482 0000413B 50                  <1> 	push	eax ; **** height
 10483 0000413C 66AB                <1> 	stosw	; YResolution (height)
 10484 0000413E B008                <1> 	mov	al, 8
 10485 00004140 AA                  <1>  	stosb	; XCharSize  ; char width
 10486 00004141 B010                <1> 	mov	al, 16
 10487 00004143 AA                  <1> 	stosb	; YCharSize  ; char height
 10488 00004144 B001                <1> 	mov	al, 1
 10489 00004146 AA                  <1> 	stosb	; NumberOfPlanes
 10490                              <1> 	;movzx	eax, dl
 10491 00004147 88D0                <1> 	mov	al, dl ; eax <= 32
 10492 00004149 AA                  <1> 	stosb	; BitsPerPixel
 10493                              <1> 	; Number of banks = (height * pitch + 65535) / 65536
 10494 0000414A 58                  <1> 	pop	eax ; **** ; height
 10495                              <1> 	; 14/12/2020
 10496 0000414B 52                  <1> 	push	edx ; ***** ; depth ; edx <= 32
 10497 0000414C F7E3                <1> 	mul	ebx  ; pitch (ebx) * height (eax)
 10498                              <1> 	;mov	edx, [esp] ; *****
 10499                              <1> 	;mov	dl, [esp] ; *****
 10500 0000414E 05FFFF0000          <1> 	add	eax, 65535
 10501 00004153 C1E810              <1> 	shr	eax, 16 ; / 65536 ; <= 127 ; 14/12/2020
 10502 00004156 AA                  <1> 	stosb	; NumberOfBanks
 10503                              <1> 	; 14/12/2020
 10504                              <1> 	;cmp	dl, 8 ; 8 bits per pixel
 10505 00004157 803C2408            <1> 	cmp	byte [esp], 8
 10506 0000415B 7704                <1> 	ja	short sml_2
 10507 0000415D B004                <1> 	mov	al, VBE_MEMORYMODEL_PACKED_PIXEL
 10508 0000415F EB02                <1> 	jmp	short sml_3
 10509                              <1> sml_2:
 10510                              <1> 	; 16, 24, 32 bts per pixel
 10511 00004161 B006                <1> 	mov	al, VBE_MEMORYMODEL_DIRECT_COLOR	
 10512                              <1> sml_3:
 10513 00004163 AA                  <1> 	stosb
 10514 00004164 30C0                <1> 	xor	al, al ; 0
 10515 00004166 AA                  <1> 	stosb	; BankSize = 0
 10516 00004167 49                  <1> 	dec	ecx ; pages - 1
 10517                              <1> 	; NumberOfImagePages = 262 for 320x200x8 mode
 10518                              <1> 	;;mov	ax, 255
 10519                              <1> 	; 14/12/2020
 10520                              <1> 	;mov	al, 255
 10521 00004168 FEC8                <1> 	dec	al ; 255
 10522 0000416A 39C1                <1> 	cmp	ecx, eax ; ecx <= 261, eax = 255 
 10523                              <1> 	;cmp	cx, ax
 10524 0000416C 7302                <1> 	jnb	short sml_4
 10525 0000416E 88C8                <1> 	mov	al, cl	 
 10526                              <1> sml_4:
 10527 00004170 AA                  <1> 	stosb	; NumberOfImagePages (1 byte)
 10528 00004171 28C0                <1> 	sub	al, al
 10529 00004173 AA                  <1> 	stosb	; Reserved_page = 0
 10530 00004174 58                  <1> 	pop	eax ; ***** ; depth
 10531 00004175 88C1                <1> 	mov	cl, al
 10532                              <1> 	; eax < = 32
 10533 00004177 2C08                <1> 	sub	al, 8 ; 8->0, 16->8, 24->16, 32->24	
 10534 00004179 BE[16740000]        <1> 	mov	esi, direct_color_fields
 10535 0000417E 01C6                <1> 	add	esi, eax
 10536 00004180 56                  <1> 	push	esi ; ******
 10537 00004181 AD                  <1> 	lodsd	; RedMaskSize (AL), RedFieldPosition (AH)
 10538                              <1> 	     	; GreenMaskSize (16), GreenFieldPosition (24)	
 10539 00004182 AB                  <1> 	stosd
 10540 00004183 AD                  <1> 	lodsd	; BlueMaskSize (AL), BlueFieldPosition (AH)
 10541                              <1> 	     	; RsvdMaskSize (16), RsvdFieldPosition (24)
 10542 00004184 AB                  <1> 	stosd
 10543 00004185 5E                  <1> 	pop	esi ; ******
 10544                              <1> 
 10545 00004186 30C0                <1> 	xor	al, al ; 0
 10546 00004188 80F920              <1> 	cmp	cl, 32
 10547 0000418B 7202                <1> 	jb	short sml_5
 10548 0000418D B002                <1> 	mov	al, VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
 10549                              <1> sml_5: 
 10550 0000418F AA                  <1> 	stosb	; DirectColorModeInfo
 10551                              <1> 
 10552                              <1> 	; // Mandatory information for VBE 2.0 and above
 10553                              <1> 
 10554 00004190 B8000000E0          <1> 	mov	eax, VBE_DISPI_LFB_PHYSICAL_ADDRESS
 10555 00004195 AB                  <1> 	stosd	; PhysBasePtr
 10556 00004196 29C0                <1> 	sub	eax, eax
 10557 00004198 AB                  <1> 	stosd	; OffScreenMemOffset = 0
 10558 00004199 66AB                <1> 	stosw	; OffScreenMemSize = 0
 10559                              <1> 
 10560                              <1> 	;// Mandatory information for VBE 3.0 and above
 10561                              <1> 
 10562                              <1> 	; ebx = pitch
 10563 0000419B 6689D8              <1> 	mov	ax, bx
 10564                              <1> 	;stosw
 10565                              <1> 
 10566                              <1> 	;xor	al, al
 10567                              <1>      	;stosb	; BnkNumberOfPages = 0
 10568                              <1>      	;stosb	; LinNumberOfPages = 0
 10569                              <1> 
 10570 0000419E AB                  <1> 	stosd	; pitch (word), 0 (byte), 0 (byte)  
 10571                              <1> 
 10572 0000419F AD                  <1> 	lodsd	; LinRedMaskSize (AL), LinRedFieldPosition (AH)
 10573                              <1> 	     	; LinGreenMaskSize (16), LinGreenFieldPosition (24)	
 10574 000041A0 AB                  <1> 	stosd
 10575 000041A1 AD                  <1> 	lodsd	; LinBlueMaskSize (AL), LinBlueFieldPosition (AH)
 10576                              <1> 	     	; LinRsvdMaskSize (16), LinRsvdFieldPosition (24)
 10577 000041A2 AB                  <1> 	stosd
 10578                              <1> 
 10579 000041A3 29C0                <1> 	sub	eax, eax
 10580 000041A5 AB                  <1> 	stosd	; MaxPixelClock = 0
 10581                              <1> 
 10582                              <1> 	;mov	eax, MODE_INFO_LIST
 10583                              <1> 	; 11/12/2020
 10584 000041A6 BE[3A120300]        <1> 	mov	esi, MODE_INFO_LIST
 10585                              <1> 	
 10586 000041AB C3                  <1> 	retn	
 10587                              <1> 
 10588                              <1> ; end of set_mode_info_list ; edi = set_mode_info_list + 68
 10589                              <1> 
 10590                              <1> pci_get_lfb_addr:
 10591                              <1> 	; 11/12/2020
 10592                              <1> 	; Get linear frame buffer base from PCI
 10593                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 10594                              <1> 	;
 10595                              <1> 	; Input:
 10596                              <1> 	;	ax = PCI device vendor id
 10597                              <1> 	; Output:
 10598                              <1> 	;	ax  = LFB address (high 16 bit) (zf=0)
 10599                              <1> 	;	eax = 0 -> not found (error) (zf=1)
 10600                              <1> 	;
 10601                              <1> 	; Modified registers: eax
 10602                              <1> 
 10603 000041AC 53                  <1> 	push	ebx
 10604 000041AD 51                  <1> 	push	ecx
 10605 000041AE 52                  <1> 	push	edx
 10606                              <1> 	;
 10607 000041AF 89C3                <1> 	mov	ebx, eax
 10608 000041B1 31C9                <1> 	xor	ecx, ecx
 10609 000041B3 28D2                <1> 	sub	dl, dl	; mov dl, 0
 10610 000041B5 E842000000          <1> 	call	pci_read_reg
 10611 000041BA 6683F8FF            <1> 	cmp	ax, 0FFFFh
 10612 000041BE 7417                <1> 	je	short pci_get_lfb_addr_fail
 10613                              <1> pci_get_lfb_addr_next_dev:
 10614 000041C0 28D2                <1> 	sub	dl, dl ; mov dl, 0
 10615 000041C2 E835000000          <1> 	call	pci_read_reg
 10616 000041C7 6639D8              <1> 	cmp	ax, bx	; check vendor
 10617 000041CA 740F                <1> 	je	short pci_get_lfb_addr_found
 10618 000041CC 6683C108            <1> 	add	cx, 08h
 10619 000041D0 6681F90002          <1> 	cmp	cx, 200h ; search bus 0 and 1
 10620 000041D5 72E9                <1> 	jb	short pci_get_lfb_addr_next_dev
 10621                              <1> pci_get_lfb_addr_fail:
 10622 000041D7 31C0                <1> 	xor	eax, eax ; no LFB
 10623                              <1> 	; zf = 1
 10624 000041D9 EB1D                <1> 	jmp	short pci_get_lfb_addr_return
 10625                              <1> pci_get_lfb_addr_found:
 10626 000041DB B210                <1> 	mov	dl, 10h	; I/O space 0
 10627 000041DD E81A000000          <1> 	call	pci_read_reg
 10628 000041E2 66A9F1FF            <1> 	test	ax, 0FFF1h
 10629 000041E6 740D                <1> 	jz	short pci_get_lfb_addr_success
 10630 000041E8 B214                <1> 	mov	dl, 14h ; I/O space 1
 10631 000041EA E80D000000          <1> 	call	pci_read_reg
 10632 000041EF 66A9F1FF            <1> 	test	ax, 0FFF1h
 10633 000041F3 75E2                <1> 	jnz	short pci_get_lfb_addr_fail
 10634                              <1> pci_get_lfb_addr_success:
 10635 000041F5 C1E810              <1> 	shr	eax, 16 ; LFB address (hw)
 10636                              <1> 	; zf = 0
 10637                              <1> pci_get_lfb_addr_return:
 10638 000041F8 5A                  <1> 	pop	edx
 10639 000041F9 59                  <1> 	pop	ecx
 10640 000041FA 5B                  <1> 	pop	ebx
 10641 000041FB C3                  <1> 	retn
 10642                              <1> 
 10643                              <1> pci_read_reg:
 10644                              <1> 	; 11/12/2020
 10645                              <1> 	; Read PCI register
 10646                              <1> 	; (vgabios.c, 02/01/2020, vruppert)
 10647                              <1> 	;
 10648                              <1> 	; Input:
 10649                              <1> 	;	cx = device/function
 10650                              <1> 	;	dl = register
 10651                              <1> 	; Output:
 10652                              <1> 	;	eax = value
 10653                              <1> 	;
 10654                              <1> 	; Modified registers: eax, edx
 10655                              <1> 
 10656 000041FC B800008000          <1> 	mov	eax, 00800000h 
 10657 00004201 6689C8              <1> 	mov	ax, cx
 10658 00004204 C1E008              <1> 	shl	eax, 8
 10659 00004207 88D0                <1> 	mov	al, dl
 10660 00004209 66BAF80C            <1> 	mov	dx, 0CF8h
 10661 0000420D EF                  <1>  	out	dx, eax
 10662 0000420E 80C204              <1> 	add	dl, 4 ; mov dx, 0CFCh
 10663 00004211 ED                  <1> 	in	eax, dx
 10664 00004212 C3                  <1> 	retn
 10665                              <1> 
 10666                              <1> %endif
 10667                              <1> 
 10668                              <1> ; -----------
 10669                              <1> 
 10670                              <1> %if 0
 10671                              <1> 
 10672                              <1> mode_info_find_mode:
 10673                              <1> 	; 25/11/2020
 10674                              <1> 	; Input:
 10675                              <1> 	;	bx = VESA VBE2 video mode (+ bochs extensions)
 10676                              <1> 	; Output:
 10677                              <1> 	;	esi = mode info address (for BX input)
 10678                              <1> 	;	esi = 0 -> not found
 10679                              <1> 	;
 10680                              <1> 	; Modified registers: eax, esi
 10681                              <1> 
 10682                              <1> 	xor	eax, eax
 10683                              <1> 	mov	esi, MODE_INFO_LIST
 10684                              <1> mifm_1:
 10685                              <1> 	mov	ax, [esi]
 10686                              <1> 	cmp	ax, bx
 10687                              <1> 	je	short mifm_2
 10688                              <1> 	add	esi, MODEINFO.size ; add esi, 68
 10689                              <1> 	cmp	esi, VBE_VESA_MODE_END_OF_LIST
 10690                              <1> 	jb	short mifm_1
 10691                              <1> 	; not found
 10692                              <1> 	sub	esi, esi ; 0
 10693                              <1> mifm_2
 10694                              <1> 	retn
 10695                              <1> 
 10696                              <1> dispi_get_bpp:
 10697                              <1> 	; 28/11/2020
 10698                              <1> 	; Input:
 10699                              <1> 	;	none
 10700                              <1> 	; Output:
 10701                              <1> 	;	al = Bits per pixel
 10702                              <1> 	;	     (8,16,24,32)
 10703                              <1> 	;	ah = Bytes per pixel
 10704                              <1> 	;	     (1,2,3,4)	
 10705                              <1> 	;
 10706                              <1> 	; Modified registers: none
 10707                              <1> 
 10708                              <1> 	;push	edx
 10709                              <1> 	;mov	dx, 01CEh ; VBE_DISPI_IOPORT_INDEX
 10710                              <1> 	;mov	ax, 03h	  ; VBE_DISPI_INDEX_BPP
 10711                              <1> 	;out	dx, ax
 10712                              <1> 	;;mov	dx, 01CFh ; VBE_DISPI_IOPORT_DATA
 10713                              <1> 	;;mov	dl, 0CFh
 10714                              <1> 	;inc	dl
 10715                              <1> 	;in	ax, dx
 10716                              <1> 	;mov	ah, al
 10717                              <1> 	;shr	ah, 3 ; / 8
 10718                              <1> 	;;test	al, 7 ; 15 bit graphics mode
 10719                              <1>  	;;jz	short get_bpp_noinc
 10720                              <1> 	;;inc	ah
 10721                              <1> ;;get_bpp_noinc:
 10722                              <1> 	;pop	edx
 10723                              <1> 	;retn
 10724                              <1> 
 10725                              <1> 	; 28/11/2020
 10726                              <1> 	; Modified registers: edx
 10727                              <1> 	;push	edx
 10728                              <1> 	mov	dx, 03h ; VBE_DISPI_INDEX_BPP
 10729                              <1> 	call	dispi_get_parms
 10730                              <1> 	;pop	edx
 10731                              <1> 	;retn
 10732                              <1> 	mov	ah, al
 10733                              <1> 	shr	ah, 3 ; / 8
 10734                              <1> 	;test	al, 7 ; 15 bit graphips mode
 10735                              <1>  	;jz	short get_bpp_noinc
 10736                              <1> 	;inc	ah
 10737                              <1> ;get_bpp_noinc:
 10738                              <1> 	;pop	edx
 10739                              <1> 	retn
 10740                              <1> 
 10741                              <1> restore_vesa_video_state:
 10742                              <1> 	; 14/01/2021
 10743                              <1> 	; 06/12/2020
 10744                              <1> 	; Input:
 10745                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 10746                              <1> 	; Output:
 10747                              <1> 	;	AX = 004Fh (successed)
 10748                              <1> 	;
 10749                              <1> 	;	eax = 0 -> buffer size problem
 10750                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 10751                              <1> 	;
 10752                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 10753                              <1> 
 10754                              <1> 	;movzx	ecx, word [vbe3stbufsize]  
 10755                              <1> 	;cmp	cx, 32 ; 32 * 64 bytes
 10756                              <1> 	;ja	short r_v_b_s_fail
 10757                              <1> 
 10758                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 10759                              <1> 	shl	cx, 4 ; dword count for movsd
 10760                              <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; destination
 10761                              <1> 					; (vbe3 pmi buff)
 10762                              <1> 	mov	esi, VBE3VIDEOSTATE ; source (kernel buff)
 10763                              <1> 	rep	movsd	
 10764                              <1> 
 10765                              <1> 	mov	ax, 4F04h
 10766                              <1> 	mov	dl, 02h ; restore
 10767                              <1> 	;mov	cx, 0Fh
 10768                              <1> 	mov	cl, 0Fh
 10769                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 10770                              <1> 	jmp	short int10h_32bit_pmi
 10771                              <1> 
 10772                              <1> ;s_v_b_s_fail:
 10773                              <1> ;r_v_b_s_fail:
 10774                              <1> ;	xor	eax, eax
 10775                              <1> ;	retn
 10776                              <1> 
 10777                              <1> save_vesa_video_state:
 10778                              <1> 	; 14/01/2021
 10779                              <1> 	; 06/12/2020
 10780                              <1> 	; Input:
 10781                              <1> 	;	[vbe3stbufsize] <= 32 ; <= 32*64 bytes
 10782                              <1> 	; Output:
 10783                              <1> 	;	AX = 004Fh (successed)
 10784                              <1> 	;
 10785                              <1> 	;	eax = 0 -> buffer size problem
 10786                              <1> 	;	eax > 0 and ax <> 004Fh -> failed
 10787                              <1> 	;
 10788                              <1> 	; Modified regs: eax, ebx, ecx, edx, esi, edi 
 10789                              <1> 
 10790                              <1> 	;cmp	word [vbe33stbufsize], 32  
 10791                              <1> 	;			; 32 * 64 bytes
 10792                              <1> 	;ja	short s_v_b_s_fail
 10793                              <1> 
 10794                              <1> 	mov	ax, 4F04h
 10795                              <1> 	mov	dl, 01h ; save
 10796                              <1> 	;mov	cx, 0Fh
 10797                              <1> 	mov	cl, 0Fh
 10798                              <1> 	xor 	ebx, ebx ; points to VBE3SAVERESTOREBLOCK
 10799                              <1> 
 10800                              <1> 	call	int10h_32bit_pmi
 10801                              <1> 
 10802                              <1> 	movzx	ecx, byte [vbe3stbufsize]; <=32	
 10803                              <1> 	shl	cx, 4 ; dword count for movsd
 10804                              <1> 	mov	esi, VBE3SAVERESTOREBLOCK ; destination
 10805                              <1> 					; (vbe3 pmi buff)
 10806                              <1> 	mov	edi, VBE3VIDEOSTATE ; source (kernel buff)
 10807                              <1> 	rep	movsd	
 10808                              <1> 	retn
 10809                              <1> 
 10810                              <1> dispi_set_bank_farcall:
 10811                              <1> 	; 11/12/2020
 10812                              <1> 	; (This may be 'sysvideo' function, later)
 10813                              <1> 	;
 10814                              <1> 	; Input: 
 10815                              <1> 	;	bx = 0000h, set bank number
 10816                              <1> 	;	   = 0100h, get bank number
 10817                              <1> 	;	dx = bank number (if bx = 0)	
 10818                              <1> 	; Output:
 10819                              <1> 	;	dx = bank number
 10820                              <1> 		 	
 10821                              <1> 	cmp	bx, 0100h
 10822                              <1> 	je	short dispi_set_bank_farcall_get
 10823                              <1> 	or	bx, bx
 10824                              <1> 	jnz	dispi_set_bank_farcall_error
 10825                              <1> 	mov	ax, dx
 10826                              <1> 	push	dx
 10827                              <1> 	push	ax
 10828                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 10829                              <1> 	mov	dx, VBE_DISPI_IOPORT_INDEX
 10830                              <1> 	out	dx, ax
 10831                              <1> 	pop	ax
 10832                              <1> 	mov	dx, VBE_DISPI_IOPORT_DATA
 10833                              <1> 	out	dx, ax
 10834                              <1> 	in	ax, dx
 10835                              <1> 	pop	dx
 10836                              <1> 	cmp	dx, ax
 10837                              <1> 	jne	short dispi_set_bank_farcall_error
 10838                              <1> 	mov	ax, 004Fh
 10839                              <1> 	retn	; retf for real mode far call
 10840                              <1> dispi_set_bank_farcall_get:
 10841                              <1> 	mov	ax, VBE_DISPI_INDEX_BANK
 10842                              <1> 	mov	dx, VBE_DISPI_IOPORT_INDEX
 10843                              <1> 	out	dx, ax
 10844                              <1> 	mov	dx, VBE_DISPI_IOPORT_DATA
 10845                              <1> 	in	ax, dx
 10846                              <1> 	mov	dx, ax
 10847                              <1> 	retn	; retf for real mode far call
 10848                              <1> dispi_set_bank_farcall_error:
 10849                              <1> 	mov	ax, 014Fh
 10850                              <1> 	retn	; retf for real mode far call
 10851                              <1> 
 10852                              <1> %endif
 10853                              <1> 
 10854                              <1> ; % include 'vidata.s' ; VIDEO DATA
 10855                              <1> 
 10856                              <1> ; /// End Of VIDEO FUNCTIONS ///
  2655                                  
  2656                                  setup_rtc_int:
  2657                                  ; source: http://wiki.osdev.org/RTC
  2658 00004213 FA                      	cli		; disable interrupts
  2659                                  	; default int frequency is 1024 Hz (Lower 4 bits of register A is 0110b or 6)
  2660                                  	; in order to change this ...
  2661                                  	; frequency  = 32768 >> (rate-1) --> 32768 >> 5 = 1024
  2662                                  	; (rate must be above 2 and not over 15)
  2663                                  	; new rate = 15 --> 32768 >> (15-1) = 2 Hz
  2664 00004214 B08A                    	mov	al, 8Ah 
  2665 00004216 E670                    	out	70h, al ; set index to register A, disable NMI
  2666 00004218 90                      	nop
  2667 00004219 E471                    	in	al, 71h ; get initial value of register A
  2668 0000421B 88C4                    	mov 	ah, al
  2669 0000421D 80E4F0                  	and	ah, 0F0h
  2670 00004220 B08A                    	mov	al, 8Ah 
  2671 00004222 E670                    	out	70h, al ; reset index to register A
  2672 00004224 88E0                    	mov	al, ah
  2673 00004226 0C0F                    	or	al, 0Fh	; new rate (0Fh -> 15)
  2674 00004228 E671                    	out	71h, al ; write only our rate to A. Note, rate is the bottom 4 bits. 
  2675                                  	; enable RTC interrupt
  2676 0000422A B08B                    	mov	al, 8Bh ;
  2677 0000422C E670                    	out	70h, al ; select register B and disable NMI
  2678 0000422E 90                      	nop
  2679 0000422F E471                    	in	al, 71h ; read the current value of register B
  2680 00004231 88C4                    	mov	ah, al  ;
  2681 00004233 B08B                    	mov 	al, 8Bh ;
  2682 00004235 E670                    	out	70h, al ; set the index again (a read will reset the index to register B)	
  2683 00004237 88E0                    	mov	al, ah  ;
  2684 00004239 0C40                    	or	al, 40h ;
  2685 0000423B E671                    	out	71h, al ; write the previous value ORed with 0x40. This turns on bit 6 of register B
  2686 0000423D FB                      	sti
  2687 0000423E C3                      	retn
  2688                                  
  2689                                  ; Write memory information
  2690                                  ; 29/01/2016
  2691                                  ; 06/11/2014
  2692                                  ; 14/08/2015 
  2693                                  memory_info:	
  2694 0000423F A1[D4890100]            	mov	eax, [memory_size] ; in pages
  2695 00004244 50                      	push	eax
  2696 00004245 C1E00C                  	shl	eax, 12		   ; in bytes
  2697 00004248 BB0A000000              	mov	ebx, 10
  2698 0000424D 89D9                    	mov	ecx, ebx	   ; 10
  2699 0000424F BE[594C0100]            	mov	esi, mem_total_b_str	
  2700 00004254 E8D7000000              	call	bintdstr
  2701 00004259 58                      	pop	eax
  2702 0000425A B107                    	mov	cl, 7
  2703 0000425C BE[7D4C0100]            	mov	esi, mem_total_p_str
  2704 00004261 E8CA000000              	call	bintdstr	
  2705                                  	; 14/08/2015
  2706 00004266 E8E2000000              	call	calc_free_mem
  2707                                  	; edx = calculated free pages
  2708                                  	; ecx = 0
  2709 0000426B A1[D8890100]            	mov 	eax, [free_pages]
  2710 00004270 39D0                    	cmp	eax, edx ; calculated free mem value 
  2711                                  		; and initial free mem value are same or not?
  2712 00004272 751D                    	jne 	short pmim ; print mem info with '?' if not
  2713 00004274 52                      	push 	edx ; free memory in pages	
  2714                                  	;mov 	eax, edx
  2715 00004275 C1E00C                  	shl	eax, 12 ; convert page count
  2716                                  			; to byte count
  2717 00004278 B10A                    	mov	cl, 10
  2718 0000427A BE[9D4C0100]            	mov	esi, free_mem_b_str
  2719 0000427F E8AC000000              	call	bintdstr
  2720 00004284 58                      	pop	eax
  2721 00004285 B107                    	mov	cl, 7
  2722 00004287 BE[C14C0100]            	mov	esi, free_mem_p_str
  2723 0000428C E89F000000              	call	bintdstr
  2724                                  pmim:
  2725 00004291 BE[474C0100]            	mov	esi, msg_memory_info
  2726                                  	;
  2727 00004296 B407                    	mov	ah, 07h ; Black background, 
  2728                                  			; light gray forecolor
  2729                                  print_kmsg: ; 29/01/2016
  2730 00004298 8825[FF890100]          	mov	[ccolor], ah
  2731                                  pkmsg_loop:
  2732 0000429E AC                      	lodsb
  2733 0000429F 08C0                    	or	al, al
  2734 000042A1 7410                    	jz	short pkmsg_ok
  2735 000042A3 56                      	push	esi
  2736                                  	; 13/05/2016
  2737 000042A4 0FB61D[FF890100]        	movzx	ebx, byte [ccolor]
  2738                                  			; Video page 0 (bh=0)
  2739 000042AB E84DE0FFFF              	call	_write_tty
  2740 000042B0 5E                      	pop	esi
  2741 000042B1 EBEB                    	jmp	short pkmsg_loop
  2742                                  pkmsg_ok:
  2743 000042B3 C3                      	retn
  2744                                  
  2745                                  ; 19/12/2020
  2746                                  ; temporary
  2747                                  ; Write default liner frame buffer address
  2748                                  ;
  2749                                  default_lfb_info:	
  2750 000042B4 66A1[E30E0000]          	mov	ax, [def_LFB_addr] ; high word
  2751 000042BA E829000000              	call	wordtohex
  2752 000042BF A3[194D0100]            	mov	dword [lfb_addr_str], eax
  2753 000042C4 BE[024D0100]            	mov	esi, msg_lfb_addr
  2754 000042C9 B40F                    	mov	ah, 0Fh ; Black background, 
  2755                                  			; white forecolor
  2756 000042CB EBCB                    	jmp	short print_kmsg
  2757                                  
  2758                                  ; Convert binary number to hexadecimal string
  2759                                  ; 10/05/2015  
  2760                                  ; dsectpm.s (28/02/2015)
  2761                                  ; Retro UNIX 386 v1 - Kernel v0.2.0.6  
  2762                                  ; 01/12/2014
  2763                                  ; 25/11/2014
  2764                                  ;
  2765                                  bytetohex:
  2766                                  	; INPUT ->
  2767                                  	; 	AL = byte (binary number)
  2768                                  	; OUTPUT ->
  2769                                  	;	AX = hexadecimal string
  2770                                  	;
  2771 000042CD 53                      	push	ebx
  2772 000042CE 31DB                    	xor	ebx, ebx
  2773 000042D0 88C3                    	mov	bl, al
  2774 000042D2 C0EB04                  	shr	bl, 4
  2775 000042D5 8A9B[1F430000]          	mov	bl, [ebx+hexchrs] 	 	
  2776 000042DB 86D8                    	xchg	bl, al
  2777 000042DD 80E30F                  	and	bl, 0Fh
  2778 000042E0 8AA3[1F430000]          	mov	ah, [ebx+hexchrs] 
  2779 000042E6 5B                      	pop	ebx	
  2780 000042E7 C3                      	retn
  2781                                  
  2782                                  wordtohex:
  2783                                  	; INPUT ->
  2784                                  	; 	AX = word (binary number)
  2785                                  	; OUTPUT ->
  2786                                  	;	EAX = hexadecimal string
  2787                                  	;
  2788 000042E8 53                      	push	ebx
  2789 000042E9 31DB                    	xor	ebx, ebx
  2790 000042EB 86E0                    	xchg	ah, al
  2791 000042ED 6650                    	push	ax
  2792 000042EF 88E3                    	mov	bl, ah
  2793 000042F1 C0EB04                  	shr	bl, 4
  2794 000042F4 8A83[1F430000]          	mov	al, [ebx+hexchrs] 	 	
  2795 000042FA 88E3                    	mov	bl, ah
  2796 000042FC 80E30F                  	and	bl, 0Fh
  2797 000042FF 8AA3[1F430000]          	mov	ah, [ebx+hexchrs]
  2798 00004305 C1E010                  	shl	eax, 16
  2799 00004308 6658                    	pop	ax
  2800 0000430A 5B                      	pop	ebx
  2801 0000430B EBC0                    	jmp	short bytetohex
  2802                                  	;mov	bl, al
  2803                                  	;shr	bl, 4
  2804                                  	;mov	bl, [ebx+hexchrs] 	 	
  2805                                  	;xchg	bl, al	 	
  2806                                  	;and	bl, 0Fh
  2807                                  	;mov	ah, [ebx+hexchrs] 
  2808                                  	;pop	ebx	
  2809                                  	;retn
  2810                                  
  2811                                  dwordtohex:
  2812                                  	; INPUT ->
  2813                                  	; 	EAX = dword (binary number)
  2814                                  	; OUTPUT ->
  2815                                  	;	EDX:EAX = hexadecimal string
  2816                                  	;
  2817 0000430D 50                      	push	eax
  2818 0000430E C1E810                  	shr	eax, 16
  2819 00004311 E8D2FFFFFF              	call	wordtohex
  2820 00004316 89C2                    	mov	edx, eax
  2821 00004318 58                      	pop	eax
  2822 00004319 E8CAFFFFFF              	call	wordtohex
  2823 0000431E C3                      	retn
  2824                                  
  2825                                  ; 10/05/2015
  2826                                  hex_digits:
  2827                                  hexchrs:
  2828 0000431F 303132333435363738-     	db '0123456789ABCDEF'
  2828 00004328 39414243444546     
  2829                                  ; 19/01/2021 - VESA EDID ready flag (4Fh)
  2830 0000432F 00                      edid:	db 0
  2831                                  
  2832                                  ; Convert binary number to decimal/numeric string
  2833                                  ; 06/11/2014
  2834                                  ; Temporary Code
  2835                                  ;
  2836                                  
  2837                                  bintdstr:
  2838                                  	; EAX = binary number
  2839                                  	; ESI = decimal/numeric string address
  2840                                  	; EBX = divisor (10)
  2841                                  	; ECX = string length (<=10)
  2842 00004330 01CE                    	add	esi, ecx
  2843                                  btdstr0:
  2844 00004332 4E                      	dec	esi
  2845 00004333 31D2                    	xor	edx, edx
  2846 00004335 F7F3                    	div	ebx
  2847 00004337 80C230                  	add	dl, 30h
  2848 0000433A 8816                    	mov	[esi], dl
  2849 0000433C FEC9                    	dec	cl
  2850 0000433E 740C                    	jz	short btdstr2 ; 08/09/2016
  2851 00004340 09C0                    	or	eax, eax
  2852 00004342 75EE                    	jnz	short btdstr0
  2853                                  btdstr1:
  2854 00004344 4E                      	dec	esi
  2855 00004345 C60620                          mov     byte [esi], 20h ; blank space
  2856 00004348 FEC9                    	dec	cl
  2857 0000434A 75F8                    	jnz	short btdstr1
  2858                                  btdstr2:
  2859 0000434C C3                      	retn
  2860                                  
  2861                                  ; Calculate free memory pages on M.A.T.
  2862                                  ; 06/11/2014
  2863                                  ; Temporary Code
  2864                                  ;
  2865                                  
  2866                                  calc_free_mem:
  2867 0000434D 31D2                    	xor	edx, edx
  2868                                  	;xor	ecx, ecx
  2869 0000434F 668B0D[E8890100]        	mov	cx, [mat_size] ; in pages
  2870 00004356 C1E10A                  	shl	ecx, 10	; 1024 dwords per page
  2871 00004359 BE00001000              	mov	esi, MEM_ALLOC_TBL
  2872                                  cfm0:
  2873 0000435E AD                      	lodsd
  2874 0000435F 51                      	push	ecx
  2875 00004360 B920000000              	mov	ecx, 32
  2876                                  cfm1:
  2877 00004365 D1E8                    	shr	eax, 1
  2878 00004367 7301                    	jnc	short cfm2
  2879 00004369 42                      	inc	edx
  2880                                  cfm2:
  2881 0000436A E2F9                    	loop	cfm1
  2882 0000436C 59                      	pop	ecx
  2883 0000436D E2EF                    	loop	cfm0
  2884 0000436F C3                      	retn
  2885                                  
  2886                                  %include 'diskio.s'  ; 07/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.2 - diskio.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 30/08/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskio.inc (22/08/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKIO.INC
    20                              <1> ; Last Modification: 22/08/2015
    21                              <1> ; 	(Initialized Disk Parameters Data is in 'DISKDATA.INC') 
    22                              <1> ; 	(Uninitialized Disk Parameters Data is in 'DISKBSS.INC') 
    23                              <1> 
    24                              <1> ; DISK I/O SYSTEM - Erdogan Tan (Retro UNIX 386 v1 project)
    25                              <1> 
    26                              <1> ; ///////// DISK I/O SYSTEM ///////////////
    27                              <1> 
    28                              <1> ; 06/02/2015
    29                              <1> diskette_io:
    30 00004370 F8                  <1> 	clc ; 20/07/2020
    31 00004371 9C                  <1> 	pushfd
    32 00004372 0E                  <1> 	push 	cs
    33 00004373 E809000000          <1> 	call 	DISKETTE_IO_1
    34 00004378 C3                  <1> 	retn
    35                              <1> 	
    36                              <1> ;;;;;; DISKETTE I/O ;;;;;;;;;;;;;;;;;;;; 06/02/2015 ;;;
    37                              <1> ;//////////////////////////////////////////////////////
    38                              <1> 
    39                              <1> ; DISKETTE I/O - Erdogan Tan (Retro UNIX 386 v1 project)
    40                              <1> ; 20/02/2015
    41                              <1> ; 06/02/2015 (unix386.s)
    42                              <1> ; 16/12/2014 - 02/01/2015 (dsectrm2.s)
    43                              <1> ;
    44                              <1> ; Code (DELAY) modifications - AWARD BIOS 1999 (ADISK.EQU, COMMON.MAC)
    45                              <1> ;
    46                              <1> ; ADISK.EQU
    47                              <1> 
    48                              <1> ;----- Wait control constants 
    49                              <1> 
    50                              <1> ;amount of time to wait while RESET is active.
    51                              <1> 
    52                              <1> WAITCPU_RESET_ON	EQU	21		;Reset on must last at least 14us
    53                              <1> 						;at 250 KBS xfer rate.
    54                              <1> 						;see INTEL MCS, 1985, pg. 5-456
    55                              <1> 
    56                              <1> WAITCPU_FOR_STATUS	EQU	100		;allow 30 microseconds for
    57                              <1> 						;status register to become valid
    58                              <1> 						;before re-reading.
    59                              <1> 
    60                              <1> ;After sending a byte to NEC, status register may remain
    61                              <1> ;incorrectly set for 24 us.
    62                              <1> 
    63                              <1> WAITCPU_RQM_LOW		EQU	24		;number of loops to check for
    64                              <1> 						;RQM low.
    65                              <1> 
    66                              <1> ; COMMON.MAC
    67                              <1> ;
    68                              <1> ;	Timing macros
    69                              <1> ;
    70                              <1> 
    71                              <1> %macro 		SIODELAY 0 			; SHORT IODELAY
    72                              <1> 		jmp short $+2
    73                              <1> %endmacro		
    74                              <1> 
    75                              <1> %macro		IODELAY  0			; NORMAL IODELAY
    76                              <1> 		jmp short $+2
    77                              <1> 		jmp short $+2
    78                              <1> %endmacro
    79                              <1> 
    80                              <1> %macro		NEWIODELAY 0
    81                              <1> 		out	0ebh,al
    82                              <1> %endmacro 
    83                              <1> 
    84                              <1> ; (According to) AWARD BIOS 1999 - ATORGS.ASM (dw -> equ, db -> equ)
    85                              <1> ;;; WAIT_FOR_MEM
    86                              <1> ;WAIT_FDU_INT_LO	equ	017798		; 2.5 secs in 30 micro units.
    87                              <1> ;WAIT_FDU_INT_HI	equ	1
    88                              <1> WAIT_FDU_INT_LH		equ	83334		; 27/02/2015 (2.5 seconds waiting)
    89                              <1> ;;; WAIT_FOR_PORT
    90                              <1> ;WAIT_FDU_SEND_LO	equ	16667		; .5 secons in 30 us units.
    91                              <1> ;WAIT_FDU_SEND_HI	equ	0
    92                              <1> WAIT_FDU_SEND_LH	equ 	16667		; 27/02/2015	
    93                              <1> ;Time to wait while waiting for each byte of NEC results = .5
    94                              <1> ;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
    95                              <1> ;WAIT_FDU_RESULTS_LO	equ	16667		; .5 seconds in 30 micro units.
    96                              <1> ;WAIT_FDU_RESULTS_HI	equ	0
    97                              <1> WAIT_FDU_RESULTS_LH	equ	16667  ; 27/02/2015
    98                              <1> ;;; WAIT_REFRESH
    99                              <1> ;amount of time to wait for head settle, per unit in parameter
   100                              <1> ;table = 1 ms.
   101                              <1> WAIT_FDU_HEAD_SETTLE	equ	33		; 1 ms in 30 micro units.
   102                              <1> 
   103                              <1> 
   104                              <1> ; //////////////// DISKETTE I/O ////////////////
   105                              <1> 
   106                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - POSTEQU.INC)
   107                              <1> 
   108                              <1> ;----------------------------------------
   109                              <1> ;	EQUATES USED BY POST AND BIOS	:
   110                              <1> ;----------------------------------------
   111                              <1> 
   112                              <1> ;--------- 8042 KEYBOARD INTERFACE AND DIAGNOSTIC CONTROL REGISTERS ------------
   113                              <1> ;PORT_A		EQU	060H		; 8042 KEYBOARD SCAN CODE/CONTROL PORT
   114                              <1> ;PORT_B		EQU	061H		; PORT B READ/WRITE DIAGNOSTIC REGISTER
   115                              <1> ;REFRESH_BIT	EQU	00010000B	; REFRESH TEST BIT
   116                              <1> 
   117                              <1> ;----------------------------------------
   118                              <1> ;	CMOS EQUATES FOR THIS SYSTEM	:
   119                              <1> ;-------------------------------------------------------------------------------
   120                              <1> ;CMOS_PORT	EQU	070H		; I/O ADDRESS OF CMOS ADDRESS PORT
   121                              <1> ;CMOS_DATA	EQU	071H		; I/O ADDRESS OF CMOS DATA PORT
   122                              <1> ;NMI		EQU	10000000B	; DISABLE NMI INTERRUPTS MASK -
   123                              <1> 					;  HIGH BIT OF CMOS LOCATION ADDRESS
   124                              <1> 
   125                              <1> ;---------- CMOS TABLE LOCATION ADDRESS'S ## -----------------------------------
   126                              <1> CMOS_DISKETTE	EQU	010H		; DISKETTE DRIVE TYPE BYTE	      ;
   127                              <1> ;		EQU	011H		; - RESERVED			      ;C
   128                              <1> CMOS_DISK	EQU	012H		; FIXED DISK TYPE BYTE		      ;H
   129                              <1> ;		EQU	013H		; - RESERVED			      ;E
   130                              <1> CMOS_EQUIP	EQU	014H		; EQUIPMENT WORD LOW BYTE	      ;C
   131                              <1> 
   132                              <1> ;---------- DISKETTE EQUATES ---------------------------------------------------
   133                              <1> INT_FLAG	EQU	10000000B	; INTERRUPT OCCURRENCE FLAG
   134                              <1> DSK_CHG 	EQU	10000000B	; DISKETTE CHANGE FLAG MASK BIT
   135                              <1> DETERMINED	EQU	00010000B	; SET STATE DETERMINED IN STATE BITS
   136                              <1> HOME		EQU	00010000B	; TRACK 0 MASK
   137                              <1> SENSE_DRV_ST	EQU	00000100B	; SENSE DRIVE STATUS COMMAND
   138                              <1> TRK_SLAP	EQU	030H		; CRASH STOP (48 TPI DRIVES)
   139                              <1> QUIET_SEEK	EQU	00AH		; SEEK TO TRACK 10
   140                              <1> ;MAX_DRV 	EQU	2		; MAX NUMBER OF DRIVES
   141                              <1> HD12_SETTLE	EQU	15		; 1.2 M HEAD SETTLE TIME
   142                              <1> HD320_SETTLE	EQU	20		; 320 K HEAD SETTLE TIME
   143                              <1> MOTOR_WAIT	EQU	37		; 2 SECONDS OF COUNTS FOR MOTOR TURN OFF
   144                              <1> 
   145                              <1> ;---------- DISKETTE ERRORS ----------------------------------------------------
   146                              <1> ;TIME_OUT	EQU	080H		; ATTACHMENT FAILED TO RESPOND
   147                              <1> ;BAD_SEEK	EQU	040H		; SEEK OPERATION FAILED
   148                              <1> BAD_NEC 	EQU	020H		; DISKETTE CONTROLLER HAS FAILED
   149                              <1> BAD_CRC 	EQU	010H		; BAD CRC ON DISKETTE READ
   150                              <1> MED_NOT_FND	EQU	00CH		; MEDIA TYPE NOT FOUND
   151                              <1> DMA_BOUNDARY	EQU	009H		; ATTEMPT TO DMA ACROSS 64K BOUNDARY
   152                              <1> BAD_DMA 	EQU	008H		; DMA OVERRUN ON OPERATION
   153                              <1> MEDIA_CHANGE	EQU	006H		; MEDIA REMOVED ON DUAL ATTACH CARD
   154                              <1> RECORD_NOT_FND	EQU	004H		; REQUESTED SECTOR NOT FOUND
   155                              <1> WRITE_PROTECT	EQU	003H		; WRITE ATTEMPTED ON WRITE PROTECT DISK
   156                              <1> BAD_ADDR_MARK	EQU	002H		; ADDRESS MARK NOT FOUND
   157                              <1> BAD_CMD 	EQU	001H		; BAD COMMAND PASSED TO DISKETTE I/O
   158                              <1> 
   159                              <1> ;---------- DISK CHANGE LINE EQUATES -------------------------------------------
   160                              <1> NOCHGLN 	EQU	001H		; NO DISK CHANGE LINE AVAILABLE
   161                              <1> CHGLN		EQU	002H		; DISK CHANGE LINE AVAILABLE
   162                              <1> 
   163                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS ---------------------------------------
   164                              <1> TRK_CAPA	EQU	00000001B	; 80 TRACK CAPABILITY
   165                              <1> FMT_CAPA	EQU	00000010B	; MULTIPLE FORMAT CAPABILITY (1.2M)
   166                              <1> DRV_DET 	EQU	00000100B	; DRIVE DETERMINED
   167                              <1> MED_DET 	EQU	00010000B	; MEDIA DETERMINED BIT
   168                              <1> DBL_STEP	EQU	00100000B	; DOUBLE STEP BIT
   169                              <1> RATE_MSK	EQU	11000000B	; MASK FOR CLEARING ALL BUT RATE
   170                              <1> RATE_500	EQU	00000000B	; 500 KBS DATA RATE
   171                              <1> RATE_300	EQU	01000000B	; 300 KBS DATA RATE
   172                              <1> RATE_250	EQU	10000000B	; 250 KBS DATA RATE
   173                              <1> STRT_MSK	EQU	00001100B	; OPERATION START RATE MASK
   174                              <1> SEND_MSK	EQU	11000000B	; MASK FOR SEND RATE BITS
   175                              <1> 
   176                              <1> ;---------- MEDIA/DRIVE STATE INDICATORS COMPATIBILITY -------------------------
   177                              <1> M3D3U		EQU	00000000B	; 360 MEDIA/DRIVE NOT ESTABLISHED
   178                              <1> M3D1U		EQU	00000001B	; 360 MEDIA,1.2DRIVE NOT ESTABLISHED
   179                              <1> M1D1U		EQU	00000010B	; 1.2 MEDIA/DRIVE NOT ESTABLISHED
   180                              <1> MED_UNK 	EQU	00000111B	; NONE OF THE ABOVE
   181                              <1> 
   182                              <1> ;---------- INTERRUPT EQUATES --------------------------------------------------
   183                              <1> ;EOI		EQU	020H		; END OF INTERRUPT COMMAND TO 8259
   184                              <1> ;INTA00		EQU	020H		; 8259 PORT
   185                              <1> INTA01		EQU	021H		; 8259 PORT
   186                              <1> INTB00		EQU	0A0H		; 2ND 8259
   187                              <1> INTB01		EQU	0A1H		;
   188                              <1> 
   189                              <1> ;-------------------------------------------------------------------------------
   190                              <1> DMA08		EQU	008H		; DMA STATUS REGISTER PORT ADDRESS
   191                              <1> DMA		EQU	000H		; DMA CH.0 ADDRESS REGISTER PORT ADDRESS
   192                              <1> DMA18		EQU	0D0H		; 2ND DMA STATUS PORT ADDRESS
   193                              <1> DMA1		EQU	0C0H		; 2ND DMA CH.0 ADDRESS REGISTER ADDRESS
   194                              <1> ;-------------------------------------------------------------------------------
   195                              <1> ;TIMER		EQU	040H		; 8254 TIMER - BASE ADDRESS
   196                              <1> 
   197                              <1> ;-------------------------------------------------------------------------------
   198                              <1> DMA_PAGE	EQU	081H		; START OF DMA PAGE REGISTERS
   199                              <1> 
   200                              <1> ; 06/02/2015 (unix386.s, protected mode modifications)
   201                              <1> ; (unix386.s <-- dsectrm2.s)
   202                              <1> ; 11/12/2014 (copy from IBM PC-XT Model 286 BIOS - DSEG.INC)
   203                              <1> 
   204                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
   205                              <1> ; 10/12/2014
   206                              <1> ;
   207                              <1> ;int40h:
   208                              <1> ;	pushf
   209                              <1> ;	push 	cs
   210                              <1> ;	;cli
   211                              <1> ;	call 	DISKETTE_IO_1
   212                              <1> ;	retn
   213                              <1> 
   214                              <1> ; DSKETTE ----- 04/21/86 DISKETTE BIOS
   215                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
   216                              <1> ;
   217                              <1> 
   218                              <1> ;-- INT13H ---------------------------------------------------------------------
   219                              <1> ; DISKETTE I/O
   220                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO THE 5 1/4 INCH 360 KB,
   221                              <1> ;	1.2 MB, 720 KB AND 1.44 MB DISKETTE DRIVES.
   222                              <1> ; INPUT
   223                              <1> ;	(AH) =  00H RESET DISKETTE SYSTEM
   224                              <1> ;		HARD RESET TO NEC, PREPARE COMMAND, RECALIBRATE REQUIRED
   225                              <1> ;		ON ALL DRIVES
   226                              <1> ;------------------------------------------------------------------------------- 
   227                              <1> ;	(AH)= 01H  READ THE STATUS OF THE SYSTEM INTO (AH)
   228                              <1> ;		@DISKETTE_STATUS FROM LAST OPERATION IS USED
   229                              <1> ;-------------------------------------------------------------------------------
   230                              <1> ;	REGISTERS FOR READ/WRITE/VERIFY/FORMAT
   231                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   232                              <1> ;	(DH) - HEAD NUMBER (0-1 ALLOWED, NOT VALUE CHECKED)
   233                              <1> ;	(CH) - TRACK NUMBER (NOT VALUE CHECKED)
   234                              <1> ;		MEDIA	DRIVE	TRACK NUMBER
   235                              <1> ;		320/360	320/360	    0-39
   236                              <1> ;		320/360	1.2M	    0-39
   237                              <1> ;		1.2M	1.2M	    0-79
   238                              <1> ;		720K	720K	    0-79
   239                              <1> ;		1.44M	1.44M	    0-79	
   240                              <1> ;	(CL) - 	SECTOR NUMBER (NOT VALUE CHECKED, NOT USED FOR FORMAT)
   241                              <1> ;		MEDIA	DRIVE	SECTOR NUMBER
   242                              <1> ;		320/360	320/360	     1-8/9
   243                              <1> ;		320/360	1.2M	     1-8/9
   244                              <1> ;		1.2M	1.2M	     1-15
   245                              <1> ;		720K	720K	     1-9
   246                              <1> ;		1.44M	1.44M	     1-18		
   247                              <1> ;	(AL)	NUMBER OF SECTORS (NOT VALUE CHECKED)
   248                              <1> ;		MEDIA	DRIVE	MAX NUMBER OF SECTORS
   249                              <1> ;		320/360	320/360	        8/9
   250                              <1> ;		320/360	1.2M	        8/9
   251                              <1> ;		1.2M	1.2M		15
   252                              <1> ;		720K	720K		9
   253                              <1> ;		1.44M	1.44M		18
   254                              <1> ;
   255                              <1> ;	(ES:BX) - ADDRESS OF BUFFER (NOT REQUIRED FOR VERIFY)
   256                              <1> ;
   257                              <1> ;-------------------------------------------------------------------------------
   258                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY
   259                              <1> ;-------------------------------------------------------------------------------
   260                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY
   261                              <1> ;-------------------------------------------------------------------------------
   262                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS
   263                              <1> ;-------------------------------------------------------------------------------
   264                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK
   265                              <1> ;		(ES,BX) MUST POINT TO THE COLLECTION OF DESIRED ADDRESS FIELDS
   266                              <1> ;		FOR THE	TRACK. EACH FIELD IS COMPOSED OF 4 BYTES, (C,H,R,N),
   267                              <1> ;		WHERE C = TRACK NUMBER, H=HEAD NUMBER, R = SECTOR NUMBER, 
   268                              <1> ;		N= NUMBER OF BYTES PER SECTOR (00=128,01=256,02=512,03=1024),
   269                              <1> ;		THERE MUST BE ONE ENTRY FOR EVERY SECTOR ON THE TRACK.
   270                              <1> ;		THIS INFORMATION IS USED TO FIND THE REQUESTED SECTOR DURING 
   271                              <1> ;		READ/WRITE ACCESS.
   272                              <1> ;		PRIOR TO FORMATTING A DISKETTE, IF THERE EXISTS MORE THAN
   273                              <1> ;		ONE SUPPORTED MEDIA FORMAT TYPE WITHIN THE DRIVE IN QUESTION,
   274                              <1> ;		THEN "SET DASD TYPE" (INT 13H, AH = 17H) OR 'SET MEDIA TYPE'
   275                              <1> ;		(INT 13H, AH =  18H) MUST BE CALLED TO SET THE DISKETTE TYPE
   276                              <1> ;		THAT IS TO BE FORMATTED. IF "SET DASD TYPE" OR "SET MEDIA TYPE"
   277                              <1> ;		IS NOT CALLED, THE FORMAT ROUTINE WILL ASSUME THE 
   278                              <1> ;		MEDIA FORMAT TO BE THE MAXIMUM CAPACITY OF THE DRIVE.
   279                              <1> ;
   280                              <1> ;		THESE PARAMETERS OF DISK BASE MUST BE CHANGED IN ORDER TO
   281                              <1> ;		FORMAT THE FOLLOWING MEDIAS:
   282                              <1> ;		---------------------------------------------
   283                              <1> ;		: MEDIA  :     DRIVE      : PARM 1 : PARM 2 :
   284                              <1> ;		---------------------------------------------
   285                              <1> ;		: 320K	 : 320K/360K/1.2M :  50H   :   8    :
   286                              <1> ;		: 360K	 : 320K/360K/1.2M :  50H   :   9    :
   287                              <1> ;		: 1.2M	 : 1.2M           :  54H   :  15    :
   288                              <1> ;		: 720K	 : 720K/1.44M     :  50H   :   9    :
   289                              <1> ;		: 1.44M	 : 1.44M          :  6CH   :  18    :		  	
   290                              <1> ;		---------------------------------------------
   291                              <1> ;		NOTES: - PARM 1 = GAP LENGTH FOR FORMAT
   292                              <1> ;		       - PARM 2 = EOT (LAST SECTOR ON TRACK)
   293                              <1> ;		       - DISK BASE IS POINTED BY DISK POINTER LOCATED
   294                              <1> ;			 AT ABSOLUTE ADDRESS 0:78.
   295                              <1> ;		       - WHEN FORMAT OPERATIONS ARE COMPLETE, THE PARAMETERS
   296                              <1> ;			 SHOULD BE RESTORED TO THEIR RESPECTIVE INITIAL VALUES.			
   297                              <1> ;-------------------------------------------------------------------------------
   298                              <1> ;	(AH) = 08H READ DRIVE PARAMETERS
   299                              <1> ;	REGISTERS
   300                              <1> ;	  INPUT
   301                              <1> ;	    (DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   302                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
   303                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
   304                              <1> ;	  OUTPUT
   305                              <1> ;	    (ES:DI) POINTS TO DRIVE PARAMETER TABLE
   306                              <1> ; 	    *** TRDOS 386 note: floppy disk parameter table (16 bytes)
   307                              <1> ;	    will be returned to user in EBX, buffer address *** 27/05/2016 ***		
   308                              <1> ;					
   309                              <1> ;	    (CH) - LOW ORDER 8 OF 10 BITS MAXIMUM NUMBER OF TRACKS
   310                              <1> ;	    (CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
   311                              <1> ;	           BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
   312                              <1> ;	    (DH) - MAXIMUM HEAD NUMBER
   313                              <1> ;	    (DL) - NUMBER OF DISKETTE DRIVES INSTALLED
   314                              <1> ;	    (BH) - 0
   315                              <1> ;	    (BL) - BITS 7 THRU 4 - 0
   316                              <1> ;	           BITS 3 THRU 0 - VALID DRIVE TYPE VALUE IN CMOS
   317                              <1> ;	    (AX) - 0
   318                              <1> ;	 UNDER THE FOLLOWING CIRCUMSTANCES:
   319                              <1> ;	    (1) THE DRIVE NUMBER IS INVALID,
   320                              <1> ;	    (2) THE DRIVE TYPE IS UNKNOWN AND CMOS IS NOT PRESENT, 
   321                              <1> ;	    (3) THE DRIVE TYPE IS UNKNOWN AND CMOS IS BAD,
   322                              <1> ;	    (4) OR THE DRIVE TYPE IS UNKNOWN AND THE CMOS DRIVE TYPE IS INVALID
   323                              <1> ;	    THEN ES,AX,BX,CX,DH,DI=0 ; DL=NUMBER OF DRIVES. 
   324                              <1> ;	    IF NO DRIVES ARE PRESENT THEN: ES,AX,BX,CX,DX,DI=0.
   325                              <1> ;	    @DISKETTE_STATUS = 0 AND CY IS RESET.
   326                              <1> ;-------------------------------------------------------------------------------
   327                              <1> ;	(AH)= 15H  READ DASD TYPE
   328                              <1> ;	OUTPUT REGISTERS
   329                              <1> ;	(AH) - ON RETURN IF CARRY FLAG NOT SET, OTHERWISE ERROR	
   330                              <1> ;		00 - DRIVE NOT PRESENT	
   331                              <1> ;		01 - DISKETTE, NO CHANGE LINE AVAILABLE
   332                              <1> ;		02 - DISKETTE, CHANGE LINE AVAILABLE	
   333                              <1> ;		03 - RESERVED (FIXED DISK)
   334                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   335                              <1> ;-------------------------------------------------------------------------------
   336                              <1> ;	(AH)= 16H  DISK CHANGE LINE STATUS
   337                              <1> ;	OUTPUT REGISTERS
   338                              <1> ;	(AH) - 00 - DISK CHANGE LINE NOT ACTIVE	
   339                              <1> ;	       06 - DISK CHANGE LINE ACTIVE & CARRY BIT ON
   340                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED)
   341                              <1> ;-------------------------------------------------------------------------------
   342                              <1> ;	(AH)= 17H  SET DASD TYPE FOR FORMAT
   343                              <1> ;	INPUT REGISTERS
   344                              <1> ;	(AL) -	00 - NOT USED	
   345                              <1> ;		01 - DISKETTE 320/360K IN 360K DRIVE	
   346                              <1> ;		02 - DISKETTE 360K IN 1.2M DRIVE
   347                              <1> ;		03 - DISKETTE 1.2M IN 1.2M DRIVE
   348                              <1> ;		04 - DISKETTE 720K IN 720K DRIVE
   349                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHECKED:
   350                              <1> ;	       (DO NOT USE WHEN DISKETTE ATTACH CARD USED)
   351                              <1> ;-------------------------------------------------------------------------------
   352                              <1> ;	(AH)= 18H  SET MEDIA TYPE FOR FORMAT
   353                              <1> ;	INPUT REGISTERS
   354                              <1> ;	(CH) - LOW ORDER 8 OF 10 BITS MAXIMUM TRACKS
   355                              <1> ;	(CL) - BITS 7 & 6 - HIGH ORDER TWO BITS OF MAXIMUM TRACKS
   356                              <1> ;	       BITS 5 THRU 0 - MAXIMUM SECTORS PER TRACK
   357                              <1> ;	(DL) - DRIVE NUMBER (0-1 ALLOWED, VALUE CHACKED)
   358                              <1> ;	OUTPUT REGISTERS:
   359                              <1> ;	(ES:DI) - POINTER TO DRIVE PARAMETERS TABLE FOR THIS MEDIA TYPE,
   360                              <1> ;		  UNCHANGED IF (AH) IS NON-ZERO
   361                              <1> ;	(AH) - 00H, CY = 0, TRACK AND SECTORS/TRACK COMBINATION IS SUPPORTED
   362                              <1> ;	     - 01H, CY = 1, FUNCTION IS NOT AVAILABLE
   363                              <1> ;	     - 0CH, CY = 1, TRACK AND SECTORS/TRACK COMBINATION IS NOT SUPPORTED
   364                              <1> ;	     - 80H, CY = 1, TIME OUT (DISKETTE NOT PRESENT)		
   365                              <1> ;-------------------------------------------------------------------------------
   366                              <1> ;	DISK CHANGE STATUS IS ONLY CHECKED WHEN A MEDIA SPECIFIED IS OTHER
   367                              <1> ;	THAN 360 KB DRIVE. IF THE DISK CHANGE LINE IS FOUND TO BE
   368                              <1> ;	ACTIVE THE FOLLOWING ACTIONS TAKE PLACE:
   369                              <1> ;		ATTEMPT TO RESET DISK CHANGE LINE TO INACTIVE STATE. 
   370                              <1> ;		IF ATTEMPT SUCCEEDS SET DASD TYPE FOR FORMAT AND RETURN DISK 
   371                              <1> ;		CHANGE ERROR CODE
   372                              <1> ;		IF ATTEMPT FAILS RETURN TIMEOUT ERROR CODE AND SET DASD TYPE 
   373                              <1> ;		TO A PREDETERMINED STATE INDICATING MEDIA TYPE UNKNOWN.
   374                              <1> ;	IF THE DISK CHANGE LINE IN INACTIVE PERFORM SET DASD TYPE FOR FORMAT.
   375                              <1> ;
   376                              <1> ; DATA VARIABLE -- @DISK_POINTER
   377                              <1> ;	DOUBLE WORD POINTER TO THE CURRENT SET OF DISKETTE PARAMETERS
   378                              <1> ;-------------------------------------------------------------------------------
   379                              <1> ; OUTPUT FOR ALL FUNCTIONS
   380                              <1> ;	AH = STATUS OF OPERATION
   381                              <1> ;		STATUS BITS ARE DEFINED IN THE EQUATES FOR @DISKETTE_STATUS
   382                              <1> ;		VARIABLE IN THE DATA SEGMENT OF THIS MODULE
   383                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN, EXCEPT FOR READ DASD
   384                              <1> ;		TYPE AH=(15)).
   385                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)
   386                              <1> ;	FOR READ/WRITE/VERIFY
   387                              <1> ;		DS,BX,DX,CX PRESERVED
   388                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISKETTE CODE, THE APPROPRIATE 
   389                              <1> ;		ACTION IS TO RESET THE DISKETTE, THEN RETRY THE OPERATION.
   390                              <1> ;		ON READ ACCESSES, NO MOTOR START DELAY IS TAKEN, SO THAT 
   391                              <1> ;		THREE RETRIES ARE REQUIRED ON READS TO ENSURE THAT THE 
   392                              <1> ;		PROBLEM IS NOT DUE TO MOTOR START-UP.
   393                              <1> ;-------------------------------------------------------------------------------
   394                              <1> ;
   395                              <1> ; DISKETTE STATE MACHINE - ABSOLUTE ADDRESS 40:90 (DRIVE A) & 91 (DRIVE B)
   396                              <1> ;
   397                              <1> ;   -----------------------------------------------------------------
   398                              <1> ;   |       |       |       |       |       |       |       |       |
   399                              <1> ;   |   7   |   6   |   5   |   4   |   3   |   2   |   1   |   0   |
   400                              <1> ;   |       |       |       |       |       |       |       |       |
   401                              <1> ;   -----------------------------------------------------------------
   402                              <1> ;	|	|	|	|	|	|	|	|
   403                              <1> ;	|	|	|	|	|	-----------------
   404                              <1> ;	|	|	|	|	|		|
   405                              <1> ;	|	|	|	|    RESERVED		|
   406                              <1> ;	|	|	|	|		  PRESENT STATE
   407                              <1> ;	|	|	|	|	000: 360K IN 360K DRIVE UNESTABLISHED
   408                              <1> ;	|	|	|	|	001: 360K IN 1.2M DRIVE UNESTABLISHED
   409                              <1> ;	|	|	|	|	010: 1.2M IN 1.2M DRIVE UNESTABLISHED
   410                              <1> ;	|	|	|	|	011: 360K IN 360K DRIVE ESTABLISHED
   411                              <1> ;	|	|	|	|	100: 360K IN 1.2M DRIVE ESTABLISHED
   412                              <1> ;	|	|	|	|	101: 1.2M IN 1.2M DRIVE ESTABLISHED
   413                              <1> ;	|	|	|	|	110: RESERVED
   414                              <1> ;	|	|	|	|	111: NONE OF THE ABOVE
   415                              <1> ;	|	|	|	|
   416                              <1> ;	|	|	|	------>	MEDIA/DRIVE ESTABLISHED
   417                              <1> ;	|	|	|
   418                              <1> ;	|	|	-------------->	DOUBLE STEPPING REQUIRED (360K IN 1.2M
   419                              <1> ;	|	|			DRIVE)
   420                              <1> ;	|	|
   421                              <1> ;	------------------------------>	DATA TRANSFER RATE FOR THIS DRIVE:
   422                              <1> ;
   423                              <1> ;						00: 500 KBS
   424                              <1> ;						01: 300 KBS
   425                              <1> ;						10: 250 KBS
   426                              <1> ;						11: RESERVED
   427                              <1> ;
   428                              <1> ;
   429                              <1> ;-------------------------------------------------------------------------------
   430                              <1> ; STATE OPERATION STARTED - ABSOLUTE ADDRESS 40:92 (DRIVE A) & 93 (DRIVE B)
   431                              <1> ;-------------------------------------------------------------------------------
   432                              <1> ; PRESENT CYLINDER NUMBER - ABSOLUTE ADDRESS 40:94 (DRIVE A) & 95 (DRIVE B)
   433                              <1> ;-------------------------------------------------------------------------------
   434                              <1> 
   435                              <1> struc MD
   436 00000000 <res 00000001>      <1> 	.SPEC1		resb	1	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   437 00000001 <res 00000001>      <1> 	.SPEC2		resb	1	; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   438 00000002 <res 00000001>      <1> 	.OFF_TIM	resb	1	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   439 00000003 <res 00000001>      <1> 	.BYT_SEC	resb	1	; 512 BYTES/SECTOR
   440 00000004 <res 00000001>      <1> 	.SEC_TRK	resb	1	; EOT (LAST SECTOR ON TRACK)
   441 00000005 <res 00000001>      <1> 	.GAP		resb	1	; GAP LENGTH
   442 00000006 <res 00000001>      <1> 	.DTL		resb	1	; DTL
   443 00000007 <res 00000001>      <1> 	.GAP3		resb	1	; GAP LENGTH FOR FORMAT
   444 00000008 <res 00000001>      <1> 	.FIL_BYT	resb	1	; FILL BYTE FOR FORMAT
   445 00000009 <res 00000001>      <1> 	.HD_TIM		resb	1	; HEAD SETTLE TIME (MILLISECONDS)
   446 0000000A <res 00000001>      <1> 	.STR_TIM	resb	1	; MOTOR START TIME (1/8 SECONDS)
   447 0000000B <res 00000001>      <1> 	.MAX_TRK	resb	1	; MAX. TRACK NUMBER
   448 0000000C <res 00000001>      <1> 	.RATE		resb	1	; DATA TRANSFER RATE
   449                              <1> endstruc
   450                              <1> 
   451                              <1> BIT7OFF	EQU	7FH
   452                              <1> BIT7ON	EQU	80H
   453                              <1> 
   454                              <1> ; 30/08/2020 - TRDOS 386 v2
   455                              <1> 
   456                              <1> ;;int13h: ; 16/02/2015
   457                              <1> ;; 16/02/2015 - 21/02/2015
   458                              <1> int40h:
   459 00004379 9C                  <1> 	pushfd
   460 0000437A 0E                  <1> 	push 	cs
   461 0000437B E801000000          <1> 	call 	DISKETTE_IO_1
   462 00004380 C3                  <1> 	retn	
   463                              <1> 
   464                              <1> DISKETTE_IO_1:
   465                              <1> 
   466 00004381 FB                  <1> 	STI				; INTERRUPTS BACK ON
   467 00004382 55                  <1> 	PUSH	eBP			; USER REGISTER
   468 00004383 57                  <1> 	PUSH	eDI			; USER REGISTER
   469 00004384 52                  <1> 	PUSH	eDX			; HEAD #, DRIVE # OR USER REGISTER
   470 00004385 53                  <1> 	PUSH	eBX			; BUFFER OFFSET PARAMETER OR REGISTER
   471 00004386 51                  <1> 	PUSH	eCX			; TRACK #-SECTOR # OR USER REGISTER
   472 00004387 89E5                <1> 	MOV	eBP,eSP			; BP     => PARAMETER LIST DEP. ON AH
   473                              <1> 					; [BP]   = SECTOR #
   474                              <1> 					; [BP+1] = TRACK #
   475                              <1> 					; [BP+2] = BUFFER OFFSET
   476                              <1> 					; FOR RETURN OF DRIVE PARAMETERS:
   477                              <1> 					; CL/[BP] = BITS 7&6 HI BITS OF MAX CYL
   478                              <1> 					; 	    BITS 0-5 MAX SECTORS/TRACK
   479                              <1> 					; CH/[BP+1] = LOW 8 BITS OF MAX CYL.
   480                              <1> 					; BL/[BP+2] = BITS 7-4 = 0
   481                              <1> 					;	      BITS 3-0 = VALID CMOS TYPE
   482                              <1> 					; BH/[BP+3] = 0
   483                              <1> 					; DL/[BP+4] = # DRIVES INSTALLED
   484                              <1> 					; DH/[BP+5] = MAX HEAD #
   485                              <1> 					; DI/[BP+6] = OFFSET TO DISK BASE
   486 00004389 06                  <1> 	push	es ; 06/02/2015	
   487 0000438A 1E                  <1> 	PUSH	DS			; BUFFER SEGMENT PARM OR USER REGISTER
   488 0000438B 56                  <1> 	PUSH	eSI			; USER REGISTERS
   489                              <1> 	;CALL	DDS			; SEGMENT OF BIOS DATA AREA TO DS
   490                              <1> 	;mov	cx, cs
   491                              <1> 	;mov	ds, cx
   492 0000438C 66B91000            <1> 	mov	cx, KDATA
   493 00004390 8ED9                <1>         mov     ds, cx
   494 00004392 8EC1                <1>         mov     es, cx
   495                              <1> 
   496                              <1> 	;CMP	AH,(FNC_TAE-FNC_TAB)/2	; CHECK FOR > LARGEST FUNCTION
   497 00004394 80FC19              <1> 	cmp	ah,(FNC_TAE-FNC_TAB)/4  ; 18/02/2015
   498 00004397 7202                <1> 	JB	short OK_FUNC		; FUNCTION OK
   499 00004399 B414                <1> 	MOV	AH,14H			; REPLACE WITH KNOWN INVALID FUNCTION
   500                              <1> OK_FUNC:
   501 0000439B 80FC01              <1> 	CMP	AH,1			; RESET OR STATUS ?
   502 0000439E 760C                <1> 	JBE	short OK_DRV		; IF RESET OR STATUS DRIVE ALWAYS OK
   503 000043A0 80FC08              <1> 	CMP	AH,8			; READ DRIVE PARMS ?
   504 000043A3 7407                <1> 	JZ	short OK_DRV		; IF SO DRIVE CHECKED LATER
   505 000043A5 80FA01              <1> 	CMP	DL,1			; DRIVES 0 AND 1 OK
   506 000043A8 7602                <1> 	JBE	short OK_DRV		; IF 0 OR 1 THEN JUMP
   507 000043AA B414                <1> 	MOV	AH,14H			; REPLACE WITH KNOWN INVALID FUNCTION
   508                              <1> OK_DRV:
   509 000043AC 31C9                <1> 	xor	ecx, ecx
   510                              <1> 	;mov	esi, ecx ; 08/02/2015
   511 000043AE 89CF                <1> 	mov	edi, ecx ; 08/02/2015
   512 000043B0 88E1                <1> 	MOV	CL,AH			; CL = FUNCTION
   513                              <1> 	;XOR	CH,CH			; CX = FUNCTION
   514                              <1> 	;SHL	CL, 1			; FUNCTION TIMES 2
   515 000043B2 C0E102              <1> 	SHL	CL, 2 ; 20/02/2015	; FUNCTION TIMES 4 (for 32 bit offset)
   516 000043B5 BB[ED430000]        <1> 	MOV	eBX,FNC_TAB		; LOAD START OF FUNCTION TABLE
   517 000043BA 01CB                <1> 	ADD	eBX,eCX			; ADD OFFSET INTO TABLE => ROUTINE
   518 000043BC 88F4                <1> 	MOV	AH,DH			; AX = HEAD #,# OF SECTORS OR DASD TYPE
   519 000043BE 30F6                <1> 	XOR	DH,DH			; DX = DRIVE #
   520 000043C0 6689C6              <1> 	MOV	SI,AX			; SI = HEAD #,# OF SECTORS OR DASD TYPE
   521 000043C3 6689D7              <1> 	MOV     DI,DX                   ; DI = DRIVE #
   522                              <1> 	;
   523                              <1> 	; 11/12/2014
   524 000043C6 8815[ED6D0000]      <1>         mov     [cfd], dl               ; current floppy drive (for 'GET_PARM')        
   525                              <1> 	;
   526 000043CC 8A25[588A0100]      <1> 	MOV	AH, [DSKETTE_STATUS]	; LOAD STATUS TO AH FOR STATUS FUNCTION
   527 000043D2 C605[588A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; INITIALIZE FOR ALL OTHERS
   528                              <1> 
   529                              <1> ;	THROUGHOUT THE DISKETTE BIOS, THE FOLLOWING INFORMATION IS CONTAINED IN
   530                              <1> ;	THE FOLLOWING MEMORY LOCATIONS AND REGISTERS. NOT ALL DISKETTE BIOS
   531                              <1> ;	FUNCTIONS REQUIRE ALL OF THESE PARAMETERS.
   532                              <1> ;
   533                              <1> ;		DI	: DRIVE #
   534                              <1> ;		SI-HI	: HEAD #
   535                              <1> ;		SI-LOW	: # OF SECTORS OR DASD TYPE FOR FORMAT
   536                              <1> ;		ES	: BUFFER SEGMENT
   537                              <1> ;		[BP]	: SECTOR #
   538                              <1> ;		[BP+1]	: TRACK #
   539                              <1> ;		[BP+2]	: BUFFER OFFSET
   540                              <1> ;
   541                              <1> ;	ACROSS CALLS TO SUBROUTINES THE CARRY FLAG (CY=1), WHERE INDICATED IN 
   542                              <1> ;	SUBROUTINE PROLOGUES, REPRESENTS AN EXCEPTION RETURN (NORMALLY AN ERROR 
   543                              <1> ;	CONDITION). IN MOST CASES, WHEN CY = 1, @DSKETTE_STATUS CONTAINS THE 
   544                              <1> ;	SPECIFIC ERROR CODE.
   545                              <1> ;
   546                              <1> 					; (AH) = @DSKETTE_STATUS
   547 000043D9 FF13                <1> 	CALL	dWORD [eBX]		; CALL THE REQUESTED FUNCTION
   548 000043DB 5E                  <1> 	POP	eSI			; RESTORE ALL REGISTERS
   549 000043DC 1F                  <1> 	POP	DS
   550 000043DD 07                  <1> 	pop	es	; 06/02/2015
   551 000043DE 59                  <1> 	POP	eCX
   552 000043DF 5B                  <1> 	POP	eBX
   553 000043E0 5A                  <1> 	POP	eDX
   554 000043E1 5F                  <1> 	POP	eDI
   555 000043E2 89E5                <1> 	MOV	eBP, eSP
   556 000043E4 50                  <1> 	PUSH	eAX
   557 000043E5 9C                  <1> 	PUSHFd
   558 000043E6 58                  <1> 	POP	eAX
   559                              <1> 	;MOV	[BP+6], AX
   560 000043E7 89450C              <1> 	mov	[ebp+12], eax  ; 18/02/2015, flags
   561 000043EA 58                  <1> 	POP	eAX
   562 000043EB 5D                  <1> 	POP	eBP
   563 000043EC CF                  <1> 	IRETd
   564                              <1> 
   565                              <1> ;-------------------------------------------------------------------------------
   566                              <1> ; DW --> dd (06/02/2015)
   567 000043ED [51440000]          <1> FNC_TAB	dd	DSK_RESET		; AH = 00H; RESET
   568 000043F1 [CA440000]          <1> 	dd	DSK_STATUS		; AH = 01H; STATUS
   569 000043F5 [DB440000]          <1> 	dd	DSK_READ		; AH = 02H; READ
   570 000043F9 [EC440000]          <1> 	dd	DSK_WRITE		; AH = 03H; WRITE
   571 000043FD [FD440000]          <1> 	dd	DSK_VERF		; AH = 04H; VERIFY
   572 00004401 [0E450000]          <1> 	dd	DSK_FORMAT		; AH = 05H; FORMAT
   573 00004405 [93450000]          <1> 	dd	FNC_ERR			; AH = 06H; INVALID
   574 00004409 [93450000]          <1> 	dd	FNC_ERR			; AH = 07H; INVALID
   575 0000440D [A0450000]          <1> 	dd	DSK_PARMS		; AH = 08H; READ DRIVE PARAMETERS
   576 00004411 [93450000]          <1> 	dd	FNC_ERR			; AH = 09H; INVALID
   577 00004415 [93450000]          <1> 	dd	FNC_ERR			; AH = 0AH; INVALID
   578 00004419 [93450000]          <1> 	dd	FNC_ERR			; AH = 0BH; INVALID
   579 0000441D [93450000]          <1> 	dd	FNC_ERR			; AH = 0CH; INVALID
   580 00004421 [93450000]          <1> 	dd	FNC_ERR			; AH = 0DH; INVALID
   581 00004425 [93450000]          <1> 	dd	FNC_ERR			; AH = 0EH; INVALID
   582 00004429 [93450000]          <1> 	dd	FNC_ERR			; AH = 0FH; INVALID
   583 0000442D [93450000]          <1> 	dd	FNC_ERR			; AH = 10H; INVALID
   584 00004431 [93450000]          <1> 	dd	FNC_ERR			; AH = 11H; INVALID
   585 00004435 [93450000]          <1> 	dd	FNC_ERR			; AH = 12H; INVALID
   586 00004439 [93450000]          <1> 	dd	FNC_ERR			; AH = 13H; INVALID
   587 0000443D [93450000]          <1> 	dd	FNC_ERR			; AH = 14H; INVALID
   588 00004441 [90460000]          <1> 	dd	DSK_TYPE		; AH = 15H; READ DASD TYPE
   589 00004445 [C0460000]          <1> 	dd	DSK_CHANGE		; AH = 16H; CHANGE STATUS
   590 00004449 [FA460000]          <1> 	dd	FORMAT_SET		; AH = 17H; SET DASD TYPE
   591 0000444D [7D470000]          <1> 	dd	SET_MEDIA		; AH = 18H; SET MEDIA TYPE	
   592                              <1> FNC_TAE EQU     $                       ; END
   593                              <1> 
   594                              <1> ;-------------------------------------------------------------------------------
   595                              <1> ; DISK_RESET	(AH = 00H)	
   596                              <1> ;		RESET THE DISKETTE SYSTEM.
   597                              <1> ;
   598                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   599                              <1> ;-------------------------------------------------------------------------------
   600                              <1> DSK_RESET:
   601 00004451 66BAF203            <1> 	MOV	DX,03F2H		; ADAPTER CONTROL PORT
   602 00004455 FA                  <1> 	CLI				; NO INTERRUPTS
   603 00004456 A0[568A0100]        <1> 	MOV	AL,[MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
   604 0000445B 243F                <1> 	AND	AL,00111111B		; KEEP SELECTED AND MOTOR ON BITS
   605 0000445D C0C004              <1> 	ROL	AL,4			; MOTOR VALUE TO HIGH NIBBLE
   606                              <1> 					; DRIVE SELECT TO LOW NIBBLE
   607 00004460 0C08                <1> 	OR	AL,00001000B		; TURN ON INTERRUPT ENABLE
   608 00004462 EE                  <1> 	OUT	DX,AL			; RESET THE ADAPTER
   609 00004463 C605[558A0100]00    <1> 	MOV	byte [SEEK_STATUS],0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
   610                              <1> 	;JMP	$+2			; WAIT FOR I/O
   611                              <1> 	;JMP	$+2			; WAIT FOR I/O (TO INSURE MINIMUM
   612                              <1> 					;      PULSE WIDTH)
   613                              <1> 	; 19/12/2014
   614                              <1> 	NEWIODELAY
   614 0000446A E6EB                <2>  out 0ebh,al
   615                              <1> 
   616                              <1> 	; 17/12/2014 
   617                              <1> 	; AWARD BIOS 1999 - RESETDRIVES (ADISK.ASM)
   618 0000446C B915000000          <1> 	mov	ecx, WAITCPU_RESET_ON	; cx = 21 -- Min. 14 micro seconds !?
   619                              <1> wdw1:
   620                              <1> 	NEWIODELAY   ; 27/02/2015
   620 00004471 E6EB                <2>  out 0ebh,al
   621 00004473 E2FC                <1> 	loop	wdw1
   622                              <1> 	;
   623 00004475 0C04                <1> 	OR	AL,00000100B		; TURN OFF RESET BIT
   624 00004477 EE                  <1> 	OUT	DX,AL			; RESET THE ADAPTER
   625                              <1> 	; 16/12/2014
   626                              <1> 	IODELAY
   626 00004478 EB00                <2>  jmp short $+2
   626 0000447A EB00                <2>  jmp short $+2
   627                              <1> 	;
   628                              <1> 	;STI				; ENABLE THE INTERRUPTS
   629 0000447C E8590C0000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
   630 00004481 723E                <1> 	JC	short DR_ERR		; IF ERROR, RETURN IT
   631 00004483 66B9C000            <1> 	MOV	CX,11000000B		; CL = EXPECTED @NEC_STATUS
   632                              <1> NXT_DRV:
   633 00004487 6651                <1> 	PUSH	CX			; SAVE FOR CALL
   634 00004489 B8[BF440000]        <1> 	MOV	eAX, DR_POP_ERR 	; LOAD NEC_OUTPUT ERROR ADDRESS
   635 0000448E 50                  <1> 	PUSH	eAX			; "
   636 0000448F B408                <1> 	MOV	AH,08H			; SENSE INTERRUPT STATUS COMMAND
   637 00004491 E8370B0000          <1> 	CALL	NEC_OUTPUT
   638 00004496 58                  <1> 	POP	eAX			; THROW AWAY ERROR RETURN
   639 00004497 E86E0C0000          <1> 	CALL	RESULTS			; READ IN THE RESULTS
   640 0000449C 6659                <1> 	POP	CX			; RESTORE AFTER CALL
   641 0000449E 7221                <1> 	JC	short DR_ERR		; ERROR RETURN
   642 000044A0 3A0D[598A0100]      <1> 	CMP	CL, [NEC_STATUS]	; TEST FOR DRIVE READY TRANSITION
   643 000044A6 7519                <1> 	JNZ	short DR_ERR		; EVERYTHING OK
   644 000044A8 FEC1                <1> 	INC	CL			; NEXT EXPECTED @NEC_STATUS
   645 000044AA 80F9C3              <1> 	CMP	CL,11000011B		; ALL POSSIBLE DRIVES CLEARED
   646 000044AD 76D8                <1> 	JBE	short NXT_DRV		; FALL THRU IF 11000100B OR >
   647                              <1> 	;
   648 000044AF E886030000          <1> 	CALL	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
   649                              <1> RESBAC:
   650 000044B4 E83A090000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
   651 000044B9 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   652 000044BC 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   653 000044BE C3                  <1> 	RETn		
   654                              <1> DR_POP_ERR:
   655 000044BF 6659                <1> 	POP	CX			; CLEAR STACK
   656                              <1> DR_ERR:
   657 000044C1 800D[588A0100]20    <1> 	OR	byte [DSKETTE_STATUS],BAD_NEC ; SET ERROR CODE
   658 000044C8 EBEA                <1> 	JMP	SHORT RESBAC		; RETURN FROM RESET
   659                              <1> 
   660                              <1> ;-------------------------------------------------------------------------------
   661                              <1> ; DISK_STATUS	(AH = 01H)
   662                              <1> ;	DISKETTE STATUS.
   663                              <1> ;
   664                              <1> ; ON ENTRY:	AH : STATUS OF PREVIOUS OPERATION
   665                              <1> ;
   666                              <1> ; ON EXIT:	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF PREVIOUS OPERATION.
   667                              <1> ;-------------------------------------------------------------------------------
   668                              <1> DSK_STATUS:
   669 000044CA 8825[588A0100]      <1> 	MOV	[DSKETTE_STATUS],AH	; PUT BACK FOR SETUP END
   670 000044D0 E81E090000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
   671 000044D5 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   672 000044D8 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   673 000044DA C3                  <1> 	RETn		
   674                              <1> 
   675                              <1> ;-------------------------------------------------------------------------------
   676                              <1> ; DISK_READ	(AH = 02H)	
   677                              <1> ;	DISKETTE READ.
   678                              <1> ;
   679                              <1> ; ON ENTRY:	DI	: DRIVE #
   680                              <1> ;		SI-HI	: HEAD #
   681                              <1> ;		SI-LOW	: # OF SECTORS
   682                              <1> ;		ES	: BUFFER SEGMENT
   683                              <1> ;		[BP]	: SECTOR #
   684                              <1> ;		[BP+1]	: TRACK #
   685                              <1> ;		[BP+2]	: BUFFER OFFSET
   686                              <1> ;
   687                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   688                              <1> ;-------------------------------------------------------------------------------
   689                              <1> 
   690                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
   691                              <1> 
   692                              <1> DSK_READ:
   693 000044DB 8025[568A0100]7F    <1> 	AND	byte [MOTOR_STATUS],01111111B ; INDICATE A READ OPERATION
   694 000044E2 66B846E6            <1> 	MOV	AX,0E646H		; AX = NEC COMMAND, DMA COMMAND
   695 000044E6 E859040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   696 000044EB C3                  <1> 	RETn
   697                              <1> 
   698                              <1> ;-------------------------------------------------------------------------------
   699                              <1> ; DISK_WRITE	(AH = 03H)
   700                              <1> ;	DISKETTE WRITE.
   701                              <1> ;
   702                              <1> ; ON ENTRY:	DI	: DRIVE #
   703                              <1> ;		SI-HI	: HEAD #
   704                              <1> ;		SI-LOW	: # OF SECTORS
   705                              <1> ;		ES	: BUFFER SEGMENT
   706                              <1> ;		[BP]	: SECTOR #
   707                              <1> ;		[BP+1]	: TRACK #
   708                              <1> ;		[BP+2]	: BUFFER OFFSET
   709                              <1> ;
   710                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   711                              <1> ;-------------------------------------------------------------------------------
   712                              <1> 
   713                              <1> ; 06/02/2015, ES:BX -> EBX (unix386.s)
   714                              <1> 
   715                              <1> DSK_WRITE:
   716 000044EC 66B84AC5            <1> 	MOV	AX,0C54AH		; AX = NEC COMMAND, DMA COMMAND
   717 000044F0 800D[568A0100]80    <1>         OR      byte [MOTOR_STATUS],10000000B ; INDICATE WRITE OPERATION
   718 000044F7 E848040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   719 000044FC C3                  <1> 	RETn
   720                              <1> 
   721                              <1> ;-------------------------------------------------------------------------------
   722                              <1> ; DISK_VERF	(AH = 04H)
   723                              <1> ;	DISKETTE VERIFY.
   724                              <1> ;
   725                              <1> ; ON ENTRY:	DI	: DRIVE #
   726                              <1> ;		SI-HI	: HEAD #
   727                              <1> ;		SI-LOW	: # OF SECTORS
   728                              <1> ;		ES	: BUFFER SEGMENT
   729                              <1> ;		[BP]	: SECTOR #
   730                              <1> ;		[BP+1]	: TRACK #
   731                              <1> ;		[BP+2]	: BUFFER OFFSET
   732                              <1> ;
   733                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   734                              <1> ;-------------------------------------------------------------------------------
   735                              <1> DSK_VERF:
   736 000044FD 8025[568A0100]7F    <1> 	AND	byte [MOTOR_STATUS],01111111B ; INDICATE A READ OPERATION
   737 00004504 66B842E6            <1> 	MOV	AX,0E642H		; AX = NEC COMMAND, DMA COMMAND
   738 00004508 E837040000          <1> 	CALL	RD_WR_VF		; COMMON READ/WRITE/VERIFY
   739 0000450D C3                  <1> 	RETn
   740                              <1> 
   741                              <1> ;-------------------------------------------------------------------------------
   742                              <1> ; DISK_FORMAT	(AH = 05H)
   743                              <1> ;	DISKETTE FORMAT.
   744                              <1> ;
   745                              <1> ; ON ENTRY:	DI	: DRIVE #
   746                              <1> ;		SI-HI	: HEAD #
   747                              <1> ;		SI-LOW	: # OF SECTORS
   748                              <1> ;		ES	: BUFFER SEGMENT
   749                              <1> ;		[BP]	: SECTOR #
   750                              <1> ;		[BP+1]	: TRACK #
   751                              <1> ;		[BP+2]	: BUFFER OFFSET
   752                              <1> ;		@DISK_POINTER POINTS TO THE PARAMETER TABLE OF THIS DRIVE
   753                              <1> ;
   754                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   755                              <1> ;-------------------------------------------------------------------------------
   756                              <1> DSK_FORMAT:
   757 0000450E E870030000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
   758 00004513 E86C050000          <1> 	CALL	FMT_INIT		; ESTABLISH STATE IF UNESTABLISHED
   759 00004518 800D[568A0100]80    <1>         OR      byte [MOTOR_STATUS], 10000000B ; INDICATE WRITE OPERATION
   760 0000451F E8B4050000          <1> 	CALL	MED_CHANGE		; CHECK MEDIA CHANGE AND RESET IF SO
   761 00004524 725D                <1>         JC      short FM_DON            ; MEDIA CHANGED, SKIP
   762 00004526 E80F030000          <1> 	CALL	SEND_SPEC		; SEND SPECIFY COMMAND TO NEC
   763 0000452B E81A060000          <1> 	CALL	CHK_LASTRATE		; ZF=1 ATTEMPT RATE IS SAME AS LAST RATE
   764 00004530 7405                <1>         JZ      short FM_WR             ; YES, SKIP SPECIFY COMMAND
   765 00004532 E8F1050000          <1> 	CALL	SEND_RATE		; SEND DATA RATE TO CONTROLLER
   766                              <1> FM_WR:
   767 00004537 E8A7060000          <1> 	CALL	FMTDMA_SET		; SET UP THE DMA FOR FORMAT
   768 0000453C 7245                <1>         JC      short FM_DON            ; RETURN WITH ERROR
   769 0000453E B44D                <1> 	MOV	AH,04DH			; ESTABLISH THE FORMAT COMMAND
   770 00004540 E804070000          <1> 	CALL	NEC_INIT		; INITIALIZE THE NEC
   771 00004545 723C                <1>         JC      short FM_DON            ; ERROR - EXIT
   772 00004547 B8[83450000]        <1>         MOV     eAX, FM_DON             ; LOAD ERROR ADDRESS
   773 0000454C 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
   774 0000454D B203                <1> 	MOV	DL,3			; BYTES/SECTOR VALUE TO NEC
   775 0000454F E873090000          <1> 	CALL	GET_PARM
   776 00004554 E8740A0000          <1> 	CALL	NEC_OUTPUT
   777 00004559 B204                <1> 	MOV	DL,4			; SECTORS/TRACK VALUE TO NEC
   778 0000455B E867090000          <1> 	CALL	GET_PARM
   779 00004560 E8680A0000          <1> 	CALL	NEC_OUTPUT
   780 00004565 B207                <1> 	MOV	DL,7			; GAP LENGTH VALUE TO NEC
   781 00004567 E85B090000          <1> 	CALL	GET_PARM
   782 0000456C E85C0A0000          <1> 	CALL	NEC_OUTPUT
   783 00004571 B208                <1> 	MOV	DL,8			; FILLER BYTE TO NEC
   784 00004573 E84F090000          <1> 	CALL	GET_PARM
   785 00004578 E8500A0000          <1> 	CALL	NEC_OUTPUT
   786 0000457D 58                  <1> 	POP	eAX			; THROW AWAY ERROR
   787 0000457E E844070000          <1> 	CALL	NEC_TERM		; TERMINATE, RECEIVE STATUS, ETC,
   788                              <1> FM_DON:
   789 00004583 E82C030000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
   790 00004588 E866080000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
   791 0000458D 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
   792 00004590 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
   793 00004592 C3                  <1> 	RETn
   794                              <1> 
   795                              <1> ;-------------------------------------------------------------------------------
   796                              <1> ; FNC_ERR
   797                              <1> ;	INVALID FUNCTION REQUESTED OR INVALID DRIVE: 
   798                              <1> ;	SET BAD COMMAND IN STATUS.
   799                              <1> ;
   800                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
   801                              <1> ;-------------------------------------------------------------------------------
   802                              <1> FNC_ERR:				; INVALID FUNCTION REQUEST
   803 00004593 6689F0              <1> 	MOV	AX,SI			; RESTORE AL
   804 00004596 B401                <1> 	MOV	AH,BAD_CMD		; SET BAD COMMAND ERROR
   805 00004598 8825[588A0100]      <1> 	MOV	[DSKETTE_STATUS],AH	; STORE IN DATA AREA
   806 0000459E F9                  <1> 	STC				; SET CARRY INDICATING ERROR
   807 0000459F C3                  <1> 	RETn
   808                              <1> 
   809                              <1> ; 30/08/2020
   810                              <1> ; 29/08/2020
   811                              <1> ; 01/06/2016
   812                              <1> ; 28/05/2016
   813                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v.2.0)
   814                              <1> ;-------------------------------------------------------------------------------
   815                              <1> ; DISK_PARMS	(AH = 08H)	
   816                              <1> ;	READ DRIVE PARAMETERS.
   817                              <1> ;
   818                              <1> ; ON ENTRY:	DI : DRIVE #
   819                              <1> ;		; 27/05/2016
   820                              <1> ;		EBX = Buffer Address for floppy disk parameters table (16 bytes)
   821                              <1> ;
   822                              <1> ; ON EXIT:	CL/[BP]   = BITS 7 & 6 HI 2 BITS OF MAX CYLINDER
   823                              <1> ;		            BITS 0-5 MAX SECTORS/TRACK
   824                              <1> ;		CH/[BP+1] = LOW 8 BITS OF MAX CYLINDER
   825                              <1> ;		BL/[BP+2] = BITS 7-4 = 0
   826                              <1> ;		            BITS 3-0 = VALID CMOS DRIVE TYPE
   827                              <1> ;		BH/[BP+3] = 0
   828                              <1> ;		DL/[BP+4] = # DRIVES INSTALLED (VALUE CHECKED)
   829                              <1> ;		DH/[BP+5] = MAX HEAD #
   830                              <1> ;	     ** 27/05/2016 - TRDOS 386 (TRDOS v2.0) **	
   831                              <1> ;            ** EBX = Buffer address for floppy disk parameters table **
   832                              <1> ;		;DI/[BP+6] = OFFSET TO DISK_BASE
   833                              <1> ;		;ES        = SEGMENT OF DISK_BASE
   834                              <1> ;
   835                              <1> ;		AX        = 0
   836                              <1> ;
   837                              <1> ;		NOTE : THE ABOVE INFORMATION IS STORED IN THE USERS STACK AT
   838                              <1> ;		       THE LOCATIONS WHERE THE MAIN ROUTINE WILL POP THEM
   839                              <1> ;		       INTO THE APPROPRIATE REGISTERS BEFORE RETURNING TO THE
   840                              <1> ;		       CALLER.
   841                              <1> ;-------------------------------------------------------------------------------
   842                              <1> DSK_PARMS:
   843 000045A0 E8DE020000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
   844                              <1>      ;	MOV	WORD [BP+2],0		; DRIVE TYPE = 0
   845                              <1>      ;  MOV     AX, [EQUIP_FLAG]        ; LOAD EQUIPMENT FLAG FOR # DISKETTES
   846                              <1>      ;  AND     AL,11000001B            ; KEEP DISKETTE DRIVE BITS
   847                              <1>      ;  MOV     DL,2                    ; DISKETTE DRIVES = 2
   848                              <1>      ;  CMP     AL,01000001B            ; 2 DRIVES INSTALLED ?
   849                              <1>      ;  JZ      short STO_DL            ; IF YES JUMP
   850                              <1>      ;  DEC     DL                      ; DISKETTE DRIVES = 1
   851                              <1>      ;  CMP     AL,00000001B            ; 1 DRIVE INSTALLED ?
   852                              <1>      ;  JNZ     short NON_DRV           ; IF NO JUMP
   853 000045A5 29D2                <1> 	sub	edx, edx
   854 000045A7 66A1[FE6D0000]      <1> 	mov     ax, [fd0_type]
   855 000045AD 6621C0              <1> 	and     ax, ax
   856 000045B0 0F849B000000        <1>         jz      NON_DRV
   857 000045B6 FEC2                <1> 	inc     dl
   858 000045B8 20E4                <1> 	and     ah, ah
   859 000045BA 7402                <1> 	jz      short STO_DL
   860 000045BC FEC2                <1> 	inc     dl
   861                              <1> STO_DL:
   862                              <1> 	; 30/08/2020
   863 000045BE 6639FA              <1> 	cmp	dx, di
   864 000045C1 0F868A000000        <1> 	jna	NON_DRV
   865                              <1> 	;
   866                              <1> 	;MOV	[BP+4],DL		; STORE NUMBER OF DRIVES
   867 000045C7 895508              <1> 	mov	[ebp+8], edx ; 20/02/2015	 	
   868 000045CA 6683FF01            <1> 	CMP	DI,1			; CHECK FOR VALID DRIVE
   869                              <1> 	;JA	short NON_DRV1		; DRIVE INVALID
   870 000045CE 0F8780000000        <1> 	ja	NON_DRV1 ; 29/08/2020
   871                              <1> 	;MOV	BYTE [BP+5],1		; MAXIMUM HEAD NUMBER =	1
   872 000045D4 C6450901            <1> 	mov	byte [ebp+9], 1  ; 20/02/2015	
   873 000045D8 E8E1080000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
   874                              <1> 	;;20/02/2015
   875                              <1> 	;;JC	short CHK_EST		; IF CMOS BAD CHECKSUM ESTABLISHED
   876                              <1> 	;;OR	AL,AL			; TEST FOR NO DRIVE TYPE
   877 000045DD 740F                <1> 	JZ	short CHK_EST		; JUMP IF SO
   878 000045DF E82B020000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   879 000045E4 7208                <1> 	JC	short CHK_EST		; TYPE NOT IN TABLE (POSSIBLE BAD CMOS)
   880                              <1> 	;MOV	[BP+2],AL		; STORE VALID CMOS DRIVE TYPE
   881                              <1>         ;mov	[ebp+4], al ; 06/02/2015
   882 000045E6 8A4B04              <1> 	MOV     CL, [eBX+MD.SEC_TRK]     ; GET SECTOR/TRACK
   883 000045E9 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]     ; GET MAX. TRACK NUMBER
   884 000045EC EB36                <1> 	JMP	SHORT STO_CX		; CMOS GOOD, USE CMOS
   885                              <1> CHK_EST:
   886 000045EE 8AA7[658A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; LOAD STATE FOR THIS DRIVE
   887 000045F4 F6C410              <1> 	TEST	AH,MED_DET		; CHECK FOR ESTABLISHED STATE
   888 000045F7 745B                <1> 	JZ	short NON_DRV1		; CMOS BAD/INVALID OR UNESTABLISHED
   889                              <1> USE_EST:
   890 000045F9 80E4C0              <1> 	AND	AH,RATE_MSK		; ISOLATE STATE
   891 000045FC 80FC80              <1> 	CMP	AH,RATE_250		; RATE 250 ?
   892 000045FF 757B                <1> 	JNE	short USE_EST2		; NO, GO CHECK OTHER RATE
   893                              <1> 
   894                              <1> ;-----	DATA RATE IS 250 KBS, TRY 360 KB TABLE FIRST
   895                              <1> 
   896 00004601 B001                <1> 	MOV	AL,01			; DRIVE TYPE 1 (360KB)
   897 00004603 E807020000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   898 00004608 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
   899 0000460B 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
   900 0000460E F687[658A0100]01    <1> 	TEST	byte [DSK_STATE+eDI],TRK_CAPA ; 80 TRACK ?
   901 00004615 740D                <1> 	JZ	short STO_CX		; MUST BE 360KB DRIVE 
   902                              <1> 
   903                              <1> ;-----	IT IS 1.44 MB DRIVE
   904                              <1> 
   905                              <1> PARM144:
   906 00004617 B004                <1> 	MOV	AL,04			; DRIVE TYPE 4 (1.44MB)
   907 00004619 E8F1010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   908 0000461E 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
   909 00004621 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
   910                              <1> STO_CX:
   911 00004624 894D00              <1> 	MOV	[eBP],eCX		; SAVE POINTER IN STACK FOR RETURN
   912                              <1> ES_DI:
   913                              <1> 	;MOV	[BP+6],BX		; ADDRESS OF MEDIA/DRIVE PARM TABLE 
   914                              <1> 	;mov	[ebp+12], ebx ; 06/02/2015
   915                              <1> 	;MOV	AX,CS			; SEGMENT MEDIA/DRIVE PARAMETER TABLE
   916                              <1> 	;MOV	ES,AX			; ES IS SEGMENT OF TABLE
   917                              <1> 	;
   918                              <1> 	; 28/05/2016
   919                              <1> 	; 27/05/2016
   920                              <1> 	; return floppy disk parameters table to user
   921                              <1> 	; in user's buffer, which is pointed by EBX
   922                              <1> 	;
   923 00004627 57                  <1> 	push	edi
   924 00004628 8B7D04              <1> 	mov	edi, [ebp+4]  		; ebx (input), user's buffer address
   925                              <1> 	; 29/08/2020
   926 0000462B 09FF                <1> 	or	edi, edi
   927 0000462D 7417                <1> 	jz	short no_copy_fdpt
   928                              <1> 	;
   929 0000462F 0FB6C0              <1> 	movzx	eax, al
   930 00004632 894504              <1>         mov	[ebp+4], eax   ; ebx	; drive type (for floppy drives)
   931                              <1> 	; 01/06/2016 (INT 33h, disk type return for floppy disks, in BL)
   932 00004635 A3[5C960100]        <1> 	mov	[user_buffer], eax	; 01/06/2016 (overwrite ebx return value)
   933                              <1> 	;(INT 33h, Function 08h will replace user's buffer addr with disk type!)
   934                              <1> 	;
   935 0000463A 89DE                <1> 	mov	esi, ebx 		; floppy disk parameter table (16 bytes)
   936 0000463C B910000000          <1> 	mov	ecx, 16 ; 16 bytes
   937 00004641 E8BED40000          <1>         call    transfer_to_user_buffer ; trdosk6.s (16/05/2016)
   938                              <1> no_copy_fdpt:
   939 00004646 5F                  <1> 	pop	edi	
   940                              <1> DP_OUT:
   941 00004647 E868020000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
   942 0000464C 6631C0              <1> 	XOR	AX,AX			; CLEAR
   943 0000464F F8                  <1> 	CLC
   944 00004650 C3                  <1> 	RETn
   945                              <1> 
   946                              <1> ;-----	NO DRIYE PRESENT HANDLER
   947                              <1> 
   948                              <1> NON_DRV:
   949                              <1> 	;MOV	BYTE [BP+4],0		; CLEAR NUMBER OF DRIVES
   950 00004651 895508              <1> 	mov	[ebp+8], edx ; 0 ; 20/02/2015
   951                              <1> NON_DRV1:
   952 00004654 6681FF8000          <1> 	CMP	DI,80H			; CHECK FOR FIXED MEDIA TYPE REQUEST
   953 00004659 720C                <1> 	JB	short NON_DRV2		; CONTINUE IF NOT REQUEST FALL THROUGH
   954                              <1> 
   955                              <1> ;-----	FIXED DISK REQUEST FALL THROUGH ERROR
   956                              <1> 	
   957 0000465B E854020000          <1> 	CALL	XLAT_OLD		; ELSE TRANSLATE TO COMPATIBLE MODE
   958 00004660 6689F0              <1> 	MOV	AX,SI			; RESTORE AL
   959 00004663 B401                <1> 	MOV	AH,BAD_CMD		; SET BAD COMMAND ERROR
   960 00004665 F9                  <1> 	STC
   961 00004666 C3                  <1> 	RETn
   962                              <1> 
   963                              <1> NON_DRV2:
   964                              <1> 	;XOR	AX,AX			; CLEAR PARMS IF NO DRIVES OR CMOS BAD
   965 00004667 31C0                <1> 	xor	eax, eax	
   966 00004669 66894500            <1> 	MOV	[eBP],AX		; TRACKS, SECTORS/TRACK = 0
   967                              <1> 	;MOV	[BP+5],AH		; HEAD = 0
   968 0000466D 886509              <1> 	mov	[ebp+9], ah ; 06/02/2015
   969                              <1> 	;MOV	[BP+6],AX		; OFFSET TO DISK_BASE = 0
   970 00004670 89450C              <1> 	mov	[ebp+12], eax
   971                              <1> 	;;MOV	ES,AX			; ES IS SEGMENT OF TABLE
   972                              <1> 	;JMP	SHORT DP_OUT
   973                              <1> 
   974                              <1> 	; 30/08/2020
   975 00004673 E83C020000          <1> 	call	XLAT_OLD
   976                              <1> 	;mov	ah, NOT_RDY ; drive not ready
   977 00004678 B407                <1> 	mov	ah, INIT_FAIL ; DRIVE PARAMETER ACTIVITY FAILED 
   978 0000467A F9                  <1> 	stc	; cf -> 1, ah = 'drive not ready' error code
   979 0000467B C3                  <1> 	retn		
   980                              <1> 
   981                              <1> ;-----	DATA RATE IS EITHER 300 KBS OR 500 KBS, TRY 1.2 MB TABLE FIRST
   982                              <1> 
   983                              <1> USE_EST2:
   984 0000467C B002                <1> 	MOV	AL,02			; DRIVE TYPE 2 (1.2MB)
   985 0000467E E88C010000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
   986 00004683 8A4B04              <1>         MOV     CL, [eBX+MD.SEC_TRK]    ; GET SECTOR/TRACK
   987 00004686 8A6B0B              <1>         MOV     CH, [eBX+MD.MAX_TRK]    ; GET MAX. TRACK NUMBER
   988 00004689 80FC40              <1> 	CMP	AH,RATE_300		; RATE 300 ?
   989 0000468C 7496                <1> 	JZ	short STO_CX		; MUST BE 1.2MB DRIVE
   990 0000468E EB87                <1> 	JMP	SHORT PARM144		; ELSE, IT IS 1.44MB DRIVE 
   991                              <1> 
   992                              <1> ; 30/08/2020
   993                              <1> 
   994                              <1> ;-------------------------------------------------------------------------------
   995                              <1> ; DISK_TYPE (AH = 15H)	
   996                              <1> ;	THIS ROUTINE RETURNS THE TYPE OF MEDIA INSTALLED.
   997                              <1> ;
   998                              <1> ;  ON ENTRY:	DI = DRIVE #
   999                              <1> ;
  1000                              <1> ;  ON EXIT:	AH = DRIVE TYPE, CY=0
  1001                              <1> ;-------------------------------------------------------------------------------
  1002                              <1> DSK_TYPE:
  1003 00004690 E8EE010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1004 00004695 8A87[658A0100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; GET PRESENT STATE INFORMATION
  1005 0000469B 08C0                <1> 	OR	AL,AL			; CHECK FOR NO DRIVE
  1006 0000469D 7418                <1> 	JZ	short NO_DRV
  1007 0000469F B401                <1> 	MOV	AH,NOCHGLN		; NO CHANGE LINE FOR 40 TRACK DRIVE
  1008 000046A1 A801                <1> 	TEST	AL,TRK_CAPA		; IS THIS DRIVE AN 80 TRACK DRIVE?
  1009 000046A3 7402                <1> 	JZ	short DT_BACK		; IF NO JUMP
  1010 000046A5 B402                <1> 	MOV	AH,CHGLN		; CHANGE LINE FOR 80 TRACK DRIVE
  1011                              <1> DT_BACK:
  1012 000046A7 6650                <1> 	PUSH	AX			; SAVE RETURN VALUE
  1013 000046A9 E806020000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1014 000046AE 6658                <1> 	POP	AX			; RESTORE RETURN VALUE
  1015 000046B0 F8                  <1> 	CLC				; NO ERROR
  1016 000046B1 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  1017 000046B4 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  1018 000046B6 C3                  <1> 	RETn
  1019                              <1> NO_DRV:	
  1020                              <1> 	;XOR	AH,AH			; NO DRIVE PRESENT OR UNKNOWN
  1021                              <1> 	;JMP	SHORT DT_BACK
  1022                              <1> 	
  1023                              <1> 	; 30/08/2020
  1024 000046B7 E8F8010000          <1> 	call	XLAT_OLD
  1025 000046BC 29C0                <1> 	sub	eax, eax
  1026 000046BE F9                  <1> 	stc	; cf = 1 -> drive not ready, ah = 0 (disk type = 0)
  1027 000046BF C3                  <1> 	retn
  1028                              <1> 
  1029                              <1> ;-------------------------------------------------------------------------------
  1030                              <1> ; DISK_CHANGE	(AH = 16H)
  1031                              <1> ;	THIS ROUTINE RETURNS THE STATE OF THE DISK CHANGE LINE.
  1032                              <1> ;
  1033                              <1> ; ON ENTRY:	DI = DRIVE #
  1034                              <1> ;
  1035                              <1> ; ON EXIT:	AH = @DSKETTE_STATUS
  1036                              <1> ;		     00 - DISK CHANGE LINE INACTIVE, CY = 0
  1037                              <1> ;		     06 - DISK CHANGE LINE ACTIVE, CY = 1
  1038                              <1> ;-------------------------------------------------------------------------------
  1039                              <1> DSK_CHANGE:
  1040 000046C0 E8BE010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1041 000046C5 8A87[658A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET MEDIA STATE INFORMATION
  1042 000046CB 08C0                <1> 	OR	AL,AL			; DRIVE PRESENT ?
  1043 000046CD 7422                <1> 	JZ	short DC_NON		; JUMP IF NO DRIVE
  1044 000046CF A801                <1> 	TEST	AL,TRK_CAPA		; 80 TRACK DRIVE ?
  1045 000046D1 7407                <1> 	JZ	short SETIT		; IF SO , CHECK CHANGE LINE
  1046                              <1> DC0:
  1047 000046D3 E88D0A0000          <1>         CALL    READ_DSKCHNG            ; GO CHECK STATE OF DISK CHANGE LINE
  1048 000046D8 7407                <1> 	JZ	short FINIS		; CHANGE LINE NOT ACTIVE
  1049                              <1> 
  1050 000046DA C605[588A0100]06    <1> SETIT:	MOV	byte [DSKETTE_STATUS], MEDIA_CHANGE ; INDICATE MEDIA REMOVED
  1051                              <1> 
  1052 000046E1 E8CE010000          <1> FINIS:	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1053 000046E6 E808070000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1054 000046EB 6689F3              <1> 	MOV	BX,SI			; GET SAVED AL TO BL
  1055 000046EE 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  1056 000046F0 C3                  <1> 	RETn
  1057                              <1> DC_NON:
  1058 000046F1 800D[588A0100]80    <1> 	OR	byte [DSKETTE_STATUS], TIME_OUT ; SET TIMEOUT, NO DRIVE
  1059 000046F8 EBE7                <1> 	JMP	SHORT FINIS
  1060                              <1> 
  1061                              <1> ;-------------------------------------------------------------------------------
  1062                              <1> ; FORMAT_SET	(AH = 17H)
  1063                              <1> ;	THIS ROUTINE IS USED TO ESTABLISH THE TYPE OF MEDIA TO BE USED
  1064                              <1> ;	FOR THE FOLLOWING FORMAT OPERATION.
  1065                              <1> ;
  1066                              <1> ; ON ENTRY:	SI LOW = DASD TYPE FOR FORMAT
  1067                              <1> ;		DI     = DRIVE #
  1068                              <1> ;
  1069                              <1> ; ON EXIT:	@DSKETTE_STATUS REFLECTS STATUS
  1070                              <1> ;		AH = @DSKETTE_STATUS
  1071                              <1> ;		CY = 1 IF ERROR
  1072                              <1> ;-------------------------------------------------------------------------------
  1073                              <1> FORMAT_SET:
  1074 000046FA E884010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1075 000046FF 6656                <1> 	PUSH	SI			; SAVE DASD TYPE
  1076 00004701 6689F0              <1> 	MOV	AX,SI			; AH = ? , AL , DASD TYPE
  1077 00004704 30E4                <1> 	XOR	AH,AH			; AH , 0 , AL , DASD TYPE
  1078 00004706 6689C6              <1> 	MOV	SI,AX			; SI = DASD TYPE
  1079 00004709 80A7[658A0100]0F    <1> 	AND	byte [DSK_STATE+eDI], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  1080 00004710 664E                <1> 	DEC	SI			; CHECK FOR 320/360K MEDIA & DRIVE
  1081 00004712 7509                <1> 	JNZ	short NOT_320		; BYPASS IF NOT
  1082 00004714 808F[658A0100]90    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+RATE_250 ; SET TO 320/360
  1083 0000471B EB48                <1> 	JMP	SHORT S0
  1084                              <1> 
  1085                              <1> NOT_320:
  1086 0000471D E8B6030000          <1> 	CALL	MED_CHANGE		; CHECK FOR TIME_OUT
  1087 00004722 803D[588A0100]80    <1> 	CMP	byte [DSKETTE_STATUS], TIME_OUT
  1088 00004729 743A                <1> 	JZ	short S0		; IF TIME OUT TELL CALLER
  1089                              <1> S3:
  1090 0000472B 664E                <1> 	DEC	SI			; CHECK FOR 320/360K IN 1.2M DRIVE
  1091 0000472D 7509                <1> 	JNZ	short NOT_320_12	; BYPASS IF NOT
  1092 0000472F 808F[658A0100]70    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+DBL_STEP+RATE_300 ; SET STATE
  1093 00004736 EB2D                <1> 	JMP	SHORT S0
  1094                              <1> 
  1095                              <1> NOT_320_12:
  1096 00004738 664E                <1> 	DEC	SI			; CHECK FOR 1.2M MEDIA IN 1.2M DRIVE
  1097 0000473A 7509                <1> 	JNZ	short NOT_12		; BYPASS IF NOT
  1098 0000473C 808F[658A0100]10    <1> 	OR	byte [DSK_STATE+eDI], MED_DET+RATE_500 ; SET STATE VARIABLE
  1099 00004743 EB20                <1> 	JMP	SHORT S0		; RETURN TO CALLER
  1100                              <1> 
  1101                              <1> NOT_12:	
  1102 00004745 664E                <1> 	DEC	SI			; CHECK FOR SET DASD TYPE 04
  1103 00004747 752B                <1> 	JNZ	short FS_ERR		; BAD COMMAND EXIT IF NOT VALID TYPE
  1104                              <1> 
  1105 00004749 F687[658A0100]04    <1> 	TEST	byte [DSK_STATE+eDI], DRV_DET ; DRIVE DETERMINED ?
  1106 00004750 740B                <1> 	JZ	short ASSUME		; IF STILL NOT DETERMINED ASSUME
  1107 00004752 B050                <1> 	MOV	AL,MED_DET+RATE_300
  1108 00004754 F687[658A0100]02    <1>         TEST    byte [DSK_STATE+eDI], FMT_CAPA ; MULTIPLE FORMAT CAPABILITY ?
  1109 0000475B 7502                <1> 	JNZ	short OR_IT_IN		; IF 1.2 M THEN DATA RATE 300
  1110                              <1> 
  1111                              <1> ASSUME:
  1112 0000475D B090                <1> 	MOV	AL,MED_DET+RATE_250	; SET UP
  1113                              <1> 
  1114                              <1> OR_IT_IN:
  1115 0000475F 0887[658A0100]      <1> 	OR	[DSK_STATE+eDI], AL	; OR IN THE CORRECT STATE
  1116                              <1> S0:
  1117 00004765 E84A010000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1118 0000476A E884060000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1119 0000476F 665B                <1> 	POP	BX			; GET SAVED AL TO BL
  1120 00004771 88D8                <1> 	MOV	AL,BL			; PUT BACK FOR RETURN
  1121 00004773 C3                  <1> 	RETn
  1122                              <1> 
  1123                              <1> FS_ERR:
  1124 00004774 C605[588A0100]01    <1> 	MOV	byte [DSKETTE_STATUS], BAD_CMD ; UNKNOWN STATE,BAD COMMAND
  1125 0000477B EBE8                <1> 	JMP	SHORT S0
  1126                              <1> 
  1127                              <1> ;-------------------------------------------------------------------------------
  1128                              <1> ; SET_MEDIA	(AH = 18H)
  1129                              <1> ;	THIS ROUTINE SETS THE TYPE OF MEDIA AND DATA RATE 
  1130                              <1> ;	TO BE USED FOR THE FOLLOWING FORMAT OPERATION.
  1131                              <1> ;
  1132                              <1> ; ON ENTRY:
  1133                              <1> ;	[BP]	= SECTOR PER TRACK
  1134                              <1> ;	[BP+1]	= TRACK #
  1135                              <1> ;	DI	= DRIVE #
  1136                              <1> ;
  1137                              <1> ; ON EXIT:
  1138                              <1> ;	@DSKETTE_STATUS REFLECTS STATUS
  1139                              <1> ;	IF NO ERROR:
  1140                              <1> ;		AH = 0
  1141                              <1> ;		CY = 0
  1142                              <1> ;		ES = SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  1143                              <1> ;		DI/[BP+6] = OFFSET OF MEDIA/DRIVE PARAMETER TABLE
  1144                              <1> ;	IF ERROR:	
  1145                              <1> ;		AH = @DSKETTE_STATUS
  1146                              <1> ;		CY = 1
  1147                              <1> ;-------------------------------------------------------------------------------
  1148                              <1> SET_MEDIA:
  1149 0000477D E801010000          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1150 00004782 F687[658A0100]01    <1>         TEST    byte [DSK_STATE+eDI], TRK_CAPA ; CHECK FOR CHANGE LINE AVAILABLE
  1151 00004789 7415                <1> 	JZ	short SM_CMOS		; JUMP IF 40 TRACK DRIVE
  1152 0000478B E848030000          <1> 	CALL	MED_CHANGE		; RESET CHANGE LINE
  1153 00004790 803D[588A0100]80    <1> 	CMP	byte [DSKETTE_STATUS], TIME_OUT ; IF TIME OUT TELL CALLER
  1154 00004797 746B                <1> 	JE	short SM_RTN
  1155 00004799 C605[588A0100]00    <1> 	MOV	byte [DSKETTE_STATUS], 0 ; CLEAR STATUS
  1156                              <1> SM_CMOS:
  1157 000047A0 E819070000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  1158                              <1> 	;;20/02/2015
  1159                              <1> 	;;JC	short MD_NOT_FND	; ERROR IN CMOS
  1160                              <1> 	;;OR	AL,AL			; TEST FOR NO DRIVE
  1161 000047A5 745D                <1> 	JZ	short SM_RTN		; RETURN IF SO
  1162 000047A7 E863000000          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL
  1163 000047AC 7231                <1> 	JC	short MD_NOT_FND	; TYPE NOT IN TABLE (BAD CMOS)
  1164 000047AE 57                  <1> 	PUSH	eDI			; SAVE REG.
  1165 000047AF 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR. TYPE TABLE
  1166 000047B1 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  1167                              <1> DR_SEARCH:
  1168 000047B6 8AA3[786D0000]      <1> 	MOV	AH, [DR_TYPE+eBX]	; GET DRIVE TYPE
  1169 000047BC 80E47F              <1> 	AND	AH,BIT7OFF		; MASK OUT MSB
  1170 000047BF 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH ?
  1171 000047C1 7516                <1> 	JNE	short NXT_MD		; NO, CHECK NEXT DRIVE TYPE
  1172                              <1> DR_FND:
  1173 000047C3 8BBB[796D0000]      <1> 	MOV	eDI, [DR_TYPE+eBX+1] 	; DI = MEDIA/DRIVE PARAM TABLE
  1174                              <1> MD_SEARCH:
  1175 000047C9 8A6704              <1>         MOV     AH, [eDI+MD.SEC_TRK]    ; GET SECTOR/TRACK
  1176 000047CC 386500              <1> 	CMP	[eBP],AH		; MATCH?
  1177 000047CF 7508                <1> 	JNE	short NXT_MD		; NO, CHECK NEXT MEDIA
  1178 000047D1 8A670B              <1>         MOV     AH, [eDI+MD.MAX_TRK]    ; GET MAX. TRACK #
  1179 000047D4 386501              <1> 	CMP 	[eBP+1],AH		; MATCH?
  1180 000047D7 740F                <1> 	JE	short MD_FND		; YES, GO GET RATE
  1181                              <1> NXT_MD:
  1182                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  1183 000047D9 83C305              <1>         add	ebx, 5 ; 18/02/2015
  1184 000047DC E2D8                <1> 	LOOP    DR_SEARCH
  1185 000047DE 5F                  <1> 	POP	eDI			; RESTORE REG.
  1186                              <1> MD_NOT_FND:
  1187 000047DF C605[588A0100]0C    <1> 	MOV	byte [DSKETTE_STATUS], MED_NOT_FND ; ERROR, MEDIA TYPE NOT FOUND
  1188 000047E6 EB1C                <1> 	JMP	SHORT SM_RTN		; RETURN
  1189                              <1> MD_FND:
  1190 000047E8 8A470C              <1>         MOV     AL, [eDI+MD.RATE]       ; GET RATE
  1191 000047EB 3C40                <1> 	CMP	AL,RATE_300		; DOUBLE STEP REQUIRED FOR RATE 300
  1192 000047ED 7502                <1> 	JNE	short MD_SET
  1193 000047EF 0C20                <1> 	OR	AL,DBL_STEP
  1194                              <1> MD_SET:
  1195                              <1> 	;MOV	[BP+6],DI		; SAVE TABLE POINTER IN STACK
  1196 000047F1 897D0C              <1> 	mov	[ebp+12], edi ; 18/02/2015
  1197 000047F4 0C10                <1> 	OR	AL,MED_DET		; SET MEDIA ESTABLISHED
  1198 000047F6 5F                  <1> 	POP	eDI
  1199 000047F7 80A7[658A0100]0F    <1> 	AND	byte [DSK_STATE+eDI], ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR STATE
  1200 000047FE 0887[658A0100]      <1> 	OR	[DSK_STATE+eDI], AL
  1201                              <1> 	;MOV	AX, CS			; SEGMENT OF MEDIA/DRIVE PARAMETER TABLE
  1202                              <1> 	;MOV	ES, AX			; ES IS SEGMENT OF TABLE
  1203                              <1> SM_RTN:
  1204 00004804 E8AB000000          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1205 00004809 E8E5050000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1206 0000480E C3                  <1> 	RETn
  1207                              <1> 
  1208                              <1> ;----------------------------------------------------------------
  1209                              <1> ; DR_TYPE_CHECK							:
  1210                              <1> ;	CHECK IF THE GIVEN DRIVE TYPE IN REGISTER (AL)		:
  1211                              <1> ;	IS SUPPORTED IN BIOS DRIVE TYPE TABLE			:
  1212                              <1> ; ON ENTRY:							:
  1213                              <1> ;	AL = DRIVE TYPE						:
  1214                              <1> ; ON EXIT:							:
  1215                              <1> ;	CS = SEGMENT MEDIA/DRIVE PARAMETER TABLE (CODE)		:
  1216                              <1> ;	CY = 0 	DRIVE TYPE SUPPORTED				:
  1217                              <1> ;	     BX = OFFSET TO MEDIA/DRIVE PARAMETER TABLE		:
  1218                              <1> ;	CY = 1	DRIVE TYPE NOT SUPPORTED 			:
  1219                              <1> ; REGISTERS ALTERED: eBX						:
  1220                              <1> ;----------------------------------------------------------------		
  1221                              <1> DR_TYPE_CHECK:
  1222 0000480F 6650                <1> 	PUSH	AX			
  1223 00004811 51                  <1> 	PUSH	eCX
  1224 00004812 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR_TYPE TABLE
  1225 00004814 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  1226                              <1> TYPE_CHK:	
  1227 00004819 8AA3[786D0000]      <1> 	MOV	AH,[DR_TYPE+eBX]	; GET DRIVE TYPE
  1228 0000481F 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH?
  1229 00004821 740D                <1> 	JE	short DR_TYPE_VALID	; YES, RETURN WITH CARRY RESET
  1230                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  1231 00004823 83C305              <1>         add	ebx, 5	; 16/02/2015 (32 bit address modification)
  1232 00004826 E2F1                <1> 	LOOP    TYPE_CHK
  1233                              <1> 	;
  1234 00004828 BB[D76D0000]        <1> 	mov	ebx, MD_TBL6		; 1.44MB fd parameter table
  1235                              <1> 					; Default for GET_PARM (11/12/2014)
  1236                              <1> 	;
  1237 0000482D F9                  <1> 	STC				; DRIVE TYPE NOT FOUND IN TABLE
  1238 0000482E EB06                <1> 	JMP	SHORT TYPE_RTN
  1239                              <1> DR_TYPE_VALID:
  1240 00004830 8B9B[796D0000]      <1> 	MOV	eBX,[DR_TYPE+eBX+1] 	; BX = MEDIA TABLE
  1241                              <1> TYPE_RTN:
  1242 00004836 59                  <1> 	POP	eCX
  1243 00004837 6658                <1> 	POP	AX
  1244 00004839 C3                  <1> 	RETn	
  1245                              <1> 		
  1246                              <1> ;----------------------------------------------------------------
  1247                              <1> ; SEND_SPEC							:
  1248                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  1249                              <1> ;	THE DRIVE PARAMETER TABLE POINTED BY @DISK_POINTER	:
  1250                              <1> ; ON ENTRY:	@DISK_POINTER = DRIVE PARAMETER TABLE		:
  1251                              <1> ; ON EXIT:	NONE						:	
  1252                              <1> ; REGISTERS ALTERED: CX, DX					:
  1253                              <1> ;----------------------------------------------------------------		
  1254                              <1> SEND_SPEC:
  1255 0000483A 50                  <1> 	PUSH	eAX			; SAVE AX
  1256 0000483B B8[61480000]        <1> 	MOV	eAX, SPECBAC		; LOAD ERROR ADDRESS
  1257 00004840 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  1258 00004841 B403                <1> 	MOV	AH,03H			; SPECIFY COMMAND
  1259 00004843 E885070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1260 00004848 28D2                <1> 	SUB	DL,DL			; FIRST SPECIFY BYTE
  1261 0000484A E878060000          <1> 	CALL	GET_PARM		; GET PARAMETER TO AH
  1262 0000484F E879070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1263 00004854 B201                <1> 	MOV	DL,1			; SECOND SPECIFY BYTE
  1264 00004856 E86C060000          <1> 	CALL	GET_PARM		; GET PARAMETER TO AH
  1265 0000485B E86D070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1266 00004860 58                  <1> 	POP	eAX			; POP ERROR RETURN
  1267                              <1> SPECBAC:
  1268 00004861 58                  <1> 	POP	eAX			; RESTORE ORIGINAL AX VALUE
  1269 00004862 C3                  <1> 	RETn
  1270                              <1> 
  1271                              <1> ;----------------------------------------------------------------
  1272                              <1> ; SEND_SPEC_MD							:
  1273                              <1> ;	SEND THE SPECIFY COMMAND TO CONTROLLER USING DATA FROM	:
  1274                              <1> ;	THE MEDIA/DRIVE PARAMETER TABLE POINTED BY (CS:BX)	:
  1275                              <1> ; ON ENTRY:	CS:BX = MEDIA/DRIVE PARAMETER TABLE		:
  1276                              <1> ; ON EXIT:	NONE						:	
  1277                              <1> ; REGISTERS ALTERED: AX						:
  1278                              <1> ;----------------------------------------------------------------		
  1279                              <1> SEND_SPEC_MD:
  1280 00004863 50                  <1> 	PUSH	eAX			; SAVE RATE DATA
  1281 00004864 B8[81480000]        <1> 	MOV	eAX, SPEC_ESBAC		; LOAD ERROR ADDRESS
  1282 00004869 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  1283 0000486A B403                <1> 	MOV	AH,03H			; SPECIFY COMMAND
  1284 0000486C E85C070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1285 00004871 8A23                <1>         MOV     AH, [eBX+MD.SPEC1]      ; GET 1ST SPECIFY BYTE
  1286 00004873 E855070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1287 00004878 8A6301              <1>         MOV     AH, [eBX+MD.SPEC2]      ; GET SECOND SPECIFY BYTE
  1288 0000487B E84D070000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE COMMAND
  1289 00004880 58                  <1> 	POP	eAX			; POP ERROR RETURN
  1290                              <1> SPEC_ESBAC:
  1291 00004881 58                  <1> 	POP	eAX			; RESTORE ORIGINAL AX VALUE
  1292 00004882 C3                  <1> 	RETn
  1293                              <1> 
  1294                              <1> ;-------------------------------------------------------------------------------
  1295                              <1> ; XLAT_NEW  
  1296                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM COMPATIBLE
  1297                              <1> ;	MODE TO NEW ARCHITECTURE.
  1298                              <1> ;
  1299                              <1> ; ON ENTRY:	DI = DRIVE #
  1300                              <1> ;-------------------------------------------------------------------------------
  1301                              <1> XLAT_NEW:
  1302 00004883 83FF01              <1> 	CMP	eDI,1				; VALID DRIVE
  1303 00004886 7725                <1> 	JA	short XN_OUT			; IF INVALID BACK
  1304 00004888 80BF[658A0100]00    <1> 	CMP	byte [DSK_STATE+eDI], 0		; NO DRIVE ?
  1305 0000488F 741D                <1> 	JZ	short DO_DET			; IF NO DRIVE ATTEMPT DETERMINE
  1306 00004891 6689F9              <1> 	MOV	CX,DI				; CX = DRIVE NUMBER
  1307 00004894 C0E102              <1> 	SHL	CL,2				; CL = SHIFT COUNT, A=0, B=4
  1308 00004897 A0[648A0100]        <1> 	MOV	AL, [HF_CNTRL]			; DRIVE INFORMATION
  1309 0000489C D2C8                <1> 	ROR	AL,CL				; TO LOW NIBBLE
  1310 0000489E 2407                <1> 	AND	AL,DRV_DET+FMT_CAPA+TRK_CAPA	; KEEP DRIVE BITS
  1311 000048A0 80A7[658A0100]F8    <1>         AND     byte [DSK_STATE+eDI], ~(DRV_DET+FMT_CAPA+TRK_CAPA)
  1312 000048A7 0887[658A0100]      <1> 	OR	[DSK_STATE+eDI], AL		; UPDATE DRIVE STATE
  1313                              <1> XN_OUT:
  1314 000048AD C3                  <1> 	RETn
  1315                              <1> DO_DET:
  1316 000048AE E8BF080000          <1> 	CALL	DRIVE_DET			; TRY TO DETERMINE
  1317 000048B3 C3                  <1> 	RETn
  1318                              <1> 
  1319                              <1> ;-------------------------------------------------------------------------------
  1320                              <1> ; XLAT_OLD 
  1321                              <1> ;	TRANSLATES DISKETTE STATE LOCATIONS FROM NEW
  1322                              <1> ;	ARCHITECTURE TO COMPATIBLE MODE.
  1323                              <1> ;
  1324                              <1> ; ON ENTRY:	DI = DRIVE
  1325                              <1> ;-------------------------------------------------------------------------------
  1326                              <1> XLAT_OLD:
  1327 000048B4 83FF01              <1> 	CMP	eDI,1			; VALID DRIVE ?
  1328                              <1>         ;JA     short XO_OUT            ; IF INVALID BACK
  1329 000048B7 0F8786000000        <1>         ja      XO_OUT
  1330 000048BD 80BF[658A0100]00    <1>         CMP	byte [DSK_STATE+eDI],0	; NO DRIVE ?
  1331 000048C4 747D                <1> 	JZ	short XO_OUT		; IF NO DRIVE TRANSLATE DONE
  1332                              <1> 
  1333                              <1> ;-----	TEST FOR SAVED DRIVE INFORMATION ALREADY SET
  1334                              <1> 
  1335 000048C6 6689F9              <1> 	MOV	CX,DI			; CX = DRIVE NUMBER
  1336 000048C9 C0E102              <1> 	SHL	CL,2			; CL = SHIFT COUNT, A=0, B=4
  1337 000048CC B402                <1> 	MOV	AH,FMT_CAPA		; LOAD MULTIPLE DATA RATE BIT MASK
  1338 000048CE D2CC                <1> 	ROR	AH,CL			; ROTATE BY MASK
  1339 000048D0 8425[648A0100]      <1> 	TEST	[HF_CNTRL], AH		; MULTIPLE-DATA RATE DETERMINED ?
  1340 000048D6 751C                <1> 	JNZ	short SAVE_SET		; IF SO, NO NEED TO RE-SAVE
  1341                              <1> 
  1342                              <1> ;-----	ERASE DRIVE BITS IN @HF_CNTRL FOR THIS DRIVE
  1343                              <1> 
  1344 000048D8 B407                <1> 	MOV	AH,DRV_DET+FMT_CAPA+TRK_CAPA ; MASK TO KEEP
  1345 000048DA D2CC                <1> 	ROR	AH,CL			; FIX MASK TO KEEP
  1346 000048DC F6D4                <1> 	NOT	AH			; TRANSLATE MASK
  1347 000048DE 2025[648A0100]      <1> 	AND	[HF_CNTRL], AH		; KEEP BITS FROM OTHER DRIVE INTACT
  1348                              <1> 
  1349                              <1> ;-----	ACCESS CURRENT DRIVE BITS AND STORE IN @HF_CNTRL
  1350                              <1> 
  1351 000048E4 8A87[658A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; ACCESS STATE
  1352 000048EA 2407                <1> 	AND	AL,DRV_DET+FMT_CAPA+TRK_CAPA ; KEEP DRIVE BITS
  1353 000048EC D2C8                <1> 	ROR	AL,CL			; FIX FOR THIS DRIVE
  1354 000048EE 0805[648A0100]      <1> 	OR	[HF_CNTRL], AL		; UPDATE SAVED DRIVE STATE
  1355                              <1> 
  1356                              <1> ;-----	TRANSLATE TO COMPATIBILITY MODE
  1357                              <1> 
  1358                              <1> SAVE_SET:
  1359 000048F4 8AA7[658A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; ACCESS STATE
  1360 000048FA 88E7                <1> 	MOV	BH,AH			; TO BH FOR LATER
  1361 000048FC 80E4C0              <1> 	AND	AH,RATE_MSK		; KEEP ONLY RATE
  1362 000048FF 80FC00              <1> 	CMP	AH,RATE_500		; RATE 500 ?
  1363 00004902 7410                <1> 	JZ	short CHK_144		; YES 1.2/1.2 OR 1.44/1.44
  1364 00004904 B001                <1> 	MOV	AL,M3D1U		; AL = 360 IN 1.2 UNESTABLISHED
  1365 00004906 80FC40              <1> 	CMP	AH,RATE_300		; RATE 300 ?
  1366 00004909 7518                <1> 	JNZ	short CHK_250		; NO, 360/360, 720/720 OR 720/1.44
  1367 0000490B F6C720              <1> 	TEST	BH,DBL_STEP		; CHECK FOR DOUBLE STEP
  1368 0000490E 751F                <1> 	JNZ	short TST_DET		; MUST BE 360 IN 1.2
  1369                              <1> UNKNO:
  1370 00004910 B007                <1> 	MOV	AL,MED_UNK		; NONE OF THE ABOVE
  1371 00004912 EB22                <1> 	JMP	SHORT AL_SET		; PROCESS COMPLETE
  1372                              <1> CHK_144:
  1373 00004914 E8A5050000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  1374                              <1> 	;;20/02/2015
  1375                              <1> 	;;JC	short UNKNO		; ERROR, SET 'NONE OF ABOVE'
  1376 00004919 74F5                <1> 	jz	short UNKNO ;; 20/02/2015
  1377 0000491B 3C02                <1> 	CMP	AL,2			; 1.2MB DRIVE ?
  1378 0000491D 75F1                <1> 	JNE	short UNKNO		; NO, GO SET 'NONE OF ABOVE'
  1379 0000491F B002                <1> 	MOV	AL,M1D1U		; AL = 1.2 IN 1.2 UNESTABLISHED
  1380 00004921 EB0C                <1> 	JMP	SHORT TST_DET
  1381                              <1> CHK_250:
  1382 00004923 B000                <1> 	MOV	AL,M3D3U		; AL = 360 IN 360 UNESTABLISHED
  1383 00004925 80FC80              <1> 	CMP	AH,RATE_250		; RATE 250 ?
  1384 00004928 75E6                <1> 	JNZ	short UNKNO		; IF SO FALL IHRU
  1385 0000492A F6C701              <1> 	TEST	BH,TRK_CAPA		; 80 TRACK CAPABILITY ?
  1386 0000492D 75E1                <1> 	JNZ	short UNKNO		; IF SO JUMP, FALL THRU TEST DET
  1387                              <1> TST_DET:
  1388 0000492F F6C710              <1> 	TEST	BH,MED_DET		; DETERMINED ?
  1389 00004932 7402                <1> 	JZ	short AL_SET		; IF NOT THEN SET
  1390 00004934 0403                <1> 	ADD	AL,3			; MAKE DETERMINED/ESTABLISHED
  1391                              <1> AL_SET:
  1392 00004936 80A7[658A0100]F8    <1> 	AND	byte [DSK_STATE+eDI], ~(DRV_DET+FMT_CAPA+TRK_CAPA) ; CLEAR DRIVE
  1393 0000493D 0887[658A0100]      <1> 	OR	[DSK_STATE+eDI], AL	; REPLACE WITH COMPATIBLE MODE
  1394                              <1> XO_OUT:
  1395 00004943 C3                  <1> 	RETn
  1396                              <1> 
  1397                              <1> ;-------------------------------------------------------------------------------
  1398                              <1> ; RD_WR_VF
  1399                              <1> ;	COMMON READ, WRITE AND VERIFY: 
  1400                              <1> ;	MAIN LOOP FOR STATE RETRIES.
  1401                              <1> ;
  1402                              <1> ; ON ENTRY:	AH = READ/WRITE/VERIFY NEC PARAMETER
  1403                              <1> ;		AL = READ/WRITE/VERIFY DMA PARAMETER
  1404                              <1> ;
  1405                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1406                              <1> ;-------------------------------------------------------------------------------
  1407                              <1> RD_WR_VF:
  1408 00004944 6650                <1> 	PUSH	AX			; SAVE DMA, NEC PARAMETERS
  1409 00004946 E838FFFFFF          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH.
  1410 0000494B E8F3000000          <1> 	CALL	SETUP_STATE		; INITIALIZE START AND END RATE
  1411 00004950 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY
  1412                              <1> DO_AGAIN:
  1413 00004952 6650                <1> 	PUSH	AX			; SAVE READ/WRITE/VERIFY PARAMETER
  1414 00004954 E87F010000          <1> 	CALL	MED_CHANGE		; MEDIA CHANGE AND RESET IF CHANGED
  1415 00004959 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY
  1416 0000495B 0F82C9000000        <1>         JC      RWV_END                 ; MEDIA CHANGE ERROR OR TIME-OUT
  1417                              <1> RWV:
  1418 00004961 6650                <1> 	PUSH	AX			; SAVE READ/WRITE/VERIFY PARAMETER
  1419 00004963 8AB7[658A0100]      <1> 	MOV	DH, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  1420 00004969 80E6C0              <1> 	AND	DH,RATE_MSK		; KEEP ONLY RATE
  1421 0000496C E84D050000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL (AL)
  1422                              <1> 	;;20/02/2015
  1423                              <1> 	;;JC	short RWV_ASSUME	; ERROR IN CMOS
  1424 00004971 7451                <1> 	jz	short RWV_ASSUME ; 20/02/2015
  1425 00004973 3C01                <1> 	CMP	AL,1			; 40 TRACK DRIVE?
  1426 00004975 750D                <1> 	JNE	short RWV_1		; NO, BYPASS CMOS VALIDITY CHECK
  1427 00004977 F687[658A0100]01    <1> 	TEST	byte [DSK_STATE+eDI], TRK_CAPA ; CHECK FOR 40 TRACK DRIVE
  1428 0000497E 7413                <1> 	JZ	short RWV_2		; YES, CMOS IS CORRECT
  1429 00004980 B002                <1> 	MOV	AL,2			; CHANGE TO 1.2M
  1430 00004982 EB0F                <1> 	JMP	SHORT RWV_2
  1431                              <1> RWV_1:
  1432 00004984 720D                <1> 	JB	short RWV_2		; NO DRIVE SPECIFIED, CONTINUE
  1433 00004986 F687[658A0100]01    <1> 	TEST    byte [DSK_STATE+eDI], TRK_CAPA ; IS IT REALLY 40 TRACK?
  1434 0000498D 7504                <1> 	JNZ	short RWV_2		; NO, 80 TRACK
  1435 0000498F B001                <1> 	MOV	AL,1			; IT IS 40 TRACK, FIX CMOS VALUE
  1436 00004991 EB04                <1> 	jmp	short rwv_3
  1437                              <1> RWV_2:
  1438 00004993 08C0                <1> 	OR	AL,AL			; TEST FOR NO DRIVE
  1439 00004995 742D                <1> 	JZ	short RWV_ASSUME	; ASSUME TYPE, USE MAX TRACK
  1440                              <1> rwv_3:
  1441 00004997 E873FEFFFF          <1> 	CALL	DR_TYPE_CHECK		; RTN CS:BX = MEDIA/DRIVE PARAM TBL.
  1442 0000499C 7226                <1> 	JC	short RWV_ASSUME	; TYPE NOT IN TABLE (BAD CMOS)
  1443                              <1> 
  1444                              <1> ;-----	SEARCH FOR MEDIA/DRIVE PARAMETER TABLE
  1445                              <1> 
  1446 0000499E 57                  <1> 	PUSH	eDI			; SAVE DRIVE #
  1447 0000499F 31DB                <1> 	XOR	eBX,eBX			; BX = INDEX TO DR_TYPE TABLE
  1448 000049A1 B906000000          <1> 	MOV	eCX,DR_CNT		; CX = LOOP COUNT
  1449                              <1> RWV_DR_SEARCH:
  1450 000049A6 8AA3[786D0000]      <1> 	MOV	AH, [DR_TYPE+eBX]	; GET DRIVE TYPE
  1451 000049AC 80E47F              <1> 	AND	AH,BIT7OFF		; MASK OUT MSB
  1452 000049AF 38E0                <1> 	CMP	AL,AH			; DRIVE TYPE MATCH?
  1453 000049B1 750B                <1> 	JNE	short RWV_NXT_MD	; NO, CHECK NEXT DRIVE TYPE
  1454                              <1> RWV_DR_FND:
  1455 000049B3 8BBB[796D0000]      <1> 	MOV	eDI, [DR_TYPE+eBX+1] 	; DI = MEDIA/DRIVE PARAMETER TABLE
  1456                              <1> RWV_MD_SEARH:
  1457 000049B9 3A770C              <1>         CMP     DH, [eDI+MD.RATE]       ; MATCH?
  1458 000049BC 741B                <1> 	JE	short RWV_MD_FND	; YES, GO GET 1ST SPECIFY BYTE
  1459                              <1> RWV_NXT_MD:
  1460                              <1> 	;ADD	BX,3			; CHECK NEXT DRIVE TYPE
  1461 000049BE 83C305              <1> 	add	eBX, 5
  1462 000049C1 E2E3                <1> 	LOOP	RWV_DR_SEARCH
  1463 000049C3 5F                  <1> 	POP	eDI			; RESTORE DRIVE #
  1464                              <1> 
  1465                              <1> ;-----	ASSUME PRIMARY DRIVE IS INSTALLED AS SHIPPED
  1466                              <1> 
  1467                              <1> RWV_ASSUME:
  1468 000049C4 BB[966D0000]        <1> 	MOV	eBX, MD_TBL1		; POINT TO 40 TRACK 250 KBS
  1469 000049C9 F687[658A0100]01    <1> 	TEST 	byte [DSK_STATE+eDI], TRK_CAPA ; TEST FOR 80 TRACK
  1470 000049D0 740A                <1> 	JZ	short RWV_MD_FND1	; MUST BE 40 TRACK
  1471 000049D2 BB[B06D0000]        <1> 	MOV	eBX, MD_TBL3		; POINT TO 80 TRACK 500 KBS
  1472 000049D7 EB03                <1> 	JMP	short RWV_MD_FND1	; GO SPECIFY PARAMTERS
  1473                              <1> 
  1474                              <1> ;-----	CS:BX POINTS TO MEDIA/DRIVE PARAMETER TABLE
  1475                              <1> 	 			
  1476                              <1> RWV_MD_FND:
  1477 000049D9 89FB                <1> 	MOV	eBX,eDI			; BX = MEDIA/DRIVE PARAMETER TABLE
  1478 000049DB 5F                  <1> 	POP	eDI			; RESTORE DRIVE #
  1479                              <1> 	
  1480                              <1> ;-----	SEND THE SPECIFY COMMAND TO THE CONTROLLER
  1481                              <1> 
  1482                              <1> RWV_MD_FND1:
  1483 000049DC E882FEFFFF          <1> 	CALL	SEND_SPEC_MD
  1484 000049E1 E864010000          <1> 	CALL	CHK_LASTRATE		; ZF=1 ATTEMP RATE IS SAME AS LAST RATE
  1485 000049E6 7405                <1> 	JZ	short RWV_DBL		; YES,SKIP SEND RATE COMMAND
  1486 000049E8 E83B010000          <1> 	CALL	SEND_RATE		; SEND DATA RATE TO NEC
  1487                              <1> RWV_DBL:
  1488 000049ED 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  1489 000049EE E822040000          <1> 	CALL	SETUP_DBL		; CHECK FOR DOUBLE STEP
  1490 000049F3 5B                  <1> 	POP	eBX			; RESTORE ADDRESS
  1491 000049F4 7226                <1> 	JC	short CHK_RET		; ERROR FROM READ ID, POSSIBLE RETRY
  1492 000049F6 6658                <1> 	POP	AX			; RESTORE NEC, DMA COMMAND
  1493 000049F8 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  1494 000049FA 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  1495 000049FB E861010000          <1> 	CALL	DMA_SETUP		; SET UP THE DMA
  1496 00004A00 5B                  <1> 	POP	eBX 
  1497 00004A01 6658                <1> 	POP	AX			; RESTORE NEC COMMAND
  1498 00004A03 722F                <1> 	JC	short RWV_BAC		; CHECK FOR DMA BOUNDARY ERROR
  1499 00004A05 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  1500 00004A07 53                  <1> 	PUSH	eBX			; SAVE MEDIA/DRIVE PARAM TBL ADDRESS
  1501 00004A08 E83C020000          <1> 	CALL	NEC_INIT		; INITIALIZE NEC
  1502 00004A0D 5B                  <1> 	POP	eBX			; RESTORE ADDRESS
  1503 00004A0E 720C                <1> 	JC	short CHK_RET		; ERROR - EXIT
  1504 00004A10 E866020000          <1> 	CALL	RWV_COM			; OP CODE COMMON TO READ/WRITE/VERIFY
  1505 00004A15 7205                <1> 	JC	short CHK_RET		; ERROR - EXIT
  1506 00004A17 E8AB020000          <1> 	CALL	NEC_TERM		; TERMINATE, GET STATUS, ETC.
  1507                              <1> CHK_RET:
  1508 00004A1C E84A030000          <1> 	CALL	RETRY			; CHECK FOR, SETUP RETRY
  1509 00004A21 6658                <1> 	POP	AX			; RESTORE READ/WRITE/VERIFY PARAMETER
  1510 00004A23 7305                <1> 	JNC	short RWV_END		; CY = 0 NO RETRY
  1511 00004A25 E928FFFFFF          <1>         JMP     DO_AGAIN                ; CY = 1 MEANS RETRY
  1512                              <1> RWV_END:
  1513 00004A2A E8F4020000          <1> 	CALL	DSTATE			; ESTABLISH STATE IF SUCCESSFUL
  1514 00004A2F E887030000          <1> 	CALL	NUM_TRANS		; AL = NUMBER TRANSFERRED
  1515                              <1> RWV_BAC:				; BAD DMA ERROR ENTRY
  1516 00004A34 6650                <1> 	PUSH	AX			; SAVE NUMBER TRANSFERRED
  1517 00004A36 E879FEFFFF          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  1518 00004A3B 6658                <1> 	POP	AX			; RESTORE NUMBER TRANSFERRED
  1519 00004A3D E8B1030000          <1> 	CALL	SETUP_END		; VARIOUS CLEANUPS
  1520 00004A42 C3                  <1> 	RETn
  1521                              <1> 
  1522                              <1> ;-------------------------------------------------------------------------------
  1523                              <1> ; SETUP_STATE:	INITIALIZES START AND END RATES.
  1524                              <1> ;-------------------------------------------------------------------------------
  1525                              <1> SETUP_STATE:
  1526 00004A43 F687[658A0100]10    <1> 	TEST	byte [DSK_STATE+eDI], MED_DET ; MEDIA DETERMINED ?
  1527 00004A4A 7537                <1> 	JNZ	short J1C		; NO STATES IF DETERMINED
  1528 00004A4C 66B84000            <1>         MOV     AX,(RATE_500*256)+RATE_300  ; AH = START RATE, AL = END RATE
  1529 00004A50 F687[658A0100]04    <1> 	TEST	byte [DSK_STATE+eDI],DRV_DET ; DRIVE ?
  1530 00004A57 740D                <1> 	JZ	short AX_SET		; DO NOT KNOW DRIVE
  1531 00004A59 F687[658A0100]02    <1> 	TEST	byte [DSK_STATE+eDI], FMT_CAPA ; MULTI-RATE?
  1532 00004A60 7504                <1> 	JNZ	short AX_SET		; JUMP IF YES
  1533 00004A62 66B88080            <1>         MOV     AX,RATE_250*257         ; START A END RATE 250 FOR 360 DRIVE
  1534                              <1> AX_SET:	
  1535 00004A66 80A7[658A0100]1F    <1> 	AND	byte [DSK_STATE+eDI], ~(RATE_MSK+DBL_STEP) ; TURN OFF THE RATE
  1536 00004A6D 08A7[658A0100]      <1> 	OR	[DSK_STATE+eDI], AH	; RATE FIRST TO TRY
  1537 00004A73 8025[608A0100]F3    <1> 	AND	byte [LASTRATE], ~STRT_MSK ; ERASE LAST TO TRY RATE BITS
  1538 00004A7A C0C804              <1> 	ROR	AL,4			; TO OPERATION LAST RATE LOCATION
  1539 00004A7D 0805[608A0100]      <1> 	OR	[LASTRATE], AL		; LAST RATE
  1540                              <1> J1C:	
  1541 00004A83 C3                  <1> 	RETn
  1542                              <1> 
  1543                              <1> ;-------------------------------------------------------------------------------
  1544                              <1> ;  FMT_INIT: ESTABLISH STATE IF UNESTABLISHED AT FORMAT TIME.
  1545                              <1> ;-------------------------------------------------------------------------------
  1546                              <1> FMT_INIT:
  1547 00004A84 F687[658A0100]10    <1> 	TEST	byte [DSK_STATE+eDI], MED_DET ; IS MEDIA ESTABLISHED
  1548 00004A8B 7546                <1> 	JNZ	short F1_OUT		; IF SO RETURN
  1549 00004A8D E82C040000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN AL
  1550                              <1> 	;; 20/02/2015
  1551                              <1> 	;;JC	short CL_DRV		; ERROR IN CMOS ASSUME NO DRIVE
  1552 00004A92 7440                <1> 	jz	short CL_DRV ;; 20/02/2015
  1553 00004A94 FEC8                <1> 	DEC	AL			; MAKE ZERO ORIGIN
  1554                              <1> 	;;JS	short CL_DRV		; NO DRIVE IF AL 0
  1555 00004A96 8AA7[658A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; AH = CURRENT STATE
  1556 00004A9C 80E40F              <1> 	AND	AH, ~(MED_DET+DBL_STEP+RATE_MSK) ; CLEAR
  1557 00004A9F 08C0                <1> 	OR	AL,AL			; CHECK FOR 360
  1558 00004AA1 7505                <1> 	JNZ	short N_360		; IF 360 WILL BE 0
  1559 00004AA3 80CC90              <1> 	OR	AH,MED_DET+RATE_250	; ESTABLISH MEDIA
  1560 00004AA6 EB25                <1> 	JMP	SHORT SKP_STATE		; SKIP OTHER STATE PROCESSING
  1561                              <1> N_360:	
  1562 00004AA8 FEC8                <1> 	DEC	AL			; 1.2 M DRIVE
  1563 00004AAA 7505                <1> 	JNZ	short N_12		; JUMP IF NOT
  1564                              <1> F1_RATE:
  1565 00004AAC 80CC10              <1> 	OR	AH,MED_DET+RATE_500	; SET FORMAT RATE
  1566 00004AAF EB1C                <1> 	JMP	SHORT SKP_STATE		; SKIP OTHER STATE PROCESSING
  1567                              <1> N_12:	
  1568 00004AB1 FEC8                <1> 	DEC	AL			; CHECK FOR TYPE 3
  1569 00004AB3 750F                <1> 	JNZ	short N_720		; JUMP IF NOT
  1570 00004AB5 F6C404              <1> 	TEST	AH,DRV_DET		; IS DRIVE DETERMINED
  1571 00004AB8 7410                <1> 	JZ	short ISNT_12		; TREAT AS NON 1.2 DRIVE
  1572 00004ABA F6C402              <1> 	TEST	AH,FMT_CAPA		; IS 1.2M
  1573 00004ABD 740B                <1> 	JZ	short ISNT_12		; JUMP IF NOT
  1574 00004ABF 80CC50              <1> 	OR	AH,MED_DET+RATE_300	; RATE 300
  1575 00004AC2 EB09                <1> 	JMP	SHORT SKP_STATE		; CONTINUE
  1576                              <1> N_720:
  1577 00004AC4 FEC8                <1> 	DEC	AL			; CHECK FOR TYPE 4
  1578 00004AC6 750C                <1> 	JNZ	short CL_DRV		; NO DRIVE, CMOS BAD
  1579 00004AC8 EBE2                <1> 	JMP	SHORT F1_RATE
  1580                              <1> ISNT_12: 
  1581 00004ACA 80CC90              <1> 	OR	AH,MED_DET+RATE_250	; MUST BE RATE 250
  1582                              <1> 
  1583                              <1> SKP_STATE:
  1584 00004ACD 88A7[658A0100]      <1> 	MOV	[DSK_STATE+eDI], AH	; STORE AWAY
  1585                              <1> F1_OUT:
  1586 00004AD3 C3                  <1> 	RETn
  1587                              <1> CL_DRV:	
  1588 00004AD4 30E4                <1> 	XOR	AH,AH			; CLEAR STATE
  1589 00004AD6 EBF5                <1> 	JMP	SHORT SKP_STATE		; SAVE IT
  1590                              <1> 
  1591                              <1> ;-------------------------------------------------------------------------------
  1592                              <1> ; MED_CHANGE	
  1593                              <1> ;	CHECKS FOR MEDIA CHANGE, RESETS MEDIA CHANGE, 
  1594                              <1> ;	CHECKS MEDIA CHANGE AGAIN.
  1595                              <1> ;
  1596                              <1> ; ON EXIT:	CY = 1 MEANS MEDIA CHANGE OR TIMEOUT
  1597                              <1> ;		@DSKETTE_STATUS = ERROR CODE
  1598                              <1> ;-------------------------------------------------------------------------------
  1599                              <1> MED_CHANGE:
  1600 00004AD8 E888060000          <1> 	CALL	READ_DSKCHNG		; READ DISK CHANCE LINE STATE
  1601 00004ADD 7447                <1> 	JZ	short MC_OUT		; BYPASS HANDLING DISK CHANGE LINE
  1602 00004ADF 80A7[658A0100]EF    <1> 	AND	byte [DSK_STATE+eDI], ~MED_DET ; CLEAR STATE FOR THIS DRIVE
  1603                              <1> 
  1604                              <1> ;	THIS SEQUENCE ENSURES WHENEVER A DISKETTE IS CHANGED THAT
  1605                              <1> ;	ON THE NEXT OPERATION THE REQUIRED MOTOR START UP TIME WILL
  1606                              <1> ;	BE WAITED. (DRIVE MOTOR MAY GO OFF UPON DOOR OPENING).
  1607                              <1> 
  1608 00004AE6 6689F9              <1> 	MOV	CX,DI			; CL = DRIVE 0
  1609 00004AE9 B001                <1> 	MOV	AL,1			; MOTOR ON BIT MASK
  1610 00004AEB D2E0                <1> 	SHL	AL,CL			; TO APPROPRIATE POSITION
  1611 00004AED F6D0                <1> 	NOT	AL			; KEEP ALL BUT MOTOR ON
  1612 00004AEF FA                  <1> 	CLI				; NO INTERRUPTS
  1613 00004AF0 2005[568A0100]      <1> 	AND	[MOTOR_STATUS], AL	; TURN MOTOR OFF INDICATOR
  1614 00004AF6 FB                  <1> 	STI				; INTERRUPTS ENABLED
  1615 00004AF7 E810040000          <1> 	CALL	MOTOR_ON		; TURN MOTOR ON
  1616                              <1> 
  1617                              <1> ;-----	THIS SEQUENCE OF SEEKS IS USED TO RESET DISKETTE CHANGE SIGNAL
  1618                              <1> 
  1619 00004AFC E850F9FFFF          <1> 	CALL	DSK_RESET		; RESET NEC
  1620 00004B01 B501                <1> 	MOV	CH,01H			; MOVE TO CYLINDER 1
  1621 00004B03 E8FF040000          <1> 	CALL	SEEK			; ISSUE SEEK
  1622 00004B08 30ED                <1> 	XOR	CH,CH			; MOVE TO CYLINDER 0
  1623 00004B0A E8F8040000          <1> 	CALL	SEEK			; ISSUE SEEK
  1624 00004B0F C605[588A0100]06    <1> 	MOV	byte [DSKETTE_STATUS], MEDIA_CHANGE ; STORE IN STATUS
  1625                              <1> OK1:
  1626 00004B16 E84A060000          <1> 	CALL	READ_DSKCHNG		; CHECK MEDIA CHANGED AGAIN
  1627 00004B1B 7407                <1> 	JZ	short OK2		; IF ACTIVE, NO DISKETTE, TIMEOUT
  1628                              <1> OK4:
  1629 00004B1D C605[588A0100]80    <1> 	MOV	byte [DSKETTE_STATUS], TIME_OUT ; TIMEOUT IF DRIVE EMPTY
  1630                              <1> OK2:		
  1631 00004B24 F9                  <1> 	STC				; MEDIA CHANGED, SET CY
  1632 00004B25 C3                  <1> 	RETn
  1633                              <1> MC_OUT:
  1634 00004B26 F8                  <1> 	CLC				; NO MEDIA CHANGED, CLEAR CY
  1635 00004B27 C3                  <1> 	RETn
  1636                              <1> 
  1637                              <1> ;-------------------------------------------------------------------------------
  1638                              <1> ; SEND_RATE
  1639                              <1> ;	SENDS DATA RATE COMMAND TO NEC
  1640                              <1> ; ON ENTRY:	DI = DRIVE #
  1641                              <1> ; ON EXIT:	NONE
  1642                              <1> ; REGISTERS ALTERED: DX
  1643                              <1> ;-------------------------------------------------------------------------------
  1644                              <1> SEND_RATE:
  1645 00004B28 6650                <1> 	PUSH	AX			; SAVE REG.
  1646 00004B2A 8025[608A0100]3F    <1> 	AND	byte [LASTRATE], ~SEND_MSK ; ELSE CLEAR LAST RATE ATTEMPTED
  1647 00004B31 8A87[658A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  1648 00004B37 24C0                <1> 	AND	AL,SEND_MSK		; KEEP ONLY RATE BITS
  1649 00004B39 0805[608A0100]      <1> 	OR	[LASTRATE], AL		; SAVE NEW RATE FOR NEXT CHECK
  1650 00004B3F C0C002              <1> 	ROL	AL,2			; MOVE TO BIT OUTPUT POSITIONS
  1651 00004B42 66BAF703            <1> 	MOV	DX,03F7H		; OUTPUT NEW DATA RATE
  1652 00004B46 EE                  <1> 	OUT	DX,AL
  1653 00004B47 6658                <1> 	POP	AX			; RESTORE REG.
  1654 00004B49 C3                  <1> 	RETn
  1655                              <1> 
  1656                              <1> ;-------------------------------------------------------------------------------
  1657                              <1> ; CHK_LASTRATE
  1658                              <1> ;	CHECK PREVIOUS DATE RATE SNT TO THE CONTROLLER.
  1659                              <1> ; ON ENTRY:
  1660                              <1> ;	DI = DRIVE #
  1661                              <1> ; ON EXIT:
  1662                              <1> ;	ZF =  1 DATA RATE IS THE SAME AS THE LAST RATE SENT TO NEC
  1663                              <1> ;	ZF =  0 DATA RATE IS DIFFERENT FROM LAST RATE
  1664                              <1> ; REGISTERS ALTERED: DX
  1665                              <1> ;-------------------------------------------------------------------------------
  1666                              <1> CHK_LASTRATE:
  1667 00004B4A 6650                <1> 	PUSH	AX			; SAVE REG
  1668 00004B4C 2225[608A0100]      <1> 	AND	AH, [LASTRATE]		; GET LAST DATA RATE SELECTED
  1669 00004B52 8A87[658A0100]      <1> 	MOV	AL, [DSK_STATE+eDI]	; GET RATE STATE OF THIS DRIVE
  1670 00004B58 6625C0C0            <1>         AND     AX, SEND_MSK*257        ; KEEP ONLY RATE BITS OF BOTH
  1671 00004B5C 38E0                <1> 	CMP	AL, AH			; COMPARE TO PREVIOUSLY TRIED
  1672                              <1> 					; ZF = 1 RATE IS THE SAME
  1673 00004B5E 6658                <1> 	POP	AX			; RESTORE REG.
  1674 00004B60 C3                  <1> 	RETn
  1675                              <1> 
  1676                              <1> ;-------------------------------------------------------------------------------
  1677                              <1> ; DMA_SETUP
  1678                              <1> ;	THIS ROUTINE SETS UP THE DMA FOR READ/WRITE/VERIFY OPERATIONS.
  1679                              <1> ;
  1680                              <1> ; ON ENTRY:	AL = DMA COMMAND
  1681                              <1> ;
  1682                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1683                              <1> ;-------------------------------------------------------------------------------
  1684                              <1> 
  1685                              <1> ; SI = Head #, # of Sectors or DASD Type
  1686                              <1> 
  1687                              <1> ; 22/08/2015
  1688                              <1> ; 08/02/2015 - Protected Mode Modification
  1689                              <1> ; 06/02/2015 - 07/02/2015
  1690                              <1> ; NOTE: Buffer address must be in 1st 16MB of Physical Memory (24 bit limit).
  1691                              <1> ; (DMA Addres = Physical Address)
  1692                              <1> ; (Retro UNIX 386 v1 Kernel/System Mode Virtual Address = Physical Address)
  1693                              <1> ;
  1694                              <1> 
  1695                              <1> 
  1696                              <1> ; 04/02/2016 (clc)
  1697                              <1> ; 20/02/2015 modification (source: AWARD BIOS 1999, DMA_SETUP)
  1698                              <1> ; 16/12/2014 (IODELAY)
  1699                              <1> 
  1700                              <1> DMA_SETUP:
  1701                              <1> 
  1702                              <1> ;; 20/02/2015
  1703 00004B61 8B5504              <1> 	mov	edx, [ebp+4] 		; Buffer address
  1704 00004B64 F7C2000000FF        <1> 	test	edx, 0FF000000h		; 16 MB limit (22/08/2015, bugfix)
  1705 00004B6A 756E                <1> 	jnz	short dma_bnd_err_stc
  1706                              <1> 	;
  1707 00004B6C 6650                <1> 	push	ax			; DMA command
  1708 00004B6E 52                  <1> 	push	edx			; *
  1709 00004B6F B203                <1> 	mov	dl, 3			; GET BYTES/SECTOR PARAMETER
  1710 00004B71 E851030000          <1> 	call	GET_PARM		; 
  1711 00004B76 88E1                <1> 	mov	cl, ah 			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  1712 00004B78 6689F0              <1> 	mov	ax, si			; Sector count
  1713 00004B7B 88C4                <1> 	mov	ah, al			; AH =  # OF SECTORS
  1714 00004B7D 28C0                <1> 	sub	al, al			; AL = 0, AX = # SECTORS * 256
  1715 00004B7F 66D1E8              <1> 	shr	ax, 1			; AX = # SECTORS * 128
  1716 00004B82 66D3E0              <1> 	shl	ax, cl			; SHIFT BY PARAMETER VALUE
  1717 00004B85 6648                <1> 	dec	ax			; -1 FOR DMA VALUE
  1718 00004B87 6689C1              <1> 	mov	cx, ax
  1719 00004B8A 5A                  <1> 	pop	edx			; *
  1720 00004B8B 6658                <1> 	pop	ax
  1721 00004B8D 3C42                <1> 	cmp	al, 42h
  1722 00004B8F 7507                <1>         jne     short NOT_VERF
  1723 00004B91 BA0000FF00          <1> 	mov	edx, 0FF0000h
  1724 00004B96 EB08                <1> 	jmp	short J33
  1725                              <1> NOT_VERF:
  1726 00004B98 6601CA              <1> 	add	dx, cx			; check for overflow
  1727 00004B9B 723E                <1> 	jc	short dma_bnd_err
  1728                              <1> 	;
  1729 00004B9D 6629CA              <1> 	sub	dx, cx			; Restore start address
  1730                              <1> J33:
  1731 00004BA0 FA                  <1> 	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1732 00004BA1 E60C                <1> 	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1733                              <1> 	IODELAY				; WAIT FOR I/O
  1733 00004BA3 EB00                <2>  jmp short $+2
  1733 00004BA5 EB00                <2>  jmp short $+2
  1734 00004BA7 E60B                <1> 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1735 00004BA9 89D0                <1> 	mov	eax, edx		; Buffer address
  1736 00004BAB E604                <1> 	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1737                              <1> 	IODELAY				; WAIT FOR I/O
  1737 00004BAD EB00                <2>  jmp short $+2
  1737 00004BAF EB00                <2>  jmp short $+2
  1738 00004BB1 88E0                <1> 	MOV	AL,AH
  1739 00004BB3 E604                <1> 	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1740 00004BB5 C1E810              <1> 	shr	eax, 16
  1741                              <1> 	IODELAY				; I/O WAIT STATE
  1741 00004BB8 EB00                <2>  jmp short $+2
  1741 00004BBA EB00                <2>  jmp short $+2
  1742 00004BBC E681                <1> 	OUT	081H,AL			; OUTPUT highest BITS TO PAGE REGISTER
  1743                              <1> 	IODELAY
  1743 00004BBE EB00                <2>  jmp short $+2
  1743 00004BC0 EB00                <2>  jmp short $+2
  1744 00004BC2 6689C8              <1> 	mov	ax, cx			; Byte count - 1
  1745 00004BC5 E605                <1> 	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1746                              <1> 	IODELAY				; WAIT FOR I/O
  1746 00004BC7 EB00                <2>  jmp short $+2
  1746 00004BC9 EB00                <2>  jmp short $+2
  1747 00004BCB 88E0                <1> 	MOV	AL, AH
  1748 00004BCD E605                <1> 	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1749                              <1> 	IODELAY
  1749 00004BCF EB00                <2>  jmp short $+2
  1749 00004BD1 EB00                <2>  jmp short $+2
  1750 00004BD3 FB                  <1> 	STI				; RE-ENABLE INTERRUPTS
  1751 00004BD4 B002                <1> 	MOV	AL, 2			; MODE FOR 8237
  1752 00004BD6 E60A                <1> 	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1753                              <1> 
  1754 00004BD8 F8                  <1> 	clc	; 04/02/2016
  1755 00004BD9 C3                  <1> 	retn
  1756                              <1> 
  1757                              <1> dma_bnd_err_stc:
  1758 00004BDA F9                  <1> 	stc
  1759                              <1> dma_bnd_err:
  1760 00004BDB C605[588A0100]09    <1> 	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  1761 00004BE2 C3                  <1> 	RETn				; CY SET BY ABOVE IF ERROR
  1762                              <1> 
  1763                              <1> ;; 16/12/2014
  1764                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1765                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1766                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1767                              <1> ;;	IODELAY
  1768                              <1> ;; 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1769                              <1> ;;	;SIODELAY
  1770                              <1> ;;      ;CMP	AL, 42H			; DMA VERIFY COMMAND
  1771                              <1> ;;      ;JNE	short NOT_VERF		; NO
  1772                              <1> ;;      ;XOR	AX, AX			; START ADDRESS
  1773                              <1> ;;      ;JMP	SHORT J33
  1774                              <1> ;;;NOT_VERF:	
  1775                              <1> ;;	;MOV	AX,ES			; GET THE ES VALUE
  1776                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  1777                              <1> ;;	;MOV	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  1778                              <1> ;;	;AND	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  1779                              <1> ;;	;ADD	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  1780                              <1> ;;	mov	eax, [ebp+4] ; 06/02/2015	
  1781                              <1> ;;	;JNC	short J33
  1782                              <1> ;;	;INC	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  1783                              <1> ;;;J33:
  1784                              <1> ;;	PUSH	eAX			; SAVE START ADDRESS
  1785                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1786                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1787                              <1> ;;	IODELAY
  1788                              <1> ;;	MOV	AL,AH
  1789                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1790                              <1> ;;	shr	eax, 16	     ; 07/02/2015
  1791                              <1> ;;	;MOV	AL,CH			; GET HIGH 4 BITS
  1792                              <1> ;;	;JMP	$+2			; I/O WAIT STATE
  1793                              <1> ;;	IODELAY
  1794                              <1> ;;	;AND	AL,00001111B
  1795                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  1796                              <1> ;;	;SIODELAY
  1797                              <1> ;;
  1798                              <1> ;;;----- DETERMINE COUNT
  1799                              <1> ;;	sub	eax, eax ; 08/02/2015
  1800                              <1> ;;	MOV	AX, SI			; AL =  # OF SECTORS
  1801                              <1> ;;	XCHG	AL, AH			; AH =  # OF SECTORS
  1802                              <1> ;;	SUB	AL, AL			; AL = 0, AX = # SECTORS * 256
  1803                              <1> ;;	SHR	AX, 1			; AX = # SECTORS * 128
  1804                              <1> ;;	PUSH	AX			; SAVE # OF SECTORS * 128
  1805                              <1> ;;	MOV	DL, 3			; GET BYTES/SECTOR PARAMETER
  1806                              <1> ;;	CALL	GET_PARM		; "
  1807                              <1> ;;	MOV	CL,AH			; SHIFT COUNT (0=128, 1=256, 2=512 ETC)
  1808                              <1> ;;	POP	AX			; AX = # SECTORS * 128
  1809                              <1> ;;	SHL	AX,CL			; SHIFT BY PARAMETER VALUE
  1810                              <1> ;;	DEC	AX			; -1 FOR DMA VALUE
  1811                              <1> ;;	PUSH	eAX  ; 08/02/2015	; SAVE COUNT VALUE
  1812                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1813                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1814                              <1> ;;	IODELAY
  1815                              <1> ;;	MOV	AL, AH
  1816                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1817                              <1> ;;	;IODELAY
  1818                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  1819                              <1> ;;	POP	eCX  ; 08/02/2015 	; RECOVER COUNT VALUE
  1820                              <1> ;;	POP	eAX  ; 08/02/2015	; RECOVER ADDRESS VALUE
  1821                              <1> ;;	;ADD	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  1822                              <1> ;;	add	ecx, eax ; 08/02/2015
  1823                              <1> ;;	MOV	AL, 2			; MODE FOR 8237
  1824                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1825                              <1> ;;	SIODELAY
  1826                              <1> ;;	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1827                              <1> ;;	;JNC	short NO_BAD		; CHECK FOR ERROR
  1828                              <1> ;;	jc	short dma_bnd_err ; 08/02/2015
  1829                              <1> ;;	and	ecx, 0FFF00000h ; 16 MB limit
  1830                              <1> ;;	jz	short NO_BAD
  1831                              <1> ;;dma_bnd_err:
  1832                              <1> ;;	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  1833                              <1> ;;NO_BAD:
  1834                              <1> ;;	RETn				; CY SET BY ABOVE IF ERROR
  1835                              <1> 
  1836                              <1> ;-------------------------------------------------------------------------------
  1837                              <1> ; FMTDMA_SET
  1838                              <1> ;	THIS ROUTINE SETS UP THE DMA CONTROLLER FOR A FORMAT OPERATION.
  1839                              <1> ;
  1840                              <1> ; ON ENTRY:	NOTHING REQUIRED
  1841                              <1> ;
  1842                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1843                              <1> ;-------------------------------------------------------------------------------
  1844                              <1> 
  1845                              <1> FMTDMA_SET:
  1846                              <1> ;; 20/02/2015 modification	
  1847 00004BE3 8B5504              <1> 	mov	edx, [ebp+4] 		; Buffer address
  1848 00004BE6 F7C20000F0FF        <1> 	test	edx, 0FFF00000h		; 16 MB limit
  1849 00004BEC 75EC                <1> 	jnz	short dma_bnd_err_stc
  1850                              <1> 	;
  1851 00004BEE 6652                <1> 	push	dx			; *
  1852 00004BF0 B204                <1> 	mov	DL, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  1853 00004BF2 E8D0020000          <1> 	call	GET_PARM		; "
  1854 00004BF7 88E0                <1> 	mov	al, ah			; AL = SECTORS/TRACK VALUE
  1855 00004BF9 28E4                <1> 	sub	ah, ah			; AX = SECTORS/TRACK VALUE
  1856 00004BFB 66C1E002            <1> 	shl	ax, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  1857 00004BFF 6648                <1> 	dec	ax			; -1 FOR DMA VALUE
  1858 00004C01 6689C1              <1> 	mov	cx, ax
  1859 00004C04 665A                <1> 	pop	dx			; *
  1860 00004C06 6601CA              <1> 	add	dx, cx			; check for overflow
  1861 00004C09 72D0                <1> 	jc	short dma_bnd_err
  1862                              <1> 	;
  1863 00004C0B 6629CA              <1> 	sub	dx, cx			; Restore start address
  1864                              <1> 	;
  1865 00004C0E B04A                <1> 	MOV	AL, 04AH		; WILL WRITE TO THE DISKETTE
  1866 00004C10 FA                  <1> 	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1867 00004C11 E60C                <1> 	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1868                              <1> 	IODELAY				; WAIT FOR I/O
  1868 00004C13 EB00                <2>  jmp short $+2
  1868 00004C15 EB00                <2>  jmp short $+2
  1869 00004C17 E60B                <1> 	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1870 00004C19 89D0                <1> 	mov	eax, edx		; Buffer address
  1871 00004C1B E604                <1> 	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1872                              <1> 	IODELAY				; WAIT FOR I/O
  1872 00004C1D EB00                <2>  jmp short $+2
  1872 00004C1F EB00                <2>  jmp short $+2
  1873 00004C21 88E0                <1> 	MOV	AL,AH
  1874 00004C23 E604                <1> 	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1875 00004C25 C1E810              <1> 	shr	eax, 16
  1876                              <1> 	IODELAY				; I/O WAIT STATE
  1876 00004C28 EB00                <2>  jmp short $+2
  1876 00004C2A EB00                <2>  jmp short $+2
  1877 00004C2C E681                <1> 	OUT	081H,AL			; OUTPUT highest BITS TO PAGE REGISTER
  1878                              <1> 	IODELAY
  1878 00004C2E EB00                <2>  jmp short $+2
  1878 00004C30 EB00                <2>  jmp short $+2
  1879 00004C32 6689C8              <1> 	mov	ax, cx			; Byte count - 1
  1880 00004C35 E605                <1> 	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1881                              <1> 	IODELAY				; WAIT FOR I/O
  1881 00004C37 EB00                <2>  jmp short $+2
  1881 00004C39 EB00                <2>  jmp short $+2
  1882 00004C3B 88E0                <1> 	MOV	AL, AH
  1883 00004C3D E605                <1> 	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1884                              <1> 	IODELAY
  1884 00004C3F EB00                <2>  jmp short $+2
  1884 00004C41 EB00                <2>  jmp short $+2
  1885 00004C43 FB                  <1> 	STI				; RE-ENABLE INTERRUPTS
  1886 00004C44 B002                <1> 	MOV	AL, 2			; MODE FOR 8237
  1887 00004C46 E60A                <1> 	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1888 00004C48 C3                  <1> 	retn
  1889                              <1> 
  1890                              <1> ;; 08/02/2015 - Protected Mode Modification
  1891                              <1> ;;	MOV	AL, 04AH		; WILL WRITE TO THE DISKETTE
  1892                              <1> ;;	CLI				; DISABLE INTERRUPTS DURING DMA SET-UP
  1893                              <1> ;;	OUT	DMA+12,AL		; SET THE FIRST/LA5T F/F
  1894                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1895                              <1> ;;	IODELAY
  1896                              <1> ;;	OUT	DMA+11,AL		; OUTPUT THE MODE BYTE
  1897                              <1> ;;	;MOV	AX,ES			; GET THE ES VALUE
  1898                              <1> ;;	;ROL	AX,4			; ROTATE LEFT
  1899                              <1> ;;	;MOV	CH,AL			; GET HIGHEST NIBBLE OF ES TO CH
  1900                              <1> ;;	;AND	AL,11110000B		; ZERO THE LOW NIBBLE FROM SEGMENT
  1901                              <1> ;;	;ADD	AX,[BP+2]		; TEST FOR CARRY FROM ADDITION
  1902                              <1> ;;	;JNC	short J33A
  1903                              <1> ;;	;INC	CH			; CARRY MEANS HIGH 4 BITS MUST BE INC
  1904                              <1> ;;	mov	eax, [ebp+4] ; 08/02/2015
  1905                              <1> ;;;J33A:
  1906                              <1> ;;	PUSH	eAX ; 08/02/2015	; SAVE START ADDRESS
  1907                              <1> ;;	OUT	DMA+4,AL		; OUTPUT LOW ADDRESS
  1908                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1909                              <1> ;;	IODELAY
  1910                              <1> ;;	MOV	AL,AH
  1911                              <1> ;;	OUT	DMA+4,AL		; OUTPUT HIGH ADDRESS
  1912                              <1> ;;	shr 	eax, 16 ; 08/02/2015
  1913                              <1> ;;	;MOV	AL,CH			; GET HIGH 4 BITS
  1914                              <1> ;;	;JMP	$+2			; I/O WAIT STATE
  1915                              <1> ;;	IODELAY
  1916                              <1> ;;	;AND	AL,00001111B
  1917                              <1> ;;	OUT	081H,AL			; OUTPUT HIGH 4 BITS TO PAGE REGISTER
  1918                              <1> ;;
  1919                              <1> ;;;----- DETERMINE COUNT
  1920                              <1> ;;	sub	eax, eax ; 08/02/2015
  1921                              <1> ;;	MOV	DL, 4			; SECTORS/TRACK VALUE IN PARM TABLE
  1922                              <1> ;;	CALL	GET_PARM		; "
  1923                              <1> ;;	XCHG	AL, AH			; AL = SECTORS/TRACK VALUE
  1924                              <1> ;;	SUB	AH, AH			; AX = SECTORS/TRACK VALUE
  1925                              <1> ;;	SHL	AX, 2			; AX = SEC/TRK * 4 (OFFSET C,H,R,N)
  1926                              <1> ;;	DEC	AX			; -1 FOR DMA VALUE
  1927                              <1> ;;	PUSH	eAX 	; 08/02/2015	; SAVE # OF BYTES TO BE TRANSFERED
  1928                              <1> ;;	OUT	DMA+5,AL		; LOW BYTE OF COUNT
  1929                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1930                              <1> ;;	IODELAY
  1931                              <1> ;;	MOV	AL, AH
  1932                              <1> ;;	OUT	DMA+5,AL		; HIGH BYTE OF COUNT
  1933                              <1> ;;	STI				; RE-ENABLE INTERRUPTS
  1934                              <1> ;;	POP	eCX	; 08/02/2015	; RECOVER COUNT VALUE
  1935                              <1> ;;	POP	eAX	; 08/02/2015	; RECOVER ADDRESS VALUE
  1936                              <1> ;;	;ADD	AX, CX			; ADD, TEST FOR 64K OVERFLOW
  1937                              <1> ;;	add	ecx, eax ; 08/02/2015
  1938                              <1> ;;	MOV	AL, 2			; MODE FOR 8237
  1939                              <1> ;;	;JMP	$+2			; WAIT FOR I/O
  1940                              <1> ;;	SIODELAY
  1941                              <1> ;;	OUT	DMA+10, AL		; INITIALIZE THE DISKETTE CHANNEL
  1942                              <1> ;;	;JNC	short FMTDMA_OK		; CHECK FOR ERROR
  1943                              <1> ;;	jc	short fmtdma_bnd_err ; 08/02/2015
  1944                              <1> ;;	and	ecx, 0FFF00000h  ; 16 MB limit
  1945                              <1> ;;	jz	short FMTDMA_OK
  1946                              <1> ;;	stc	; 20/02/2015
  1947                              <1> ;;fmtdma_bnd_err:
  1948                              <1> ;;	MOV	byte [DSKETTE_STATUS], DMA_BOUNDARY ; SET ERROR
  1949                              <1> ;;FMTDMA_OK:
  1950                              <1> ;;	RETn				; CY SET BY ABOVE IF ERROR
  1951                              <1> 
  1952                              <1> ;-------------------------------------------------------------------------------
  1953                              <1> ; NEC_INIT	
  1954                              <1> ;	THIS ROUTINE SEEKS TO THE REQUESTED TRACK AND INITIALIZES
  1955                              <1> ;	THE NEC FOR THE READ/WRITE/VERIFY/FORMAT OPERATION.
  1956                              <1> ;
  1957                              <1> ; ON ENTRY:	AH = NEC COMMAND TO BE PERFORMED
  1958                              <1> ;
  1959                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1960                              <1> ;-------------------------------------------------------------------------------
  1961                              <1> NEC_INIT:
  1962 00004C49 6650                <1> 	PUSH	AX			; SAVE NEC COMMAND
  1963 00004C4B E8BC020000          <1> 	CALL	MOTOR_ON		; TURN MOTOR ON FOR SPECIFIC DRIVE
  1964                              <1> 
  1965                              <1> ;-----	DO THE SEEK OPERATION
  1966                              <1> 
  1967 00004C50 8A6D01              <1> 	MOV	CH,[eBP+1]		; CH = TRACK #
  1968 00004C53 E8AF030000          <1> 	CALL	SEEK			; MOVE TO CORRECT TRACK
  1969 00004C58 6658                <1> 	POP	AX			; RECOVER COMMAND
  1970 00004C5A 721E                <1> 	JC	short ER_1		; ERROR ON SEEK
  1971 00004C5C BB[7A4C0000]        <1> 	MOV	eBX, ER_1		; LOAD ERROR ADDRESS
  1972 00004C61 53                  <1> 	PUSH	eBX			; PUSH NEC_OUT ERROR RETURN
  1973                              <1> 
  1974                              <1> ;-----	SEND OUT THE PARAMETERS TO THE CONTROLLER
  1975                              <1> 
  1976 00004C62 E866030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE OPERATION COMMAND
  1977 00004C67 6689F0              <1> 	MOV	AX,SI			; AH = HEAD #
  1978 00004C6A 89FB                <1> 	MOV	eBX,eDI			; BL = DRIVE #
  1979 00004C6C C0E402              <1> 	SAL	AH,2			; MOVE IT TO BIT 2
  1980 00004C6F 80E404              <1> 	AND	AH,00000100B		; ISOLATE THAT BIT
  1981 00004C72 08DC                <1> 	OR	AH,BL			; OR IN THE DRIVE NUMBER
  1982 00004C74 E854030000          <1> 	CALL	NEC_OUTPUT		; FALL THRU CY SET IF ERROR
  1983 00004C79 5B                  <1> 	POP	eBX			; THROW AWAY ERROR RETURN
  1984                              <1> ER_1:
  1985 00004C7A C3                  <1> 	RETn
  1986                              <1> 
  1987                              <1> ;-------------------------------------------------------------------------------
  1988                              <1> ; RWV_COM
  1989                              <1> ;	THIS ROUTINE SENDS PARAMETERS TO THE NEC SPECIFIC TO THE 
  1990                              <1> ;	READ/WRITE/VERIFY OPERATIONS.
  1991                              <1> ;
  1992                              <1> ; ON ENTRY:	CS:BX = ADDRESS OF MEDIA/DRIVE PARAMETER TABLE
  1993                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  1994                              <1> ;-------------------------------------------------------------------------------
  1995                              <1> RWV_COM:
  1996 00004C7B B8[C64C0000]        <1> 	MOV	eAX, ER_2		; LOAD ERROR ADDRESS
  1997 00004C80 50                  <1> 	PUSH	eAX			; PUSH NEC_OUT ERROR RETURN
  1998 00004C81 8A6501              <1> 	MOV	AH,[eBP+1]		; OUTPUT TRACK #
  1999 00004C84 E844030000          <1> 	CALL	NEC_OUTPUT
  2000 00004C89 6689F0              <1> 	MOV	AX,SI			; OUTPUT HEAD #
  2001 00004C8C E83C030000          <1> 	CALL	NEC_OUTPUT
  2002 00004C91 8A6500              <1>         MOV     AH,[eBP]                ; OUTPUT SECTOR #
  2003 00004C94 E834030000          <1> 	CALL	NEC_OUTPUT
  2004 00004C99 B203                <1> 	MOV	DL,3			; BYTES/SECTOR PARAMETER FROM BLOCK
  2005 00004C9B E827020000          <1> 	CALL	GET_PARM 		; ... TO THE NEC
  2006 00004CA0 E828030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  2007 00004CA5 B204                <1> 	MOV	DL,4			; EOT PARAMETER FROM BLOCK
  2008 00004CA7 E81B020000          <1> 	CALL	GET_PARM 		; ... TO THE NEC
  2009 00004CAC E81C030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  2010 00004CB1 8A6305              <1>         MOV     AH, [eBX+MD.GAP]        ; GET GAP LENGTH
  2011                              <1> _R15:
  2012 00004CB4 E814030000          <1> 	CALL	NEC_OUTPUT
  2013 00004CB9 B206                <1> 	MOV	DL,6			; DTL PARAMETER PROM BLOCK
  2014 00004CBB E807020000          <1> 	CALL	GET_PARM		;  TO THE NEC
  2015 00004CC0 E808030000          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO CONTROLLER
  2016 00004CC5 58                  <1> 	POP	eAX			; THROW AWAY ERROR EXIT
  2017                              <1> ER_2:
  2018 00004CC6 C3                  <1> 	RETn
  2019                              <1> 
  2020                              <1> ;-------------------------------------------------------------------------------
  2021                              <1> ; NEC_TERM
  2022                              <1> ;	THIS ROUTINE WAITS FOR THE OPERATION THEN ACCEPTS THE STATUS 
  2023                              <1> ;	FROM THE NEC FOR THE READ/WRITE/VERIFY/FORWAT OPERATION.
  2024                              <1> ;
  2025                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2026                              <1> ;-------------------------------------------------------------------------------
  2027                              <1> NEC_TERM:
  2028                              <1> 
  2029                              <1> ;-----	LET THE OPERATION HAPPEN
  2030                              <1> 
  2031 00004CC7 56                  <1> 	PUSH	eSI			; SAVE HEAD #, # OF SECTORS
  2032 00004CC8 E80D040000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  2033 00004CCD 9C                  <1> 	PUSHF
  2034 00004CCE E837040000          <1> 	CALL	RESULTS			; GET THE NEC STATUS
  2035 00004CD3 724B                <1> 	JC	short SET_END_POP
  2036 00004CD5 9D                  <1> 	POPF
  2037 00004CD6 723E                <1> 	JC	short SET_END		; LOOK FOR ERROR
  2038                              <1> 
  2039                              <1> ;-----	CHECK THE RESULTS RETURNED BY THE CONTROLLER
  2040                              <1> 
  2041 00004CD8 FC                  <1> 	CLD				; SET THE CORRECT DIRECTION
  2042 00004CD9 BE[598A0100]        <1> 	MOV	eSI, NEC_STATUS		; POINT TO STATUS FIELD
  2043 00004CDE AC                  <1> 	lodsb				; GET ST0
  2044 00004CDF 24C0                <1> 	AND	AL,11000000B		; TEST FOR NORMAL TERMINATION
  2045 00004CE1 7433                <1> 	JZ	short SET_END
  2046 00004CE3 3C40                <1> 	CMP	AL,01000000B		; TEST FOR ABNORMAL TERMINATION
  2047 00004CE5 7527                <1> 	JNZ	short J18		; NOT ABNORMAL, BAD NEC
  2048                              <1> 
  2049                              <1> ;-----	ABNORMAL TERMINATION, FIND OUT WHY
  2050                              <1> 
  2051 00004CE7 AC                  <1> 	lodsb				; GET ST1
  2052 00004CE8 D0E0                <1> 	SAL	AL,1			; TEST FOR EDT FOUND
  2053 00004CEA B404                <1> 	MOV	AH,RECORD_NOT_FND
  2054 00004CEC 7222                <1> 	JC	short J19
  2055 00004CEE C0E002              <1> 	SAL	AL,2
  2056 00004CF1 B410                <1> 	MOV	AH,BAD_CRC
  2057 00004CF3 721B                <1> 	JC	short J19
  2058 00004CF5 D0E0                <1> 	SAL	AL,1			; TEST FOR DMA OVERRUN
  2059 00004CF7 B408                <1> 	MOV	AH,BAD_DMA
  2060 00004CF9 7215                <1> 	JC	short J19
  2061 00004CFB C0E002              <1> 	SAL	AL,2			; TEST FOR RECORD NOT FOUND
  2062 00004CFE B404                <1> 	MOV	AH,RECORD_NOT_FND
  2063 00004D00 720E                <1> 	JC	short J19
  2064 00004D02 D0E0                <1> 	SAL	AL,1
  2065 00004D04 B403                <1> 	MOV	AH,WRITE_PROTECT	; TEST FOR WRITE_PROTECT
  2066 00004D06 7208                <1> 	JC	short J19
  2067 00004D08 D0E0                <1> 	SAL	AL,1			; TEST MISSING ADDRESS MARK
  2068 00004D0A B402                <1> 	MOV	AH,BAD_ADDR_MARK
  2069 00004D0C 7202                <1> 	JC	short J19
  2070                              <1> 
  2071                              <1> ;----- 	NEC MUST HAVE FAILED
  2072                              <1> J18:
  2073 00004D0E B420                <1> 	MOV	AH,BAD_NEC
  2074                              <1> J19:
  2075 00004D10 0825[588A0100]      <1> 	OR	[DSKETTE_STATUS], AH
  2076                              <1> SET_END:
  2077 00004D16 803D[588A0100]01    <1> 	CMP	byte [DSKETTE_STATUS], 1 ; SET ERROR CONDITION
  2078 00004D1D F5                  <1> 	CMC
  2079 00004D1E 5E                  <1> 	POP	eSI
  2080 00004D1F C3                  <1> 	RETn				; RESTORE HEAD #, # OF SECTORS
  2081                              <1> 
  2082                              <1> SET_END_POP:
  2083 00004D20 9D                  <1> 	POPF
  2084 00004D21 EBF3                <1> 	JMP	SHORT SET_END
  2085                              <1> 
  2086                              <1> ;-------------------------------------------------------------------------------
  2087                              <1> ; DSTATE:	ESTABLISH STATE UPON SUCCESSFUL OPERATION.
  2088                              <1> ;-------------------------------------------------------------------------------
  2089                              <1> DSTATE:
  2090 00004D23 803D[588A0100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; CHECK FOR ERROR
  2091 00004D2A 753E                <1> 	JNZ	short SETBAC		    ; IF ERROR JUMP
  2092 00004D2C 808F[658A0100]10    <1> 	OR	byte [DSK_STATE+eDI],MED_DET ; NO ERROR, MARK MEDIA AS DETERMINED
  2093 00004D33 F687[658A0100]04    <1> 	TEST	byte [DSK_STATE+eDI],DRV_DET ; DRIVE DETERMINED ?
  2094 00004D3A 752E                <1> 	JNZ	short SETBAC		; IF DETERMINED NO TRY TO DETERMINE
  2095 00004D3C 8A87[658A0100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; LOAD STATE
  2096 00004D42 24C0                <1> 	AND	AL,RATE_MSK		; KEEP ONLY RATE
  2097 00004D44 3C80                <1> 	CMP	AL,RATE_250		; RATE 250 ?
  2098 00004D46 751B                <1> 	JNE	short M_12		; NO, MUST BE 1.2M OR 1.44M DRIVE
  2099                              <1> 
  2100                              <1> ;----- 	CHECK IF IT IS 1.44M
  2101                              <1> 
  2102 00004D48 E871010000          <1> 	CALL	CMOS_TYPE		; RETURN DRIVE TYPE IN (AL)
  2103                              <1> 	;;20/02/2015
  2104                              <1> 	;;JC	short M_12		; CMOS BAD
  2105 00004D4D 7414                <1> 	jz	short M_12 ;; 20/02/2015
  2106 00004D4F 3C04                <1> 	CMP	AL, 4			; 1.44MB DRIVE ?
  2107 00004D51 7410                <1> 	JE	short M_12		; YES
  2108                              <1> M_720:
  2109 00004D53 80A7[658A0100]FD    <1> 	AND	byte [DSK_STATE+eDI], ~FMT_CAPA ; TURN OFF FORMAT CAPABILITY
  2110 00004D5A 808F[658A0100]04    <1> 	OR	byte [DSK_STATE+eDI],DRV_DET  ; MARK DRIVE DETERMINED
  2111 00004D61 EB07                <1> 	JMP	SHORT SETBAC		; BACK
  2112                              <1> M_12:	
  2113 00004D63 808F[658A0100]06    <1> 	OR	byte [DSK_STATE+eDI],DRV_DET+FMT_CAPA 
  2114                              <1> 					; TURN ON DETERMINED & FMT CAPA
  2115                              <1> SETBAC:
  2116 00004D6A C3                  <1> 	RETn
  2117                              <1> 
  2118                              <1> ;-------------------------------------------------------------------------------
  2119                              <1> ; RETRY	
  2120                              <1> ;	DETERMINES WHETHER A RETRY IS NECESSARY. 
  2121                              <1> ;	IF RETRY IS REQUIRED THEN STATE INFORMATION IS UPDATED FOR RETRY.
  2122                              <1> ;
  2123                              <1> ; ON EXIT:	CY = 1 FOR RETRY, CY = 0 FOR NO RETRY
  2124                              <1> ;-------------------------------------------------------------------------------
  2125                              <1> RETRY:
  2126 00004D6B 803D[588A0100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; GET STATUS OF OPERATION
  2127 00004D72 7445                <1> 	JZ	short NO_RETRY		; SUCCESSFUL OPERATION
  2128 00004D74 803D[588A0100]80    <1> 	CMP	byte [DSKETTE_STATUS],TIME_OUT ; IF TIME OUT NO RETRY
  2129 00004D7B 743C                <1> 	JZ	short NO_RETRY
  2130 00004D7D 8AA7[658A0100]      <1> 	MOV	AH,[DSK_STATE+eDI]	; GET MEDIA STATE OF DRIVE
  2131 00004D83 F6C410              <1> 	TEST	AH,MED_DET		; ESTABLISHED/DETERMINED ?
  2132 00004D86 7531                <1> 	JNZ	short NO_RETRY		; IF ESTABLISHED STATE THEN TRUE ERROR
  2133 00004D88 80E4C0              <1> 	AND	AH,RATE_MSK		; ISOLATE RATE
  2134 00004D8B 8A2D[608A0100]      <1> 	MOV	CH,[LASTRATE]		; GET START OPERATION STATE
  2135 00004D91 C0C504              <1> 	ROL	CH,4			; TO CORRESPONDING BITS
  2136 00004D94 80E5C0              <1> 	AND	CH,RATE_MSK		; ISOLATE RATE BITS
  2137 00004D97 38E5                <1> 	CMP	CH,AH			; ALL RATES TRIED
  2138 00004D99 741E                <1> 	JE	short NO_RETRY		; IF YES, THEN TRUE ERROR
  2139                              <1> 
  2140                              <1> ;	SETUP STATE INDICATOR FOR RETRY ATTEMPT TO NEXT RATE
  2141                              <1> ;	 00000000B (500) -> 10000000B	(250)
  2142                              <1> ;	 10000000B (250) -> 01000000B	(300)
  2143                              <1> ;	 01000000B (300) -> 00000000B	(500)
  2144                              <1> 
  2145 00004D9B 80FC01              <1> 	CMP	AH,RATE_500+1		; SET CY FOR RATE 500
  2146 00004D9E D0DC                <1> 	RCR	AH,1			; TO NEXT STATE
  2147 00004DA0 80E4C0              <1> 	AND	AH,RATE_MSK		; KEEP ONLY RATE BITS
  2148 00004DA3 80A7[658A0100]1F    <1> 	AND	byte [DSK_STATE+eDI], ~(RATE_MSK+DBL_STEP)
  2149                              <1> 					; RATE, DBL STEP OFF
  2150 00004DAA 08A7[658A0100]      <1> 	OR	[DSK_STATE+eDI],AH	; TURN ON NEW RATE
  2151 00004DB0 C605[588A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; RESET STATUS FOR RETRY
  2152 00004DB7 F9                  <1> 	STC				; SET CARRY FOR RETRY
  2153 00004DB8 C3                  <1> 	RETn				; RETRY RETURN
  2154                              <1> 
  2155                              <1> NO_RETRY:
  2156 00004DB9 F8                  <1> 	CLC				; CLEAR CARRY NO RETRY
  2157 00004DBA C3                  <1> 	RETn				; NO RETRY RETURN
  2158                              <1> 
  2159                              <1> ;-------------------------------------------------------------------------------
  2160                              <1> ; NUM_TRANS
  2161                              <1> ;	THIS ROUTINE CALCULATES THE NUMBER OF SECTORS THAT WERE
  2162                              <1> ;	ACTUALLY TRANSFERRED TO/FROM THE DISKETTE.
  2163                              <1> ;
  2164                              <1> ; ON ENTRY:	[BP+1] = TRACK
  2165                              <1> ;		SI-HI  = HEAD
  2166                              <1> ;		[BP]   = START SECTOR
  2167                              <1> ;
  2168                              <1> ; ON EXIT:	AL = NUMBER ACTUALLY TRANSFERRED
  2169                              <1> ;-------------------------------------------------------------------------------
  2170                              <1> NUM_TRANS:
  2171 00004DBB 30C0                <1> 	XOR	AL,AL			; CLEAR FOR ERROR
  2172 00004DBD 803D[588A0100]00    <1> 	CMP	byte [DSKETTE_STATUS],0	; CHECK FOR ERROR
  2173 00004DC4 752C                <1> 	JNZ	NT_OUT			; IF ERROR 0 TRANSFERRED
  2174 00004DC6 B204                <1> 	MOV	DL,4			; SECTORS/TRACK OFFSET TO DL
  2175 00004DC8 E8FA000000          <1> 	CALL	GET_PARM		; AH = SECTORS/TRACK
  2176 00004DCD 8A1D[5E8A0100]      <1> 	MOV	BL, [NEC_STATUS+5]	; GET ENDING SECTOR
  2177 00004DD3 6689F1              <1> 	MOV	CX,SI			; CH = HEAD # STARTED
  2178 00004DD6 3A2D[5D8A0100]      <1> 	CMP	CH, [NEC_STATUS+4]	; GET HEAD ENDED UP ON
  2179 00004DDC 750D                <1> 	JNZ	DIF_HD			; IF ON SAME HEAD, THEN NO ADJUST
  2180 00004DDE 8A2D[5C8A0100]      <1> 	MOV	CH, [NEC_STATUS+3]	; GET TRACK ENDED UP ON
  2181 00004DE4 3A6D01              <1> 	CMP	CH,[eBP+1]		; IS IT ASKED FOR TRACK
  2182 00004DE7 7404                <1> 	JZ	short SAME_TRK		; IF SAME TRACK NO INCREASE
  2183 00004DE9 00E3                <1> 	ADD	BL,AH			; ADD SECTORS/TRACK
  2184                              <1> DIF_HD:
  2185 00004DEB 00E3                <1> 	ADD	BL,AH			; ADD SECTORS/TRACK
  2186                              <1> SAME_TRK:
  2187 00004DED 2A5D00              <1> 	SUB	BL,[eBP]		; SUBTRACT START FROM END
  2188 00004DF0 88D8                <1> 	MOV	AL,BL			; TO AL
  2189                              <1> NT_OUT:
  2190 00004DF2 C3                  <1> 	RETn
  2191                              <1> 
  2192                              <1> ;-------------------------------------------------------------------------------
  2193                              <1> ; SETUP_END
  2194                              <1> ;	RESTORES @MOTOR_COUNT TO PARAMETER PROVIDED IN TABLE 
  2195                              <1> ;	AND LOADS @DSKETTE_STATUS TO AH, AND SETS CY.
  2196                              <1> ;
  2197                              <1> ; ON EXIT:
  2198                              <1> ;	AH, @DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2199                              <1> ;-------------------------------------------------------------------------------
  2200                              <1> SETUP_END:
  2201 00004DF3 B202                <1> 	MOV	DL,2			; GET THE MOTOR WAIT PARAMETER
  2202 00004DF5 6650                <1> 	PUSH	AX			; SAVE NUMBER TRANSFERRED
  2203 00004DF7 E8CB000000          <1> 	CALL	GET_PARM
  2204 00004DFC 8825[578A0100]      <1> 	MOV	[MOTOR_COUNT],AH	; STORE UPON RETURN
  2205 00004E02 6658                <1> 	POP	AX			; RESTORE NUMBER TRANSFERRED
  2206 00004E04 8A25[588A0100]      <1> 	MOV	AH, [DSKETTE_STATUS]	; GET STATUS OF OPERATION
  2207 00004E0A 08E4                <1> 	OR	AH,AH			; CHECK FOR ERROR
  2208 00004E0C 7402                <1> 	JZ	short NUN_ERR		; NO ERROR
  2209 00004E0E 30C0                <1> 	XOR	AL,AL			; CLEAR NUMBER RETURNED
  2210                              <1> NUN_ERR: 
  2211 00004E10 80FC01              <1> 	CMP	AH,1			; SET THE CARRY FLAG TO INDICATE
  2212 00004E13 F5                  <1> 	CMC				; SUCCESS OR FAILURE
  2213 00004E14 C3                  <1> 	RETn
  2214                              <1> 
  2215                              <1> ;-------------------------------------------------------------------------------
  2216                              <1> ; SETUP_DBL
  2217                              <1> ;	CHECK DOUBLE STEP.
  2218                              <1> ;
  2219                              <1> ; ON ENTRY :	DI = DRIVE
  2220                              <1> ;
  2221                              <1> ; ON EXIT :	CY = 1 MEANS ERROR
  2222                              <1> ;-------------------------------------------------------------------------------
  2223                              <1> SETUP_DBL:
  2224 00004E15 8AA7[658A0100]      <1> 	MOV	AH, [DSK_STATE+eDI]	; ACCESS STATE
  2225 00004E1B F6C410              <1> 	TEST	AH,MED_DET		; ESTABLISHED STATE ?
  2226 00004E1E 757E                <1> 	JNZ	short NO_DBL			; IF ESTABLISHED THEN DOUBLE DONE
  2227                              <1> 
  2228                              <1> ;-----	CHECK FOR TRACK 0 TO SPEED UP ACKNOWLEDGE OF UNFORMATTED DISKETTE
  2229                              <1> 
  2230 00004E20 C605[558A0100]00    <1> 	MOV	byte [SEEK_STATUS],0	; SET RECALIBRATE REQUIRED ON ALL DRIVES
  2231 00004E27 E8E0000000          <1> 	CALL	MOTOR_ON		; ENSURE MOTOR STAY ON
  2232 00004E2C B500                <1> 	MOV	CH,0			; LOAD TRACK 0
  2233 00004E2E E8D4010000          <1> 	CALL	SEEK			; SEEK TO TRACK 0
  2234 00004E33 E868000000          <1> 	CALL	READ_ID			; READ ID FUNCTION
  2235 00004E38 7249                <1> 	JC	short SD_ERR		; IF ERROR NO TRACK 0
  2236                              <1> 
  2237                              <1> ;-----	INITIALIZE START AND MAX TRACKS (TIMES 2 FOR BOTH HEADS)
  2238                              <1> 
  2239 00004E3A 66B95004            <1> 	MOV	CX,0450H 		; START, MAX TRACKS
  2240 00004E3E F687[658A0100]01    <1> 	TEST	byte [DSK_STATE+eDI],TRK_CAPA ; TEST FOR 80 TRACK CAPABILITY
  2241 00004E45 7402                <1> 	JZ	short CNT_OK		; IF NOT COUNT IS SETUP
  2242 00004E47 B1A0                <1> 	MOV	CL,0A0H			; MAXIMUM TRACK 1.2 MB
  2243                              <1> 
  2244                              <1> ;	ATTEMPT READ ID OF ALL TRACKS, ALL HEADS UNTIL SUCCESS; UPON SUCCESS,
  2245                              <1> ;	MUST SEE IF ASKED FOR TRACK IN SINGLE STEP MODE = TRACK ID READ; IF NOT
  2246                              <1> ;	THEN SET DOUBLE STEP ON.
  2247                              <1> 
  2248                              <1> CNT_OK:
  2249 00004E49 C605[578A0100]FF    <1>         MOV     byte [MOTOR_COUNT], 0FFH ; ENSURE MOTOR STAYS ON FOR OPERATION 
  2250 00004E50 6651                <1> 	PUSH	CX			; SAVE TRACK, COUNT
  2251 00004E52 C605[588A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; CLEAR STATUS, EXPECT ERRORS
  2252 00004E59 6631C0              <1> 	XOR	AX,AX			; CLEAR AX
  2253 00004E5C D0ED                <1> 	SHR	CH,1			; HALVE TRACK, CY = HEAD
  2254 00004E5E C0D003              <1> 	RCL	AL,3			; AX = HEAD IN CORRECT BIT
  2255 00004E61 6650                <1> 	PUSH	AX			; SAVE HEAD
  2256 00004E63 E89F010000          <1> 	CALL	SEEK			; SEEK TO TRACK
  2257 00004E68 6658                <1> 	POP	AX			; RESTORE HEAD
  2258 00004E6A 6609C7              <1> 	OR	DI,AX			; DI = HEAD OR'ED DRIVE
  2259 00004E6D E82E000000          <1> 	CALL	READ_ID			; READ ID HEAD 0
  2260 00004E72 9C                  <1> 	PUSHF				; SAVE RETURN FROM READ_ID
  2261 00004E73 6681E7FB00          <1> 	AND	DI,11111011B		; TURN OFF HEAD 1 BIT
  2262 00004E78 9D                  <1> 	POPF				; RESTORE ERROR RETURN
  2263 00004E79 6659                <1> 	POP	CX			; RESTORE COUNT
  2264 00004E7B 7308                <1> 	JNC	short DO_CHK		; IF OK, ASKED = RETURNED TRACK ?
  2265 00004E7D FEC5                <1> 	INC	CH			; INC FOR NEXT TRACK
  2266 00004E7F 38CD                <1> 	CMP	CH,CL			; REACHED MAXIMUM YET
  2267 00004E81 75C6                <1> 	JNZ	short CNT_OK		; CONTINUE TILL ALL TRIED
  2268                              <1> 
  2269                              <1> ;-----	FALL THRU, READ ID FAILED FOR ALL TRACKS
  2270                              <1> 
  2271                              <1> SD_ERR:	
  2272 00004E83 F9                  <1> 	STC				; SET CARRY FOR ERROR
  2273 00004E84 C3                  <1> 	RETn				; SETUP_DBL ERROR EXIT
  2274                              <1> 
  2275                              <1> DO_CHK:
  2276 00004E85 8A0D[5C8A0100]      <1> 	MOV	CL, [NEC_STATUS+3]	; LOAD RETURNED TRACK
  2277 00004E8B 888F[698A0100]      <1> 	MOV	[DSK_TRK+eDI], CL	; STORE TRACK NUMBER
  2278 00004E91 D0ED                <1> 	SHR	CH,1			; HALVE TRACK
  2279 00004E93 38CD                <1> 	CMP	CH,CL			; IS IT THE SAME AS ASKED FOR TRACK
  2280 00004E95 7407                <1> 	JZ	short NO_DBL		; IF SAME THEN NO DOUBLE STEP
  2281 00004E97 808F[658A0100]20    <1> 	OR	byte [DSK_STATE+eDI],DBL_STEP ; TURN ON DOUBLE STEP REQUIRED
  2282                              <1> NO_DBL:
  2283 00004E9E F8                  <1> 	CLC				; CLEAR ERROR FLAG
  2284 00004E9F C3                  <1> 	RETn
  2285                              <1> 
  2286                              <1> ;-------------------------------------------------------------------------------
  2287                              <1> ; READ_ID
  2288                              <1> ;	READ ID FUNCTION.
  2289                              <1> ;
  2290                              <1> ; ON ENTRY:	DI : BIT 2 = HEAD; BITS 1,0 = DRIVE
  2291                              <1> ;
  2292                              <1> ; ON EXIT: 	DI : BIT 2 IS RESET, BITS 1,0 = DRIVE
  2293                              <1> ;		@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION
  2294                              <1> ;-------------------------------------------------------------------------------
  2295                              <1> READ_ID:
  2296 00004EA0 B8[BD4E0000]        <1> 	MOV	eAX, ER_3		; MOVE NEC OUTPUT ERROR ADDRESS
  2297 00004EA5 50                  <1> 	PUSH	eAX
  2298 00004EA6 B44A                <1> 	MOV	AH,4AH			; READ ID COMMAND
  2299 00004EA8 E820010000          <1> 	CALL	NEC_OUTPUT		; TO CONTROLLER
  2300 00004EAD 6689F8              <1> 	MOV	AX,DI			; DRIVE # TO AH, HEAD 0
  2301 00004EB0 88C4                <1> 	MOV	AH,AL
  2302 00004EB2 E816010000          <1> 	CALL	NEC_OUTPUT		; TO CONTROLLER
  2303 00004EB7 E80BFEFFFF          <1> 	CALL	NEC_TERM		; WAIT FOR OPERATION, GET STATUS
  2304 00004EBC 58                  <1> 	POP	eAX			; THROW AWAY ERROR ADDRESS
  2305                              <1> ER_3:
  2306 00004EBD C3                  <1> 	RETn
  2307                              <1> 
  2308                              <1> ;-------------------------------------------------------------------------------
  2309                              <1> ; CMOS_TYPE
  2310                              <1> ;	RETURNS DISKETTE TYPE FROM CMOS
  2311                              <1> ;
  2312                              <1> ; ON ENTRY:	DI = DRIVE #
  2313                              <1> ;
  2314                              <1> ; ON EXIT:	AL = TYPE; CY REFLECTS STATUS
  2315                              <1> ;-------------------------------------------------------------------------------
  2316                              <1> 
  2317                              <1> CMOS_TYPE: ; 11/12/2014
  2318 00004EBE 8A87[FE6D0000]      <1> mov	al, [eDI+fd0_type]
  2319 00004EC4 20C0                <1> and 	al, al ; 18/12/2014
  2320 00004EC6 C3                  <1> retn
  2321                              <1> 
  2322                              <1> ;CMOS_TYPE:
  2323                              <1> ;	MOV	AL, CMOS_DIAG		; CMOS DIAGNOSTIC STATUS BYTE ADDRESS
  2324                              <1> ;	CALL	CMOS_READ		; GET CMOS STATUS
  2325                              <1> ;	TEST	AL,BAD_BAT+BAD_CKSUM	; BATTERY GOOD AND CHECKSUM VALID
  2326                              <1> ;	STC				; SET CY = 1 INDICATING ERROR FOR RETURN
  2327                              <1> ;	JNZ	short BAD_CM		; ERROR IF EITHER BIT ON
  2328                              <1> ;	MOV	AL,CMOS_DISKETTE	; ADDRESS OF DISKETTE BYTE IN CMOS
  2329                              <1> ;	CALL	CMOS_READ		; GET DISKETTE BYTE
  2330                              <1> ;	OR	DI,DI			; SEE WHICH DRIVE IN QUESTION
  2331                              <1> ;	JNZ	short TB		; IF DRIVE 1, DATA IN LOW NIBBLE
  2332                              <1> ;	ROR	AL,4			; EXCHANGE NIBBLES IF SECOND DRIVE
  2333                              <1> ;TB:
  2334                              <1> ;	AND	AL,0FH			; KEEP ONLY DRIVE DATA, RESET CY, 0
  2335                              <1> ;BAD_CM:
  2336                              <1> ;	RETn				; CY, STATUS OF READ
  2337                              <1> 
  2338                              <1> ;-------------------------------------------------------------------------------
  2339                              <1> ; GET_PARM
  2340                              <1> ;	THIS ROUTINE FETCHES THE INDEXED POINTER FROM THE DISK_BASE
  2341                              <1> ;	BLOCK POINTED TO BY THE DATA VARIABLE @DISK_POINTER. A BYTE FROM
  2342                              <1> ;	THAT TABLE IS THEN MOVED INTO AH, THE INDEX OF THAT BYTE BEING
  2343                              <1> ;	THE PARAMETER IN DL.
  2344                              <1> ;
  2345                              <1> ; ON ENTRY:	DL = INDEX OF BYTE TO BE FETCHED
  2346                              <1> ;
  2347                              <1> ; ON EXIT:	AH = THAT BYTE FROM BLOCK
  2348                              <1> ;		AL,DH DESTROYED
  2349                              <1> ;-------------------------------------------------------------------------------
  2350                              <1> GET_PARM:
  2351                              <1> 	;PUSH	DS
  2352 00004EC7 56                  <1> 	PUSH	eSI
  2353                              <1>     	;SUB	AX,AX			; DS = 0, BIOS DATA AREA
  2354                              <1>     	;MOV	DS,AX
  2355                              <1> 	;;mov	ax, cs
  2356                              <1> 	;;mov	ds, ax
  2357                              <1> 	; 08/02/2015 (protected mode modifications, bx -> ebx)
  2358 00004EC8 87D3                <1> 	XCHG	eDX,eBX			; BL = INDEX
  2359                              <1> 	;SUB	BH,BH			; BX = INDEX
  2360 00004ECA 81E3FF000000        <1> 	and	ebx, 0FFh
  2361                              <1>     	;LDS	SI, [DISK_POINTER]	; POINT TO BLOCK
  2362                              <1> 	;
  2363                              <1> 	; 17/12/2014
  2364 00004ED0 66A1[ED6D0000]      <1> 	mov	ax, [cfd] ; current (AL) and previous fd (AH)
  2365 00004ED6 38E0                <1> 	cmp	al, ah
  2366 00004ED8 7425                <1> 	je	short gpndc
  2367 00004EDA A2[EE6D0000]        <1> 	mov	[pfd], al ; current drive -> previous drive
  2368 00004EDF 53                  <1> 	push	ebx ; 08/02/2015
  2369 00004EE0 88C3                <1> 	mov	bl, al 
  2370                              <1> 	; 11/12/2014
  2371 00004EE2 8A83[FE6D0000]      <1> 	mov	al, [eBX+fd0_type]	; Drive type (0,1,2,3,4)
  2372                              <1> 	; 18/12/2014
  2373 00004EE8 20C0                <1> 	and	al, al
  2374 00004EEA 7507                <1> 	jnz	short gpdtc
  2375 00004EEC BB[D76D0000]        <1> 	mov	ebx, MD_TBL6		; 1.44 MB param. tbl. (default)
  2376 00004EF1 EB05                <1>         jmp     short gpdpu
  2377                              <1> gpdtc:	
  2378 00004EF3 E817F9FFFF          <1> 	call	DR_TYPE_CHECK
  2379                              <1> 	; cf = 1 -> eBX points to 1.44MB fd parameter table (default)
  2380                              <1> gpdpu:
  2381 00004EF8 891D[746D0000]      <1> 	mov	[DISK_POINTER], ebx
  2382 00004EFE 5B                  <1> 	pop	ebx
  2383                              <1> gpndc:
  2384 00004EFF 8B35[746D0000]      <1> 	mov	esi, [DISK_POINTER] ; 08/02/2015, si -> esi
  2385 00004F05 8A241E              <1> 	MOV	AH, [eSI+eBX]		; GET THE WORD
  2386 00004F08 87D3                <1> 	XCHG	eDX,eBX			; RESTORE BX
  2387 00004F0A 5E                  <1> 	POP	eSI
  2388                              <1> 	;POP	DS
  2389 00004F0B C3                  <1> 	RETn
  2390                              <1> 
  2391                              <1> ;-------------------------------------------------------------------------------
  2392                              <1> ; MOTOR_ON
  2393                              <1> ;	TURN MOTOR ON AND WAIT FOR MOTOR START UP TIME. THE @MOTOR_COUNT
  2394                              <1> ;	IS REPLACED WITH A SUFFICIENTLY HIGH NUMBER (0FFH) TO ENSURE
  2395                              <1> ;	THAT THE MOTOR DOES NOT GO OFF DURING THE OPERATION. IF THE
  2396                              <1> ;	MOTOR NEEDED TO BE TURNED ON, THE MULTI-TASKING HOOK FUNCTION
  2397                              <1> ;	(AX=90FDH, INT 15) IS CALLED TELLING THE OPERATING SYSTEM
  2398                              <1> ;	THAT THE BIOS IS ABOUT TO WAIT FOR MOTOR START UP. IF THIS
  2399                              <1> ;	FUNCTION RETURNS WITH CY = 1, IT MEANS THAT THE MINIMUM WAIT
  2400                              <1> ;	HAS BEEN COMPLETED. AT THIS POINT A CHECK IS MADE TO ENSURE
  2401                              <1> ;	THAT THE MOTOR WASN'T TURNED OFF BY THE TIMER. IF THE HOOK DID
  2402                              <1> ;	NOT WAIT, THE WAIT FUNCTION (AH=086H) IS CALLED TO WAIT THE
  2403                              <1> ;	PRESCRIBED AMOUNT OF TIME. IF THE CARRY FLAG IS SET ON RETURN,
  2404                              <1> ;	IT MEANS THAT THE FUNCTION IS IN USE AND DID NOT PERFORM THE
  2405                              <1> ;	WAIT. A TIMER 1 WAIT LOOP WILL THEN DO THE WAIT.
  2406                              <1> ;
  2407                              <1> ; ON ENTRY:	DI = DRIVE #
  2408                              <1> ; ON EXIT:	AX,CX,DX DESTROYED
  2409                              <1> ;-------------------------------------------------------------------------------
  2410                              <1> MOTOR_ON:
  2411 00004F0C 53                  <1> 	PUSH	eBX			; SAVE REG.
  2412 00004F0D E82A000000          <1> 	CALL	TURN_ON			; TURN ON MOTOR
  2413 00004F12 7226                <1> 	JC	short MOT_IS_ON		; IF CY=1 NO WAIT
  2414 00004F14 E89BF9FFFF          <1> 	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  2415 00004F19 E865F9FFFF          <1> 	CALL	XLAT_NEW		; TRANSLATE STATE TO PRESENT ARCH,
  2416                              <1> 	;CALL	TURN_ON 		; CHECK AGAIN IF MOTOR ON
  2417                              <1> 	;JC	MOT_IS_ON		; IF NO WAIT MEANS IT IS ON
  2418                              <1> M_WAIT:
  2419 00004F1E B20A                <1> 	MOV	DL,10			; GET THE MOTOR WAIT PARAMETER
  2420 00004F20 E8A2FFFFFF          <1> 	CALL	GET_PARM
  2421                              <1> 	;MOV	AL,AH			; AL = MOTOR WAIT PARAMETER
  2422                              <1> 	;XOR	AH,AH			; AX = MOTOR WAIT PARAMETER
  2423                              <1> 	;CMP	AL,8			; SEE IF AT LEAST A SECOND IS SPECIFIED
  2424 00004F25 80FC08              <1> 	cmp	ah, 8
  2425                              <1> 	;JAE	short GP2		; IF YES, CONTINUE
  2426 00004F28 7702                <1> 	ja	short J13
  2427                              <1> 	;MOV	AL,8			; ONE SECOND WAIT FOR MOTOR START UP
  2428 00004F2A B408                <1> 	mov	ah, 8
  2429                              <1> 
  2430                              <1> ;-----	AS CONTAINS NUMBER OF 1/8 SECONDS (125000 MICROSECONDS) TO WAIT
  2431                              <1> GP2:	
  2432                              <1> ;----- 	FOLLOWING LOOPS REQUIRED WHEN RTC WAIT FUNCTION IS ALREADY IN USE
  2433                              <1> J13:					; WAIT FOR 1/8 SECOND PER (AL)
  2434 00004F2C B95E200000          <1> 	MOV	eCX,8286		; COUNT FOR 1/8 SECOND AT 15.085737 US
  2435 00004F31 E810D5FFFF          <1> 	CALL	WAITF			; GO TO FIXED WAIT ROUTINE
  2436                              <1> 	;DEC	AL			; DECREMENT TIME VALUE
  2437 00004F36 FECC                <1> 	dec	ah
  2438 00004F38 75F2                <1> 	JNZ	short J13		; ARE WE DONE YET
  2439                              <1> MOT_IS_ON:
  2440 00004F3A 5B                  <1> 	POP	eBX			; RESTORE REG.
  2441 00004F3B C3                  <1> 	RETn
  2442                              <1> 
  2443                              <1> ;-------------------------------------------------------------------------------
  2444                              <1> ; TURN_ON
  2445                              <1> ;	TURN MOTOR ON AND RETURN WAIT STATE.
  2446                              <1> ;
  2447                              <1> ; ON ENTRY:	DI = DRIVE #
  2448                              <1> ;
  2449                              <1> ; ON EXIT:	CY = 0 MEANS WAIT REQUIRED
  2450                              <1> ;		CY = 1 MEANS NO WAIT REQUIRED
  2451                              <1> ;		AX,BX,CX,DX DESTROYED
  2452                              <1> ;-------------------------------------------------------------------------------
  2453                              <1> TURN_ON:
  2454 00004F3C 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2455 00004F3E 88D9                <1> 	MOV	CL,BL			; CL = DRIVE #
  2456 00004F40 C0C304              <1> 	ROL	BL,4			; BL = DRIVE SELECT
  2457 00004F43 FA                  <1> 	CLI				; NO INTERRUPTS WHILE DETERMINING STATUS
  2458 00004F44 C605[578A0100]FF    <1> 	MOV	byte [MOTOR_COUNT],0FFH	; ENSURE MOTOR STAYS ON FOR OPERATION
  2459 00004F4B A0[568A0100]        <1> 	MOV	AL, [MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  2460 00004F50 2430                <1> 	AND	AL,00110000B		; KEEP ONLY DRIVE SELECT BITS
  2461 00004F52 B401                <1> 	MOV	AH,1			; MASK FOR DETERMINING MOTOR BIT
  2462 00004F54 D2E4                <1> 	SHL	AH,CL			; AH = MOTOR ON, A=00000001, B=00000010
  2463                              <1> 
  2464                              <1> ;  AL = DRIVE SELECT FROM @MOTOR_STATUS
  2465                              <1> ;  BL = DRIVE SELECT DESIRED
  2466                              <1> ;  AH = MOTOR ON MASK DESIRED
  2467                              <1> 
  2468 00004F56 38D8                <1> 	CMP	AL,BL			; REQUESTED DRIVE ALREADY SELECTED ?
  2469 00004F58 7508                <1> 	JNZ	short TURN_IT_ON	; IF NOT SELECTED JUMP
  2470 00004F5A 8425[568A0100]      <1> 	TEST	AH, [MOTOR_STATUS]	; TEST MOTOR ON BIT
  2471 00004F60 7535                <1> 	JNZ	short NO_MOT_WAIT	; JUMP IF MOTOR ON AND SELECTED
  2472                              <1> 
  2473                              <1> TURN_IT_ON:
  2474 00004F62 08DC                <1> 	OR	AH,BL			; AH = DRIVE SELECT AND MOTOR ON
  2475 00004F64 8A3D[568A0100]      <1> 	MOV	BH,[MOTOR_STATUS]	; SAVE COPY OF @MOTOR_STATUS BEFORE
  2476 00004F6A 80E70F              <1> 	AND	BH,00001111B		; KEEP ONLY MOTOR BITS
  2477 00004F6D 8025[568A0100]CF    <1> 	AND	byte [MOTOR_STATUS],11001111B ; CLEAR OUT DRIVE SELECT
  2478 00004F74 0825[568A0100]      <1> 	OR	[MOTOR_STATUS],AH	; OR IN DRIVE SELECTED AND MOTOR ON
  2479 00004F7A A0[568A0100]        <1> 	MOV	AL,[MOTOR_STATUS]	; GET DIGITAL OUTPUT REGISTER REFLECTION
  2480 00004F7F 88C3                <1> 	MOV	BL,AL			; BL=@MOTOR_STATUS AFTER, BH=BEFORE
  2481 00004F81 80E30F              <1> 	AND	BL,00001111B		; KEEP ONLY MOTOR BITS
  2482 00004F84 FB                  <1> 	STI				; ENABLE INTERRUPTS AGAIN
  2483 00004F85 243F                <1> 	AND	AL,00111111B		; STRIP AWAY UNWANTED BITS
  2484 00004F87 C0C004              <1> 	ROL	AL,4			; PUT BITS IN DESIRED POSITIONS
  2485 00004F8A 0C0C                <1> 	OR	AL,00001100B		; NO RESET, ENABLE DMA/INTERRUPT
  2486 00004F8C 66BAF203            <1> 	MOV	DX,03F2H		; SELECT DRIVE AND TURN ON MOTOR
  2487 00004F90 EE                  <1> 	OUT	DX,AL
  2488 00004F91 38FB                <1> 	CMP	BL,BH			; NEW MOTOR TURNED ON ?
  2489                              <1> 	;JZ	short NO_MOT_WAIT	; NO WAIT REQUIRED IF JUST SELECT
  2490 00004F93 7403                <1> 	je	short no_mot_w1 ; 27/02/2015 
  2491 00004F95 F8                  <1> 	CLC				; (re)SET CARRY MEANING WAIT
  2492 00004F96 C3                  <1> 	RETn
  2493                              <1> 
  2494                              <1> NO_MOT_WAIT:
  2495 00004F97 FB                  <1> 	sti
  2496                              <1> no_mot_w1: ; 27/02/2015
  2497 00004F98 F9                  <1> 	STC				; SET NO WAIT REQUIRED
  2498                              <1> 	;STI				; INTERRUPTS BACK ON
  2499 00004F99 C3                  <1> 	RETn
  2500                              <1> 
  2501                              <1> ;-------------------------------------------------------------------------------
  2502                              <1> ; HD_WAIT
  2503                              <1> ;	WAIT FOR HEAD SETTLE TIME.
  2504                              <1> ;
  2505                              <1> ; ON ENTRY:	DI = DRIVE #
  2506                              <1> ;
  2507                              <1> ; ON EXIT:	AX,BX,CX,DX DESTROYED
  2508                              <1> ;-------------------------------------------------------------------------------
  2509                              <1> HD_WAIT:
  2510 00004F9A B209                <1> 	MOV	DL,9			; GET HEAD SETTLE PARAMETER
  2511 00004F9C E826FFFFFF          <1> 	CALL	GET_PARM
  2512 00004FA1 08E4                <1> 	or	ah, ah	; 17/12/2014
  2513 00004FA3 7519                <1> 	jnz	short DO_WAT
  2514 00004FA5 F605[568A0100]80    <1>         TEST    byte [MOTOR_STATUS],10000000B ; SEE IF A WRITE OPERATION
  2515                              <1> 	;JZ	short ISNT_WRITE	; IF NOT, DO NOT ENFORCE ANY VALUES
  2516                              <1> 	;OR	AH,AH			; CHECK FOR ANY WAIT?
  2517                              <1> 	;JNZ	short DO_WAT		; IF THERE DO NOT ENFORCE
  2518 00004FAC 741E                <1> 	jz	short HW_DONE
  2519 00004FAE B40F                <1> 	MOV	AH,HD12_SETTLE		; LOAD 1.2M HEAD SETTLE MINIMUM
  2520 00004FB0 8A87[658A0100]      <1> 	MOV	AL,[DSK_STATE+eDI]	; LOAD STATE
  2521 00004FB6 24C0                <1> 	AND	AL,RATE_MSK		; KEEP ONLY RATE
  2522 00004FB8 3C80                <1> 	CMP	AL,RATE_250		; 1.2 M DRIVE ?
  2523 00004FBA 7502                <1> 	JNZ	short DO_WAT		; DEFAULT HEAD SETTLE LOADED
  2524                              <1> ;GP3:
  2525 00004FBC B414                <1> 	MOV	AH,HD320_SETTLE		; USE 320/360 HEAD SETTLE
  2526                              <1> ;	JMP	SHORT DO_WAT
  2527                              <1> 
  2528                              <1> ;ISNT_WRITE:
  2529                              <1> ;	OR	AH,AH			; CHECK FOR NO WAIT
  2530                              <1> ;	JZ	short HW_DONE		; IF NOT WRITE AND 0 ITS OK
  2531                              <1> 
  2532                              <1> ;-----	AH CONTAINS NUMBER OF MILLISECONDS TO WAIT
  2533                              <1> DO_WAT:
  2534                              <1> ;	MOV	AL,AH			; AL = # MILLISECONDS
  2535                              <1> ;	;XOR	AH,AH			; AX = # MILLISECONDS
  2536                              <1> J29:					; 	1 MILLISECOND LOOP
  2537                              <1> 	;mov	cx, WAIT_FDU_HEAD_SETTLE ; 33 ; 1 ms in 30 micro units.
  2538 00004FBE B942000000          <1> 	MOV	eCX,66			; COUNT AT 15.085737 US PER COUNT
  2539 00004FC3 E87ED4FFFF          <1> 	CALL	WAITF			; DELAY FOR 1 MILLISECOND
  2540                              <1> 	;DEC	AL			; DECREMENT THE COUNT
  2541 00004FC8 FECC                <1> 	dec	ah
  2542 00004FCA 75F2                <1> 	JNZ	short J29		; DO AL MILLISECOND # OF TIMES
  2543                              <1> HW_DONE:
  2544 00004FCC C3                  <1> 	RETn
  2545                              <1> 
  2546                              <1> ;-------------------------------------------------------------------------------
  2547                              <1> ; NEC_OUTPUT
  2548                              <1> ;	THIS ROUTINE SENDS A BYTE TO THE NEC CONTROLLER AFTER TESTING
  2549                              <1> ;	FOR CORRECT DIRECTION AND CONTROLLER READY THIS ROUTINE WILL
  2550                              <1> ;	TIME OUT IF THE BYTE IS NOT ACCEPTED WITHIN A REASONABLE AMOUNT
  2551                              <1> ;	OF TIME, SETTING THE DISKETTE STATUS ON COMPLETION.
  2552                              <1> ; 
  2553                              <1> ; ON ENTRY: 	AH = BYTE TO BE OUTPUT
  2554                              <1> ;
  2555                              <1> ; ON EXIT:	CY = 0  SUCCESS
  2556                              <1> ;		CY = 1  FAILURE -- DISKETTE STATUS UPDATED
  2557                              <1> ;		        IF A FAILURE HAS OCCURRED, THE RETURN IS MADE ONE LEVEL
  2558                              <1> ;		        HIGHER THAN THE CALLER OF NEC OUTPUT. THIS REMOVES THE
  2559                              <1> ;		        REQUIREMENT OF TESTING AFTER EVERY CALL OF NEC_OUTPUT.
  2560                              <1> ;		AX,CX,DX DESTROYED
  2561                              <1> ;-------------------------------------------------------------------------------
  2562                              <1> 
  2563                              <1> ; 09/12/2014 [Erdogan Tan] 
  2564                              <1> ;	(from 'PS2 Hardware Interface Tech. Ref. May 88', Page 09-05.)
  2565                              <1> ; Diskette Drive Controller Status Register (3F4h)
  2566                              <1> ;	This read only register facilitates the transfer of data between
  2567                              <1> ;	the system microprocessor and the controller.
  2568                              <1> ; Bit 7 - When set to 1, the Data register is ready to transfer data 
  2569                              <1> ;	  with the system micrprocessor.
  2570                              <1> ; Bit 6 - The direction of data transfer. If this bit is set to 0,
  2571                              <1> ;	  the transfer is to the controller.
  2572                              <1> ; Bit 5 - When this bit is set to 1, the controller is in the non-DMA mode.
  2573                              <1> ; Bit 4 - When this bit is set to 1, a Read or Write command is being executed.
  2574                              <1> ; Bit 3 - Reserved.
  2575                              <1> ; Bit 2 - Reserved.
  2576                              <1> ; Bit 1 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  2577                              <1> ; Bit 0 - When this bit is set to 1, dskette drive 1 is in the seek mode.
  2578                              <1> 
  2579                              <1> ; Data Register (3F5h)
  2580                              <1> ; This read/write register passes data, commands and parameters, and provides
  2581                              <1> ; diskette status information.
  2582                              <1>   		
  2583                              <1> NEC_OUTPUT:
  2584                              <1> 	;PUSH	BX			; SAVE REG.
  2585 00004FCD 66BAF403            <1> 	MOV	DX,03F4H		; STATUS PORT
  2586                              <1> 	;MOV	BL,2			; HIGH ORDER COUNTER
  2587                              <1> 	;XOR	CX,CX			; COUNT FOR TIME OUT
  2588                              <1> 	; 16/12/2014
  2589                              <1> 	; waiting for (max.) 0.5 seconds
  2590                              <1>         ;;mov     byte [wait_count], 0 ;; 27/02/2015
  2591                              <1> 	;
  2592                              <1> 	; 17/12/2014
  2593                              <1> 	; Modified from AWARD BIOS 1999 - ADISK.ASM - SEND_COMMAND
  2594                              <1> 	;
  2595                              <1> 	;WAIT_FOR_PORT:	Waits for a bit at a port pointed to by DX to
  2596                              <1> 	;		go on.
  2597                              <1> 	;INPUT:
  2598                              <1> 	;	AH=Mask for isolation bits.
  2599                              <1> 	;	AL=pattern to look for.
  2600                              <1> 	;	DX=Port to test for
  2601                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  2602                              <1> 	;	     (normally 30 microseconds per period.)
  2603                              <1> 	;
  2604                              <1> 	;WFP_SHORT:  
  2605                              <1> 	;	Wait for port if refresh cycle is short (15-80 Us range).
  2606                              <1> 	;
  2607                              <1> 
  2608                              <1> ;	mov	bl, WAIT_FDU_SEND_HI+1	; 0+1
  2609                              <1> ;	mov	cx, WAIT_FDU_SEND_LO	; 16667
  2610 00004FD1 B91B410000          <1> 	mov	ecx, WAIT_FDU_SEND_LH   ; 16667 (27/02/2015)
  2611                              <1> ;
  2612                              <1> ;WFPS_OUTER_LP:
  2613                              <1> ;	;
  2614                              <1> ;WFPS_CHECK_PORT:
  2615                              <1> J23:
  2616 00004FD6 EC                  <1> 	IN	AL,DX			; GET STATUS
  2617 00004FD7 24C0                <1> 	AND	AL,11000000B		; KEEP STATUS AND DIRECTION
  2618 00004FD9 3C80                <1> 	CMP	AL,10000000B		; STATUS 1 AND DIRECTION 0 ?
  2619 00004FDB 7418                <1> 	JZ	short J27		; STATUS AND DIRECTION OK
  2620                              <1> WFPS_HI:
  2621 00004FDD E461                <1> 	IN	AL, PORT_B	;061h	; SYS1	; wait for hi to lo
  2622 00004FDF A810                <1> 	TEST	AL,010H			; transition on memory
  2623 00004FE1 75FA                <1> 	JNZ	SHORT WFPS_HI		; refresh.
  2624                              <1> WFPS_LO:
  2625 00004FE3 E461                <1> 	IN	AL, PORT_B		; SYS1
  2626 00004FE5 A810                <1> 	TEST	AL,010H
  2627 00004FE7 74FA                <1> 	JZ	SHORT WFPS_LO
  2628                              <1> 	;LOOP	SHORT WFPS_CHECK_PORT
  2629 00004FE9 E2EB                <1> 	loop	J23	; 27/02/2015
  2630                              <1> ;	;
  2631                              <1> ;	dec	bl
  2632                              <1> ;	jnz	short WFPS_OUTER_LP
  2633                              <1> ;	jmp	short WFPS_TIMEOUT	; fail
  2634                              <1> ;J23:
  2635                              <1> ;	IN	AL,DX			; GET STATUS
  2636                              <1> ;	AND	AL,11000000B		; KEEP STATUS AND DIRECTION
  2637                              <1> ;	CMP	AL,10000000B		; STATUS 1 AND DIRECTION 0 ?
  2638                              <1> ;	JZ	short J27		; STATUS AND DIRECTION OK
  2639                              <1> 	;LOOP	J23			; CONTINUE TILL CX EXHAUSTED
  2640                              <1> 	;DEC	BL			; DECREMENT COUNTER
  2641                              <1> 	;JNZ	short J23		; REPEAT TILL DELAY FINISHED, CX = 0
  2642                              <1>    
  2643                              <1> 	;;27/02/2015
  2644                              <1> 	;16/12/2014
  2645                              <1>         ;;cmp     byte [wait_count], 10   ; (10/18.2 seconds)
  2646                              <1> 	;;jb	short J23
  2647                              <1> 
  2648                              <1> ;WFPS_TIMEOUT:
  2649                              <1> 
  2650                              <1> ;-----	FALL THRU TO ERROR RETURN
  2651                              <1> 
  2652 00004FEB 800D[588A0100]80    <1> 	OR	byte [DSKETTE_STATUS],TIME_OUT
  2653                              <1> 	;POP	BX			; RESTORE REG.
  2654 00004FF2 58                  <1> 	POP	eAX ; 08/02/2015	; DISCARD THE RETURN ADDRESS
  2655 00004FF3 F9                  <1> 	STC				; INDICATE ERROR TO CALLER
  2656 00004FF4 C3                  <1> 	RETn
  2657                              <1> 
  2658                              <1> ;-----	DIRECTION AND STATUS OK; OUTPUT BYTE
  2659                              <1> 
  2660                              <1> J27:	
  2661 00004FF5 88E0                <1> 	MOV	AL,AH			; GET BYTE TO OUTPUT
  2662 00004FF7 6642                <1> 	INC	DX			; DATA PORT = STATUS PORT + 1
  2663 00004FF9 EE                  <1> 	OUT	DX,AL			; OUTPUT THE BYTE
  2664                              <1> 	;;NEWIODELAY  ;; 27/02/2015
  2665                              <1> 	; 27/02/2015
  2666 00004FFA 9C                  <1> 	PUSHF				; SAVE FLAGS
  2667 00004FFB B903000000          <1> 	MOV	eCX, 3			; 30 TO 45 MICROSECONDS WAIT FOR
  2668 00005000 E841D4FFFF          <1> 	CALL 	WAITF			; NEC FLAGS UPDATE CYCLE
  2669 00005005 9D                  <1> 	POPF				; RESTORE FLAGS FOR EXIT
  2670                              <1> 	;POP	BX			; RESTORE REG
  2671 00005006 C3                  <1> 	RETn				; CY = 0 FROM TEST INSTRUCTION
  2672                              <1> 
  2673                              <1> ;-------------------------------------------------------------------------------
  2674                              <1> ; SEEK
  2675                              <1> ;	THIS ROUTINE WILL MOVE THE HEAD ON THE NAMED DRIVE TO THE NAMED
  2676                              <1> ;	TRACK. IF THE DRIVE HAS NOT BEEN ACCESSED SINCE THE DRIVE
  2677                              <1> ;	RESET COMMAND WAS ISSUED, THE DRIVE WILL BE RECALIBRATED.
  2678                              <1> ;
  2679                              <1> ; ON ENTRY:	DI = DRIVE #
  2680                              <1> ;		CH = TRACK #
  2681                              <1> ;
  2682                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2683                              <1> ;		AX,BX,CX DX DESTROYED
  2684                              <1> ;-------------------------------------------------------------------------------
  2685                              <1> SEEK:
  2686 00005007 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2687 00005009 B001                <1> 	MOV	AL,1			; ESTABLISH MASK FOR RECALIBRATE TEST
  2688 0000500B 86CB                <1> 	XCHG	CL,BL			; SET DRIVE VALULE INTO CL
  2689 0000500D D2C0                <1> 	ROL	AL,CL			; SHIFT MASK BY THE DRIVE VALUE
  2690 0000500F 86CB                <1> 	XCHG	CL,BL			; RECOVER TRACK VALUE
  2691 00005011 8405[558A0100]      <1> 	TEST	AL,[SEEK_STATUS]	; TEST FOR RECALIBRATE REQUIRED
  2692 00005017 7526                <1> 	JNZ	short J28A		; JUMP IF RECALIBRATE NOT REQUIRED
  2693                              <1> 
  2694 00005019 0805[558A0100]      <1> 	OR	[SEEK_STATUS],AL	; TURN ON THE NO RECALIBRATE BIT IN FLAG
  2695 0000501F E862000000          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  2696 00005024 730E                <1> 	JNC	short AFT_RECAL		; RECALIBRATE DONE
  2697                              <1> 
  2698                              <1> ;-----	ISSUE RECALIBRATE FOR 80 TRACK DISKETTES
  2699                              <1> 
  2700 00005026 C605[588A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; CLEAR OUT INVALID STATUS
  2701 0000502D E854000000          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  2702 00005032 7251                <1> 	JC	short RB		; IF RECALIBRATE FAILS TWICE THEN ERROR
  2703                              <1> 
  2704                              <1> AFT_RECAL:
  2705 00005034 C687[698A0100]00    <1>         MOV     byte [DSK_TRK+eDI],0    ; SAVE NEW CYLINDER AS PRESENT POSITION
  2706 0000503B 08ED                <1> 	OR	CH,CH			; CHECK FOR SEEK TO TRACK 0
  2707 0000503D 743F                <1> 	JZ	short DO_WAIT		; HEAD SETTLE, CY = 0 IF JUMP
  2708                              <1> 
  2709                              <1> ;-----	DRIVE IS IN SYNCHRONIZATION WITH CONTROLLER, SEEK TO TRACK
  2710                              <1> 
  2711 0000503F F687[658A0100]20    <1> J28A:	TEST	byte [DSK_STATE+eDI],DBL_STEP ; CHECK FOR DOUBLE STEP REQUIRED
  2712 00005046 7402                <1> 	JZ	short _R7		; SINGLE STEP REQUIRED BYPASS DOUBLE
  2713 00005048 D0E5                <1> 	SHL	CH,1			; DOUBLE NUMBER OF STEP TO TAKE
  2714                              <1> 
  2715 0000504A 3AAF[698A0100]      <1> _R7:	CMP	CH, [DSK_TRK+eDI]	; SEE IF ALREADY AT THE DESIRED TRACK
  2716 00005050 7433                <1> 	JE	short RB		; IF YES, DO NOT NEED TO SEEK
  2717                              <1> 
  2718 00005052 BA[85500000]        <1> 	MOV	eDX, NEC_ERR		; LOAD RETURN ADDRESS
  2719 00005057 52                  <1> 	PUSH	eDX ; (*)		; ON STACK FOR NEC OUTPUT ERROR
  2720 00005058 88AF[698A0100]      <1> 	MOV	[DSK_TRK+eDI],CH	; SAVE NEW CYLINDER AS PRESENT POSITION
  2721 0000505E B40F                <1> 	MOV	AH,0FH			; SEEK COMMAND TO NEC
  2722 00005060 E868FFFFFF          <1> 	CALL	NEC_OUTPUT
  2723 00005065 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2724 00005067 88DC                <1> 	MOV	AH,BL			; OUTPUT DRIVE NUMBER
  2725 00005069 E85FFFFFFF          <1> 	CALL	NEC_OUTPUT
  2726 0000506E 8AA7[698A0100]      <1> 	MOV	AH, [DSK_TRK+eDI]	; GET CYLINDER NUMBER
  2727 00005074 E854FFFFFF          <1> 	CALL	NEC_OUTPUT
  2728 00005079 E829000000          <1> 	CALL	CHK_STAT_2		; ENDING INTERRUPT AND SENSE STATUS
  2729                              <1> 
  2730                              <1> ;-----	WAIT FOR HEAD SETTLE
  2731                              <1> 
  2732                              <1> DO_WAIT:
  2733 0000507E 9C                  <1> 	PUSHF				; SAVE STATUS
  2734 0000507F E816FFFFFF          <1> 	CALL	HD_WAIT			; WAIT FOR HEAD SETTLE TIME
  2735 00005084 9D                  <1> 	POPF				; RESTORE STATUS
  2736                              <1> RB:
  2737                              <1> NEC_ERR:
  2738                              <1> 	; 08/02/2015 (code trick here from original IBM PC/AT DISKETTE.ASM)
  2739                              <1> 	; (*) nec_err -> retn (push edx -> pop edx) -> nec_err -> retn
  2740 00005085 C3                  <1> 	RETn				; RETURN TO CALLER
  2741                              <1> 
  2742                              <1> ;-------------------------------------------------------------------------------
  2743                              <1> ; RECAL
  2744                              <1> ;	RECALIBRATE DRIVE
  2745                              <1> ;
  2746                              <1> ; ON ENTRY:	DI = DRIVE #
  2747                              <1> ;
  2748                              <1> ; ON EXIT:	CY REFLECTS STATUS OF OPERATION.
  2749                              <1> ;-------------------------------------------------------------------------------
  2750                              <1> RECAL:
  2751 00005086 6651                <1> 	PUSH	CX
  2752 00005088 B8[A4500000]        <1> 	MOV	eAX, RC_BACK		; LOAD NEC_OUTPUT ERROR
  2753 0000508D 50                  <1> 	PUSH	eAX
  2754 0000508E B407                <1> 	MOV	AH,07H			; RECALIBRATE COMMAND
  2755 00005090 E838FFFFFF          <1> 	CALL	NEC_OUTPUT
  2756 00005095 89FB                <1> 	MOV	eBX,eDI			; BX = DRIVE #
  2757 00005097 88DC                <1> 	MOV	AH,BL
  2758 00005099 E82FFFFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT THE DRIVE NUMBER
  2759 0000509E E804000000          <1> 	CALL	CHK_STAT_2		; GET THE INTERRUPT AND SENSE INT STATUS
  2760 000050A3 58                  <1> 	POP	eAX			; THROW AWAY ERROR
  2761                              <1> RC_BACK:
  2762 000050A4 6659                <1> 	POP	CX
  2763 000050A6 C3                  <1> 	RETn
  2764                              <1> 
  2765                              <1> ;-------------------------------------------------------------------------------
  2766                              <1> ; CHK_STAT_2
  2767                              <1> ;	THIS ROUTINE HANDLES THE INTERRUPT RECEIVED AFTER RECALIBRATE,
  2768                              <1> ;	OR SEEK TO THE ADAPTER. THE INTERRUPT IS WAITED FOR, THE
  2769                              <1> ;	INTERRUPT STATUS SENSED, AND THE RESULT RETURNED TO THE CALLER.
  2770                              <1> ;
  2771                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2772                              <1> ;-------------------------------------------------------------------------------
  2773                              <1> CHK_STAT_2:
  2774 000050A7 B8[CF500000]        <1>         MOV     eAX, CS_BACK            ; LOAD NEC_OUTPUT ERROR ADDRESS
  2775 000050AC 50                  <1> 	PUSH	eAX
  2776 000050AD E828000000          <1> 	CALL	WAIT_INT		; WAIT FOR THE INTERRUPT
  2777 000050B2 721A                <1> 	JC	short J34		; IF ERROR, RETURN IT
  2778 000050B4 B408                <1> 	MOV	AH,08H			; SENSE INTERRUPT STATUS COMMAND
  2779 000050B6 E812FFFFFF          <1> 	CALL	NEC_OUTPUT
  2780 000050BB E84A000000          <1> 	CALL	RESULTS			; READ IN THE RESULTS
  2781 000050C0 720C                <1> 	JC	short J34
  2782 000050C2 A0[598A0100]        <1> 	MOV	AL,[NEC_STATUS]		; GET THE FIRST STATUS BYTE
  2783 000050C7 2460                <1> 	AND	AL,01100000B		; ISOLATE THE BITS
  2784 000050C9 3C60                <1> 	CMP	AL,01100000B		; TEST FOR CORRECT VALUE
  2785 000050CB 7403                <1> 	JZ	short J35		; IF ERROR, GO MARK IT
  2786 000050CD F8                  <1> 	CLC				; GOOD RETURN
  2787                              <1> J34:
  2788 000050CE 58                  <1> 	POP	eAX			; THROW AWAY ERROR RETURN
  2789                              <1> CS_BACK:
  2790 000050CF C3                  <1> 	RETn
  2791                              <1> J35:
  2792 000050D0 800D[588A0100]40    <1> 	OR	byte [DSKETTE_STATUS], BAD_SEEK
  2793 000050D7 F9                  <1> 	STC				; ERROR RETURN CODE
  2794 000050D8 EBF4                <1> 	JMP	SHORT J34
  2795                              <1> 
  2796                              <1> ;-------------------------------------------------------------------------------
  2797                              <1> ; WAIT_INT
  2798                              <1> ;	THIS ROUTINE WAITS FOR AN INTERRUPT TO OCCUR A TIME OUT ROUTINE
  2799                              <1> ;	TAKES PLACE DURING THE WAIT, SO THAT AN ERROR MAY BE RETURNED
  2800                              <1> ;	IF THE DRIVE IS NOT READY.
  2801                              <1> ;
  2802                              <1> ; ON EXIT: 	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2803                              <1> ;-------------------------------------------------------------------------------
  2804                              <1> 
  2805                              <1> ; 17/12/2014
  2806                              <1> ; 2.5 seconds waiting !
  2807                              <1> ;(AWARD BIOS - 1999, WAIT_FDU_INT_LOW, WAIT_FDU_INT_HI)
  2808                              <1> ; amount of time to wait for completion interrupt from NEC.
  2809                              <1> 
  2810                              <1> 
  2811                              <1> WAIT_INT:
  2812 000050DA FB                  <1> 	STI				; TURN ON INTERRUPTS, JUST IN CASE
  2813 000050DB F8                  <1> 	CLC				; CLEAR TIMEOUT INDICATOR
  2814                              <1>        ;MOV	BL,10			; CLEAR THE COUNTERS
  2815                              <1>        ;XOR	CX,CX			; FOR 2 SECOND WAIT
  2816                              <1> 
  2817                              <1> 	; Modification from AWARD BIOS - 1999 (ATORGS.ASM, WAIT
  2818                              <1> 	;
  2819                              <1> 	;WAIT_FOR_MEM:	
  2820                              <1> 	;	Waits for a bit at a specified memory location pointed
  2821                              <1> 	;	to by ES:[DI] to become set.
  2822                              <1> 	;INPUT:
  2823                              <1> 	;	AH=Mask to test with.
  2824                              <1> 	;	ES:[DI] = memory location to watch.
  2825                              <1> 	;	BH:CX=Number of memory refresh periods to delay.
  2826                              <1> 	;	     (normally 30 microseconds per period.)
  2827                              <1> 
  2828                              <1> 	; waiting for (max.) 2.5 secs in 30 micro units.
  2829                              <1> ;	mov 	cx, WAIT_FDU_INT_LO		; 017798
  2830                              <1> ;;	mov 	bl, WAIT_FDU_INT_HI
  2831                              <1> ;	mov 	bl, WAIT_FDU_INT_HI + 1
  2832                              <1> 	; 27/02/2015
  2833 000050DC B986450100          <1> 	mov 	ecx, WAIT_FDU_INT_LH	; 83334 (2.5 seconds)		
  2834                              <1> WFMS_CHECK_MEM:
  2835 000050E1 F605[558A0100]80    <1> 	test	byte [SEEK_STATUS],INT_FLAG ; TEST FOR INTERRUPT OCCURRING
  2836 000050E8 7516                <1>         jnz     short J37
  2837                              <1> WFMS_HI:
  2838 000050EA E461                <1> 	IN	AL,PORT_B  ; 061h	; SYS1, wait for lo to hi
  2839 000050EC A810                <1> 	TEST	AL,010H			; transition on memory
  2840 000050EE 75FA                <1> 	JNZ	SHORT WFMS_HI		; refresh.
  2841                              <1> WFMS_LO:
  2842 000050F0 E461                <1> 	IN	AL,PORT_B		;SYS1
  2843 000050F2 A810                <1> 	TEST	AL,010H
  2844 000050F4 74FA                <1> 	JZ	SHORT WFMS_LO
  2845 000050F6 E2E9                <1>         LOOP    WFMS_CHECK_MEM
  2846                              <1> ;WFMS_OUTER_LP:
  2847                              <1> ;;	or	bl, bl			; check outer counter
  2848                              <1> ;;	jz	short J36A		; WFMS_TIMEOUT
  2849                              <1> ;	dec	bl
  2850                              <1> ;	jz	short J36A	
  2851                              <1> ;	jmp	short WFMS_CHECK_MEM
  2852                              <1> 
  2853                              <1> 	;17/12/2014
  2854                              <1> 	;16/12/2014
  2855                              <1> ;        mov     byte [wait_count], 0    ; Reset (INT 08H) counter
  2856                              <1> ;J36:
  2857                              <1> ;	TEST	byte [SEEK_STATUS],INT_FLAG ; TEST FOR INTERRUPT OCCURRING
  2858                              <1> ;	JNZ	short J37
  2859                              <1> 	;16/12/2014
  2860                              <1> 	;LOOP	J36			; COUNT DOWN WHILE WAITING
  2861                              <1> 	;DEC	BL			; SECOND LEVEL COUNTER
  2862                              <1> 	;JNZ	short J36
  2863                              <1> ;       cmp     byte [wait_count], 46   ; (46/18.2 seconds)
  2864                              <1> ;	jb	short J36
  2865                              <1> 
  2866                              <1> ;WFMS_TIMEOUT:
  2867                              <1> ;J36A:
  2868 000050F8 800D[588A0100]80    <1> 	OR	byte [DSKETTE_STATUS], TIME_OUT ; NOTHING HAPPENED
  2869 000050FF F9                  <1> 	STC				; ERROR RETURN
  2870                              <1> J37:
  2871 00005100 9C                  <1> 	PUSHF				; SAVE CURRENT CARRY
  2872 00005101 8025[558A0100]7F    <1> 	AND	byte [SEEK_STATUS], ~INT_FLAG ; TURN OFF INTERRUPT FLAG
  2873 00005108 9D                  <1> 	POPF				; RECOVER CARRY
  2874 00005109 C3                  <1> 	RETn				; GOOD RETURN CODE
  2875                              <1> 
  2876                              <1> ;-------------------------------------------------------------------------------
  2877                              <1> ; RESULTS
  2878                              <1> ;	THIS ROUTINE WILL READ ANYTHING THAT THE NEC CONTROLLER RETURNS 
  2879                              <1> ;	FOLLOWING AN INTERRUPT.
  2880                              <1> ;
  2881                              <1> ; ON EXIT:	@DSKETTE_STATUS, CY REFLECT STATUS OF OPERATION.
  2882                              <1> ;		AX,BX,CX,DX DESTROYED
  2883                              <1> ;-------------------------------------------------------------------------------
  2884                              <1> RESULTS:
  2885 0000510A 57                  <1> 	PUSH	eDI
  2886 0000510B BF[598A0100]        <1> 	MOV	eDI, NEC_STATUS		; POINTER TO DATA AREA
  2887 00005110 B307                <1> 	MOV	BL,7			; MAX STATUS BYTES
  2888 00005112 66BAF403            <1> 	MOV	DX,03F4H		; STATUS PORT
  2889                              <1> 
  2890                              <1> ;-----	WAIT FOR REQUEST FOR MASTER
  2891                              <1> 
  2892                              <1> _R10: 
  2893                              <1> 	; 16/12/2014
  2894                              <1> 	; wait for (max) 0.5 seconds
  2895                              <1> 	;MOV	BH,2			; HIGH ORDER COUNTER
  2896                              <1> 	;XOR	CX,CX			; COUNTER
  2897                              <1> 
  2898                              <1> 	;Time to wait while waiting for each byte of NEC results = .5
  2899                              <1> 	;seconds.  .5 seconds = 500,000 micros.  500,000/30 = 16,667.
  2900                              <1> 	; 27/02/2015
  2901 00005116 B91B410000          <1> 	mov 	ecx, WAIT_FDU_RESULTS_LH ; 16667  
  2902                              <1> 	;mov	cx, WAIT_FDU_RESULTS_LO  ; 16667
  2903                              <1> 	;mov	bh, WAIT_FDU_RESULTS_HI+1 ; 0+1
  2904                              <1> 
  2905                              <1> WFPSR_OUTER_LP:
  2906                              <1> 	;
  2907                              <1> WFPSR_CHECK_PORT:
  2908                              <1> J39:					; WAIT FOR MASTER
  2909 0000511B EC                  <1> 	IN	AL,DX			; GET STATUS
  2910 0000511C 24C0                <1> 	AND	AL,11000000B		; KEEP ONLY STATUS AND DIRECTION
  2911 0000511E 3CC0                <1> 	CMP	AL,11000000B		; STATUS 1 AND DIRECTION 1 ?
  2912 00005120 7418                <1> 	JZ	short J42		; STATUS AND DIRECTION OK
  2913                              <1> WFPSR_HI:
  2914 00005122 E461                <1> 	IN	AL, PORT_B	;061h	; SYS1	; wait for hi to lo
  2915 00005124 A810                <1> 	TEST	AL,010H			; transition on memory
  2916 00005126 75FA                <1> 	JNZ	SHORT WFPSR_HI		; refresh.
  2917                              <1> WFPSR_LO:
  2918 00005128 E461                <1> 	IN	AL, PORT_B		; SYS1
  2919 0000512A A810                <1> 	TEST	AL,010H
  2920 0000512C 74FA                <1> 	JZ	SHORT WFPSR_LO
  2921 0000512E E2EB                <1>         LOOP    WFPSR_CHECK_PORT
  2922                              <1> 	;; 27/02/2015
  2923                              <1> 	;;dec	bh
  2924                              <1> 	;;jnz	short WFPSR_OUTER_LP
  2925                              <1> 	;jmp	short WFPSR_TIMEOUT	; fail
  2926                              <1> 
  2927                              <1> 	;;mov	byte [wait_count], 0
  2928                              <1> ;J39:					; WAIT FOR MASTER
  2929                              <1> ;	IN	AL,DX			; GET STATUS
  2930                              <1> ;	AND	AL,11000000B		; KEEP ONLY STATUS AND DIRECTION
  2931                              <1> ;	CMP	AL,11000000B		; STATUS 1 AND DIRECTION 1 ?
  2932                              <1> ;	JZ	short J42		; STATUS AND DIRECTION OK
  2933                              <1> 	;LOOP	J39			; LOOP TILL TIMEOUT
  2934                              <1> 	;DEC	BH			; DECREMENT HIGH ORDER COUNTER
  2935                              <1> 	;JNZ	short J39		; REPEAT TILL DELAY DONE
  2936                              <1> 	;
  2937                              <1> 	;;cmp	byte [wait_count], 10  ; (10/18.2 seconds)
  2938                              <1> 	;;jb	short J39	
  2939                              <1> 
  2940                              <1> ;WFPSR_TIMEOUT:
  2941 00005130 800D[588A0100]80    <1> 	OR	byte [DSKETTE_STATUS],TIME_OUT
  2942 00005137 F9                  <1> 	STC				; SET ERROR RETURN
  2943 00005138 EB29                <1> 	JMP	SHORT POPRES		; POP REGISTERS AND RETURN
  2944                              <1> 
  2945                              <1> ;-----	READ IN THE STATUS
  2946                              <1> 
  2947                              <1> J42:
  2948 0000513A EB00                <1> 	JMP	$+2			; I/O DELAY
  2949 0000513C 6642                <1> 	INC	DX			; POINT AT DATA PORT
  2950 0000513E EC                  <1> 	IN	AL,DX			; GET THE DATA
  2951                              <1> 	; 16/12/2014
  2952                              <1> 	NEWIODELAY
  2952 0000513F E6EB                <2>  out 0ebh,al
  2953 00005141 8807                <1>         MOV     [eDI],AL                ; STORE THE BYTE
  2954 00005143 47                  <1> 	INC	eDI			; INCREMENT THE POINTER
  2955                              <1> 	; 16/12/2014
  2956                              <1> ;	push	cx
  2957                              <1> ;	mov	cx, 30
  2958                              <1> ;wdw2:
  2959                              <1> ;	NEWIODELAY
  2960                              <1> ;	loop	wdw2
  2961                              <1> ;	pop	cx
  2962                              <1> 
  2963 00005144 B903000000          <1> 	MOV	eCX,3			; MINIMUM 24 MICROSECONDS FOR NEC
  2964 00005149 E8F8D2FFFF          <1> 	CALL	WAITF			; WAIT 30 TO 45 MICROSECONDS
  2965 0000514E 664A                <1> 	DEC	DX			; POINT AT STATUS PORT
  2966 00005150 EC                  <1> 	IN	AL,DX			; GET STATUS
  2967                              <1> 	; 16/12/2014
  2968                              <1> 	NEWIODELAY
  2968 00005151 E6EB                <2>  out 0ebh,al
  2969                              <1> 	;
  2970 00005153 A810                <1> 	TEST	AL,00010000B		; TEST FOR NEC STILL BUSY
  2971 00005155 740C                <1> 	JZ	short POPRES		; RESULTS DONE ?
  2972                              <1> 
  2973 00005157 FECB                <1> 	DEC	BL			; DECREMENT THE STATUS COUNTER
  2974 00005159 75BB                <1>         JNZ     short _R10              ; GO BACK FOR MORE
  2975 0000515B 800D[588A0100]20    <1> 	OR	byte [DSKETTE_STATUS],BAD_NEC ; TOO MANY STATUS BYTES
  2976 00005162 F9                  <1> 	STC				; SET ERROR FLAG
  2977                              <1> 
  2978                              <1> ;-----	RESULT OPERATION IS DONE
  2979                              <1> POPRES:
  2980 00005163 5F                  <1> 	POP	eDI
  2981 00005164 C3                  <1> 	RETn				; RETURN WITH CARRY SET
  2982                              <1> 
  2983                              <1> ;-------------------------------------------------------------------------------
  2984                              <1> ; READ_DSKCHNG
  2985                              <1> ;	READS THE STATE OF THE DISK CHANGE LINE.
  2986                              <1> ;
  2987                              <1> ; ON ENTRY:	DI = DRIVE #
  2988                              <1> ;
  2989                              <1> ; ON EXIT:	DI = DRIVE #
  2990                              <1> ;		ZF = 0 : DISK CHANGE LINE INACTIVE
  2991                              <1> ;		ZF = 1 : DISK CHANGE LINE ACTIVE
  2992                              <1> ;		AX,CX,DX DESTROYED
  2993                              <1> ;-------------------------------------------------------------------------------
  2994                              <1> READ_DSKCHNG:
  2995 00005165 E8A2FDFFFF          <1> 	CALL	MOTOR_ON		; TURN ON THE MOTOR IF OFF
  2996 0000516A 66BAF703            <1> 	MOV	DX,03F7H		; ADDRESS DIGITAL INPUT REGISTER
  2997 0000516E EC                  <1> 	IN	AL,DX			; INPUT DIGITAL INPUT REGISTER
  2998 0000516F A880                <1> 	TEST	AL,DSK_CHG		; CHECK FOR DISK CHANGE LINE ACTIVE
  2999 00005171 C3                  <1> 	RETn				; RETURN TO CALLER WITH ZERO FLAG SET
  3000                              <1> 
  3001                              <1> ;-------------------------------------------------------------------------------
  3002                              <1> ; DRIVE_DET
  3003                              <1> ;	DETERMINES WHETHER DRIVE IS 80 OR 40 TRACKS AND
  3004                              <1> ;	UPDATES STATE INFORMATION ACCORDINGLY.
  3005                              <1> ; ON ENTRY:	DI = DRIVE #
  3006                              <1> ;-------------------------------------------------------------------------------
  3007                              <1> DRIVE_DET:
  3008 00005172 E895FDFFFF          <1> 	CALL	MOTOR_ON		; TURN ON MOTOR IF NOT ALREADY ON
  3009 00005177 E80AFFFFFF          <1> 	CALL	RECAL			; RECALIBRATE DRIVE
  3010 0000517C 7251                <1> 	JC	short DD_BAC		; ASSUME NO DRIVE PRESENT
  3011 0000517E B530                <1> 	MOV	CH,TRK_SLAP		; SEEK TO TRACK 48
  3012 00005180 E882FEFFFF          <1> 	CALL	SEEK
  3013 00005185 7248                <1> 	JC	short DD_BAC		; ERROR NO DRIVE
  3014 00005187 B50B                <1> 	MOV	CH,QUIET_SEEK+1		; SEEK TO TRACK 10
  3015                              <1> SK_GIN:
  3016 00005189 FECD                <1> 	DEC	CH			; DECREMENT TO NEXT TRACK
  3017 0000518B 6651                <1> 	PUSH	CX			; SAVE TRACK
  3018 0000518D E875FEFFFF          <1> 	CALL	SEEK
  3019 00005192 723C                <1> 	JC	short POP_BAC		; POP AND RETURN
  3020 00005194 B8[D0510000]        <1> 	MOV	eAX, POP_BAC		; LOAD NEC OUTPUT ERROR ADDRESS
  3021 00005199 50                  <1> 	PUSH	eAX
  3022 0000519A B404                <1> 	MOV	AH,SENSE_DRV_ST		; SENSE DRIVE STATUS COMMAND BYTE
  3023 0000519C E82CFEFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO NEC
  3024 000051A1 6689F8              <1> 	MOV	AX,DI			; AL = DRIVE
  3025 000051A4 88C4                <1> 	MOV	AH,AL			; AH = DRIVE
  3026 000051A6 E822FEFFFF          <1> 	CALL	NEC_OUTPUT		; OUTPUT TO NEC
  3027 000051AB E85AFFFFFF          <1> 	CALL	RESULTS			; GO GET STATUS
  3028 000051B0 58                  <1> 	POP	eAX			; THROW AWAY ERROR ADDRESS
  3029 000051B1 6659                <1> 	POP	CX			; RESTORE TRACK
  3030 000051B3 F605[598A0100]10    <1> 	TEST	byte [NEC_STATUS], HOME	; TRACK 0 ?
  3031 000051BA 74CD                <1> 	JZ	short SK_GIN		; GO TILL TRACK 0
  3032 000051BC 08ED                <1> 	OR	CH,CH			; IS HOME AT TRACK 0
  3033 000051BE 7408                <1> 	JZ	short IS_80		; MUST BE 80 TRACK DRIVE
  3034                              <1> 
  3035                              <1> ;	DRIVE IS A 360; SET DRIVE TO DETERMINED;
  3036                              <1> ;	SET MEDIA TO DETERMINED AT RATE 250.
  3037                              <1> 
  3038 000051C0 808F[658A0100]94    <1> 	OR	byte [DSK_STATE+eDI], DRV_DET+MED_DET+RATE_250
  3039 000051C7 C3                  <1> 	RETn				; ALL INFORMATION SET
  3040                              <1> IS_80:
  3041 000051C8 808F[658A0100]01    <1> 	OR	byte [DSK_STATE+eDI], TRK_CAPA ; SETUP 80 TRACK CAPABILITY
  3042                              <1> DD_BAC:
  3043 000051CF C3                  <1> 	RETn
  3044                              <1> POP_BAC:
  3045 000051D0 6659                <1> 	POP	CX			; THROW AWAY
  3046 000051D2 C3                  <1> 	RETn
  3047                              <1> 
  3048                              <1> fdc_int:  
  3049                              <1> 	  ; 30/07/2015	
  3050                              <1> 	  ; 16/02/2015
  3051                              <1> ;int_0Eh: ; 11/12/2014
  3052                              <1> 
  3053                              <1> ;--- HARDWARE INT 0EH -- ( IRQ LEVEL  6 ) --------------------------------------
  3054                              <1> ; DISK_INT
  3055                              <1> ;	THIS ROUTINE HANDLES THE DISKETTE INTERRUPT.
  3056                              <1> ;
  3057                              <1> ; ON EXIT:	THE INTERRUPT FLAG IS SET IN @SEEK_STATUS.
  3058                              <1> ;-------------------------------------------------------------------------------
  3059                              <1> DISK_INT_1:
  3060                              <1> 
  3061 000051D3 6650                <1> 	PUSH	AX			; SAVE WORK REGISTER
  3062 000051D5 1E                  <1> 	push	ds
  3063 000051D6 66B81000            <1> 	mov	ax, KDATA
  3064 000051DA 8ED8                <1> 	mov 	ds, ax
  3065 000051DC 800D[558A0100]80    <1>         OR      byte [SEEK_STATUS], INT_FLAG ; TURN ON INTERRUPT OCCURRED
  3066 000051E3 B020                <1> 	MOV     AL,EOI                  ; END OF INTERRUPT MARKER
  3067 000051E5 E620                <1> 	OUT	INTA00,AL		; INTERRUPT CONTROL PORT
  3068 000051E7 1F                  <1> 	pop	ds
  3069 000051E8 6658                <1> 	POP	AX			; RECOVER REGISTER
  3070 000051EA CF                  <1> 	IRETd				; RETURN FROM INTERRUPT
  3071                              <1> 
  3072                              <1> ;-------------------------------------------------------------------------------
  3073                              <1> ; DSKETTE_SETUP
  3074                              <1> ;	THIS ROUTINE DOES A PRELIMINARY CHECK TO SEE WHAT TYPE OF
  3075                              <1> ;	DISKETTE DRIVES ARE ATTACH TO THE SYSTEM.
  3076                              <1> ;-------------------------------------------------------------------------------
  3077                              <1> 
  3078                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  3079                              <1> 
  3080                              <1> DSKETTE_SETUP:
  3081                              <1> 	;PUSH	AX			; SAVE REGISTERS
  3082                              <1> 	;PUSH	BX
  3083                              <1> 	;PUSH	CX
  3084 000051EB 52                  <1> 	PUSH	eDX
  3085                              <1> 	;PUSH	DI
  3086                              <1> 	;;PUSH	DS
  3087                              <1> 	; 14/12/2014
  3088                              <1> 	;mov	word [DISK_POINTER], MD_TBL6
  3089                              <1> 	;mov	[DISK_POINTER+2], cs
  3090                              <1> 	;
  3091                              <1> 	;OR	byte [RTC_WAIT_FLAG], 1	; NO RTC WAIT, FORCE USE OF LOOP
  3092 000051EC 31FF                <1> 	XOR	eDI,eDI			; INITIALIZE DRIVE POINTER
  3093 000051EE 66C705[658A0100]00- <1> 	MOV	WORD [DSK_STATE],0	; INITIALIZE STATES
  3093 000051F6 00                  <1>
  3094 000051F7 8025[608A0100]33    <1> 	AND	byte [LASTRATE],~(STRT_MSK+SEND_MSK) ; CLEAR START & SEND
  3095 000051FE 800D[608A0100]C0    <1> 	OR	byte [LASTRATE],SEND_MSK ; INITIALIZE SENT TO IMPOSSIBLE
  3096 00005205 C605[558A0100]00    <1> 	MOV	byte [SEEK_STATUS],0	; INDICATE RECALIBRATE NEEDED
  3097 0000520C C605[578A0100]00    <1> 	MOV	byte [MOTOR_COUNT],0	; INITIALIZE MOTOR COUNT
  3098 00005213 C605[568A0100]00    <1> 	MOV	byte [MOTOR_STATUS],0	; INITIALIZE DRIVES TO OFF STATE
  3099 0000521A C605[588A0100]00    <1> 	MOV	byte [DSKETTE_STATUS],0	; NO ERRORS
  3100                              <1> 	;
  3101                              <1> 	; 28/02/2015
  3102                              <1> 	;mov	word [cfd], 100h 
  3103 00005221 E82BF2FFFF          <1> 	call	DSK_RESET
  3104 00005226 5A                  <1> 	pop	edx
  3105 00005227 F8                  <1> 	clc	; 29/05/2016
  3106 00005228 C3                  <1> 	retn
  3107                              <1> 
  3108                              <1> ;SUP0:
  3109                              <1> ;	CALL	DRIVE_DET		; DETERMINE DRIVE
  3110                              <1> ;	CALL	XLAT_OLD		; TRANSLATE STATE TO COMPATIBLE MODE
  3111                              <1> ;	; 02/01/2015
  3112                              <1> ;	;INC	DI			; POINT TO NEXT DRIVE
  3113                              <1> ;	;CMP	DI,MAX_DRV		; SEE IF DONE
  3114                              <1> ;	;JNZ	short SUP0		; REPEAT FOR EACH ORIVE
  3115                              <1> ;       cmp     byte [fd1_type], 0	
  3116                              <1> ;	jna	short sup1
  3117                              <1> ;	or	di, di
  3118                              <1> ;	jnz	short sup1
  3119                              <1> ;	inc	di
  3120                              <1> ;       jmp     short SUP0
  3121                              <1> ;sup1:
  3122                              <1> ;	MOV	byte [SEEK_STATUS],0	; FORCE RECALIBRATE
  3123                              <1> ;	;AND	byte [RTC_WAIT_FLAG],0FEH ; ALLOW FOR RTC WAIT
  3124                              <1> ;	CALL	SETUP_END		; VARIOUS CLEANUPS
  3125                              <1> ;	;;POP	DS			; RESTORE CALLERS REGISTERS
  3126                              <1> ;	;POP	DI
  3127                              <1> ;	POP	eDX
  3128                              <1> ;	;POP	CX
  3129                              <1> ;	;POP	BX
  3130                              <1> ;	;POP	AX
  3131                              <1> ;	RETn
  3132                              <1> 
  3133                              <1> ;//////////////////////////////////////////////////////
  3134                              <1> ;; END OF DISKETTE I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  3135                              <1> ;
  3136                              <1> 
  3137                              <1> int13h: ; 21/02/2015
  3138 00005229 F8                  <1> 	clc ; 20/07/2020
  3139 0000522A 9C                  <1> 	pushfd
  3140 0000522B 0E                  <1> 	push 	cs
  3141 0000522C E848010000          <1> 	call 	DISK_IO
  3142 00005231 C3                  <1> 	retn
  3143                              <1> 
  3144                              <1> ;;;;;; DISK I/O ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 21/02/2015 ;;;
  3145                              <1> ;/////////////////////////////////////////////////////////////////////
  3146                              <1> 
  3147                              <1> ; DISK I/O - Erdogan Tan (Retro UNIX 386 v1 project)
  3148                              <1> ; 18/02/2016
  3149                              <1> ; 17/02/2016
  3150                              <1> ; 23/02/2015
  3151                              <1> ; 21/02/2015 (unix386.s)
  3152                              <1> ; 22/12/2014 - 14/02/2015 (dsectrm2.s)
  3153                              <1> ;
  3154                              <1> ; Original Source Code:
  3155                              <1> ; DISK ----- 09/25/85 FIXED DISK BIOS
  3156                              <1> ; (IBM PC XT Model 286 System BIOS Source Code, 04-21-86)
  3157                              <1> ;
  3158                              <1> ; Modifications: by reference of AWARD BIOS 1999 (D1A0622) 
  3159                              <1> ;		 Source Code - ATORGS.ASM, AHDSK.ASM
  3160                              <1> ;
  3161                              <1> 
  3162                              <1> 
  3163                              <1> ;The wait for controller to be not busy is 10 seconds.
  3164                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  3165                              <1> ;;WAIT_HDU_CTLR_BUSY_LO	equ	1615h		
  3166                              <1> ;;WAIT_HDU_CTLR_BUSY_HI	equ	  05h
  3167                              <1> WAIT_HDU_CTRL_BUSY_LH	equ	51615h	 ;21/02/2015		
  3168                              <1> 
  3169                              <1> ;The wait for controller to issue completion interrupt is 10 seconds.
  3170                              <1> ;10,000,000 / 30 = 333,333.  333,333 decimal = 051615h
  3171                              <1> ;;WAIT_HDU_INT_LO	equ	1615h
  3172                              <1> ;;WAIT_HDU_INT_HI	equ	  05h
  3173                              <1> WAIT_HDU_INT_LH		equ	51615h	; 21/02/2015
  3174                              <1> 
  3175                              <1> ;The wait for Data request on read and write longs is
  3176                              <1> ;2000 us. (?)
  3177                              <1> ;;WAIT_HDU_DRQ_LO	equ	1000	; 03E8h
  3178                              <1> ;;WAIT_HDU_DRQ_HI	equ	0
  3179                              <1> WAIT_HDU_DRQ_LH		equ	1000	; 21/02/2015
  3180                              <1> 
  3181                              <1> ; Port 61h (PORT_B)
  3182                              <1> SYS1		equ	61h	; PORT_B  (diskette.inc)
  3183                              <1> 
  3184                              <1> ; 23/12/2014
  3185                              <1> %define CMD_BLOCK       eBP-8  ; 21/02/2015
  3186                              <1> 
  3187                              <1> ; 30/08/2020 - TRDOS 386 v2
  3188                              <1> 
  3189                              <1> ;--- INT 13H -------------------------------------------------------------------
  3190                              <1> ;									       :
  3191                              <1> ; FIXED DISK I/O INTERFACE						       :
  3192                              <1> ;									       :
  3193                              <1> ;	THIS INTERFACE PROVIDES ACCESS TO 5 1/4" FIXED DISKS THROUGH           :
  3194                              <1> ;	THE IBM FIXED DISK CONTROLLER.					       :
  3195                              <1> ;									       :
  3196                              <1> ;	THE  BIOS  ROUTINES  ARE  MEANT  TO  BE  ACCESSED  THROUGH	       :
  3197                              <1> ;	SOFTWARE  INTERRUPTS  ONLY.    ANY  ADDRESSES  PRESENT	IN	       :
  3198                              <1> ;	THESE  LISTINGS  ARE  INCLUDED	 ONLY	FOR  COMPLETENESS,	       :
  3199                              <1> ;	NOT  FOR  REFERENCE.  APPLICATIONS   WHICH  REFERENCE  ANY	       :
  3200                              <1> ;	ABSOLUTE  ADDRESSES  WITHIN  THE  CODE	SEGMENTS  OF  BIOS	       :
  3201                              <1> ;	VIOLATE  THE  STRUCTURE  AND  DESIGN  OF  BIOS. 		       :
  3202                              <1> ;									       :
  3203                              <1> ;------------------------------------------------------------------------------:
  3204                              <1> ;									       :
  3205                              <1> ; INPUT  (AH)= HEX COMMAND VALUE					       :
  3206                              <1> ;									       :
  3207                              <1> ;	(AH)= 00H  RESET DISK (DL = 80H,81H) / DISKETTE 		       :
  3208                              <1> ;	(AH)= 01H  READ THE STATUS OF THE LAST DISK OPERATION INTO (AL)        :
  3209                              <1> ;		    NOTE: DL < 80H - DISKETTE				       :
  3210                              <1> ;			  DL > 80H - DISK				       :
  3211                              <1> ;	(AH)= 02H  READ THE DESIRED SECTORS INTO MEMORY 		       :
  3212                              <1> ;	(AH)= 03H  WRITE THE DESIRED SECTORS FROM MEMORY		       :
  3213                              <1> ;	(AH)= 04H  VERIFY THE DESIRED SECTORS				       :
  3214                              <1> ;	(AH)= 05H  FORMAT THE DESIRED TRACK				       :
  3215                              <1> ;	(AH)= 06H  UNUSED						       :
  3216                              <1> ;	(AH)= 07H  UNUSED						       :
  3217                              <1> ;	(AH)= 08H  RETURN THE CURRENT DRIVE PARAMETERS			       :
  3218                              <1> ;	(AH)= 09H  INITIALIZE DRIVE PAIR CHARACTERISTICS		       :
  3219                              <1> ;		    INTERRUPT 41 POINTS TO DATA BLOCK FOR DRIVE 0	       :
  3220                              <1> ;		    INTERRUPT 46 POINTS TO DATA BLOCK FOR DRIVE 1	       :
  3221                              <1> ;	(AH)= 0AH  READ LONG						       :
  3222                              <1> ;	(AH)= 0BH  WRITE LONG  (READ & WRITE LONG ENCOMPASS 512 + 4 BYTES ECC) :
  3223                              <1> ;	(AH)= 0CH  SEEK 						       :
  3224                              <1> ;	(AH)= 0DH  ALTERNATE DISK RESET (SEE DL)			       :
  3225                              <1> ;	(AH)= 0EH  UNUSED						       :
  3226                              <1> ;	(AH)= 0FH  UNUSED						       :
  3227                              <1> ;	(AH)= 10H  TEST DRIVE READY					       :
  3228                              <1> ;	(AH)= 11H  RECALIBRATE						       :
  3229                              <1> ;	(AH)= 12H  UNUSED						       :
  3230                              <1> ;	(AH)= 13H  UNUSED						       :
  3231                              <1> ;	(AH)= 14H  CONTROLLER INTERNAL DIAGNOSTIC			       :
  3232                              <1> ;	(AH)= 15H  READ DASD TYPE					       :
  3233                              <1> ;									       :
  3234                              <1> ;-------------------------------------------------------------------------------
  3235                              <1> ;									       :
  3236                              <1> ;	REGISTERS USED FOR FIXED DISK OPERATIONS			       :
  3237                              <1> ;									       :
  3238                              <1> ;		(DL)	-  DRIVE NUMBER     (80H-81H FOR DISK. VALUE CHECKED)  :
  3239                              <1> ;		(DH)	-  HEAD NUMBER	    (0-15 ALLOWED, NOT VALUE CHECKED)  :
  3240                              <1> ;		(CH)	-  CYLINDER NUMBER  (0-1023, NOT VALUE CHECKED)(SEE CL):
  3241                              <1> ;		(CL)	-  SECTOR NUMBER    (1-17, NOT VALUE CHECKED)	       :
  3242                              <1> ;									       :
  3243                              <1> ;			   NOTE: HIGH 2 BITS OF CYLINDER NUMBER ARE PLACED     :
  3244                              <1> ;				 IN THE HIGH 2 BITS OF THE CL REGISTER	       :
  3245                              <1> ;				 (10 BITS TOTAL)			       :
  3246                              <1> ;									       :
  3247                              <1> ;		(AL)	-  NUMBER OF SECTORS (MAXIMUM POSSIBLE RANGE 1-80H,    :
  3248                              <1> ;					      FOR READ/WRITE LONG 1-79H)       :
  3249                              <1> ;									       :
  3250                              <1> ;		(ES:BX) -  ADDRESS OF BUFFER FOR READS AND WRITES,	       :
  3251                              <1> ;			   (NOT REQUIRED FOR VERIFY)			       :
  3252                              <1> ;									       :
  3253                              <1> ;		FORMAT (AH=5) ES:BX POINTS TO A 512 BYTE BUFFER. THE FIRST     :
  3254                              <1> ;			   2*(SECTORS/TRACK) BYTES CONTAIN F,N FOR EACH SECTOR.:
  3255                              <1> ;			   F = 00H FOR A GOOD SECTOR			       :
  3256                              <1> ;			       80H FOR A BAD SECTOR			       :
  3257                              <1> ;			   N = SECTOR NUMBER				       :
  3258                              <1> ;			   FOR AN INTERLEAVE OF 2 AND 17 SECTORS/TRACK	       :
  3259                              <1> ;			   THE TABLE SHOULD BE: 			       :
  3260                              <1> ;									       :
  3261                              <1> ;		   DB	   00H,01H,00H,0AH,00H,02H,00H,0BH,00H,03H,00H,0CH     :
  3262                              <1> ;		   DB	   00H,04H,00H,0DH,00H,05H,00H,0EH,00H,06H,00H,0FH     :
  3263                              <1> ;		   DB	   00H,07H,00H,10H,00H,08H,00H,11H,00H,09H	       :
  3264                              <1> ;									       :
  3265                              <1> ;-------------------------------------------------------------------------------
  3266                              <1> 
  3267                              <1> ;-------------------------------------------------------------------------------
  3268                              <1> ; OUTPUT								       :
  3269                              <1> ;	AH = STATUS OF CURRENT OPERATION				       :
  3270                              <1> ;	     STATUS BITS ARE DEFINED IN THE EQUATES BELOW		       :
  3271                              <1> ;	CY = 0	SUCCESSFUL OPERATION (AH=0 ON RETURN)			       :
  3272                              <1> ;	CY = 1	FAILED OPERATION (AH HAS ERROR REASON)			       :
  3273                              <1> ;									       :
  3274                              <1> ;	NOTE:	ERROR 11H  INDICATES THAT THE DATA READ HAD A RECOVERABLE      :
  3275                              <1> ;		ERROR WHICH WAS CORRECTED BY THE ECC ALGORITHM.  THE DATA      :
  3276                              <1> ;		IS PROBABLY GOOD,   HOWEVER THE BIOS ROUTINE INDICATES AN      :
  3277                              <1> ;		ERROR TO ALLOW THE CONTROLLING PROGRAM A CHANCE TO DECIDE      :
  3278                              <1> ;		FOR ITSELF.  THE  ERROR  MAY  NOT  RECUR  IF  THE DATA IS      :
  3279                              <1> ;		REWRITTEN.						       :
  3280                              <1> ;									       :
  3281                              <1> ;	IF DRIVE PARAMETERS WERE REQUESTED (DL >= 80H), 		       :
  3282                              <1> ;	   INPUT:							       :
  3283                              <1> ;	     (DL) = DRIVE NUMBER					       :	
  3284                              <1> ;	     ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)						       :	 	
  3285                              <1> ;	     EBX = Buffer address for fixed disk parameters table (32 bytes)   :
  3286                              <1> ;	   OUTPUT:							       :
  3287                              <1> ;	     (DL) = NUMBER OF CONSECUTIVE ACKNOWLEDGING DRIVES ATTACHED (1-2)  :
  3288                              <1> ;		    (CONTROLLER CARD ZERO TALLY ONLY)			       :
  3289                              <1> ;	     (DH) = MAXIMUM USEABLE VALUE FOR HEAD NUMBER		       :
  3290                              <1> ;	     (CH) = MAXIMUM USEABLE VALUE FOR CYLINDER NUMBER		       :
  3291                              <1> ;	     (CL) = MAXIMUM USEABLE VALUE FOR SECTOR NUMBER		       :
  3292                              <1> ;		    AND CYLINDER NUMBER HIGH BITS			       :
  3293                              <1> ;									       :
  3294                              <1> ;	IF READ DASD TYPE WAS REQUESTED,				       :
  3295                              <1> ;									       :
  3296                              <1> ;	AH = 0 - NOT PRESENT						       :
  3297                              <1> ;	     1 - DISKETTE - NO CHANGE LINE AVAILABLE			       :
  3298                              <1> ;	     2 - DISKETTE - CHANGE LINE AVAILABLE			       :
  3299                              <1> ;	     3 - FIXED DISK						       :
  3300                              <1> ;									       :
  3301                              <1> ;	CX,DX = NUMBER OF 512 BYTE BLOCKS WHEN AH = 3			       :
  3302                              <1> ;									       :
  3303                              <1> ;	REGISTERS WILL BE PRESERVED EXCEPT WHEN THEY ARE USED TO RETURN        :
  3304                              <1> ;	INFORMATION.							       :
  3305                              <1> ;									       :
  3306                              <1> ;	NOTE: IF AN ERROR IS REPORTED BY THE DISK CODE, THE APPROPRIATE        :
  3307                              <1> ;		ACTION IS TO RESET THE DISK, THEN RETRY THE OPERATION.	       :
  3308                              <1> ;									       :
  3309                              <1> ;-------------------------------------------------------------------------------
  3310                              <1> 
  3311                              <1> SENSE_FAIL	EQU	0FFH		; NOT IMPLEMENTED
  3312                              <1> NO_ERR		EQU	0E0H		; STATUS ERROR/ERROR REGISTER=0
  3313                              <1> WRITE_FAULT	EQU	0CCH		; WRITE FAULT ON SELECTED DRIVE
  3314                              <1> UNDEF_ERR	EQU	0BBH		; UNDEFINED ERROR OCCURRED
  3315                              <1> NOT_RDY 	EQU	0AAH		; DRIVE NOT READY
  3316                              <1> TIME_OUT	EQU	80H		; ATTACHMENT FAILED TO RESPOND
  3317                              <1> BAD_SEEK	EQU	40H		; SEEK OPERATION FAILED
  3318                              <1> BAD_CNTLR	EQU	20H		; CONTROLLER HAS FAILED
  3319                              <1> DATA_CORRECTED	EQU	11H		; ECC CORRECTED DATA ERROR
  3320                              <1> BAD_ECC 	EQU	10H		; BAD ECC ON DISK READ
  3321                              <1> BAD_TRACK	EQU	0BH		; NOT IMPLEMENTED
  3322                              <1> BAD_SECTOR	EQU	0AH		; BAD SECTOR FLAG DETECTED
  3323                              <1> ;DMA_BOUNDARY	EQU	09H		; DATA EXTENDS TOO FAR
  3324                              <1> INIT_FAIL	EQU	07H		; DRIVE PARAMETER ACTIVITY FAILED
  3325                              <1> BAD_RESET	EQU	05H		; RESET FAILED
  3326                              <1> ;RECORD_NOT_FND	EQU	04H		; REQUESTED SECTOR NOT FOUND
  3327                              <1> ;BAD_ADDR_MARK	EQU	02H		; ADDRESS MARK NOT FOUND
  3328                              <1> ;BAD_CMD 	EQU	01H		; BAD COMMAND PASSED TO DISK I/O
  3329                              <1> 
  3330                              <1> ;--------------------------------------------------------
  3331                              <1> ;							:
  3332                              <1> ; FIXED DISK PARAMETER TABLE				:
  3333                              <1> ;  -  THE TABLE IS COMPOSED OF A BLOCK DEFINED AS:	:
  3334                              <1> ;							:
  3335                              <1> ;  +0	(1 WORD) - MAXIMUM NUMBER OF CYLINDERS		:
  3336                              <1> ;  +2	(1 BYTE) - MAXIMUM NUMBER OF HEADS		:
  3337                              <1> ;  +3	(1 WORD) - NOT USED/SEE PC-XT			:
  3338                              <1> ;  +5	(1 WORD) - STARTING WRITE PRECOMPENSATION CYL	:
  3339                              <1> ;  +7	(1 BYTE) - MAXIMUM ECC DATA BURST LENGTH	:
  3340                              <1> ;  +8	(1 BYTE) - CONTROL BYTE 			:
  3341                              <1> ;		   BIT	  7 DISABLE RETRIES -OR-	:
  3342                              <1> ;		   BIT	  6 DISABLE RETRIES		:
  3343                              <1> ;		   BIT	  3 MORE THAN 8 HEADS		:
  3344                              <1> ;  +9	(3 BYTES)- NOT USED/SEE PC-XT			:
  3345                              <1> ; +12	(1 WORD) - LANDING ZONE 			:
  3346                              <1> ; +14	(1 BYTE) - NUMBER OF SECTORS/TRACK		:
  3347                              <1> ; +15	(1 BYTE) - RESERVED FOR FUTURE USE		:
  3348                              <1> ;							:
  3349                              <1> ;	 - TO DYNAMICALLY DEFINE A SET OF PARAMETERS	:
  3350                              <1> ;	   BUILD A TABLE FOR UP TO 15 TYPES AND PLACE	:
  3351                              <1> ;	   THE CORRESPONDING VECTOR INTO INTERRUPT 41	:
  3352                              <1> ;	   FOR DRIVE 0 AND INTERRUPT 46 FOR DRIVE 1.	:
  3353                              <1> ;							:
  3354                              <1> ;--------------------------------------------------------
  3355                              <1> 
  3356                              <1> ;--------------------------------------------------------
  3357                              <1> ;							:
  3358                              <1> ; HARDWARE SPECIFIC VALUES				:
  3359                              <1> ;							:
  3360                              <1> ;  -  CONTROLLER I/O PORT				:
  3361                              <1> ;							:
  3362                              <1> ;     > WHEN READ FROM: 				:
  3363                              <1> ;	HF_PORT+0 - READ DATA (FROM CONTROLLER TO CPU)	:
  3364                              <1> ;	HF_PORT+1 - GET ERROR REGISTER			:
  3365                              <1> ;	HF_PORT+2 - GET SECTOR COUNT			:
  3366                              <1> ;	HF_PORT+3 - GET SECTOR NUMBER			:
  3367                              <1> ;	HF_PORT+4 - GET CYLINDER LOW			:
  3368                              <1> ;	HF_PORT+5 - GET CYLINDER HIGH (2 BITS)		:
  3369                              <1> ;	HF_PORT+6 - GET SIZE/DRIVE/HEAD 		:
  3370                              <1> ;	HF_PORT+7 - GET STATUS REGISTER 		:
  3371                              <1> ;							:
  3372                              <1> ;     > WHEN WRITTEN TO:				:
  3373                              <1> ;	HF_PORT+0 - WRITE DATA (FROM CPU TO CONTROLLER) :
  3374                              <1> ;	HF_PORT+1 - SET PRECOMPENSATION CYLINDER	:
  3375                              <1> ;	HF_PORT+2 - SET SECTOR COUNT			:
  3376                              <1> ;	HF_PORT+3 - SET SECTOR NUMBER			:
  3377                              <1> ;	HF_PORT+4 - SET CYLINDER LOW			:
  3378                              <1> ;	HF_PORT+5 - SET CYLINDER HIGH (2 BITS)		:
  3379                              <1> ;	HF_PORT+6 - SET SIZE/DRIVE/HEAD 		:
  3380                              <1> ;	HF_PORT+7 - SET COMMAND REGISTER		:
  3381                              <1> ;							:
  3382                              <1> ;--------------------------------------------------------
  3383                              <1> 
  3384                              <1> ;HF_PORT 	EQU	01F0H	; DISK PORT
  3385                              <1> ;HF1_PORT	equ	0170h	
  3386                              <1> ;HF_REG_PORT	EQU	03F6H
  3387                              <1> ;HF1_REG_PORT	equ	0376h
  3388                              <1> 
  3389                              <1> HDC1_BASEPORT	equ	1F0h
  3390                              <1> HDC2_BASEPORT	equ	170h		
  3391                              <1> 
  3392                              <1> align 2
  3393                              <1> 
  3394                              <1> ;-----		STATUS REGISTER
  3395                              <1> 
  3396                              <1> ST_ERROR	EQU	00000001B	;
  3397                              <1> ST_INDEX	EQU	00000010B	;
  3398                              <1> ST_CORRCTD	EQU	00000100B	; ECC CORRECTION SUCCESSFUL
  3399                              <1> ST_DRQ		EQU	00001000B	;
  3400                              <1> ST_SEEK_COMPL	EQU	00010000B	; SEEK COMPLETE
  3401                              <1> ST_WRT_FLT	EQU	00100000B	; WRITE FAULT
  3402                              <1> ST_READY	EQU	01000000B	;
  3403                              <1> ST_BUSY 	EQU	10000000B	;
  3404                              <1> 
  3405                              <1> ;-----		ERROR REGISTER
  3406                              <1> 
  3407                              <1> ERR_DAM 	EQU	00000001B	; DATA ADDRESS MARK NOT FOUND
  3408                              <1> ERR_TRK_0	EQU	00000010B	; TRACK 0 NOT FOUND ON RECAL
  3409                              <1> ERR_ABORT	EQU	00000100B	; ABORTED COMMAND
  3410                              <1> ;		EQU	00001000B	; NOT USED
  3411                              <1> ERR_ID		EQU	00010000B	; ID NOT FOUND
  3412                              <1> ;		EQU	00100000B	; NOT USED
  3413                              <1> ERR_DATA_ECC	EQU	01000000B
  3414                              <1> ERR_BAD_BLOCK	EQU	10000000B
  3415                              <1> 
  3416                              <1> 
  3417                              <1> RECAL_CMD	EQU	00010000B	; DRIVE RECAL	(10H)
  3418                              <1> READ_CMD	EQU	00100000B	;	READ	(20H)
  3419                              <1> WRITE_CMD	EQU	00110000B	;	WRITE	(30H)
  3420                              <1> VERIFY_CMD	EQU	01000000B	;	VERIFY	(40H)
  3421                              <1> FMTTRK_CMD	EQU	01010000B	; FORMAT TRACK	(50H)
  3422                              <1> INIT_CMD	EQU	01100000B	;   INITIALIZE	(60H)
  3423                              <1> SEEK_CMD	EQU	01110000B	;	SEEK	(70H)
  3424                              <1> DIAG_CMD	EQU	10010000B	; DIAGNOSTIC	(90H)
  3425                              <1> SET_PARM_CMD	EQU	10010001B	; DRIVE PARMS	(91H)
  3426                              <1> NO_RETRIES	EQU	00000001B	; CHD MODIFIER	(01H)
  3427                              <1> ECC_MODE	EQU	00000010B	; CMD MODIFIER	(02H)
  3428                              <1> BUFFER_MODE	EQU	00001000B	; CMD MODIFIER	(08H)
  3429                              <1> 
  3430                              <1> ;MAX_FILE	EQU	2
  3431                              <1> ;S_MAX_FILE	EQU	2
  3432                              <1> MAX_FILE	equ	4		; 22/12/2014
  3433                              <1> S_MAX_FILE	equ	4		; 22/12/2014
  3434                              <1> 
  3435                              <1> DELAY_1 	EQU	25H		; DELAY FOR OPERATION COMPLETE
  3436                              <1> DELAY_2 	EQU	0600H		; DELAY FOR READY
  3437                              <1> DELAY_3 	EQU	0100H		; DELAY FOR DATA REQUEST
  3438                              <1> 
  3439                              <1> HF_FAIL 	EQU	08H		; CMOS FLAG IN BYTE 0EH
  3440                              <1> 
  3441                              <1> ;-----		COMMAND BLOCK REFERENCE
  3442                              <1> 
  3443                              <1> ;CMD_BLOCK      EQU     BP-8            ; @CMD_BLOCK REFERENCES BLOCK HEAD IN SS
  3444                              <1> 					;  (BP) POINTS TO COMMAND BLOCK TAIL
  3445                              <1> 					;	AS DEFINED BY THE "ENTER" PARMS
  3446                              <1> ; 19/12/2014
  3447                              <1> ORG_VECTOR	equ	4*13h		; INT 13h vector
  3448                              <1> DISK_VECTOR	equ	4*40h		; INT 40h vector (for floppy disks)
  3449                              <1> ;HDISK_INT	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  3450                              <1> ;HDISK_INT1	equ	4*76h		; Primary HDC - Hardware interrupt (IRQ14)
  3451                              <1> ;HDISK_INT2	equ	4*77h		; Secondary HDC - Hardware interrupt (IRQ15)
  3452                              <1> ;HF_TBL_VEC	equ	4*41h		; Pointer to 1st fixed disk parameter table
  3453                              <1> ;HF1_TBL_VEC	equ	4*46h		; Pointer to 2nd fixed disk parameter table
  3454                              <1> 
  3455                              <1> align 2
  3456                              <1> 
  3457                              <1> ;----------------------------------------------------------------
  3458                              <1> ; FIXED DISK I/O SETUP						:
  3459                              <1> ;								:
  3460                              <1> ;  -  ESTABLISH TRANSFER VECTORS FOR THE FIXED DISK		:
  3461                              <1> ;  -  PERFORM POWER ON DIAGNOSTICS				:
  3462                              <1> ;     SHOULD AN ERROR OCCUR A "1701" MESSAGE IS DISPLAYED       :
  3463                              <1> ;								:
  3464                              <1> ;----------------------------------------------------------------
  3465                              <1> 
  3466                              <1> ; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
  3467                              <1> 
  3468                              <1> DISK_SETUP:
  3469                              <1> 	;CLI
  3470                              <1> 	;;MOV	AX,ABS0 			; GET ABSOLUTE SEGMENT
  3471                              <1> 	;xor	ax,ax
  3472                              <1> 	;MOV	DS,AX				; SET SEGMENT REGISTER
  3473                              <1> 	;MOV	AX, [ORG_VECTOR] 		; GET DISKETTE VECTOR
  3474                              <1> 	;MOV	[DISK_VECTOR],AX		;  INTO INT 40H
  3475                              <1> 	;MOV	AX, [ORG_VECTOR+2]
  3476                              <1> 	;MOV	[DISK_VECTOR+2],AX
  3477                              <1> 	;MOV	word [ORG_VECTOR],DISK_IO	; FIXED DISK HANDLER
  3478                              <1> 	;MOV	[ORG_VECTOR+2],CS
  3479                              <1> 	; 1st controller (primary master, slave)   - IRQ 14
  3480                              <1> 	;;MOV	word [HDISK_INT],HD_INT		; FIXED DISK INTERRUPT
  3481                              <1> 	;mov	word [HDISK_INT1],HD_INT	;
  3482                              <1> 	;;MOV	[HDISK_INT+2],CS
  3483                              <1> 	;mov	[HDISK_INT1+2],CS
  3484                              <1> 	; 2nd controller (secondary master, slave) - IRQ 15
  3485                              <1> 	;mov	word [HDISK_INT2],HD1_INT	;
  3486                              <1> 	;mov	[HDISK_INT2+2],CS
  3487                              <1> 	;
  3488                              <1> 	;;MOV	word [HF_TBL_VEC],HD0_DPT	; PARM TABLE DRIVE 80
  3489                              <1> 	;;MOV	word [HF_TBL_VEC+2],DPT_SEGM
  3490                              <1> 	;;MOV	word [HF1_TBL_VEC],HD1_DPT	; PARM TABLE DRIVE 81
  3491                              <1> 	;;MOV	word [HF1_TBL_VEC+2],DPT_SEGM
  3492                              <1> 	;push	cs
  3493                              <1> 	;pop	ds
  3494                              <1> 	;mov	word [HDPM_TBL_VEC],HD0_DPT	; PARM TABLE DRIVE 80h
  3495                              <1> 	;mov	word [HDPM_TBL_VEC+2],DPT_SEGM
  3496 00005232 C705[708A0100]0000- <1> 	mov 	dword [HDPM_TBL_VEC], (DPT_SEGM*16)+HD0_DPT
  3496 0000523A 0900                <1>
  3497                              <1> 	;mov	word [HDPS_TBL_VEC],HD1_DPT	; PARM TABLE DRIVE 81h
  3498                              <1> 	;mov	word [HDPS_TBL_VEC+2],DPT_SEGM
  3499 0000523C C705[748A0100]2000- <1> 	mov 	dword [HDPS_TBL_VEC], (DPT_SEGM*16)+HD1_DPT
  3499 00005244 0900                <1>
  3500                              <1> 	;mov	word [HDSM_TBL_VEC],HD2_DPT	; PARM TABLE DRIVE 82h
  3501                              <1> 	;mov	word [HDSM_TBL_VEC+2],DPT_SEGM
  3502 00005246 C705[788A0100]4000- <1> 	mov 	dword [HDSM_TBL_VEC], (DPT_SEGM*16)+HD2_DPT
  3502 0000524E 0900                <1>
  3503                              <1> 	;mov	word [HDSS_TBL_VEC],HD3_DPT	; PARM TABLE DRIVE 83h
  3504                              <1> 	;mov	word [HDSS_TBL_VEC+2],DPT_SEGM
  3505 00005250 C705[7C8A0100]6000- <1> 	mov 	dword [HDSS_TBL_VEC], (DPT_SEGM*16)+HD3_DPT
  3505 00005258 0900                <1>
  3506                              <1> 	;
  3507                              <1> 	;;IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  3508                              <1> 	;;;AND	AL,0BFH
  3509                              <1> 	;;and	al, 3Fh			; enable IRQ 14 and IRQ 15
  3510                              <1> 	;;;JMP	$+2
  3511                              <1> 	;;IODELAY
  3512                              <1> 	;;OUT	INTB01,AL
  3513                              <1> 	;;IODELAY
  3514                              <1> 	;;IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  3515                              <1> 	;;AND	AL,0FBH 		;  SECOND CHIP
  3516                              <1> 	;;;JMP	$+2
  3517                              <1> 	;;IODELAY
  3518                              <1> 	;;OUT	INTA01,AL
  3519                              <1> 	;
  3520                              <1> 	;STI
  3521                              <1> 	;;PUSH	DS			; MOVE ABS0 POINTER TO
  3522                              <1> 	;;POP	ES			; EXTRA SEGMENT POINTER
  3523                              <1> 	;;;CALL	DDS			; ESTABLISH DATA SEGMENT
  3524                              <1> 	;;MOV	byte [DISK_STATUS1],0 	; RESET THE STATUS INDICATOR
  3525                              <1> 	;;MOV	byte [HF_NUM],0		; ZERO NUMBER OF FIXED DISKS
  3526                              <1> 	;;MOV	byte [CONTROL_BYTE],0
  3527                              <1> 	;;MOV	byte [PORT_OFF],0	; ZERO CARD OFFSET
  3528                              <1> 	; 20/12/2014 - private code by Erdogan Tan
  3529                              <1> 		      ; (out of original PC-AT, PC-XT BIOS code)
  3530                              <1> 	;mov	si, hd0_type
  3531 0000525A BE[006E0000]        <1> 	mov	esi, hd0_type
  3532                              <1> 	;mov	cx, 4
  3533 0000525F B904000000          <1> 	mov	ecx, 4
  3534                              <1> hde_l:
  3535 00005264 AC                  <1> 	lodsb
  3536 00005265 3C80                <1> 	cmp	al, 80h			; 8?h = existing
  3537 00005267 7206                <1> 	jb	short _L4
  3538 00005269 FE05[6C8A0100]      <1> 	inc	byte [HF_NUM]		; + 1 hard (fixed) disk drives
  3539                              <1> _L4: ; 26/02/2015
  3540 0000526F E2F3                <1> 	loop	hde_l	
  3541                              <1> ;_L4:					; 0 <= [HF_NUM] =< 4
  3542                              <1> ;L4:
  3543                              <1> 	; 
  3544                              <1> 	;; 31/12/2014 - cancel controller diagnostics here
  3545                              <1> 	;;;mov 	cx, 3  ; 26/12/2014 (Award BIOS 1999)
  3546                              <1> 	;;mov 	cl, 3
  3547                              <1> 	;;
  3548                              <1> 	;;MOV	DL,80H			; CHECK THE CONTROLLER
  3549                              <1> ;;hdc_dl:
  3550                              <1> 	;;MOV	AH,14H			; USE CONTROLLER DIAGNOSTIC COMMAND
  3551                              <1> 	;;INT	13H			; CALL BIOS WITH DIAGNOSTIC COMMAND
  3552                              <1> 	;;;JC	short CTL_ERRX		; DISPLAY ERROR MESSAGE IF BAD RETURN
  3553                              <1> 	;;;jc	short POD_DONE ;22/12/2014
  3554                              <1> 	;;jnc	short hdc_reset0
  3555                              <1> 	;;loop	hdc_dl
  3556                              <1> 	;;; 27/12/2014
  3557                              <1> 	;;stc
  3558                              <1> 	;;retn
  3559                              <1> 	;
  3560                              <1> ;;hdc_reset0:
  3561                              <1> 	; 18/01/2015
  3562 00005271 8A0D[6C8A0100]      <1> 	mov	cl, [HF_NUM]
  3563 00005277 20C9                <1> 	and	cl, cl
  3564 00005279 740E                <1> 	jz	short POD_DONE
  3565                              <1> 	;
  3566 0000527B B27F                <1> 	mov	dl, 7Fh
  3567                              <1> hdc_reset1:
  3568 0000527D FEC2                <1> 	inc	dl
  3569                              <1> 	;; 31/12/2015
  3570                              <1> 	;;push	dx
  3571                              <1> 	;;push	cx
  3572                              <1> 	;;push	ds
  3573                              <1> 	;;sub	ax, ax
  3574                              <1> 	;;mov	ds, ax
  3575                              <1> 	;;MOV	AX, [TIMER_LOW]		; GET START TIMER COUNTS
  3576                              <1> 	;;pop	ds
  3577                              <1> 	;;MOV	BX,AX
  3578                              <1> 	;;ADD	AX,6*182		; 60 SECONDS* 18.2
  3579                              <1> 	;;MOV	CX,AX
  3580                              <1> 	;;mov	word [wait_count], 0	; 22/12/2014 (reset wait counter)
  3581                              <1> 	;;
  3582                              <1> 	;; 31/12/2014 - cancel HD_RESET_1
  3583                              <1> 	;;CALL	HD_RESET_1		; SET UP DRIVE 0, (1,2,3)
  3584                              <1> 	;;pop	cx
  3585                              <1> 	;;pop	dx
  3586                              <1> 	;;
  3587                              <1> 	; 18/01/2015
  3588 0000527F B40D                <1> 	mov	ah, 0Dh ; ALTERNATE RESET
  3589                              <1> 	;int	13h
  3590 00005281 E8A3FFFFFF          <1> 	call	int13h
  3591 00005286 E2F5                <1> 	loop	hdc_reset1
  3592 00005288 F8                  <1> 	clc 	; 29/05/2016
  3593                              <1> POD_DONE:
  3594 00005289 C3                  <1> 	RETn
  3595                              <1> 
  3596                              <1> ;;-----	POD_ERROR
  3597                              <1> 
  3598                              <1> ;;CTL_ERRX:
  3599                              <1> ;	;MOV	SI,OFFSET F1782 	; CONTROLLER ERROR
  3600                              <1> ;	;CALL	SET_FAIL		; DO NOT IPL FROM DISK
  3601                              <1> ;	;CALL	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  3602                              <1> ;	;JMP	short POD_DONE
  3603                              <1> 
  3604                              <1> ;;HD_RESET_1:
  3605                              <1> ;;	;PUSH	BX			; SAVE TIMER LIMITS
  3606                              <1> ;;	;PUSH	CX
  3607                              <1> ;;RES_1: MOV	AH,09H			; SET DRIVE PARAMETERS
  3608                              <1> ;;	INT	13H
  3609                              <1> ;;	JC	short RES_2
  3610                              <1> ;;	MOV	AH,11H			; RECALIBRATE DRIVE
  3611                              <1> ;;	INT	13H
  3612                              <1> ;;	JNC	short RES_CK		; DRIVE OK
  3613                              <1> ;;RES_2: ;CALL	POD_TCHK		; CHECK TIME OUT
  3614                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  3615                              <1> ;;					; (30 seconds)		
  3616                              <1> ;;	;cmc
  3617                              <1> ;;	;JNC	short RES_1
  3618                              <1> ;;	jb	short RES_1
  3619                              <1> ;;;RES_FL: ;MOV	SI,OFFSET F1781 	; INDICATE DISK 1 FAILURE;
  3620                              <1> ;;	;TEST	DL,1
  3621                              <1> ;;	;JNZ	RES_E1
  3622                              <1> ;;	;MOV	SI,OFFSET F1780 	; INDICATE DISK 0 FAILURE
  3623                              <1> ;;	;CALL	SET_FAIL		; DO NOT TRY TO IPL DISK 0
  3624                              <1> ;;	;JMP	SHORT RES_E1
  3625                              <1> ;;RES_ER: ; 22/12/2014
  3626                              <1> ;;RES_OK:
  3627                              <1> ;;	;POP	CX			; RESTORE TIMER LIMITS
  3628                              <1> ;;	;POP	BX
  3629                              <1> ;;	RETn
  3630                              <1> ;;
  3631                              <1> ;;RES_RS: MOV	AH,00H			; RESET THE DRIVE
  3632                              <1> ;;	INT	13H
  3633                              <1> ;;RES_CK: MOV	AH,08H			; GET MAX CYLINDER,HEAD,SECTOR
  3634                              <1> ;;	MOV	BL,DL			; SAVE DRIVE CODE
  3635                              <1> ;;	INT	13H
  3636                              <1> ;;	JC	short RES_ER
  3637                              <1> ;;	MOV	[NEC_STATUS],CX 	; SAVE MAX CYLINDER, SECTOR
  3638                              <1> ;;	MOV	DL,BL			; RESTORE DRIVE CODE
  3639                              <1> ;;RES_3: MOV	AX,0401H		; VERIFY THE LAST SECTOR
  3640                              <1> ;;	INT	13H
  3641                              <1> ;;	JNC	short RES_OK		; VERIFY OK
  3642                              <1> ;;	CMP	AH,BAD_SECTOR		; OK ALSO IF JUST ID READ
  3643                              <1> ;;	JE	short RES_OK
  3644                              <1> ;;	CMP	AH,DATA_CORRECTED
  3645                              <1> ;;	JE	short RES_OK
  3646                              <1> ;;	CMP	AH,BAD_ECC
  3647                              <1> ;;	JE	short RES_OK
  3648                              <1> ;;	;CALL	POD_TCHK		; CHECK FOR TIME OUT
  3649                              <1> ;;	cmp	word [wait_count], 6*182 ; waiting time (in timer ticks)
  3650                              <1> ;;					; (60 seconds)		
  3651                              <1> ;;	cmc
  3652                              <1> ;;	JC	short RES_ER		; FAILED
  3653                              <1> ;;	MOV	CX,[NEC_STATUS] 	; GET SECTOR ADDRESS, AND CYLINDER
  3654                              <1> ;;	MOV	AL,CL			; SEPARATE OUT SECTOR NUMBER
  3655                              <1> ;;	AND	AL,3FH
  3656                              <1> ;;	DEC	AL			; TRY PREVIOUS ONE
  3657                              <1> ;;	JZ	short RES_RS		; WE'VE TRIED ALL SECTORS ON TRACK
  3658                              <1> ;;	AND	CL,0C0H 		; KEEP CYLINDER BITS
  3659                              <1> ;;	OR	CL,AL			; MERGE SECTOR WITH CYLINDER BITS
  3660                              <1> ;;	MOV	[NEC_STATUS],CX 	; SAVE CYLINDER, NEW SECTOR NUMBER
  3661                              <1> ;;	JMP	short RES_3		; TRY AGAIN
  3662                              <1> ;;;RES_ER: MOV	SI,OFFSET F1791 	; INDICATE DISK 1 ERROR
  3663                              <1> ;;	;TEST	DL,1
  3664                              <1> ;;	;JNZ	short RES_E1
  3665                              <1> ;;	;MOV	SI,OFFSET F1790 	; INDICATE DISK 0 ERROR
  3666                              <1> ;;;RES_E1:
  3667                              <1> ;;	;CALL	E_MSG			; DISPLAY ERROR AND SET (BP) ERROR FLAG
  3668                              <1> ;;;RES_OK:
  3669                              <1> ;;	;POP	CX			; RESTORE TIMER LIMITS
  3670                              <1> ;;	;POP	BX
  3671                              <1> ;;	;RETn
  3672                              <1> ;
  3673                              <1> ;;SET_FAIL:
  3674                              <1> ;	;MOV	AX,X*(CMOS_DIAG+NMI)	; GET CMOS ERROR BYTE
  3675                              <1> ;	;CALL	CMOS_READ
  3676                              <1> ;	;OR	AL,HF_FAIL		; SET DO NOT IPL FROM DISK FLAG
  3677                              <1> ;	;XCHG	AH,AL			; SAVE IT
  3678                              <1> ;	;CALL	CMOS_WRITE		; PUT IT OUT
  3679                              <1> ;	;RETn
  3680                              <1> ;
  3681                              <1> ;;POD_TCHK:				; CHECK FOR 30 SECOND TIME OUT
  3682                              <1> ;	;POP	AX			; SAVE RETURN
  3683                              <1> ;	;POP	CX			; GET TIME OUT LIMITS
  3684                              <1> ;	;POP	BX
  3685                              <1> ;	;PUSH	BX			; AND SAVE THEM AGAIN
  3686                              <1> ;	;PUSH	CX
  3687                              <1> ;	;PUSH	AX
  3688                              <1> ;	;push	ds
  3689                              <1> ;	;xor	ax, ax
  3690                              <1> ;	;mov	ds, ax			; RESTORE RETURN
  3691                              <1> ;	;MOV	AX, [TIMER_LOW]		; AX = CURRENT TIME
  3692                              <1> ;	;				; BX = START TIME
  3693                              <1> ;	;				; CX = END TIME
  3694                              <1> ;	;pop	ds
  3695                              <1> ;	;CMP	BX,CX
  3696                              <1> ;	;JB	short TCHK1		; START < END
  3697                              <1> ;	;CMP	BX,AX
  3698                              <1> ;	;JB	short TCHKG		; END < START < CURRENT
  3699                              <1> ;	;JMP	SHORT TCHK2		; END, CURRENT < START
  3700                              <1> ;;TCHK1: CMP	AX,BX
  3701                              <1> ;;	JB	short TCHKNG		; CURRENT < START < END
  3702                              <1> ;;TCHK2: CMP	AX,CX
  3703                              <1> ;;	JB	short TCHKG		; START < CURRENT < END
  3704                              <1> ;;					; OR CURRENT < END < START
  3705                              <1> ;;TCHKNG: STC				; CARRY SET INDICATES TIME OUT
  3706                              <1> ;;	RETn
  3707                              <1> ;;TCHKG: CLC				; INDICATE STILL TIME
  3708                              <1> ;;	RETn
  3709                              <1> ;;
  3710                              <1> ;;int_13h:
  3711                              <1> 
  3712                              <1> ;----------------------------------------
  3713                              <1> ;	FIXED DISK BIOS ENTRY POINT	:
  3714                              <1> ;----------------------------------------
  3715                              <1> 
  3716                              <1> ; 30/08/2020
  3717                              <1> ; 29/08/2020
  3718                              <1> ; 15/01/2017
  3719                              <1> ; 14/01/2017
  3720                              <1> ; 07/01/2017
  3721                              <1> ; 02/01/2017
  3722                              <1> ; 01/06/2016
  3723                              <1> ; 16/05/2016, 27/05/2016, 28/05/2016, 29/05/2016
  3724                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
  3725                              <1> int33h:  ; DISK I/O
  3726                              <1> 	; 29/05/2016
  3727 0000528A 80642408FE          <1> 	and	byte [esp+8], 11111110b  ; clear carry bit of eflags register
  3728                              <1> 	; 16/05/2016
  3729 0000528F 1E                  <1> 	push	ds
  3730 00005290 53                  <1> 	push	ebx ; user's buffer address (virtual)
  3731 00005291 66BB1000            <1> 	mov	bx, KDATA ; System (Kernel's) data segment
  3732 00005295 8EDB                <1> 	mov	ds, bx
  3733                              <1> 
  3734                              <1> 	;;15/01/2017
  3735                              <1> 	; 14/01/2017
  3736                              <1> 	; 02/01/2017
  3737                              <1> 	;;mov	byte [intflg], 33h	; disk io interrupt 
  3738                              <1> 	;pop	ebx
  3739                              <1> 	;mov	[user_buffer], ebx		
  3740                              <1> 
  3741 00005297 8F05[5C960100]      <1> 	pop	dword [user_buffer] ; 01/06/2016
  3742                              <1> 
  3743 0000529D C605[968F0100]00    <1> 	mov	byte [scount], 0 ; sector count for transfer
  3744 000052A4 80FC03              <1> 	cmp	ah, 03h ; chs write
  3745 000052A7 7744                <1> 	ja	short int33h_2
  3746 000052A9 7407                <1> 	je	short int33h_0
  3747 000052AB 80FC02              <1> 	cmp	ah, 02h ; chs read
  3748 000052AE 726F                <1> 	jb	short int33h_5
  3749 000052B0 EB68                <1> 	jmp	short int33h_4
  3750                              <1> int33h_0:
  3751                              <1> 	; transfer user's buffer content to sector buffer
  3752 000052B2 51                  <1> 	push	ecx
  3753 000052B3 0FB6C8              <1> 	movzx	ecx, al
  3754                              <1> int33h_1:
  3755 000052B6 56                  <1> 	push	esi
  3756 000052B7 8B35[5C960100]      <1> 	mov	esi, [user_buffer]
  3757                              <1> 	; esi = user's buffer address (virtual, ebx)
  3758 000052BD 57                  <1> 	push	edi
  3759 000052BE 06                  <1> 	push	es
  3760 000052BF 50                  <1> 	push	eax
  3761 000052C0 66B81000            <1> 	mov	ax, KDATA
  3762 000052C4 8EC0                <1> 	mov	es, ax
  3763 000052C6 BF00000700          <1> 	mov	edi, Cluster_Buffer
  3764 000052CB C1E109              <1> 	shl	ecx, 9 ; * 512
  3765 000052CE E87BC80000          <1> 	call	transfer_from_user_buffer
  3766 000052D3 58                  <1> 	pop	eax
  3767 000052D4 07                  <1> 	pop	es
  3768 000052D5 5F                  <1> 	pop	edi
  3769 000052D6 5E                  <1> 	pop	esi
  3770 000052D7 59                  <1> 	pop	ecx
  3771 000052D8 7345                <1> 	jnc	short int33h_5
  3772 000052DA 8B1D[5C960100]      <1> 	mov	ebx, [user_buffer] ; 01/06/2016
  3773 000052E0 1F                  <1> 	pop	ds
  3774                              <1> 
  3775                              <1> 	;;15/01/2017
  3776                              <1> 	; 02/01/2017
  3777                              <1> 	;cli
  3778                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  3779                              <1> 	;
  3780                              <1> 	; (*) 29/05/2016
  3781                              <1> 	; (*) retf 4 ; skip eflags on stack
  3782                              <1> 
  3783                              <1> 	; 29/05/2016 -set carry flag on stack-
  3784                              <1> 	; [esp] = EIP
  3785                              <1> 	; [esp+4] = CS
  3786                              <1> 	; [esp+8] = E-FLAGS
  3787 000052E1 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  3788                              <1> 	; [esp+12] = ESP (user)
  3789                              <1> 	; [esp+16] = SS (User)
  3790 000052E6 B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  3791                              <1> 	;iretd
  3792 000052EB EB7E                <1> 	jmp	short int33h_7  ; 07/01/2017	
  3793                              <1> 
  3794                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
  3795                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
  3796                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
  3797                              <1> 	; // RETF instruction:
  3798                              <1> 	;
  3799                              <1> 	; IF OperandMode=32 THEN
  3800                              <1>  	;    Load CS:EIP from stack;
  3801                              <1>  	;    Set CS RPL to CPL;
  3802                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
  3803                              <1>  	;    Load SS:eSP from stack;
  3804                              <1>  	; ELSE (* OperandMode=16 *)
  3805                              <1>  	;    Load CS:IP from stack;
  3806                              <1>  	;    Set CS RPL to CPL;
  3807                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
  3808                              <1> 	;    Load SS:eSP from stack;
  3809                              <1>  	; FI;
  3810                              <1> 	;
  3811                              <1> 	; //
  3812                              <1> 
  3813                              <1> int33h_2:
  3814 000052ED 80FC05              <1> 	cmp	ah, 05h ; format track
  3815 000052F0 770A                <1> 	ja	short int33h_3
  3816 000052F2 722B                <1> 	jb	short int33h_5
  3817 000052F4 51                  <1> 	push	ecx
  3818 000052F5 B901000000          <1> 	mov	ecx, 1
  3819 000052FA EBBA                <1> 	jmp	short int33h_1
  3820                              <1> int33h_3:
  3821 000052FC 80FC1C              <1> 	cmp	ah, 1Ch ; LBA write
  3822 000052FF 771E                <1> 	ja	short int33h_5
  3823 00005301 74AF                <1> 	je	short int33h_0
  3824 00005303 80FC1B              <1> 	cmp	ah, 1Bh ; LBA read
  3825 00005306 7412                <1> 	je	short int33h_4
  3826                              <1> 	; 29/08/2020
  3827 00005308 80FC08              <1> 	cmp	ah, 08h ; get disk parameters
  3828                              <1> 	;jne	short int33h_5
  3829 0000530B 7405                <1> 	je	short int33h_10
  3830 0000530D 80FC15              <1> 	cmp	ah, 15h	; read DASD type (get disk size)
  3831 00005310 750D                <1> 	jne	short int33h_5
  3832                              <1> int33h_10:
  3833                              <1> 	; 01/06/2016
  3834 00005312 8B1D[5C960100]      <1> 	mov	ebx, [user_buffer] ; user's buffer address
  3835 00005318 EB0A                <1> 	jmp	short int33h_6
  3836                              <1> int33h_4:
  3837 0000531A A2[968F0100]        <1> 	mov	byte [scount], al ; <= 128 sectors
  3838                              <1> int33h_5:
  3839 0000531F BB00000700          <1> 	mov	ebx, Cluster_Buffer ; max. 65536 bytes
  3840                              <1> 				    ; buf. addr: 70000h	
  3841                              <1> 	;mov	byte [ClusterBuffer_Valid], 0
  3842                              <1> int33h_6:
  3843 00005324 1F                  <1> 	pop	ds
  3844 00005325 9C                  <1> 	pushfd
  3845 00005326 0E                  <1> 	push 	cs
  3846 00005327 E84D000000          <1> 	call 	DISK_IO
  3847 0000532C 2E8B1D[5C960100]    <1> 	mov	ebx, [CS:user_buffer] ; 01/06/2016
  3848 00005333 723D                <1> 	jc	short int33h_9
  3849                              <1> 	;
  3850 00005335 2E803D[968F0100]00  <1> 	cmp	byte [CS:scount], 0
  3851 0000533D 762C                <1> 	jna	short int33h_7
  3852                              <1> 	;
  3853                              <1> 	; transfer sector buffer content to user's buffer
  3854 0000533F 06                  <1> 	push	es
  3855 00005340 1E                  <1> 	push	ds
  3856 00005341 50                  <1> 	push	eax
  3857 00005342 66B81000            <1> 	mov	ax, KDATA
  3858 00005346 8ED8                <1> 	mov	ds, ax
  3859 00005348 8EC0                <1> 	mov	es, ax
  3860 0000534A 51                  <1> 	push	ecx
  3861 0000534B 56                  <1> 	push	esi
  3862 0000534C 57                  <1> 	push	edi
  3863 0000534D 0FB60D[968F0100]    <1> 	movzx	ecx, byte [scount]
  3864 00005354 C1E109              <1> 	shl	ecx, 9 ; * 512 bytes
  3865 00005357 89DF                <1> 	mov	edi, ebx ; user's buffer address
  3866 00005359 BE00000700          <1> 	mov	esi, Cluster_Buffer
  3867 0000535E E8A1C70000          <1> 	call	transfer_to_user_buffer
  3868 00005363 5F                  <1> 	pop	edi
  3869 00005364 5E                  <1> 	pop	esi
  3870 00005365 59                  <1> 	pop	ecx
  3871 00005366 58                  <1> 	pop	eax
  3872 00005367 1F                  <1> 	pop	ds
  3873 00005368 07                  <1> 	pop	es
  3874 00005369 7202                <1> 	jc	short int33h_8
  3875                              <1> int33h_7:
  3876 0000536B FA                  <1> 	cli
  3877                              <1> 	;;15/01/2017
  3878                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
  3879                              <1> 	; cf = 0  ; use eflags which is in stack
  3880 0000536C CF                  <1> 	iretd	
  3881                              <1> int33h_8:
  3882 0000536D B8FF000000          <1> 	mov	eax, 0FFh ; Unknown error !?
  3883                              <1> int33h_9:
  3884                              <1> 	; cf = 1
  3885                              <1> 
  3886                              <1> 	; (*) 29/05/2016	
  3887                              <1> 	; (*) retf 4 ; skip eflags on stack
  3888                              <1> 	; Note: This 'retf 4' was wrong, -it was causing
  3889                              <1> 	;       to stack errors in ring 3-
  3890                              <1> 	;	POP sequence of 'retf 4' is as
  3891                              <1> 	;       "eip, cs, eflags, esp, ss, +4 bytes" 
  3892                              <1>         ;       it is not as "eip, cs, +4 bytes, esp, ss" ! 
  3893                              <1> 
  3894                              <1> 	; 29/05/2016 -set carry flag on stack-
  3895 00005372 804C240801          <1> 	or	byte [esp+8], 1  ; set carry bit of eflags register
  3896                              <1> 	;iretd
  3897 00005377 EBF2                <1> 	jmp	short int33h_7 ; 07/01/2017
  3898                              <1> 
  3899                              <1> ; 30/08/2020
  3900                              <1> ; 09/12/2017
  3901                              <1> ; 29/05/2016
  3902                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  3903                              <1> 
  3904                              <1> DISK_IO:
  3905 00005379 80FA80              <1> 	CMP	DL,80H			; TEST FOR FIXED DISK DRIVE
  3906                              <1> 	;JAE	short A1		; YES, HANDLE HERE
  3907                              <1> 	;;;INT	40H			; DISKETTE HANDLER
  3908                              <1> 	;;call	int40h
  3909 0000537C 0F82FFEFFFFF        <1> 	jb	DISKETTE_IO_1
  3910                              <1> ;RET_2:
  3911                              <1> 	;RETf	2			; BACK TO CALLER
  3912                              <1> ;	retf	4
  3913                              <1> A1:
  3914 00005382 FB                  <1> 	STI				; ENABLE INTERRUPTS
  3915                              <1> 	;; 04/01/2015
  3916                              <1> 	;;OR	AH,AH
  3917                              <1> 	;;JNZ	short A2
  3918                              <1> 	;;INT	40H			; RESET NEC WHEN AH=0
  3919                              <1> 	;;SUB	AH,AH
  3920 00005383 80FA83              <1> 	CMP	DL,(80H + S_MAX_FILE - 1) ; 83h ; 30/08/2020 
  3921                              <1> 	;JA	short RET_2
  3922 00005386 7614                <1> 	jna	short _A0
  3923                              <1> 	; 29/05/2016
  3924 00005388 1E                  <1> 	push	ds
  3925 00005389 50                  <1> 	push	eax ; 30/08/2020 (ax --> eax)
  3926 0000538A 66B81000            <1> 	mov	ax, KDATA
  3927 0000538E 8ED8                <1> 	mov	ds, ax
  3928 00005390 58                  <1> 	pop	eax ; 
  3929 00005391 B4AA                <1>         mov     ah, 0AAh        ; Hard disk drive not ready !
  3930                              <1> 				; (Programmer's guide to AMIBIOS, 1992)
  3931 00005393 8825[6B8A0100]      <1> 	mov     byte [DISK_STATUS1], ah
  3932 00005399 1F                  <1> 	pop	ds
  3933 0000539A EB38                <1> 	jmp	short RET_2
  3934                              <1> _A0:
  3935                              <1> 	; 18/01/2015
  3936 0000539C 08E4                <1> 	or	ah,ah
  3937 0000539E 743A                <1> 	jz	short A4
  3938 000053A0 80FC0D              <1> 	cmp	ah,0Dh	; Alternate reset
  3939 000053A3 7504                <1> 	jne	short A2
  3940 000053A5 28E4                <1> 	sub	ah,ah	; Reset
  3941 000053A7 EB31                <1> 	jmp	short A4
  3942                              <1> A2:
  3943 000053A9 80FC08              <1> 	CMP	AH,08H			; GET PARAMETERS IS A SPECIAL CASE
  3944                              <1> 	;JNZ	short A3
  3945                              <1>         ;JMP    GET_PARM_N
  3946 000053AC 0F8452030000        <1> 	je	GET_PARM_N
  3947 000053B2 80FC15              <1> A3:	CMP	AH,15H			; READ DASD TYPE IS ALSO
  3948                              <1> 	;JNZ	short A4
  3949                              <1>         ;JMP    READ_DASD_TYPE
  3950 000053B5 0F84DB020000        <1>         je      READ_DASD_TYPE
  3951                              <1> 	; 02/02/2015
  3952 000053BB 80FC1D              <1> 	cmp	ah, 1Dh			;(Temporary for Retro UNIX 386 v1)
  3953                              <1> 	; 12/01/2015
  3954 000053BE F5                  <1> 	cmc
  3955 000053BF 7319                <1> 	jnc	short A4
  3956                              <1> int33h_bad_cmd:
  3957                              <1> 	; 16/05/2016
  3958                              <1> 	; 30/01/2015
  3959                              <1> 	; 29/05/2016
  3960 000053C1 1E                  <1> 	push	ds
  3961 000053C2 6650                <1> 	push	ax
  3962 000053C4 66B81000            <1> 	mov	ax, KDATA
  3963 000053C8 8ED8                <1> 	mov	ds, ax
  3964 000053CA 6658                <1> 	pop	ax
  3965 000053CC B401                <1> 	mov	ah, BAD_CMD
  3966 000053CE 8825[6B8A0100]      <1> 	mov     [DISK_STATUS1], ah ; BAD_CMD  ; COMMAND ERROR
  3967                              <1>         ;jmp	short RET_2
  3968                              <1> RET_2:
  3969                              <1> 	; (*) 29/05/2016
  3970                              <1> 	; (*) retf 4
  3971 000053D4 804C240801          <1> 	or	byte [esp+8], 1 ; set carry bit of eflags register
  3972 000053D9 CF                  <1> 	iretd
  3973                              <1> A4:					; SAVE REGISTERS DURING OPERATION
  3974 000053DA C8080000            <1> 	ENTER	8,0			; SAVE (BP) AND MAKE ROOM FOR @CMD_BLOCK
  3975 000053DE 53                  <1> 	PUSH	eBX			;  IN THE STACK, THE COMMAND BLOCK IS:
  3976 000053DF 51                  <1> 	PUSH	eCX			;   @CMD_BLOCK == BYTE PTR [BP]-8
  3977 000053E0 52                  <1> 	PUSH	eDX
  3978 000053E1 1E                  <1> 	PUSH	DS
  3979 000053E2 06                  <1> 	PUSH	ES
  3980 000053E3 56                  <1> 	PUSH	eSI
  3981 000053E4 57                  <1> 	PUSH	eDI
  3982                              <1> 	;;04/01/2015
  3983                              <1> 	;;OR	AH,AH			; CHECK FOR RESET
  3984                              <1> 	;;JNZ	short A5
  3985                              <1> 	;;MOV	DL,80H			; FORCE DRIVE 80 FOR RESET
  3986                              <1> ;;A5:	
  3987                              <1> 	;push	cs
  3988                              <1> 	;pop	ds
  3989                              <1> 	; 21/02/2015
  3990 000053E5 6650                <1> 	push	ax
  3991 000053E7 66B81000            <1> 	mov	ax, KDATA
  3992 000053EB 8ED8                <1> 	mov	ds, ax
  3993 000053ED 8EC0                <1> 	mov	es, ax	
  3994 000053EF 6658                <1> 	pop	ax
  3995 000053F1 E88D000000          <1> 	CALL	DISK_IO_CONT		; PERFORM THE OPERATION
  3996                              <1> 	;;CALL	DDS			; ESTABLISH SEGMENT
  3997 000053F6 8A25[6B8A0100]      <1> 	MOV	AH,[DISK_STATUS1]	; GET STATUS FROM OPERATION
  3998                              <1> 	;(*) CMP AH,1			; SET THE CARRY FLAG TO INDICATE
  3999                              <1> 	;(*) CMC			; SUCCESS OR FAILURE
  4000 000053FC 5F                  <1> 	POP	eDI			; RESTORE REGISTERS
  4001 000053FD 5E                  <1> 	POP	eSI
  4002 000053FE 07                  <1>         POP     ES
  4003 000053FF 1F                  <1>         POP     DS
  4004 00005400 5A                  <1> 	POP	eDX
  4005 00005401 59                  <1> 	POP	eCX
  4006 00005402 5B                  <1> 	POP	eBX
  4007 00005403 C9                  <1> 	LEAVE				; ADJUST (SP) AND RESTORE (BP)
  4008                              <1> 	;RETf	2			; THROW AWAY SAVED FLAGS
  4009                              <1> 	; (*) 29/05/2016
  4010                              <1> 	; (*) retf 4
  4011 00005404 80FC01              <1> 	cmp	ah, 1
  4012 00005407 7205                <1> 	jc	short _A5 
  4013 00005409 804C240801          <1> 	or	byte [esp+8], 1 ; set carry bit of eflags register
  4014                              <1> _A5:
  4015 0000540E CF                  <1> 	iretd
  4016                              <1> 
  4017                              <1> ; 21/02/2015
  4018                              <1> ;       dw --> dd
  4019                              <1> D1:					; FUNCTION TRANSFER TABLE
  4020 0000540F [D2550000]          <1> 	dd	DISK_RESET		; 000H
  4021 00005413 [49560000]          <1> 	dd	RETURN_STATUS		; 001H
  4022 00005417 [56560000]          <1> 	dd	DISK_READ		; 002H
  4023 0000541B [5F560000]          <1> 	dd	DISK_WRITE		; 003H
  4024 0000541F [68560000]          <1> 	dd	DISK_VERF		; 004H
  4025 00005423 [80560000]          <1> 	dd	FMT_TRK 		; 005H
  4026 00005427 [C8550000]          <1> 	dd	BAD_COMMAND		; 006H	FORMAT BAD SECTORS
  4027 0000542B [C8550000]          <1> 	dd	BAD_COMMAND		; 007H	FORMAT DRIVE
  4028 0000542F [C8550000]          <1> 	dd	BAD_COMMAND		; 008H	RETURN PARAMETERS
  4029 00005433 [9D570000]          <1> 	dd	INIT_DRV		; 009H
  4030 00005437 [FC570000]          <1> 	dd	RD_LONG 		; 00AH
  4031 0000543B [05580000]          <1> 	dd	WR_LONG 		; 00BH
  4032 0000543F [0E580000]          <1> 	dd	DISK_SEEK		; 00CH
  4033 00005443 [D2550000]          <1> 	dd	DISK_RESET		; 00DH
  4034 00005447 [C8550000]          <1> 	dd	BAD_COMMAND		; 00EH	READ BUFFER
  4035 0000544B [C8550000]          <1> 	dd	BAD_COMMAND		; 00FH	WRITE BUFFER
  4036 0000544F [36580000]          <1> 	dd	TST_RDY 		; 010H
  4037 00005453 [5A580000]          <1> 	dd	HDISK_RECAL		; 011H
  4038 00005457 [C8550000]          <1> 	dd	BAD_COMMAND		; 012H	MEMORY DIAGNOSTIC
  4039 0000545B [C8550000]          <1> 	dd	BAD_COMMAND		; 013H	DRIVE DIAGNOSTIC
  4040 0000545F [90580000]          <1> 	dd	CTLR_DIAGNOSTIC 	; 014H	CONTROLLER DIAGNOSTIC
  4041                              <1> 	; 02/02/2015 (Temporary - Retro UNIX 386 v1 - DISK I/O test)
  4042 00005463 [C8550000]          <1> 	dd	BAD_COMMAND		; 015h
  4043 00005467 [C8550000]          <1> 	dd	BAD_COMMAND		; 016h
  4044 0000546B [C8550000]          <1> 	dd	BAD_COMMAND		; 017h
  4045 0000546F [C8550000]          <1> 	dd	BAD_COMMAND		; 018h
  4046 00005473 [C8550000]          <1> 	dd	BAD_COMMAND		; 019h
  4047 00005477 [C8550000]          <1> 	dd	BAD_COMMAND		; 01Ah
  4048 0000547B [56560000]          <1> 	dd	DISK_READ		; 01Bh ; LBA read
  4049 0000547F [5F560000]          <1> 	dd	DISK_WRITE		; 01Ch ; LBA write
  4050                              <1> D1L     EQU    $ - D1
  4051                              <1> 
  4052                              <1> DISK_IO_CONT:
  4053                              <1> 	;;CALL	DDS			; ESTABLISH SEGMENT
  4054 00005483 80FC01              <1> 	CMP	AH,01H			; RETURN STATUS
  4055                              <1> 	;;JNZ	short SU0
  4056                              <1>         ;;JMP	RETURN_STATUS
  4057 00005486 0F84BD010000        <1> 	je	RETURN_STATUS
  4058                              <1> SU0:
  4059 0000548C C605[6B8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; RESET THE STATUS INDICATOR
  4060                              <1> 	;;PUSH	BX			; SAVE DATA ADDRESS
  4061                              <1> 	;mov	si, bx ;; 14/02/2015
  4062 00005493 89DE                <1> 	mov	esi, ebx ; 21/02/2015
  4063 00005495 8A1D[6C8A0100]      <1> 	MOV	BL,[HF_NUM]		; GET NUMBER OF DRIVES
  4064                              <1> 	;; 04/01/2015
  4065                              <1> 	;;PUSH	AX
  4066 0000549B 80E27F              <1> 	AND	DL,7FH			; GET DRIVE AS 0 OR 1
  4067                              <1> 					; (get drive number as 0 to 3)
  4068 0000549E 38D3                <1> 	CMP	BL,DL
  4069                              <1>         ;;JBE   BAD_COMMAND_POP         ; INVALID DRIVE
  4070 000054A0 0F8622010000        <1>         jbe     BAD_COMMAND ;; 14/02/2015
  4071                              <1>         ;
  4072                              <1> 	;;03/01/2015
  4073 000054A6 29DB                <1> 	sub	ebx, ebx
  4074 000054A8 88D3                <1> 	mov	bl, dl
  4075                              <1> 	;sub	bh, bh
  4076 000054AA 883D[808A0100]      <1> 	mov	[LBAMode], bh 	; 0
  4077                              <1> 	;;test	byte [bx+hd0_type], 1	; LBA ready ?
  4078                              <1> 	;test	byte [ebx+hd0_type], 1
  4079                              <1> 	;jz	short su1		; no
  4080                              <1> 	;inc	byte [LBAMode]
  4081                              <1> ;su1:
  4082                              <1> 	; 21/02/2015 (32 bit modification)
  4083                              <1> 	;04/01/2015
  4084 000054B0 6650                <1> 	push	ax ; ***
  4085                              <1> 	;PUSH	ES ; **
  4086 000054B2 6652                <1> 	PUSH	DX ; *
  4087 000054B4 6650                <1> 	push	ax
  4088 000054B6 E8BB060000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS
  4089                              <1> 	; 02/02/2015
  4090                              <1> 	;mov	ax, [ES:BX+16] ; I/O port base address (1F0h, 170h)
  4091 000054BB 668B4310            <1> 	mov	ax, [ebx+16]
  4092 000054BF 66A3[F06D0000]      <1> 	mov	[HF_PORT], ax
  4093                              <1> 	;mov	dx, [ES:BX+18] ; control port address (3F6h, 376h)
  4094 000054C5 668B5312            <1> 	mov	dx, [ebx+18]
  4095 000054C9 668915[F26D0000]    <1> 	mov	[HF_REG_PORT], dx
  4096                              <1> 	;mov	al, [ES:BX+20] ; head register upper nibble (A0h,B0h,E0h,F0h)
  4097 000054D0 8A4314              <1> 	mov	al, [ebx+20]
  4098                              <1> 	; 23/02/2015
  4099 000054D3 A840                <1> 	test	al, 40h	 ; LBA bit (bit 6)
  4100 000054D5 7406                <1> 	jz 	short su1
  4101 000054D7 FE05[808A0100]      <1> 	inc	byte [LBAMode] ; 1 
  4102                              <1> su1: 	 
  4103 000054DD C0E804              <1> 	shr 	al, 4
  4104 000054E0 2401                <1> 	and	al, 1			
  4105 000054E2 A2[F46D0000]        <1> 	mov	[hf_m_s], al 
  4106                              <1> 	;
  4107                              <1> 	; 03/01/2015
  4108                              <1> 	;MOV	AL,byte [ES:BX+8]	; GET CONTROL BYTE MODIFIER
  4109 000054E7 8A4308              <1> 	mov	al, [ebx+8]
  4110                              <1> 	;MOV	DX,[HF_REG_PORT]	; Device Control register	
  4111 000054EA EE                  <1> 	OUT	DX,AL			; SET EXTRA HEAD OPTION
  4112                              <1> 					; Control Byte:  (= 08h, here)
  4113                              <1> 					; bit 0 - 0
  4114                              <1> 					; bit 1 - nIEN (1 = disable irq)
  4115                              <1> 					; bit 2 - SRST (software RESET)
  4116                              <1> 					; bit 3 - use extra heads (8 to 15)
  4117                              <1> 					;         -always set to 1-	
  4118                              <1> 					; (bits 3 to 7 are reserved
  4119                              <1> 					;          for ATA devices)
  4120 000054EB 8A25[6D8A0100]      <1> 	MOV	AH,[CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  4121 000054F1 80E4C0              <1> 	AND	AH,0C0H 		; CONTROL BYTE
  4122 000054F4 08C4                <1> 	OR	AH,AL
  4123 000054F6 8825[6D8A0100]      <1> 	MOV	[CONTROL_BYTE],AH	
  4124                              <1> 	; 04/01/2015
  4125 000054FC 6658                <1> 	pop	ax
  4126 000054FE 665A                <1> 	pop	dx ; * ;; 14/02/2015
  4127 00005500 20E4                <1> 	and	ah, ah	; Reset function ?
  4128 00005502 7507                <1> 	jnz	short su2
  4129                              <1> 	;;pop	dx ; * ;; 14/02/2015
  4130                              <1> 	;pop	es ; **
  4131 00005504 6658                <1> 	pop	ax ; ***
  4132                              <1> 	;;pop	bx
  4133 00005506 E9C7000000          <1>         jmp     DISK_RESET
  4134                              <1> su2:
  4135 0000550B 803D[808A0100]00    <1> 	cmp	byte [LBAMode], 0
  4136 00005512 7662                <1> 	jna	short su3
  4137                              <1> 	;
  4138                              <1> 	; 02/02/2015 (LBA read/write function calls)
  4139 00005514 80FC1B              <1> 	cmp	ah, 1Bh
  4140 00005517 720B                <1> 	jb	short lbarw1
  4141 00005519 80FC1C              <1> 	cmp	ah, 1Ch
  4142 0000551C 775D                <1> 	ja 	short invldfnc
  4143                              <1> 	;;pop	dx ; * ; 14/02/2015
  4144                              <1> 	;mov	ax, cx ; Lower word of LBA address (bits 0-15)
  4145 0000551E 89C8                <1> 	mov	eax, ecx ; LBA address (21/02/2015)
  4146                              <1> 	;; 14/02/2015
  4147 00005520 88D1                <1> 	mov	cl, dl ; 14/02/2015
  4148                              <1> 	;;mov	dx, bx
  4149                              <1> 	;mov	dx, si ; higher word of LBA address (bits 16-23)
  4150                              <1> 	;;mov	bx, di
  4151                              <1> 	;mov	si, di ; Buffer offset
  4152 00005522 EB32                <1> 	jmp	short lbarw2
  4153                              <1> lbarw1:
  4154                              <1> 	; convert CHS to LBA
  4155                              <1> 	;
  4156                              <1> 	; LBA calculation - AWARD BIOS - 1999 - AHDSK.ASM
  4157                              <1> 	; LBA = "# of Heads" * Sectors/Track * Cylinder + Head * Sectors/Track
  4158                              <1> 	;	+ Sector - 1
  4159 00005524 6652                <1> 	push	dx ; * ;; 14/02/2015
  4160                              <1> 	;xor	dh, dh
  4161 00005526 31D2                <1> 	xor	edx, edx
  4162                              <1> 	;mov	dl, [ES:BX+14]	; sectors per track (logical)
  4163 00005528 8A530E              <1> 	mov	dl, [ebx+14]
  4164                              <1> 	;xor	ah, ah
  4165 0000552B 31C0                <1> 	xor	eax, eax
  4166                              <1> 	;mov	al, [ES:BX+2]	; heads (logical) 	
  4167 0000552D 8A4302              <1> 	mov	al, [ebx+2]
  4168 00005530 FEC8                <1> 	dec	al
  4169 00005532 6640                <1> 	inc	ax		; 0 =  256
  4170 00005534 66F7E2              <1> 	mul 	dx
  4171                              <1> 		; AX = # of Heads" * Sectors/Track
  4172 00005537 6689CA              <1> 	mov	dx, cx
  4173                              <1> 	;and	cx, 3Fh	 ; sector  (1 to 63)
  4174 0000553A 83E13F              <1> 	and	ecx, 3fh
  4175 0000553D 86D6                <1> 	xchg	dl, dh
  4176 0000553F C0EE06              <1> 	shr	dh, 6
  4177                              <1> 		; DX = cylinder (0 to 1023)
  4178                              <1> 	;mul 	dx
  4179                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder
  4180 00005542 F7E2                <1> 	mul	edx
  4181 00005544 FEC9                <1> 	dec	cl  ; sector - 1
  4182                              <1> 	;add	ax, cx
  4183                              <1> 	;adc	dx, 0
  4184                              <1> 		; DX:AX = # of Heads" * Sectors/Track * Cylinder + Sector -1
  4185 00005546 01C8                <1> 	add	eax, ecx
  4186 00005548 6659                <1> 	pop	cx ; * ; ch = head, cl = drive number (zero based)
  4187                              <1> 	;push	dx
  4188                              <1> 	;push	ax
  4189 0000554A 50                  <1> 	push	eax
  4190                              <1> 	;mov	al, [ES:BX+14]	; sectors per track (logical)	
  4191 0000554B 8A430E              <1> 	mov	al, [ebx+14]
  4192 0000554E F6E5                <1> 	mul	ch
  4193                              <1> 		;  AX = Head * Sectors/Track
  4194 00005550 0FB7C0              <1>         movzx	eax, ax ; 09/12/2017
  4195                              <1> 	;pop	dx
  4196 00005553 5A                  <1> 	pop	edx
  4197                              <1> 	;add	ax, dx
  4198                              <1> 	;pop	dx
  4199                              <1> 	;adc	dx, 0 ; add carry bit
  4200 00005554 01D0                <1> 	add	eax, edx
  4201                              <1> lbarw2:
  4202 00005556 29D2                <1> 	sub	edx, edx ; 21/02/2015
  4203 00005558 88CA                <1> 	mov	dl, cl ; 21/02/2015
  4204 0000555A C645F800            <1>         mov     byte [CMD_BLOCK], 0 ; Features Register
  4205                              <1> 				; NOTE: Features register (1F1h, 171h)
  4206                              <1> 				; is not used for ATA device R/W functions. 
  4207                              <1> 				; It is old/obsolete 'write precompensation'
  4208                              <1> 				; register and error register
  4209                              <1> 				; for old ATA/IDE devices.
  4210                              <1> 	; 18/01/2014
  4211                              <1> 	;mov	ch, [hf_m_s]	; Drive 0 (master) or 1 (slave)
  4212 0000555E 8A0D[F46D0000]      <1> 	mov	cl, [hf_m_s]
  4213                              <1> 	;shl	ch, 4		; bit 4 (drive bit)
  4214                              <1> 	;or	ch, 0E0h	; bit 5 = 1
  4215                              <1> 				; bit 6 = 1 = LBA mode
  4216                              <1> 				; bit 7 = 1
  4217 00005564 80C90E              <1> 	or	cl, 0Eh ; 1110b
  4218                              <1> 	;and	dh, 0Fh		; LBA byte 4 (bits 24 to 27)
  4219 00005567 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh
  4220 0000556C C1E11C              <1> 	shl	ecx, 28 ; 21/02/2015
  4221                              <1> 	;or	dh, ch
  4222 0000556F 09C8                <1> 	or	eax, ecx	
  4223                              <1> 	;;mov	[CMD_BLOCK+2], al ; LBA byte 1 (bits 0 to 7)
  4224                              <1> 				  ; (Sector Number Register)
  4225                              <1> 	;;mov	[CMD_BLOCK+3], ah ; LBA byte 2 (bits 8 to 15)
  4226                              <1> 				  ; (Cylinder Low Register)
  4227                              <1> 	;mov	[CMD_BLOCK+2], ax ; LBA byte 1, 2
  4228                              <1> 	;mov	[CMD_BLOCK+4], dl ; LBA byte 3 (bits 16 to 23)
  4229                              <1> 				  ; (Cylinder High Register)
  4230                              <1> 	;;mov	[CMD_BLOCK+5], dh ; LBA byte 4 (bits 24 to 27)
  4231                              <1> 				  ; (Drive/Head Register)
  4232                              <1> 	
  4233                              <1> 	;mov	[CMD_BLOCK+4], dx ; LBA byte 4, LBA & DEV select bits
  4234 00005571 8945FA              <1> 	mov	[CMD_BLOCK+2], eax ; 21/02/2015
  4235                              <1> 	;14/02/2015
  4236                              <1> 	;mov	dl, cl ; Drive number (INIT_DRV)		
  4237 00005574 EB38                <1> 	jmp	short su4
  4238                              <1> su3:
  4239                              <1> 	; 02/02/2015 
  4240                              <1> 	; (Temporary functions 1Bh & 1Ch are not valid for CHS mode) 
  4241 00005576 80FC14              <1> 	cmp 	ah, 14h
  4242 00005579 7604                <1> 	jna 	short chsfnc
  4243                              <1> invldfnc:
  4244                              <1>         ; 14/02/2015  
  4245                              <1> 	;pop	es ; **
  4246 0000557B 6658                <1>         pop     ax ; ***
  4247                              <1>         ;jmp     short BAD_COMMAND_POP
  4248 0000557D EB49                <1>         jmp     short BAD_COMMAND
  4249                              <1> chsfnc:	
  4250                              <1> 	;MOV	AX,[ES:BX+5]		; GET WRITE PRE-COMPENSATION CYLINDER
  4251 0000557F 668B4305            <1> 	mov	ax, [ebx+5]
  4252 00005583 66C1E802            <1> 	SHR	AX,2
  4253 00005587 8845F8              <1> 	MOV	[CMD_BLOCK],AL
  4254                              <1> 	;;MOV	AL,[ES:BX+8]		; GET CONTROL BYTE MODIFIER
  4255                              <1> 	;;PUSH	DX
  4256                              <1> 	;;MOV	DX,[HF_REG_PORT]
  4257                              <1> 	;;OUT	DX,AL			; SET EXTRA HEAD OPTION
  4258                              <1> 	;;POP	DX ; * 
  4259                              <1> 	;;POP	ES ; **
  4260                              <1> 	;;MOV	AH,[CONTROL_BYTE]	; SET EXTRA HEAD OPTION IN
  4261                              <1> 	;;AND	AH,0C0H 		; CONTROL BYTE	
  4262                              <1> 	;;OR	AH,AL
  4263                              <1> 	;;MOV	[CONTROL_BYTE],AH
  4264                              <1> 	;
  4265 0000558A 88C8                <1> 	MOV	AL,CL			; GET SECTOR NUMBER
  4266 0000558C 243F                <1> 	AND	AL,3FH
  4267 0000558E 8845FA              <1> 	MOV	[CMD_BLOCK+2],AL
  4268 00005591 886DFB              <1> 	MOV	[CMD_BLOCK+3],CH 	; GET CYLINDER NUMBER
  4269 00005594 88C8                <1> 	MOV	AL,CL
  4270 00005596 C0E806              <1> 	SHR	AL,6
  4271 00005599 8845FC              <1> 	MOV	[CMD_BLOCK+4],AL 	; CYLINDER HIGH ORDER 2 BITS
  4272                              <1> 	;;05/01/2015
  4273                              <1> 	;;MOV	AL,DL			; DRIVE NUMBER
  4274 0000559C A0[F46D0000]        <1> 	mov	al, [hf_m_s]
  4275 000055A1 C0E004              <1> 	SHL	AL,4
  4276 000055A4 80E60F              <1> 	AND	DH,0FH			; HEAD NUMBER
  4277 000055A7 08F0                <1> 	OR	AL,DH
  4278                              <1> 	;OR	AL,80H or 20H
  4279 000055A9 0CA0                <1> 	OR	AL,80h+20h		; ECC AND 512 BYTE SECTORS
  4280 000055AB 8845FD              <1> 	MOV	[CMD_BLOCK+5],AL 	; ECC/SIZE/DRIVE/HEAD
  4281                              <1> su4:
  4282                              <1> 	;POP	ES ; **
  4283                              <1>         ;; 14/02/2015
  4284                              <1>         ;;POP   AX
  4285                              <1>         ;;MOV   [CMD_BLOCK+1],AL        ; SECTOR COUNT
  4286                              <1>         ;;PUSH  AX
  4287                              <1>         ;;MOV   AL,AH                   ; GET INTO LOW BYTE
  4288                              <1>         ;;XOR   AH,AH                   ; ZERO HIGH BYTE
  4289                              <1>         ;;SAL   AX,1                    ; *2 FOR TABLE LOOKUP
  4290 000055AE 6658                <1>         pop     ax ; ***
  4291 000055B0 8845F9              <1>         mov     [CMD_BLOCK+1], al
  4292 000055B3 29DB                <1>         sub	ebx, ebx
  4293 000055B5 88E3                <1> 	mov     bl, ah
  4294                              <1>         ;xor     bh, bh
  4295                              <1>         ;sal     bx, 1
  4296 000055B7 66C1E302            <1>         sal	bx, 2	; 32 bit offset (21/02/2015)
  4297                              <1> 	;;MOV   SI,AX                   ; PUT INTO SI FOR BRANCH
  4298                              <1>         ;;CMP   AX,D1L                  ; TEST WITHIN RANGE
  4299                              <1>         ;;JNB   short BAD_COMMAND_POP
  4300                              <1>         ;cmp     bx, D1L
  4301 000055BB 83FB74              <1> 	cmp	ebx, D1L
  4302 000055BE 7308                <1> 	jnb	short BAD_COMMAND
  4303                              <1>         ;xchg    bx, si
  4304 000055C0 87DE                <1>         xchg	ebx, esi
  4305                              <1> 	;;;POP	AX			; RESTORE AX
  4306                              <1> 	;;;POP	BX			; AND DATA ADDRESS
  4307                              <1> 	
  4308                              <1> 	;;PUSH	CX
  4309                              <1> 	;;PUSH	AX			; ADJUST ES:BX
  4310                              <1> 	;MOV	CX,BX			; GET 3 HIGH ORDER NIBBLES OF BX
  4311                              <1> 	;SHR	CX,4
  4312                              <1> 	;MOV	AX,ES
  4313                              <1> 	;ADD	AX,CX
  4314                              <1> 	;MOV	ES,AX
  4315                              <1> 	;AND	BX,000FH		; ES:BX CHANGED TO ES:000X
  4316                              <1> 	;;POP	AX
  4317                              <1> 	;;POP	CX
  4318                              <1> 	;;JMP	word [CS:SI+D1]
  4319                              <1> 	;jmp	word [SI+D1]
  4320 000055C2 FFA6[0F540000]      <1> 	jmp	dword [esi+D1]
  4321                              <1> ;;BAD_COMMAND_POP:
  4322                              <1> ;;	POP	AX
  4323                              <1> ;;	POP	BX
  4324                              <1> BAD_COMMAND:
  4325 000055C8 C605[6B8A0100]01    <1>         MOV     byte [DISK_STATUS1],BAD_CMD  ; COMMAND ERROR
  4326 000055CF B000                <1> 	MOV	AL,0
  4327 000055D1 C3                  <1> 	RETn
  4328                              <1> 
  4329                              <1> ;----------------------------------------
  4330                              <1> ;	RESET THE DISK SYSTEM  (AH=00H) :
  4331                              <1> ;----------------------------------------
  4332                              <1> 
  4333                              <1> ; 18-1-2015 : one controller reset (not other one)
  4334                              <1> 
  4335                              <1> DISK_RESET:
  4336 000055D2 FA                  <1> 	CLI
  4337 000055D3 E4A1                <1> 	IN	AL,INTB01		; GET THE MASK REGISTER
  4338                              <1> 	;JMP	$+2
  4339                              <1> 	IODELAY
  4339 000055D5 EB00                <2>  jmp short $+2
  4339 000055D7 EB00                <2>  jmp short $+2
  4340                              <1> 	;AND	AL,0BFH 		; ENABLE FIXED DISK INTERRUPT
  4341 000055D9 243F                <1> 	and	al,3Fh			; 22/12/2014 (IRQ 14 & IRQ 15)
  4342 000055DB E6A1                <1> 	OUT	INTB01,AL
  4343 000055DD FB                  <1> 	STI				; START INTERRUPTS
  4344                              <1> 	; 14/02/2015
  4345 000055DE 6689D7              <1> 	mov	di, dx	
  4346                              <1> 	; 04/01/2015
  4347                              <1> 	;xor	di,di
  4348                              <1> drst0:
  4349 000055E1 B004                <1> 	MOV	AL,04H  ; bit 2 - SRST 
  4350                              <1> 	;MOV	DX,HF_REG_PORT
  4351 000055E3 668B15[F26D0000]    <1> 	MOV	DX,[HF_REG_PORT]
  4352 000055EA EE                  <1> 	OUT	DX,AL			; RESET
  4353                              <1> ;	MOV	CX,10			; DELAY COUNT
  4354                              <1> ;DRD:	DEC	CX
  4355                              <1> ;	JNZ	short DRD		; WAIT 4.8 MICRO-SEC
  4356                              <1> 	;mov	cx,2			; wait for 30 micro seconds	
  4357 000055EB B902000000          <1>         mov	ecx, 2 ; 21/02/2015
  4358 000055F0 E851CEFFFF          <1> 	call    WAITF                   ; (Award Bios 1999 - WAIT_REFRESH,
  4359                              <1>                                         ; 40 micro seconds)
  4360 000055F5 A0[6D8A0100]        <1> 	mov	al,[CONTROL_BYTE]
  4361 000055FA 240F                <1> 	AND	AL,0FH			; SET HEAD OPTION
  4362 000055FC EE                  <1> 	OUT	DX,AL			; TURN RESET OFF
  4363 000055FD E86A040000          <1> 	CALL	NOT_BUSY
  4364 00005602 7515                <1> 	JNZ	short DRERR		; TIME OUT ON RESET
  4365 00005604 668B15[F06D0000]    <1> 	MOV	DX,[HF_PORT]
  4366 0000560B FEC2                <1> 	inc	dl  ; HF_PORT+1
  4367                              <1> 	; 02/01/2015 - Award BIOS 1999 - AHDSK.ASM
  4368                              <1>         ;mov     cl, 10
  4369 0000560D B90A000000          <1>         mov     ecx, 10 ; 21/02/2015 
  4370                              <1> drst1:
  4371 00005612 EC                  <1> 	IN	AL,DX			; GET RESET STATUS
  4372 00005613 3C01                <1> 	CMP	AL,1
  4373                              <1> 	; 04/01/2015
  4374 00005615 740A                <1> 	jz	short drst2
  4375                              <1> 	;JNZ	short DRERR		; BAD RESET STATUS
  4376                              <1>         	; Drive/Head Register - bit 4
  4377 00005617 E2F9                <1> 	loop	drst1
  4378                              <1> DRERR:	
  4379 00005619 C605[6B8A0100]05    <1> 	MOV	byte [DISK_STATUS1],BAD_RESET ; CARD FAILED
  4380 00005620 C3                  <1> 	RETn
  4381                              <1> drst2:
  4382                              <1> 	; 14/02/2015
  4383 00005621 6689FA              <1> 	mov	dx,di
  4384                              <1> ;drst3:
  4385                              <1> ;	; 05/01/2015
  4386                              <1> ;	shl 	di,1
  4387                              <1> ;	; 04/01/2015
  4388                              <1> ;	mov	ax,[di+hd_cports]
  4389                              <1> ;	cmp	ax,[HF_REG_PORT]
  4390                              <1> ;	je	short drst4
  4391                              <1> ;	mov	[HF_REG_PORT], ax
  4392                              <1> ;	; 03/01/2015
  4393                              <1> ;	mov	ax,[di+hd_ports]
  4394                              <1> ;       mov     [HF_PORT], ax
  4395                              <1> ;	; 05/01/2014
  4396                              <1> ;	shr	di,1
  4397                              <1> ;	; 04/01/2015
  4398                              <1> ;	jmp	short drst0	; reset other controller
  4399                              <1> ;drst4:
  4400                              <1> ;	; 05/01/2015
  4401                              <1> ;	shr	di,1
  4402                              <1> ;	mov	al,[di+hd_dregs]
  4403                              <1> ;	and	al,10h ; bit 4 only
  4404                              <1> ;	shr	al,4 ; bit 4  -> bit 0
  4405                              <1> ;	mov	[hf_m_s], al ; (0 = master, 1 = slave)
  4406                              <1> 	;
  4407 00005624 A0[F46D0000]        <1> 	mov	al, [hf_m_s] ; 18/01/2015
  4408 00005629 A801                <1> 	test	al,1
  4409                              <1> ;	jnz	short drst6
  4410 0000562B 7516                <1>         jnz     short drst4
  4411 0000562D 8065FDEF            <1> 	AND     byte [CMD_BLOCK+5],0EFH ; SET TO DRIVE 0
  4412                              <1> ;drst5:
  4413                              <1> drst3:
  4414 00005631 E867010000          <1> 	CALL	INIT_DRV		; SET MAX HEADS
  4415                              <1> 	;mov	dx,di
  4416 00005636 E81F020000          <1> 	CALL	HDISK_RECAL		; RECAL TO RESET SEEK SPEED
  4417                              <1> 	; 04/01/2014
  4418                              <1> ;	inc	di
  4419                              <1> ;	mov	dx,di
  4420                              <1> ;	cmp	dl,[HF_NUM]
  4421                              <1> ;	jb	short drst3
  4422                              <1> ;DRE:
  4423 0000563B C605[6B8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; IGNORE ANY SET UP ERRORS
  4424 00005642 C3                  <1> 	RETn
  4425                              <1> ;drst6:
  4426                              <1> drst4:		; Drive/Head Register - bit 4
  4427 00005643 804DFD10            <1> 	OR      byte [CMD_BLOCK+5],010H ; SET TO DRIVE 1     
  4428                              <1>         ;jmp    short drst5
  4429 00005647 EBE8                <1>         jmp     short drst3
  4430                              <1> 
  4431                              <1> ;----------------------------------------
  4432                              <1> ;	DISK STATUS ROUTINE  (AH = 01H) :
  4433                              <1> ;----------------------------------------
  4434                              <1> 
  4435                              <1> RETURN_STATUS:
  4436 00005649 A0[6B8A0100]        <1> 	MOV	AL,[DISK_STATUS1]	; OBTAIN PREVIOUS STATUS
  4437 0000564E C605[6B8A0100]00    <1>         MOV     byte [DISK_STATUS1],0   ; RESET STATUS
  4438 00005655 C3                  <1> 	RETn
  4439                              <1> 
  4440                              <1> ;----------------------------------------
  4441                              <1> ;	DISK READ ROUTINE    (AH = 02H) :
  4442                              <1> ;----------------------------------------
  4443                              <1> 
  4444                              <1> DISK_READ:
  4445 00005656 C645FE20            <1> 	MOV	byte [CMD_BLOCK+6],READ_CMD
  4446 0000565A E986020000          <1>         JMP     COMMANDI
  4447                              <1> 
  4448                              <1> ;----------------------------------------
  4449                              <1> ;	DISK WRITE ROUTINE   (AH = 03H) :
  4450                              <1> ;----------------------------------------
  4451                              <1> 
  4452                              <1> DISK_WRITE:
  4453 0000565F C645FE30            <1> 	MOV	byte [CMD_BLOCK+6],WRITE_CMD
  4454 00005663 E9D8020000          <1>         JMP     COMMANDO
  4455                              <1> 
  4456                              <1> ;----------------------------------------
  4457                              <1> ;	DISK VERIFY	     (AH = 04H) :
  4458                              <1> ;----------------------------------------
  4459                              <1> 
  4460                              <1> DISK_VERF:
  4461 00005668 C645FE40            <1> 	MOV	byte [CMD_BLOCK+6],VERIFY_CMD
  4462 0000566C E846030000          <1> 	CALL	COMMAND
  4463 00005671 750C                <1> 	JNZ	short VERF_EXIT		; CONTROLLER STILL BUSY
  4464 00005673 E8B8030000          <1> 	CALL	_WAIT			; (Original: CALL WAIT)	
  4465 00005678 7505                <1> 	JNZ	short VERF_EXIT		; TIME OUT
  4466 0000567A E845040000          <1> 	CALL	CHECK_STATUS
  4467                              <1> VERF_EXIT:
  4468 0000567F C3                  <1> 	RETn
  4469                              <1> 
  4470                              <1> ;----------------------------------------
  4471                              <1> ;	FORMATTING	     (AH = 05H) :
  4472                              <1> ;----------------------------------------
  4473                              <1> 
  4474                              <1> FMT_TRK:				; FORMAT TRACK	(AH = 005H)
  4475 00005680 C645FE50            <1> 	MOV	byte [CMD_BLOCK+6],FMTTRK_CMD
  4476                              <1> 	;PUSH	ES
  4477                              <1> 	;PUSH	BX
  4478 00005684 53                  <1> 	push	ebx
  4479 00005685 E8EC040000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS ADDRESS
  4480                              <1> 	;MOV	AL,[ES:BX+14]		; GET SECTORS/TRACK
  4481 0000568A 8A430E              <1> 	mov	al, [ebx+14]
  4482 0000568D 8845F9              <1> 	MOV	[CMD_BLOCK+1],AL 	; SET SECTOR COUNT IN COMMAND
  4483 00005690 5B                  <1> 	pop	ebx
  4484                              <1> 	;POP	BX
  4485                              <1> 	;POP	ES
  4486 00005691 E9B1020000          <1>         JMP     CMD_OF                  ; GO EXECUTE THE COMMAND
  4487                              <1> 
  4488                              <1> ; 30/08/2020
  4489                              <1> 
  4490                              <1> ;----------------------------------------
  4491                              <1> ;	READ DASD TYPE	     (AH = 15H) :
  4492                              <1> ;----------------------------------------
  4493                              <1> 
  4494                              <1> READ_DASD_TYPE:
  4495                              <1> READ_D_T:				; GET DRIVE PARAMETERS
  4496 00005696 1E                  <1> 	PUSH	DS			; SAVE REGISTERS
  4497                              <1> 	;PUSH	ES
  4498 00005697 53                  <1> 	PUSH	eBX
  4499                              <1> 	;CALL	DDS			; ESTABLISH ADDRESSING
  4500                              <1> 	;push	cs
  4501                              <1> 	;pop	ds
  4502 00005698 66BB1000            <1>         mov	bx, KDATA
  4503 0000569C 8EDB                <1> 	mov	ds, bx
  4504                              <1> 	;mov	es, bx
  4505 0000569E C605[6B8A0100]00    <1> 	MOV     byte [DISK_STATUS1],0
  4506 000056A5 8A1D[6C8A0100]      <1> 	MOV	BL,[HF_NUM]		; GET NUMBER OF DRIVES
  4507 000056AB 80E27F              <1> 	AND	DL,7FH			; GET DRIVE NUMBER
  4508 000056AE 38D3                <1> 	CMP	BL,DL
  4509 000056B0 763C                <1> 	JBE	short RDT_NOT_PRESENT 	; RETURN DRIVE NOT PRESENT
  4510 000056B2 0FB6C2              <1> 	movzx	eax, dl ; 28/08/2020
  4511 000056B5 E8BC040000          <1> 	CALL	GET_VEC 		; GET DISK PARAMETERS ADDRESS
  4512                              <1> 	
  4513                              <1> 	; 28/08/2020 - TRDOS 386 v2
  4514 000056BA F6431440            <1> 	test	byte [ebx+20], 40h	; LBA bit (bit 6)
  4515 000056BE 751D                <1> 	jnz	short RDT3 ; LBA disk (may be > 8GB)
  4516                              <1> 
  4517                              <1> 	;MOV	AL,[ES:BX+2]		; HEADS
  4518 000056C0 8A4302              <1> 	mov	al, [ebx+2]
  4519                              <1> 	;MOV	CL,[ES:BX+14]
  4520 000056C3 8A4B0E              <1> 	mov	cl, [ebx+14]
  4521 000056C6 F6E9                <1> 	IMUL	CL			; * NUMBER OF SECTORS
  4522                              <1> 	;MOV	CX,[ES:BX]		; MAX NUMBER OF CYLINDERS
  4523 000056C8 668B0B              <1> 	mov	cx, [ebx]
  4524                              <1> 	;
  4525                              <1> 	; 02/01/2015 
  4526                              <1> 	; ** leave the last cylinder as reserved for diagnostics **
  4527                              <1> 	; (Also in Award BIOS - 1999, AHDSK.ASM, FUN15 -> sub ax, 1)
  4528 000056CB 6649                <1> 	DEC	CX			; LEAVE ONE FOR DIAGNOSTICS
  4529                              <1> 	;
  4530 000056CD 66F7E9              <1> 	IMUL	CX			; NUMBER OF SECTORS
  4531 000056D0 6689D1              <1> 	MOV	CX,DX			; HIGH ORDER HALF
  4532 000056D3 6689C2              <1> 	MOV	DX,AX			; LOW ORDER HALF
  4533                              <1> 	;SUB	AX,AX
  4534                              <1> 	; 28/08/2020
  4535                              <1> 	;sub	al, al
  4536                              <1> RDT4:
  4537 000056D6 29C0                <1> 	sub	eax, eax ; 28/08/2020
  4538                              <1> 	;
  4539 000056D8 B403                <1> 	MOV	AH,03H			; INDICATE FIXED DISK
  4540                              <1> 	; 30/08/2020 (clc is not needed here)
  4541                              <1> 	;and	byte [esp+8], 0FEh ; clear carry bit of eflags register
  4542                              <1> RDT2:	
  4543 000056DA 5B                  <1> 	POP	eBX			; RESTORE REGISTERS
  4544                              <1> 	;POP	ES
  4545 000056DB 1F                  <1> 	POP	DS
  4546                              <1> 	; (*) CLC			; CLEAR CARRY
  4547                              <1> 	;RETf	2
  4548                              <1> 	; (*) 29/05/2016
  4549                              <1> 	; (*) retf 4
  4550                              <1> 	; 30/08/2020 (clc is not needed here)
  4551                              <1> 	;and	byte [esp+8], 0FEh ; clear carry bit of eflags register
  4552 000056DC CF                  <1> 	iretd
  4553                              <1> 
  4554                              <1> RDT3:	; 28/08/2020
  4555                              <1> 	; (use the result of INT 13h, function 48h as disk size)
  4556                              <1> 	; eax = al = zero based hard disk number
  4557                              <1> 	; 29/08/2020
  4558                              <1> 	;add	al, 2 ; hd0 = physical disk drive 2
  4559 000056DD C0E002              <1> 	shl	al, 2 ; * 4
  4560                              <1> RDT5:
  4561                              <1> 	;add	eax, drv.size
  4562 000056E0 05[366E0000]        <1> 	add	eax, drv.size+8 ; 29/08/2020
  4563 000056E5 668B10              <1> 	mov	dx, [eax]   ; low word of disk size
  4564 000056E8 668B4802            <1> 	mov	cx, [eax+2] ; high word of disk size
  4565                              <1> 	;sub	eax, eax
  4566 000056EC EBE8                <1> 	jmp	short RDT4		
  4567                              <1> 
  4568                              <1> RDT_NOT_PRESENT:
  4569                              <1> 	; 30/08/2020
  4570 000056EE C605[6B8A0100]AA    <1> 	mov	byte [DISK_STATUS1], NOT_RDY ; DRIVE NOT READY
  4571                              <1> 
  4572                              <1> 	;SUB	AX,AX			; DRIVE NOT PRESENT RETURN
  4573 000056F5 29C0                <1> 	sub	eax, eax ; 30/08/2020
  4574 000056F7 6689C1              <1> 	MOV	CX,AX			; ZERO BLOCK COUNT
  4575 000056FA 6689C2              <1> 	MOV	DX,AX
  4576                              <1> 	; 30/08/2020
  4577 000056FD 804C241001          <1> 	or	byte [esp+16], 1 ; set carry bit of eflags register
  4578                              <1> 		; cf = 1 -> ah = 0, drive not ready, disk type = 0
  4579 00005702 EBD6                <1> 	JMP	short RDT2
  4580                              <1> 
  4581                              <1> ; 28/05/2016
  4582                              <1> ; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  4583                              <1> 
  4584                              <1> ;----------------------------------------
  4585                              <1> ;	GET PARAMETERS	     (AH = 08H) :
  4586                              <1> ;----------------------------------------
  4587                              <1> 
  4588                              <1> GET_PARM_N:
  4589                              <1> 	; ebx = user's buffer address for parameters table
  4590                              <1> ;GET_PARM:				; GET DRIVE PARAMETERS
  4591 00005704 1E                  <1> 	PUSH	DS			; SAVE REGISTERS
  4592 00005705 06                  <1> 	PUSH	ES
  4593 00005706 53                  <1> 	PUSH	eBX
  4594                              <1> 	;MOV	AX,ABS0 		; ESTABLISH ADDRESSING
  4595                              <1> 	;MOV	DS,AX
  4596                              <1> 	;TEST	DL,1			; CHECK FOR DRIVE 1
  4597                              <1> 	;JZ	short G0
  4598                              <1> 	;LES	BX,@HF1_TBL_VEC
  4599                              <1> 	;JMP	SHORT G1
  4600                              <1> ;G0:	LES	BX,@HF_TBL_VEC
  4601                              <1> ;G1:
  4602                              <1> 	;CALL	DDS			; ESTABLISH SEGMENT
  4603                              <1> 	; 22/12/2014
  4604                              <1> 	;push	cs
  4605                              <1> 	;pop	ds
  4606 00005707 66BB1000            <1> 	mov	bx, KDATA
  4607 0000570B 8EDB                <1> 	mov	ds, bx
  4608 0000570D 8EC3                <1> 	mov	es, bx	; 27/05/2016
  4609                              <1> 	;
  4610 0000570F 80EA80              <1> 	SUB	DL,80H
  4611                              <1> 	;CMP	DL,MAX_FILE		; TEST WITHIN RANGE
  4612                              <1> 	;JAE	short G4 ; 29/08/2020 - BugFix
  4613                              <1> 	; 30/08/2020
  4614 00005712 3A15[6C8A0100]      <1> 	cmp	dl, [HF_NUM] ; is hard disk index < hard disk count ?	
  4615 00005718 736A                <1> 	jae	short G4     ; no, error ! drive not ready !	
  4616                              <1> 	;
  4617 0000571A 31DB                <1> 	xor	ebx, ebx ; 21/02/2015
  4618                              <1> 	; 22/12/2014
  4619 0000571C 88D3                <1> 	mov	bl, dl
  4620                              <1> 	;xor	bh, bh  
  4621 0000571E C0E302              <1> 	shl	bl, 2			; convert index to offset
  4622                              <1> 	;add	bx, HF_TBL_VEC
  4623 00005721 81C3[708A0100]      <1> 	add	ebx, HF_TBL_VEC
  4624                              <1> 	;mov	ax, [bx+2]
  4625                              <1> 	;mov	es, ax			; dpt segment
  4626                              <1> 	;mov	bx, [bx]		; dpt offset
  4627 00005727 8B1B                <1> 	mov	ebx, [ebx] ; 32 bit offset	
  4628                              <1> 
  4629 00005729 C605[6B8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0
  4630                              <1>         ;MOV	AX,[ES:BX]		; MAX NUMBER OF CYLINDERS
  4631 00005730 668B03              <1> 	mov	ax, [ebx]
  4632                              <1> 	;;SUB	AX,2			; ADJUST FOR 0-N
  4633 00005733 6648                <1> 	dec	ax			; max. cylinder number
  4634 00005735 88C5                <1> 	MOV	CH,AL
  4635 00005737 66250003            <1> 	AND	AX,0300H		; HIGH TWO BITS OF CYLINDER
  4636 0000573B 66D1E8              <1> 	SHR	AX,1
  4637 0000573E 66D1E8              <1> 	SHR	AX,1
  4638                              <1> 	;OR	AL,[ES:BX+14]		; SECTORS
  4639 00005741 0A430E              <1> 	or	al, [ebx+14]
  4640 00005744 88C1                <1> 	MOV	CL,AL
  4641                              <1> 	;MOV	DH,[ES:BX+2]		; HEADS
  4642 00005746 8A7302              <1> 	mov	dh, [ebx+2]
  4643 00005749 FECE                <1> 	DEC	DH			; 0-N RANGE
  4644 0000574B 8A15[6C8A0100]      <1> 	MOV	DL,[HF_NUM]		; DRIVE COUNT
  4645 00005751 6629C0              <1> 	SUB	AX,AX
  4646                              <1>         ;27/12/2014 
  4647                              <1> 	;mov	di, bx			; HDPT offset
  4648                              <1> 
  4649                              <1> 	; 29/08/2020
  4650 00005754 833C2400            <1> 	cmp	dword [esp], 0
  4651 00005758 7703                <1> 	ja	short G7 ; ebx > 0
  4652                              <1> 
  4653                              <1> 	; if EBX (user's buffer address) = 0, do not copy DPT
  4654 0000575A 5B                  <1> 	pop	ebx
  4655 0000575B EB24                <1> 	jmp	short G5
  4656                              <1> G7:
  4657                              <1> 	; 27/05/2016
  4658                              <1> 	; return fixed disk parameters table to user
  4659                              <1> 	; in user's buffer, which is pointed by EBX
  4660                              <1> 	;
  4661 0000575D 873C24              <1> 	xchg	edi, [esp]		; ebx (input)-> edi, edi -> [esp]
  4662 00005760 56                  <1> 	push	esi
  4663 00005761 89DE                <1> 	mov	esi, ebx		; hard disk parameter table (32 bytes)	
  4664 00005763 89FB                <1> 	mov	ebx, edi		; ebx = user's buffer address
  4665 00005765 51                  <1> 	push	ecx
  4666 00005766 50                  <1> 	push	eax
  4667 00005767 B920000000          <1> 	mov	ecx, 32 ; 32 bytes
  4668 0000576C E893C30000          <1> 	call	transfer_to_user_buffer ; trdosk6.s (16/05/2016)
  4669 00005771 58                  <1> 	pop	eax
  4670 00005772 59                  <1> 	pop	ecx
  4671 00005773 5E                  <1> 	pop	esi
  4672 00005774 5F                  <1> 	pop	edi
  4673 00005775 730A                <1> 	jnc	short G5
  4674                              <1> 	; 29/05/2016 (*)
  4675 00005777 B8FF000000          <1> 	mov	eax, 0FFh ; unknown error !
  4676                              <1> G6:
  4677 0000577C 804C241001          <1> 	or	byte [esp+16], 1 ; set carry bit of eflags register
  4678                              <1> G5:
  4679                              <1> 	; 27/05/2016
  4680                              <1> 	;POP	eBX			; RESTORE REGISTERS
  4681 00005781 07                  <1> 	POP	ES
  4682 00005782 1F                  <1> 	POP	DS
  4683                              <1> 	;RETf	2
  4684                              <1> 	; (*) 29/05/2016
  4685                              <1> 	; (*) retf 4
  4686                              <1> 	; (*) or byte [esp+8], 1 ; set carry bit of eflags register
  4687 00005783 CF                  <1> 	iretd
  4688                              <1> G4:
  4689 00005784 C605[6B8A0100]07    <1> 	MOV     byte [DISK_STATUS1],INIT_FAIL ; OPERATION FAILED
  4690                              <1> 	;mov	ah, NOT_DRY ; 30/08/2020 - 'drive not ready' error code
  4691 0000578B B407                <1> 	MOV	AH,INIT_FAIL
  4692 0000578D 28C0                <1> 	SUB	AL,AL
  4693                              <1> 	;SUB	DX,DX
  4694                              <1> 	; 30/08/2020
  4695 0000578F 8A15[6C8A0100]      <1> 	mov	dl, [HF_NUM] ; disk count
  4696 00005795 28F6                <1> 	sub	dh, dh
  4697 00005797 6629C9              <1> 	SUB	CX,CX
  4698                              <1> 	; 29/05/2016 (*)
  4699                              <1> 	;STC				; SET ERROR FLAG
  4700                              <1> 	;JMP	short G5
  4701                              <1> 	; 29/08/2020 - BugFix
  4702 0000579A 5B                  <1> 	pop	ebx
  4703 0000579B EBDF                <1> 	jmp	short G6
  4704                              <1> 
  4705                              <1> ;----------------------------------------
  4706                              <1> ;	INITIALIZE DRIVE     (AH = 09H) :
  4707                              <1> ;----------------------------------------
  4708                              <1> 	; 03/01/2015
  4709                              <1> 	; According to ATA-ATAPI specification v2.0 to v5.0
  4710                              <1> 	; logical sector per logical track
  4711                              <1> 	; and logical heads - 1 would be set but
  4712                              <1> 	; it is seen as it will be good
  4713                              <1> 	; if physical parameters will be set here
  4714                              <1> 	; because, number of heads <= 16.
  4715                              <1> 	; (logical heads usually more than 16)
  4716                              <1> 	; NOTE: ATA logical parameters (software C, H, S)
  4717                              <1> 	;	== INT 13h physical parameters
  4718                              <1> 
  4719                              <1> ;INIT_DRV:
  4720                              <1> ;	MOV	byte [CMD_BLOCK+6],SET_PARM_CMD
  4721                              <1> ;	CALL	GET_VEC 		; ES:BX -> PARAMETER BLOCK
  4722                              <1> ;	MOV	AL,[ES:BX+2]		; GET NUMBER OF HEADS
  4723                              <1> ;	DEC	AL			; CONVERT TO 0-INDEX
  4724                              <1> ;	MOV	AH,[CMD_BLOCK+5] 	; GET SDH REGISTER
  4725                              <1> ;	AND	AH,0F0H 		; CHANGE HEAD NUMBER
  4726                              <1> ;	OR	AH,AL			; TO MAX HEAD
  4727                              <1> ;	MOV	[CMD_BLOCK+5],AH
  4728                              <1> ;	MOV	AL,[ES:BX+14]		; MAX SECTOR NUMBER
  4729                              <1> ;	MOV	[CMD_BLOCK+1],AL
  4730                              <1> ;	SUB	AX,AX
  4731                              <1> ;	MOV	[CMD_BLOCK+3],AL 	; ZERO FLAGS
  4732                              <1> ;	CALL	COMMAND 		; TELL CONTROLLER
  4733                              <1> ;	JNZ	short INIT_EXIT		; CONTROLLER BUSY ERROR
  4734                              <1> ;	CALL	NOT_BUSY		; WAIT FOR IT TO BE DONE
  4735                              <1> ;	JNZ	short INIT_EXIT		; TIME OUT
  4736                              <1> ;	CALL	CHECK_STATUS
  4737                              <1> ;INIT_EXIT:
  4738                              <1> ;	RETn
  4739                              <1> 
  4740                              <1> ; 04/01/2015
  4741                              <1> ; 02/01/2015 - Derived from from AWARD BIOS 1999
  4742                              <1> ;				 AHDSK.ASM - INIT_DRIVE
  4743                              <1> INIT_DRV:
  4744                              <1> 	;xor	ah,ah
  4745 0000579D 31C0                <1> 	xor	eax, eax ; 21/02/2015
  4746 0000579F B00B                <1> 	mov	al,11 ; Physical heads from translated HDPT
  4747 000057A1 3825[808A0100]      <1>         cmp     [LBAMode], ah   ; 0
  4748 000057A7 7702                <1> 	ja	short idrv0
  4749 000057A9 B002                <1> 	mov	al,2  ; Physical heads from standard HDPT
  4750                              <1> idrv0:
  4751                              <1> 	; DL = drive number (0 based)
  4752 000057AB E8C6030000          <1> 	call	GET_VEC
  4753                              <1> 	;push	bx
  4754 000057B0 53                  <1> 	push	ebx ; 21/02/2015
  4755                              <1> 	;add	bx,ax
  4756 000057B1 01C3                <1> 	add	ebx, eax
  4757                              <1> 	;; 05/01/2015
  4758 000057B3 8A25[F46D0000]      <1> 	mov	ah, [hf_m_s] ; drive number (0= master, 1= slave)
  4759                              <1> 	;;and 	ah,1 
  4760 000057B9 C0E404              <1> 	shl	ah,4
  4761 000057BC 80CCA0              <1> 	or	ah,0A0h  ; Drive/Head register - 10100000b (A0h)	
  4762                              <1> 	;mov	al,[es:bx]
  4763 000057BF 8A03                <1> 	mov	al, [ebx] ; 21/02/2015
  4764 000057C1 FEC8                <1> 	dec	al	 ; last head number 
  4765                              <1> 	;and	al,0Fh
  4766 000057C3 08E0                <1> 	or	al,ah	 ; lower 4 bits for head number
  4767                              <1> 	;
  4768 000057C5 C645FE91            <1> 	mov	byte [CMD_BLOCK+6],SET_PARM_CMD
  4769 000057C9 8845FD              <1> 	mov	[CMD_BLOCK+5],al
  4770                              <1> 	;pop	bx
  4771 000057CC 5B                  <1> 	pop	ebx
  4772 000057CD 29C0                <1> 	sub	eax, eax ; 21/02/2015
  4773 000057CF B004                <1> 	mov	al,4 ; Physical sec per track from translated HDPT
  4774 000057D1 803D[808A0100]00    <1> 	cmp	byte [LBAMode], 0
  4775 000057D8 7702                <1> 	ja	short idrv1
  4776 000057DA B00E                <1> 	mov	al,14 ; Physical sec per track from standard HDPT
  4777                              <1> idrv1:
  4778                              <1> 	;xor	ah,ah
  4779                              <1> 	;add	bx,ax
  4780 000057DC 01C3                <1> 	add	ebx, eax ; 21/02/2015
  4781                              <1> 	;mov	al,[es:bx]
  4782                              <1> 			; sector number
  4783 000057DE 8A03                <1> 	mov	al, [ebx]
  4784 000057E0 8845F9              <1> 	mov	[CMD_BLOCK+1],al
  4785 000057E3 28C0                <1> 	sub	al,al
  4786 000057E5 8845FB              <1> 	mov	[CMD_BLOCK+3],al  ; ZERO FLAGS
  4787 000057E8 E8CA010000          <1> 	call	COMMAND 	  ; TELL CONTROLLER
  4788 000057ED 750C                <1> 	jnz	short INIT_EXIT	  ; CONTROLLER BUSY ERROR
  4789 000057EF E878020000          <1> 	call	NOT_BUSY	  ; WAIT FOR IT TO BE DONE
  4790 000057F4 7505                <1> 	jnz	short INIT_EXIT	  ; TIME OUT
  4791 000057F6 E8C9020000          <1> 	call	CHECK_STATUS
  4792                              <1> INIT_EXIT:
  4793 000057FB C3                  <1> 	RETn
  4794                              <1> 
  4795                              <1> ;----------------------------------------
  4796                              <1> ;	READ LONG	     (AH = 0AH) :
  4797                              <1> ;----------------------------------------
  4798                              <1> 
  4799                              <1> RD_LONG:
  4800                              <1> 	;MOV	@CMD_BLOCK+6,READ_CMD OR ECC_MODE
  4801 000057FC C645FE22            <1>         mov     byte [CMD_BLOCK+6],READ_CMD + ECC_MODE 
  4802 00005800 E9E0000000          <1>         JMP     COMMANDI
  4803                              <1> 
  4804                              <1> ;----------------------------------------
  4805                              <1> ;	WRITE LONG	     (AH = 0BH) :
  4806                              <1> ;----------------------------------------
  4807                              <1> 
  4808                              <1> WR_LONG:
  4809                              <1> 	;MOV	@CMD_BLOCK+6,WRITE_CMD OR ECC_MODE
  4810 00005805 C645FE32            <1>         MOV     byte [CMD_BLOCK+6],WRITE_CMD + ECC_MODE
  4811 00005809 E932010000          <1>         JMP     COMMANDO
  4812                              <1> 
  4813                              <1> ;----------------------------------------
  4814                              <1> ;	SEEK		     (AH = 0CH) :
  4815                              <1> ;----------------------------------------
  4816                              <1> 
  4817                              <1> DISK_SEEK:
  4818 0000580E C645FE70            <1>         MOV     byte [CMD_BLOCK+6],SEEK_CMD
  4819 00005812 E8A0010000          <1> 	CALL	COMMAND
  4820 00005817 751C                <1> 	JNZ	short DS_EXIT 		; CONTROLLER BUSY ERROR
  4821 00005819 E812020000          <1> 	CALL	_WAIT
  4822 0000581E 7515                <1>         JNZ     DS_EXIT                 ; TIME OUT ON SEEK
  4823 00005820 E89F020000          <1> 	CALL	CHECK_STATUS
  4824 00005825 803D[6B8A0100]40    <1>         CMP     byte [DISK_STATUS1],BAD_SEEK
  4825 0000582C 7507                <1> 	JNE	short DS_EXIT
  4826 0000582E C605[6B8A0100]00    <1>         MOV     byte [DISK_STATUS1],0
  4827                              <1> DS_EXIT:
  4828 00005835 C3                  <1> 	RETn
  4829                              <1> 
  4830                              <1> ;----------------------------------------
  4831                              <1> ;	TEST DISK READY      (AH = 10H) :
  4832                              <1> ;----------------------------------------
  4833                              <1> 
  4834                              <1> TST_RDY:				; WAIT FOR CONTROLLER
  4835 00005836 E831020000          <1> 	CALL	NOT_BUSY
  4836 0000583B 751C                <1> 	JNZ	short TR_EX
  4837 0000583D 8A45FD              <1> 	MOV	AL,[CMD_BLOCK+5] 	; SELECT DRIVE
  4838 00005840 668B15[F06D0000]    <1> 	MOV	DX,[HF_PORT]
  4839 00005847 80C206              <1> 	add	dl,6
  4840 0000584A EE                  <1> 	OUT	DX,AL
  4841 0000584B E88C020000          <1> 	CALL	CHECK_ST		; CHECK STATUS ONLY
  4842 00005850 7507                <1> 	JNZ	short TR_EX
  4843 00005852 C605[6B8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0 	; WIPE OUT DATA CORRECTED ERROR
  4844                              <1> TR_EX:	
  4845 00005859 C3                  <1> 	RETn
  4846                              <1> 
  4847                              <1> ;----------------------------------------
  4848                              <1> ;	RECALIBRATE	     (AH = 11H) :
  4849                              <1> ;----------------------------------------
  4850                              <1> 
  4851                              <1> HDISK_RECAL:
  4852 0000585A C645FE10            <1>         MOV     byte [CMD_BLOCK+6],RECAL_CMD ; 10h, 16
  4853 0000585E E854010000          <1> 	CALL	COMMAND 		; START THE OPERATION
  4854 00005863 7523                <1> 	JNZ	short RECAL_EXIT	; ERROR
  4855 00005865 E8C6010000          <1> 	CALL	_WAIT			; WAIT FOR COMPLETION
  4856 0000586A 7407                <1> 	JZ	short RECAL_X 		; TIME OUT ONE OK ?
  4857 0000586C E8BF010000          <1> 	CALL	_WAIT			; WAIT FOR COMPLETION LONGER
  4858 00005871 7515                <1> 	JNZ	short RECAL_EXIT	; TIME OUT TWO TIMES IS ERROR
  4859                              <1> RECAL_X:
  4860 00005873 E84C020000          <1> 	CALL	CHECK_STATUS
  4861 00005878 803D[6B8A0100]40    <1> 	CMP	byte [DISK_STATUS1],BAD_SEEK ; SEEK NOT COMPLETE
  4862 0000587F 7507                <1> 	JNE	short RECAL_EXIT	; IS OK
  4863 00005881 C605[6B8A0100]00    <1> 	MOV	byte [DISK_STATUS1],0
  4864                              <1> RECAL_EXIT:
  4865 00005888 803D[6B8A0100]00    <1>         CMP     byte [DISK_STATUS1],0
  4866 0000588F C3                  <1> 	RETn
  4867                              <1> 
  4868                              <1> ;----------------------------------------
  4869                              <1> ;      CONTROLLER DIAGNOSTIC (AH = 14H) :
  4870                              <1> ;----------------------------------------
  4871                              <1> 
  4872                              <1> CTLR_DIAGNOSTIC:
  4873 00005890 FA                  <1>         CLI                             ; DISABLE INTERRUPTS WHILE CHANGING MASK
  4874 00005891 E4A1                <1> 	IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  4875                              <1> 	;AND	AL,0BFH
  4876 00005893 243F                <1> 	and	al, 3Fh			; enable IRQ 14 & IRQ 15
  4877                              <1> 	;JMP	$+2
  4878                              <1> 	IODELAY
  4878 00005895 EB00                <2>  jmp short $+2
  4878 00005897 EB00                <2>  jmp short $+2
  4879 00005899 E6A1                <1> 	OUT	INTB01,AL
  4880                              <1> 	IODELAY
  4880 0000589B EB00                <2>  jmp short $+2
  4880 0000589D EB00                <2>  jmp short $+2
  4881 0000589F E421                <1> 	IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  4882 000058A1 24FB                <1> 	AND	AL,0FBH 		;  SECOND CHIP
  4883                              <1> 	;JMP	$+2
  4884                              <1> 	IODELAY
  4884 000058A3 EB00                <2>  jmp short $+2
  4884 000058A5 EB00                <2>  jmp short $+2
  4885 000058A7 E621                <1> 	OUT	INTA01,AL
  4886 000058A9 FB                  <1> 	STI
  4887 000058AA E8BD010000          <1> 	CALL	NOT_BUSY		; WAIT FOR CARD
  4888 000058AF 752B                <1> 	JNZ	short CD_ERR		; BAD CARD
  4889                              <1> 	;MOV	DX, HF_PORT+7
  4890 000058B1 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  4891 000058B8 80C207              <1> 	add	dl, 7
  4892 000058BB B090                <1> 	MOV	AL,DIAG_CMD		; START DIAGNOSE
  4893 000058BD EE                  <1> 	OUT	DX,AL
  4894 000058BE E8A9010000          <1> 	CALL	NOT_BUSY		; WAIT FOR IT TO COMPLETE
  4895 000058C3 B480                <1> 	MOV	AH,TIME_OUT
  4896 000058C5 7517                <1> 	JNZ	short CD_EXIT 		; TIME OUT ON DIAGNOSTIC
  4897                              <1> 	;MOV	DX,HF_PORT+1		; GET ERROR REGISTER
  4898 000058C7 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  4899 000058CE FEC2                <1> 	inc	dl
  4900 000058D0 EC                  <1> 	IN	AL,DX
  4901 000058D1 A2[628A0100]        <1> 	MOV	[HF_ERROR],AL		; SAVE IT
  4902 000058D6 B400                <1> 	MOV	AH,0
  4903 000058D8 3C01                <1> 	CMP	AL,1			; CHECK FOR ALL OK
  4904 000058DA 7402                <1> 	JE	SHORT CD_EXIT
  4905 000058DC B420                <1> CD_ERR: MOV	AH,BAD_CNTLR
  4906                              <1> CD_EXIT:
  4907 000058DE 8825[6B8A0100]      <1> 	MOV	[DISK_STATUS1],AH
  4908 000058E4 C3                  <1> 	RETn
  4909                              <1> 
  4910                              <1> ;----------------------------------------
  4911                              <1> ; COMMANDI				:
  4912                              <1> ;	REPEATEDLY INPUTS DATA TILL	:
  4913                              <1> ;	NSECTOR RETURNS ZERO		:
  4914                              <1> ;----------------------------------------
  4915                              <1> COMMANDI:
  4916 000058E5 E862020000          <1> 	CALL	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  4917 000058EA 7253                <1> 	JC	short CMD_ABORT
  4918                              <1> 	;MOV	DI,BX
  4919 000058EC 89DF                <1> 	mov	edi, ebx ; 21/02/2015
  4920 000058EE E8C4000000          <1> 	CALL	COMMAND 		; OUTPUT COMMAND
  4921 000058F3 754A                <1> 	JNZ	short CMD_ABORT
  4922                              <1> CMD_I1:
  4923 000058F5 E836010000          <1> 	CALL	_WAIT			; WAIT FOR DATA REQUEST INTERRUPT
  4924 000058FA 7543                <1> 	JNZ	short TM_OUT		; TIME OUT
  4925                              <1> cmd_i1x: ; 18/02/2016
  4926                              <1> 	;MOV	CX,256			; SECTOR SIZE IN WORDS
  4927 000058FC B900010000          <1> 	mov	ecx, 256 ; 21/02/2015	
  4928                              <1> 	;MOV	DX,HF_PORT
  4929 00005901 668B15[F06D0000]    <1> 	mov	dx,[HF_PORT]
  4930 00005908 FA                  <1> 	CLI
  4931 00005909 FC                  <1> 	CLD
  4932 0000590A F3666D              <1> 	REP	INSW			; GET THE SECTOR
  4933 0000590D FB                  <1> 	STI
  4934 0000590E F645FE02            <1> 	TEST	byte [CMD_BLOCK+6],ECC_MODE ; CHECK FOR NORMAL INPUT
  4935 00005912 7419                <1> 	JZ	short CMD_I3
  4936 00005914 E880010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  4937 00005919 7224                <1> 	JC	short TM_OUT
  4938                              <1> 	;MOV	DX,HF_PORT
  4939 0000591B 668B15[F06D0000]    <1> 	mov	dx,[HF_PORT]
  4940                              <1> 	;MOV	CX,4			; GET ECC BYTES
  4941 00005922 B904000000          <1> 	mov 	ecx, 4 ; mov cx, 4 
  4942 00005927 EC                  <1> CMD_I2: IN	AL,DX
  4943                              <1> 	;MOV	[ES:DI],AL		; GO SLOW FOR BOARD
  4944 00005928 8807                <1> 	mov 	[edi], al ; 21/02/2015
  4945 0000592A 47                  <1> 	INC	eDI
  4946 0000592B E2FA                <1> 	LOOP	CMD_I2
  4947                              <1> CMD_I3: 
  4948                              <1> 	; wait for 400 ns
  4949 0000592D 80C207              <1> 	add 	dl, 7
  4950 00005930 EC                  <1> 	in	al, dx
  4951 00005931 EC                  <1> 	in	al, dx
  4952 00005932 EC                  <1> 	in	al, dx
  4953                              <1> 	;
  4954 00005933 E88C010000          <1> 	CALL	CHECK_STATUS
  4955 00005938 7505                <1> 	JNZ	short CMD_ABORT		; ERROR RETURNED
  4956 0000593A FE4DF9              <1> 	DEC	byte [CMD_BLOCK+1]	; CHECK FOR MORE
  4957                              <1> 	;JNZ	SHORT CMD_I1
  4958 0000593D 75BD                <1> 	jnz	short cmd_i1x ; 18/02/2016
  4959                              <1> CMD_ABORT:
  4960 0000593F C3                  <1> TM_OUT: RETn
  4961                              <1> 
  4962                              <1> ;----------------------------------------
  4963                              <1> ; COMMANDO				:
  4964                              <1> ;	REPEATEDLY OUTPUTS DATA TILL	:
  4965                              <1> ;	NSECTOR RETURNS ZERO		:
  4966                              <1> ;----------------------------------------
  4967                              <1> COMMANDO:
  4968 00005940 E807020000          <1> 	CALL	CHECK_DMA		; CHECK 64K BOUNDARY ERROR
  4969 00005945 72F8                <1> 	JC	short CMD_ABORT
  4970 00005947 89DE                <1> CMD_OF: MOV	eSI,eBX ; 21/02/2015
  4971 00005949 E869000000          <1> 	CALL	COMMAND 		; OUTPUT COMMAND
  4972 0000594E 75EF                <1> 	JNZ	short CMD_ABORT
  4973 00005950 E844010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  4974 00005955 72E8                <1> 	JC	short TM_OUT			; TOO LONG
  4975                              <1> CMD_O1: ;PUSH	DS
  4976                              <1> 	;PUSH	ES			; MOVE ES TO DS
  4977                              <1> 	;POP	DS
  4978                              <1> 	;MOV	CX,256			; PUT THE DATA OUT TO THE CARD
  4979                              <1> 	;MOV	DX,HF_PORT
  4980                              <1> 	; 01/02/2015
  4981 00005957 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  4982                              <1> 	;push	es
  4983                              <1> 	;pop	ds
  4984                              <1> 	;mov	cx, 256
  4985 0000595E B900010000          <1> 	mov	ecx, 256 ; 21/02/2015
  4986 00005963 FA                  <1> 	CLI
  4987 00005964 FC                  <1> 	CLD
  4988 00005965 F3666F              <1> 	REP	OUTSW
  4989 00005968 FB                  <1> 	STI
  4990                              <1> 	;POP	DS			; RESTORE DS
  4991 00005969 F645FE02            <1> 	TEST	byte [CMD_BLOCK+6],ECC_MODE ; CHECK FOR NORMAL OUTPUT
  4992 0000596D 7419                <1> 	JZ	short CMD_O3
  4993 0000596F E825010000          <1> 	CALL	WAIT_DRQ		; WAIT FOR DATA REQUEST
  4994 00005974 72C9                <1> 	JC	short TM_OUT
  4995                              <1> 	;MOV	DX,HF_PORT
  4996 00005976 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  4997                              <1> 	;MOV	CX,4			; OUTPUT THE ECC BYTES
  4998 0000597D B904000000          <1> 	mov	ecx, 4  ; mov cx, 4
  4999                              <1> CMD_O2: ;MOV	AL,[ES:SI]
  5000 00005982 8A06                <1> 	mov	al, [esi]
  5001 00005984 EE                  <1> 	OUT	DX,AL
  5002 00005985 46                  <1> 	INC	eSI
  5003 00005986 E2FA                <1> 	LOOP	CMD_O2
  5004                              <1> CMD_O3:
  5005 00005988 E8A3000000          <1> 	CALL	_WAIT			; WAIT FOR SECTOR COMPLETE INTERRUPT
  5006 0000598D 75B0                <1> 	JNZ	short TM_OUT		; ERROR RETURNED
  5007 0000598F E830010000          <1> 	CALL	CHECK_STATUS
  5008 00005994 75A9                <1> 	JNZ	short CMD_ABORT
  5009 00005996 F605[618A0100]08    <1> 	TEST	byte [HF_STATUS],ST_DRQ	; CHECK FOR MORE
  5010 0000599D 75B8                <1> 	JNZ	SHORT CMD_O1
  5011                              <1> 	;MOV	DX,HF_PORT+2		; CHECK RESIDUAL SECTOR COUNT
  5012 0000599F 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  5013                              <1> 	;add	dl, 2
  5014 000059A6 FEC2                <1> 	inc	dl
  5015 000059A8 FEC2                <1> 	inc	dl
  5016 000059AA EC                  <1> 	IN	AL,DX			;
  5017 000059AB A8FF                <1> 	TEST	AL,0FFH 		;
  5018 000059AD 7407                <1> 	JZ	short CMD_O4			; COUNT = 0  OK
  5019 000059AF C605[6B8A0100]BB    <1> 	MOV	byte [DISK_STATUS1],UNDEF_ERR 
  5020                              <1> 					; OPERATION ABORTED - PARTIAL TRANSFER
  5021                              <1> CMD_O4:
  5022 000059B6 C3                  <1> 	RETn
  5023                              <1> 
  5024                              <1> ;--------------------------------------------------------
  5025                              <1> ; COMMAND						:
  5026                              <1> ;	THIS ROUTINE OUTPUTS THE COMMAND BLOCK		:
  5027                              <1> ; OUTPUT						:
  5028                              <1> ;	BL = STATUS					:
  5029                              <1> ;	BH = ERROR REGISTER				:
  5030                              <1> ;--------------------------------------------------------
  5031                              <1> 
  5032                              <1> COMMAND:
  5033 000059B7 53                  <1> 	PUSH	eBX			; WAIT FOR SEEK COMPLETE AND READY
  5034                              <1> 	;;MOV	CX,DELAY_2		; SET INITIAL DELAY BEFORE TEST
  5035                              <1> COMMAND1:
  5036                              <1> 	;;PUSH	CX			; SAVE LOOP COUNT
  5037 000059B8 E879FEFFFF          <1> 	CALL	TST_RDY 		; CHECK DRIVE READY
  5038                              <1> 	;;POP	CX
  5039 000059BD 7419                <1> 	JZ	short COMMAND2		; DRIVE IS READY
  5040 000059BF 803D[6B8A0100]80    <1>         CMP     byte [DISK_STATUS1],TIME_OUT ; TST_RDY TIMED OUT--GIVE UP
  5041                              <1> 	;JZ	short CMD_TIMEOUT
  5042                              <1> 	;;LOOP	COMMAND1		; KEEP TRYING FOR A WHILE
  5043                              <1> 	;JMP	SHORT COMMAND4		; ITS NOT GOING TO GET READY
  5044 000059C6 7507                <1> 	jne	short COMMAND4
  5045                              <1> CMD_TIMEOUT:
  5046 000059C8 C605[6B8A0100]20    <1> 	MOV	byte [DISK_STATUS1],BAD_CNTLR
  5047                              <1> COMMAND4:
  5048 000059CF 5B                  <1> 	POP	eBX
  5049 000059D0 803D[6B8A0100]00    <1>         CMP     byte [DISK_STATUS1],0   ; SET CONDITION CODE FOR CALLER
  5050 000059D7 C3                  <1> 	RETn
  5051                              <1> COMMAND2:
  5052 000059D8 5B                  <1> 	POP	eBX
  5053 000059D9 57                  <1> 	PUSH	eDI
  5054 000059DA C605[638A0100]00    <1> 	MOV	byte [HF_INT_FLAG],0	; RESET INTERRUPT FLAG
  5055 000059E1 FA                  <1> 	CLI				; INHIBIT INTERRUPTS WHILE CHANGING MASK
  5056 000059E2 E4A1                <1> 	IN	AL,INTB01		; TURN ON SECOND INTERRUPT CHIP
  5057                              <1> 	;AND	AL,0BFH
  5058 000059E4 243F                <1> 	and	al, 3Fh			; Enable IRQ 14 & 15
  5059                              <1> 	;JMP	$+2
  5060                              <1> 	IODELAY
  5060 000059E6 EB00                <2>  jmp short $+2
  5060 000059E8 EB00                <2>  jmp short $+2
  5061 000059EA E6A1                <1> 	OUT	INTB01,AL
  5062 000059EC E421                <1> 	IN	AL,INTA01		; LET INTERRUPTS PASS THRU TO
  5063 000059EE 24FB                <1> 	AND	AL,0FBH 		;  SECOND CHIP
  5064                              <1> 	;JMP	$+2
  5065                              <1> 	IODELAY
  5065 000059F0 EB00                <2>  jmp short $+2
  5065 000059F2 EB00                <2>  jmp short $+2
  5066 000059F4 E621                <1> 	OUT	INTA01,AL
  5067 000059F6 FB                  <1> 	STI
  5068 000059F7 31FF                <1> 	XOR	eDI,eDI			; INDEX THE COMMAND TABLE
  5069                              <1> 	;MOV	DX,HF_PORT+1		; DISK ADDRESS
  5070 000059F9 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  5071 00005A00 FEC2                <1> 	inc	dl
  5072 00005A02 F605[6D8A0100]C0    <1> 	TEST	byte [CONTROL_BYTE],0C0H ; CHECK FOR RETRY SUPPRESSION
  5073 00005A09 7411                <1> 	JZ	short COMMAND3
  5074 00005A0B 8A45FE              <1> 	MOV	AL, [CMD_BLOCK+6] 	; YES-GET OPERATION CODE
  5075 00005A0E 24F0                <1> 	AND	AL,0F0H 		; GET RID OF MODIFIERS
  5076 00005A10 3C20                <1> 	CMP	AL,20H			; 20H-40H IS READ, WRITE, VERIFY
  5077 00005A12 7208                <1> 	JB	short COMMAND3
  5078 00005A14 3C40                <1> 	CMP	AL,40H
  5079 00005A16 7704                <1> 	JA	short COMMAND3
  5080 00005A18 804DFE01            <1> 	OR	byte [CMD_BLOCK+6],NO_RETRIES 
  5081                              <1> 					; VALID OPERATION FOR RETRY SUPPRESS
  5082                              <1> COMMAND3:
  5083 00005A1C 8A443DF8            <1> 	MOV	AL,[CMD_BLOCK+eDI]	; GET THE COMMAND STRING BYTE
  5084 00005A20 EE                  <1> 	OUT	DX,AL			; GIVE IT TO CONTROLLER
  5085                              <1> 	IODELAY
  5085 00005A21 EB00                <2>  jmp short $+2
  5085 00005A23 EB00                <2>  jmp short $+2
  5086 00005A25 47                  <1> 	INC	eDI			; NEXT BYTE IN COMMAND BLOCK
  5087 00005A26 6642                <1> 	INC	DX			; NEXT DISK ADAPTER REGISTER
  5088 00005A28 6683FF07            <1> 	cmp	di, 7	; 1/1/2015	; ALL DONE?
  5089 00005A2C 75EE                <1> 	JNZ	short COMMAND3		; NO--GO DO NEXT ONE
  5090 00005A2E 5F                  <1> 	POP	eDI
  5091 00005A2F C3                  <1> 	RETn				; ZERO FLAG IS SET
  5092                              <1> 
  5093                              <1> ;CMD_TIMEOUT:
  5094                              <1> ;	MOV	byte [DISK_STATUS1],BAD_CNTLR
  5095                              <1> ;COMMAND4:
  5096                              <1> ;	POP	BX
  5097                              <1> ;	CMP	[DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  5098                              <1> ;	RETn
  5099                              <1> 
  5100                              <1> ;----------------------------------------
  5101                              <1> ;	WAIT FOR INTERRUPT		:
  5102                              <1> ;----------------------------------------
  5103                              <1> ;WAIT:
  5104                              <1> _WAIT:
  5105 00005A30 FB                  <1> 	STI				; MAKE SURE INTERRUPTS ARE ON
  5106                              <1> 	;SUB	CX,CX			; SET INITIAL DELAY BEFORE TEST
  5107                              <1> 	;CLC
  5108                              <1> 	;MOV	AX,9000H		; DEVICE WAIT INTERRUPT
  5109                              <1> 	;INT	15H
  5110                              <1> 	;JC	WT2			; DEVICE TIMED OUT
  5111                              <1> 	;MOV	BL,DELAY_1		; SET DELAY COUNT
  5112                              <1> 
  5113                              <1> 	;mov	bl, WAIT_HDU_INT_HI
  5114                              <1> 	;; 21/02/2015
  5115                              <1> 	;;mov	bl, WAIT_HDU_INT_HI + 1
  5116                              <1> 	;;mov	cx, WAIT_HDU_INT_LO
  5117 00005A31 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH
  5118                              <1> 					; (AWARD BIOS -> WAIT_FOR_MEM)
  5119                              <1> ;-----	WAIT LOOP
  5120                              <1> 
  5121                              <1> WT1:	
  5122                              <1> 	;TEST	byte [HF_INT_FLAG],80H	; TEST FOR INTERRUPT
  5123 00005A36 F605[638A0100]C0    <1> 	test 	byte [HF_INT_FLAG],0C0h
  5124                              <1> 	;LOOPZ	WT1
  5125 00005A3D 7517                <1> 	JNZ	short WT3		; INTERRUPT--LETS GO
  5126                              <1> 	;DEC	BL
  5127                              <1> 	;JNZ	short WT1		; KEEP TRYING FOR A WHILE
  5128                              <1> 
  5129                              <1> WT1_hi:
  5130 00005A3F E461                <1> 	in	al, SYS1 ; 61h (PORT_B)	; wait for lo to hi
  5131 00005A41 A810                <1> 	test	al, 10h			; transition on memory
  5132 00005A43 75FA                <1> 	jnz	short WT1_hi		; refresh.
  5133                              <1> WT1_lo:
  5134 00005A45 E461                <1> 	in	al, SYS1 		; 061h (PORT_B)	
  5135 00005A47 A810                <1> 	test	al, 10h			
  5136 00005A49 74FA                <1> 	jz	short WT1_lo
  5137 00005A4B E2E9                <1> 	loop	WT1
  5138                              <1> 	;;or	bl, bl
  5139                              <1> 	;;jz	short WT2	
  5140                              <1> 	;;dec	bl
  5141                              <1> 	;;jmp	short WT1
  5142                              <1> 	;dec	bl
  5143                              <1> 	;jnz	short WT1	
  5144                              <1> 
  5145 00005A4D C605[6B8A0100]80    <1> WT2:	MOV	byte [DISK_STATUS1],TIME_OUT ; REPORT TIME OUT ERROR
  5146 00005A54 EB0E                <1> 	JMP	SHORT WT4
  5147 00005A56 C605[6B8A0100]00    <1> WT3:	MOV	byte [DISK_STATUS1],0
  5148 00005A5D C605[638A0100]00    <1> 	MOV	byte [HF_INT_FLAG],0
  5149 00005A64 803D[6B8A0100]00    <1> WT4:	CMP	byte [DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  5150 00005A6B C3                  <1> 	RETn
  5151                              <1> 
  5152                              <1> ;----------------------------------------
  5153                              <1> ;	WAIT FOR CONTROLLER NOT BUSY	:
  5154                              <1> ;----------------------------------------
  5155                              <1> NOT_BUSY:
  5156 00005A6C FB                  <1> 	STI				; MAKE SURE INTERRUPTS ARE ON
  5157                              <1> 	;PUSH	eBX
  5158                              <1> 	;SUB	CX,CX			; SET INITIAL DELAY BEFORE TEST
  5159 00005A6D 668B15[F06D0000]    <1> 	mov	DX, [HF_PORT]
  5160 00005A74 80C207              <1> 	add	dl, 7			; Status port (HF_PORT+7)
  5161                              <1> 	;MOV	BL,DELAY_1
  5162                              <1> 					; wait for 10 seconds
  5163                              <1> 	;mov 	cx, WAIT_HDU_INT_LO	; 1615h
  5164                              <1> 	;;mov 	bl, WAIT_HDU_INT_HI	;   05h
  5165                              <1> 	;mov	bl, WAIT_HDU_INT_HI + 1
  5166 00005A77 B915160500          <1> 	mov	ecx, WAIT_HDU_INT_LH  ; 21/02/2015
  5167                              <1> 	;
  5168                              <1> ;;      mov     byte [wait_count], 0    ; Reset wait counter
  5169                              <1> NB1:	
  5170 00005A7C EC                  <1> 	IN	AL,DX			; CHECK STATUS
  5171                              <1> 	;TEST	AL,ST_BUSY
  5172 00005A7D 2480                <1> 	and	al, ST_BUSY
  5173                              <1> 	;LOOPNZ	NB1
  5174 00005A7F 7410                <1> 	JZ	short NB2		; NOT BUSY--LETS GO
  5175                              <1> 	;DEC	BL			
  5176                              <1> 	;JNZ	short NB1		; KEEP TRYING FOR A WHILE
  5177                              <1> 
  5178 00005A81 E461                <1> NB1_hi: IN	AL,SYS1			; wait for hi to lo
  5179 00005A83 A810                <1> 	TEST	AL,010H			; transition on memory
  5180 00005A85 75FA                <1> 	JNZ	SHORT NB1_hi		; refresh.
  5181 00005A87 E461                <1> NB1_lo: IN	AL,SYS1
  5182 00005A89 A810                <1> 	TEST	AL,010H
  5183 00005A8B 74FA                <1> 	JZ	short NB1_lo
  5184 00005A8D E2ED                <1> 	LOOP	NB1
  5185                              <1> 	;dec	bl
  5186                              <1> 	;jnz	short NB1
  5187                              <1> 	;
  5188                              <1> ;;      cmp     byte [wait_count], 182  ; 10 seconds (182 timer ticks)
  5189                              <1> ;;	jb	short NB1
  5190                              <1> 	;
  5191                              <1> 	;MOV	[DISK_STATUS1],TIME_OUT	; REPORT TIME OUT ERROR
  5192                              <1> 	;JMP	SHORT NB3
  5193 00005A8F B080                <1> 	mov	al, TIME_OUT
  5194                              <1> NB2:	
  5195                              <1> 	;MOV	byte [DISK_STATUS1],0
  5196                              <1> ;NB3:	
  5197                              <1> 	;POP	eBX
  5198 00005A91 A2[6B8A0100]        <1> 	mov	[DISK_STATUS1], al	;;; will be set after return
  5199                              <1> 	;CMP	byte [DISK_STATUS1],0 	; SET CONDITION CODE FOR CALLER
  5200 00005A96 08C0                <1> 	or	al, al			; (zf = 0 --> timeout)
  5201 00005A98 C3                  <1> 	RETn
  5202                              <1> 
  5203                              <1> ;----------------------------------------
  5204                              <1> ;	WAIT FOR DATA REQUEST		:
  5205                              <1> ;----------------------------------------
  5206                              <1> WAIT_DRQ:
  5207                              <1> 	;MOV	CX,DELAY_3
  5208                              <1> 	;MOV	DX,HF_PORT+7
  5209 00005A99 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  5210 00005AA0 80C207              <1> 	add	dl, 7
  5211                              <1> 	;;MOV	bl, WAIT_HDU_DRQ_HI	; 0
  5212                              <1> 	;MOV	cx, WAIT_HDU_DRQ_LO	; 1000 (30 milli seconds)
  5213                              <1> 					; (but it is written as 2000
  5214                              <1> 					; micro seconds in ATORGS.ASM file
  5215                              <1> 					; of Award Bios - 1999, D1A0622)
  5216 00005AA3 B9E8030000          <1> 	mov 	ecx, WAIT_HDU_DRQ_LH ; 21/02/2015 
  5217 00005AA8 EC                  <1> WQ_1:	IN	AL,DX			; GET STATUS
  5218 00005AA9 A808                <1> 	TEST	AL,ST_DRQ		; WAIT FOR DRQ
  5219 00005AAB 7516                <1> 	JNZ	short WQ_OK
  5220                              <1> 	;LOOP	WQ_1			; KEEP TRYING FOR A SHORT WHILE
  5221                              <1> WQ_hi:	
  5222 00005AAD E461                <1> 	IN	AL,SYS1			; wait for hi to lo
  5223 00005AAF A810                <1> 	TEST	AL,010H			; transition on memory
  5224 00005AB1 75FA                <1> 	JNZ	SHORT WQ_hi		; refresh.
  5225 00005AB3 E461                <1> WQ_lo:  IN      AL,SYS1
  5226 00005AB5 A810                <1> 	TEST	AL,010H
  5227 00005AB7 74FA                <1> 	JZ	SHORT WQ_lo
  5228 00005AB9 E2ED                <1> 	LOOP	WQ_1
  5229                              <1> 
  5230 00005ABB C605[6B8A0100]80    <1>         MOV     byte [DISK_STATUS1],TIME_OUT ; ERROR
  5231 00005AC2 F9                  <1> 	STC
  5232                              <1> WQ_OK:
  5233 00005AC3 C3                  <1> 	RETn
  5234                              <1> ;WQ_OK:	;CLC
  5235                              <1> ;	RETn
  5236                              <1> 
  5237                              <1> ;----------------------------------------
  5238                              <1> ;	CHECK FIXED DISK STATUS 	:
  5239                              <1> ;----------------------------------------
  5240                              <1> CHECK_STATUS:
  5241 00005AC4 E813000000          <1> 	CALL	CHECK_ST		; CHECK THE STATUS BYTE
  5242 00005AC9 7509                <1> 	JNZ	short CHECK_S1		; AN ERROR WAS FOUND
  5243 00005ACB A801                <1> 	TEST	AL,ST_ERROR		; WERE THERE ANY OTHER ERRORS
  5244 00005ACD 7405                <1> 	JZ	short CHECK_S1		; NO ERROR REPORTED
  5245 00005ACF E849000000          <1> 	CALL	CHECK_ER		; ERROR REPORTED
  5246                              <1> CHECK_S1:
  5247 00005AD4 803D[6B8A0100]00    <1> 	CMP	byte [DISK_STATUS1],0 	; SET STATUS FOR CALLER
  5248 00005ADB C3                  <1> 	RETn
  5249                              <1> 
  5250                              <1> ;----------------------------------------
  5251                              <1> ;	CHECK FIXED DISK STATUS BYTE	:
  5252                              <1> ;----------------------------------------
  5253                              <1> CHECK_ST:
  5254                              <1> 	;MOV	DX,HF_PORT+7		; GET THE STATUS
  5255 00005ADC 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]
  5256 00005AE3 80C207              <1> 	add	dl, 7
  5257                              <1> 	
  5258                              <1> 	; 17/02/2016
  5259                              <1> 	;(http://wiki.osdev.org/ATA_PIO_Mode)
  5260                              <1> 	;"delay 400ns to allow drive to set new values of BSY and DRQ"
  5261 00005AE6 EC                  <1> 	IN	AL,DX
  5262                              <1> 	;in	al, dx ; 100ns
  5263                              <1> 	;in	al, dx ; 100ns
  5264                              <1>  	;in	al, dx ; 100ns
  5265                              <1> 	NEWIODELAY ; 18/02/2016 (AWARD BIOS - 1999, 'CKST' in AHSDK.ASM)
  5265 00005AE7 E6EB                <2>  out 0ebh,al
  5266                              <1> 	;
  5267 00005AE9 A2[618A0100]        <1> 	MOV	[HF_STATUS],AL
  5268 00005AEE B400                <1> 	MOV	AH,0
  5269 00005AF0 A880                <1> 	TEST	AL,ST_BUSY		; IF STILL BUSY
  5270 00005AF2 751A                <1> 	JNZ	short CKST_EXIT		;  REPORT OK
  5271 00005AF4 B4CC                <1> 	MOV	AH,WRITE_FAULT
  5272 00005AF6 A820                <1> 	TEST	AL,ST_WRT_FLT		; CHECK FOR WRITE FAULT
  5273 00005AF8 7514                <1> 	JNZ	short CKST_EXIT
  5274 00005AFA B4AA                <1> 	MOV	AH,NOT_RDY
  5275 00005AFC A840                <1> 	TEST	AL,ST_READY		; CHECK FOR NOT READY
  5276 00005AFE 740E                <1> 	JZ	short CKST_EXIT
  5277 00005B00 B440                <1> 	MOV	AH,BAD_SEEK
  5278 00005B02 A810                <1> 	TEST	AL,ST_SEEK_COMPL	; CHECK FOR SEEK NOT COMPLETE
  5279 00005B04 7408                <1> 	JZ	short CKST_EXIT
  5280 00005B06 B411                <1> 	MOV	AH,DATA_CORRECTED
  5281 00005B08 A804                <1> 	TEST	AL,ST_CORRCTD		; CHECK FOR CORRECTED ECC
  5282 00005B0A 7502                <1> 	JNZ	short CKST_EXIT
  5283 00005B0C B400                <1> 	MOV	AH,0
  5284                              <1> CKST_EXIT:
  5285 00005B0E 8825[6B8A0100]      <1> 	MOV	[DISK_STATUS1],AH	; SET ERROR FLAG
  5286 00005B14 80FC11              <1> 	CMP	AH,DATA_CORRECTED	; KEEP GOING WITH DATA CORRECTED
  5287 00005B17 7403                <1> 	JZ	short CKST_EX1
  5288 00005B19 80FC00              <1> 	CMP	AH,0
  5289                              <1> CKST_EX1:
  5290 00005B1C C3                  <1> 	RETn
  5291                              <1> 
  5292                              <1> ;----------------------------------------
  5293                              <1> ;	CHECK FIXED DISK ERROR REGISTER :
  5294                              <1> ;----------------------------------------
  5295                              <1> CHECK_ER:
  5296                              <1> 	;MOV	DX, HF_PORT+1		; GET THE ERROR REGISTER
  5297 00005B1D 668B15[F06D0000]    <1> 	mov	dx, [HF_PORT]		;
  5298 00005B24 FEC2                <1> 	inc	dl
  5299 00005B26 EC                  <1> 	IN	AL,DX
  5300 00005B27 A2[628A0100]        <1> 	MOV	[HF_ERROR],AL
  5301 00005B2C 53                  <1> 	PUSH	eBX ; 21/02/2015
  5302 00005B2D B908000000          <1> 	MOV	eCX,8			; TEST ALL 8 BITS
  5303 00005B32 D0E0                <1> CK1:	SHL	AL,1			; MOVE NEXT ERROR BIT TO CARRY
  5304 00005B34 7202                <1> 	JC	short CK2		; FOUND THE ERROR
  5305 00005B36 E2FA                <1> 	LOOP	CK1			; KEEP TRYING
  5306 00005B38 BB[E46D0000]        <1> CK2:	MOV	eBX, ERR_TBL		; COMPUTE ADDRESS OF
  5307 00005B3D 01CB                <1> 	ADD	eBX,eCX			; ERROR CODE
  5308                              <1> 	;;MOV	AH,BYTE [CS:BX]		; GET ERROR CODE
  5309                              <1> 	;mov	ah, [bx]
  5310 00005B3F 8A23                <1> 	mov	ah, [ebx] ; 21/02/2015	
  5311 00005B41 8825[6B8A0100]      <1> CKEX:	MOV	[DISK_STATUS1],AH	; SAVE ERROR CODE
  5312 00005B47 5B                  <1> 	POP	eBX
  5313 00005B48 80FC00              <1> 	CMP	AH,0
  5314 00005B4B C3                  <1> 	RETn
  5315                              <1> 
  5316                              <1> ;--------------------------------------------------------
  5317                              <1> ; CHECK_DMA						:
  5318                              <1> ;  -CHECK ES:BX AND # SECTORS TO MAKE SURE THAT IT WILL :
  5319                              <1> ;   FIT WITHOUT SEGMENT OVERFLOW.			:
  5320                              <1> ;  -ES:BX HAS BEEN REVISED TO THE FORMAT SSSS:000X	:
  5321                              <1> ;  -OK IF # SECTORS < 80H (7FH IF LONG READ OR WRITE)	:
  5322                              <1> ;  -OK IF # SECTORS = 80H (7FH) AND BX <= 00H (04H)	:
  5323                              <1> ;  -ERROR OTHERWISE					:
  5324                              <1> ;--------------------------------------------------------
  5325                              <1> CHECK_DMA:
  5326 00005B4C 6650                <1> 	PUSH	AX			; SAVE REGISTERS
  5327 00005B4E 66B80080            <1> 	MOV	AX,8000H		; AH = MAX # SECTORS AL = MAX OFFSET
  5328 00005B52 F645FE02            <1>         TEST    byte [CMD_BLOCK+6],ECC_MODE
  5329 00005B56 7404                <1> 	JZ	short CKD1
  5330 00005B58 66B8047F            <1> 	MOV	AX,7F04H		; ECC IS 4 MORE BYTES
  5331 00005B5C 3A65F9              <1> CKD1:	CMP	AH, [CMD_BLOCK+1] 	; NUMBER OF SECTORS
  5332 00005B5F 7706                <1> 	JA	short CKDOK		; IT WILL FIT
  5333 00005B61 7208                <1> 	JB	short CKDERR		; TOO MANY
  5334 00005B63 38D8                <1> 	CMP	AL,BL			; CHECK OFFSET ON MAX SECTORS
  5335 00005B65 7204                <1> 	JB	short CKDERR		; ERROR
  5336 00005B67 F8                  <1> CKDOK:	CLC				; CLEAR CARRY
  5337 00005B68 6658                <1> 	POP	AX
  5338 00005B6A C3                  <1> 	RETn				; NORMAL RETURN
  5339 00005B6B F9                  <1> CKDERR: STC				; INDICATE ERROR
  5340 00005B6C C605[6B8A0100]09    <1>         MOV     byte [DISK_STATUS1],DMA_BOUNDARY
  5341 00005B73 6658                <1> 	POP	AX
  5342 00005B75 C3                  <1> 	RETn
  5343                              <1> 
  5344                              <1> ;----------------------------------------
  5345                              <1> ;	SET UP ES:BX-> DISK PARMS	:
  5346                              <1> ;----------------------------------------
  5347                              <1> 					
  5348                              <1> ; INPUT -> DL = 0 based drive number
  5349                              <1> ; OUTPUT -> ES:BX = disk parameter table address
  5350                              <1> 
  5351                              <1> GET_VEC:
  5352                              <1> 	;SUB	AX,AX			; GET DISK PARAMETER ADDRESS
  5353                              <1> 	;MOV	ES,AX
  5354                              <1> 	;TEST	DL,1
  5355                              <1> 	;JZ	short GV_0
  5356                              <1> ;	LES	BX,[HF1_TBL_VEC] 	; ES:BX -> DRIVE PARAMETERS
  5357                              <1> ;	JMP	SHORT GV_EXIT
  5358                              <1> ;GV_0:
  5359                              <1> ;	LES	BX,[HF_TBL_VEC]		; ES:BX -> DRIVE PARAMETERS
  5360                              <1> ;
  5361                              <1> 	;xor	bh, bh
  5362 00005B76 31DB                <1> 	xor	ebx, ebx
  5363 00005B78 88D3                <1> 	mov	bl, dl
  5364                              <1> 	;;02/01/2015
  5365                              <1> 	;;shl	bl, 1			; port address offset
  5366                              <1> 	;;mov	ax, [bx+hd_ports]	; Base port address (1F0h, 170h)
  5367                              <1> 	;;shl	bl, 1			; dpt pointer offset
  5368 00005B7A C0E302              <1> 	shl	bl, 2	;;
  5369                              <1> 	;add	bx, HF_TBL_VEC		; Disk parameter table pointer
  5370 00005B7D 81C3[708A0100]      <1> 	add	ebx, HF_TBL_VEC ; 21/02/2015
  5371                              <1> 	;push	word [bx+2]		; dpt segment
  5372                              <1> 	;pop	es
  5373                              <1> 	;mov	bx, [bx]		; dpt offset
  5374 00005B83 8B1B                <1> 	mov	ebx, [ebx]		
  5375                              <1> ;GV_EXIT:
  5376 00005B85 C3                  <1> 	RETn
  5377                              <1> 
  5378                              <1> hdc1_int: ; 21/02/2015
  5379                              <1> ;--- HARDWARE INT 76H -- ( IRQ LEVEL  14 ) ----------------------
  5380                              <1> ;								:
  5381                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  5382                              <1> ;								:
  5383                              <1> ;----------------------------------------------------------------
  5384                              <1> 
  5385                              <1> ; 22/12/2014
  5386                              <1> ; IBM PC-XT Model 286 System BIOS Source Code - DISK.ASM (HD_INT)
  5387                              <1> ;	 '11/15/85'
  5388                              <1> ; AWARD BIOS 1999 (D1A0622) 
  5389                              <1> ;	Source Code - ATORGS.ASM (INT_HDISK, INT_HDISK1)
  5390                              <1> 
  5391                              <1> ;int_76h:
  5392                              <1> HD_INT:
  5393 00005B86 6650                <1> 	PUSH	AX
  5394 00005B88 1E                  <1> 	PUSH	DS
  5395                              <1> 	;CALL	DDS
  5396                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  5397 00005B89 66B81000            <1> 	mov	ax, KDATA
  5398 00005B8D 8ED8                <1> 	mov 	ds, ax
  5399                              <1> 	;
  5400                              <1> 	;;MOV	@HF_INT_FLAG,0FFH	; ALL DONE
  5401                              <1>         ;mov     byte [CS:HF_INT_FLAG], 0FFh
  5402 00005B8F C605[638A0100]FF    <1> 	mov	byte [HF_INT_FLAG], 0FFh
  5403                              <1> 	;
  5404 00005B96 6652                <1> 	push	dx
  5405 00005B98 66BAF701            <1> 	mov	dx, HDC1_BASEPORT+7	; Status Register (1F7h)
  5406                              <1> 					; Clear Controller
  5407                              <1> Clear_IRQ1415:				; (Award BIOS - 1999)
  5408 00005B9C EC                  <1> 	in	al, dx			;
  5409 00005B9D 665A                <1> 	pop	dx
  5410                              <1> 	NEWIODELAY
  5410 00005B9F E6EB                <2>  out 0ebh,al
  5411                              <1> 	;
  5412 00005BA1 B020                <1> 	MOV	AL,EOI			; NON-SPECIFIC END OF INTERRUPT
  5413 00005BA3 E6A0                <1> 	OUT	INTB00,AL		; FOR CONTROLLER #2
  5414                              <1> 	;JMP	$+2			; WAIT
  5415                              <1> 	NEWIODELAY
  5415 00005BA5 E6EB                <2>  out 0ebh,al
  5416 00005BA7 E620                <1> 	OUT	INTA00,AL		; FOR CONTROLLER #1
  5417 00005BA9 1F                  <1> 	POP	DS
  5418                              <1> 	;STI				; RE-ENABLE INTERRUPTS
  5419                              <1> 	;MOV	AX,9100H		; DEVICE POST
  5420                              <1> 	;INT	15H			;  INTERRUPT
  5421                              <1> irq15_iret: ; 25/02/2015
  5422 00005BAA 6658                <1> 	POP	AX
  5423 00005BAC CF                  <1> 	IRETd				; RETURN FROM INTERRUPT
  5424                              <1> 
  5425                              <1> hdc2_int: ; 21/02/2015
  5426                              <1> ;++++ HARDWARE INT 77H ++ ( IRQ LEVEL  15 ) +++++++++++++++++++++
  5427                              <1> ;								:
  5428                              <1> ;	FIXED DISK INTERRUPT ROUTINE				:
  5429                              <1> ;								:
  5430                              <1> ;++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
  5431                              <1> 
  5432                              <1> ;int_77h:
  5433                              <1> HD1_INT:
  5434 00005BAD 6650                <1> 	PUSH	AX
  5435                              <1> 	; Check if that is a spurious IRQ (from slave PIC)
  5436                              <1> 	; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  5437 00005BAF B00B                <1> 	mov	al, 0Bh  ; In-Service Register
  5438 00005BB1 E6A0                <1> 	out	0A0h, al
  5439 00005BB3 EB00                <1>         jmp short $+2
  5440 00005BB5 EB00                <1> 	jmp short $+2
  5441 00005BB7 E4A0                <1> 	in	al, 0A0h
  5442 00005BB9 2480                <1> 	and 	al, 80h ; bit 7 (is it real IRQ 15 or fake?)
  5443 00005BBB 74ED                <1> 	jz	short irq15_iret ; Fake (spurious)IRQ, do not send EOI)
  5444                              <1> 	;
  5445 00005BBD 1E                  <1> 	PUSH	DS
  5446                              <1> 	;CALL	DDS
  5447                              <1> 	; 21/02/2015 (32 bit, 386 pm modification)
  5448 00005BBE 66B81000            <1> 	mov	ax, KDATA
  5449 00005BC2 8ED8                <1> 	mov 	ds, ax
  5450                              <1> 	;
  5451                              <1> 	;;MOV	@HF_INT_FLAG,0FFH	; ALL DONE
  5452                              <1>         ;or      byte [CS:HF_INT_FLAG],0C0h 
  5453 00005BC4 800D[638A0100]C0    <1> 	or	byte [HF_INT_FLAG], 0C0h
  5454                              <1> 	;
  5455 00005BCB 6652                <1> 	push	dx
  5456 00005BCD 66BA7701            <1> 	mov	dx, HDC2_BASEPORT+7	; Status Register (177h)
  5457                              <1> 					; Clear Controller (Award BIOS 1999)
  5458 00005BD1 EBC9                <1> 	jmp	short Clear_IRQ1415
  5459                              <1> 
  5460                              <1> 
  5461                              <1> ;%include 'diskdata.inc' ; 11/03/2015
  5462                              <1> ;%include 'diskbss.inc' ; 11/03/2015
  5463                              <1> 
  5464                              <1> 
  5465                              <1> ;////////////////////////////////////////////////////////////////////
  5466                              <1> ;; END OF DISK I/O SYTEM ///
  2887                                  %include 'memory.s'  ; 09/03/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - memory.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 15/12/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; memory.inc (18/10/2015)
    15                              <1> ; ****************************************************************************
    16                              <1> 
    17                              <1> ; MEMORY.ASM - Retro UNIX 386 v1 MEMORY MANAGEMENT FUNCTIONS (PROCEDURES)
    18                              <1> ; Retro UNIX 386 v1 Kernel (unix386.s, v0.2.0.14) - MEMORY.INC
    19                              <1> ; Last Modification: 18/10/2015
    20                              <1> 
    21                              <1> ; ///////// MEMORY MANAGEMENT FUNCTIONS (PROCEDURES) ///////////////
    22                              <1> 
    23                              <1> ;;04/11/2014 (unix386.s)	
    24                              <1> ;PDE_A_PRESENT	equ	1		; Present flag for PDE
    25                              <1> ;PDE_A_WRITE	equ 	2		; Writable (write permission) flag
    26                              <1> ;PDE_A_USER	equ	4		; User (non-system/kernel) page flag
    27                              <1> ;;
    28                              <1> ;PTE_A_PRESENT	equ	1		; Present flag for PTE (bit 0)
    29                              <1> ;PTE_A_WRITE	equ 	2		; Writable (write permission) flag (bit 1)
    30                              <1> ;PTE_A_USER	equ	4		; User (non-system/kernel) page flag (bit 2)
    31                              <1> ;PTE_A_ACCESS   equ	32		; Accessed flag (bit 5) ; 09/03/2015
    32                              <1> 
    33                              <1> ; 27/04/2015
    34                              <1> ; 09/03/2015
    35                              <1> PAGE_SIZE 	equ 4096		; page size in bytes
    36                              <1> PAGE_SHIFT 	equ 12			; page table shift count
    37                              <1> PAGE_D_SHIFT 	equ 22	; 12 + 10	; page directory shift count
    38                              <1> PAGE_OFF	equ 0FFFh		; 12 bit byte offset in page frame
    39                              <1> PTE_MASK 	equ 03FFh		; page table entry mask
    40                              <1> PTE_DUPLICATED  equ 200h		; duplicated page sign (AVL bit 0)
    41                              <1> PDE_A_CLEAR	equ 0F000h		; to clear PDE attribute bits
    42                              <1> PTE_A_CLEAR	equ 0F000h		; to clear PTE attribute bits
    43                              <1> LOGIC_SECT_SIZE equ 512			; logical sector size
    44                              <1> ERR_MAJOR_PF	equ 0E0h		; major error: page fault
    45                              <1> ERR_MINOR_IM	equ 4 ;15/10/2016 (1->4); insufficient (out of) memory
    46                              <1> ERR_MINOR_PV	equ 6 ;15/10/2016 (1->4); protection violation
    47                              <1> SWP_DISK_READ_ERR 	   equ 40
    48                              <1> SWP_DISK_NOT_PRESENT_ERR   equ 41
    49                              <1> SWP_SECTOR_NOT_PRESENT_ERR equ 42
    50                              <1> SWP_NO_FREE_SPACE_ERR      equ 43
    51                              <1> SWP_DISK_WRITE_ERR         equ 44
    52                              <1> SWP_NO_PAGE_TO_SWAP_ERR    equ 45
    53                              <1> PTE_A_ACCESS_BIT equ 5  ; Bit 5 (accessed flag)        
    54                              <1> SECTOR_SHIFT     equ 3  ; sector shift (to convert page block number)
    55                              <1> ; 12/07/2016
    56                              <1> PTE_SHARED	 equ 400h		; AVL bit 1, direct memory access bit	
    57                              <1> 					; (Indicates that the page is not allocated
    58                              <1> 					; for the process, it is a shared or system
    59                              <1>                                         ; page, it must not be deallocated!)
    60                              <1> ; 14/12/2020
    61                              <1> ; (Linear Frame Buffer - video memory mark : AVL bit 1, outside M.A.T.)
    62                              <1> PDE_EXTERNAL	equ 400h	; Page directory entry for external memory blocks
    63                              <1> PTE_EXTERNAL	equ 400h	; Allocated kernel pages for Linear Frame Buffer
    64                              <1> 				; (Out of memory allocation table)	
    65                              <1> 
    66                              <1> ;
    67                              <1> ;; Retro Unix 386 v1 - paging method/principles
    68                              <1> ;;
    69                              <1> ;; 10/10/2014
    70                              <1> ;; RETRO UNIX 386 v1 - PAGING METHOD/PRINCIPLES
    71                              <1> ;;
    72                              <1> ;; KERNEL PAGE MAP: 1 to 1 physical memory page map
    73                              <1> ;;	(virtual address = physical address)
    74                              <1> ;; KERNEL PAGE TABLES:
    75                              <1> ;;	Kernel page directory and all page tables are
    76                              <1> ;;	on memory as initialized, as equal to physical memory
    77                              <1> ;;	layout. Kernel pages can/must not be swapped out/in.
    78                              <1> ;;
    79                              <1> ;;	what for: User pages may be swapped out, when accessing
    80                              <1> ;;	a page in kernel/system mode, if it would be swapped out,
    81                              <1> ;;	kernel would have to swap it in! But it is also may be
    82                              <1> ;;	in use by a user process. (In system/kernel mode
    83                              <1> ;;	kernel can access all memory pages even if they are
    84                              <1> ;;	reserved/allocated for user processes. Swap out/in would
    85                              <1> ;;	cause conflicts.) 
    86                              <1> ;;	
    87                              <1> ;;	As result of these conditions,
    88                              <1> ;;	all kernel pages must be initialized as equal to 
    89                              <1> ;;	physical layout for preventing page faults. 
    90                              <1> ;;	Also, calling "allocate page" procedure after
    91                              <1> ;;	a page fault can cause another page fault (double fault)
    92                              <1> ;;	if all kernel page tables would not be initialized.
    93                              <1> ;;
    94                              <1> ;;	[first_page] = Beginning of users space, as offset to 
    95                              <1> ;;	memory allocation table. (double word aligned)
    96                              <1> ;;
    97                              <1> ;;	[next_page] = first/next free space to be searched
    98                              <1> ;;	as offset to memory allocation table. (dw aligned)
    99                              <1> ;;
   100                              <1> ;;	[last_page] = End of memory (users space), as offset
   101                              <1> ;;	to memory allocation table. (double word aligned)
   102                              <1> ;;
   103                              <1> ;; USER PAGE TABLES:
   104                              <1> ;;	Demand paging (& 'copy on write' allocation method) ...
   105                              <1> ;;		'ready only' marked copies of the 
   106                              <1> ;;		parent process's page table entries (for
   107                              <1> ;;		same physical memory).
   108                              <1> ;;		(A page will be copied to a new page after
   109                              <1> ;;		 if it causes R/W page fault.)
   110                              <1> ;;
   111                              <1> ;;	Every user process has own (different)
   112                              <1> ;;	page directory and page tables.	
   113                              <1> ;;
   114                              <1> ;;	Code starts at virtual address 0, always.
   115                              <1> ;;	(Initial value of EIP is 0 in user mode.)
   116                              <1> ;;	(Programs can be written/developed as simple
   117                              <1> ;;	 flat memory programs.)
   118                              <1> ;;
   119                              <1> ;; MEMORY ALLOCATION STRATEGY:
   120                              <1> ;;	Memory page will be allocated by kernel only 
   121                              <1> ;;		(in kernel/system mode only).
   122                              <1> ;;	* After a
   123                              <1> ;;	  - 'not present' page fault
   124                              <1> ;;	  - 'writing attempt on read only page' page fault 	 	
   125                              <1> ;;	* For loading (opening, reading) a file or disk/drive
   126                              <1> ;;	* As responce to 'allocate additional memory blocks' 
   127                              <1> ;;	  request by running process.
   128                              <1> ;;	* While creating a process, allocating a new buffer,
   129                              <1> ;;	  new page tables etc.
   130                              <1> ;;
   131                              <1> ;;	At first,
   132                              <1> ;;	- 'allocate page' procedure will be called;
   133                              <1> ;,	   if it will return with a valid (>0) physical address
   134                              <1> ;;	   (that means the relevant M.A.T. bit has been RESET)	
   135                              <1> ;;	   relevant memory page/block will be cleared (zeroed).
   136                              <1> ;;	- 'allocate page' will be called for allocating page
   137                              <1> ;;	   directory, page table and running space (data/code).
   138                              <1> ;;	- every successful 'allocate page' call will decrease
   139                              <1> ;;	  'free_pages' count (pointer).
   140                              <1> ;;	- 'out of (insufficient) memory error' will be returned
   141                              <1> ;;	  if 'free_pages' points to a ZERO.
   142                              <1> ;;	- swapping out and swapping in (if it is not a new page)
   143                              <1> ;;	  procedures will be called as responce to 'out of memory'
   144                              <1> ;;	  error except errors caused by attribute conflicts.
   145                              <1> ;;	 (swapper functions)	 
   146                              <1> ;;					
   147                              <1> ;;	At second,
   148                              <1> ;;	- page directory entry will be updated then page table
   149                              <1> ;;	  entry will be updated.		
   150                              <1> ;;
   151                              <1> ;; MEMORY ALLOCATION TABLE FORMAT:
   152                              <1> ;;	- M.A.T. has a size according to available memory as
   153                              <1> ;;	  follows:
   154                              <1> ;;		  - 1 (allocation) bit per 1 page (4096 bytes)
   155                              <1> ;;		  - a bit with value of 0 means allocated page
   156                              <1> ;;		  - a bit with value of 1 means a free page
   157                              <1> ;,	- 'free_pages' pointer holds count of free pages
   158                              <1> ;;	  depending on M.A.T.
   159                              <1> ;;		(NOTE: Free page count will not be checked
   160                              <1> ;;		again -on M.A.T.- after initialization. 
   161                              <1> ;;		Kernel will trust on initial count.)
   162                              <1> ;,	- 'free_pages' count will be decreased by allocation
   163                              <1> ;;	  and it will be increased by deallocation procedures.
   164                              <1> ;;	
   165                              <1> ;;	- Available memory will be calculated during
   166                              <1> ;;	  the kernel's initialization stage (in real mode).
   167                              <1> ;;	  Memory allocation table and kernel page tables 
   168                              <1> ;;	  will be formatted/sized as result of available
   169                              <1> ;;	  memory calculation before paging is enabled.
   170                              <1> ;;
   171                              <1> ;; For 4GB Available/Present Memory: (max. possible memory size)
   172                              <1> ;;	- Memory Allocation Table size will be 128 KB.
   173                              <1> ;;	- Memory allocation for kernel page directory size 
   174                              <1> ;;	  is always 4 KB. (in addition to total allocation size
   175                              <1> ;;	  for page tables)
   176                              <1> ;;	- Memory allocation for kernel page tables (1024 tables)
   177                              <1> ;;	  is 4 MB (1024*4*1024 bytes).
   178                              <1> ;;	- User (available) space will be started 
   179                              <1> ;;	  at 6th MB of the memory (after 1MB+4MB).
   180                              <1> ;;	- The first 640 KB is for kernel's itself plus
   181                              <1> ;;	  memory allocation table and kernel's page directory
   182                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
   183                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
   184                              <1> ;; 	  for buffers.
   185                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
   186                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
   187                              <1> ;;	- Kernel page tables start at 100000h (2nd MB)
   188                              <1> ;;
   189                              <1> ;; For 1GB Available Memory:
   190                              <1> ;;	- Memory Allocation Table size will be 32 KB.
   191                              <1> ;;	- Memory allocation for kernel page directory size 
   192                              <1> ;;	  is always 4 KB. (in addition to total allocation size
   193                              <1> ;;	  for page tables)
   194                              <1> ;;	- Memory allocation for kernel page tables (256 tables)
   195                              <1> ;;	  is 1 MB (256*4*1024 bytes).
   196                              <1> ;;	- User (available) space will be started 
   197                              <1> ;;	  at 3th MB of the memory (after 1MB+1MB).
   198                              <1> ;;	- The first 640 KB is for kernel's itself plus
   199                              <1> ;;	  memory allocation table and kernel's page directory
   200                              <1> ;;	  (D0000h-EFFFFh may be used as kernel space...)	
   201                              <1> ;;	- B0000h to B7FFFh address space (32 KB) will be used
   202                              <1> ;; 	  for buffers.
   203                              <1> ;;	- ROMBIOS, VIDEO BUFFER and VIDEO ROM space are reserved.
   204                              <1> ;,	  (A0000h-AFFFFh, C0000h-CFFFFh, F0000h-FFFFFh)
   205                              <1> ;;	- Kernel page tables start at 100000h (2nd MB).	
   206                              <1> ;;
   207                              <1> ;;
   208                              <1> 
   209                              <1> 
   210                              <1> ;;************************************************************************************
   211                              <1> ;; 
   212                              <1> ;; RETRO UNIX 386 v1 - Paging (Method for Copy On Write paging principle)
   213                              <1> ;; DEMAND PAGING - PARENT&CHILD PAGE TABLE DUPLICATION PRINCIPLES (23/04/2015)
   214                              <1> 
   215                              <1> ;; Main factor: "sys fork" system call 
   216                              <1> ;;	
   217                              <1> ;; 		FORK
   218                              <1> ;;                      |----> parent - duplicated PTEs, read only pages
   219                              <1> ;;  writable pages ---->|
   220                              <1> ;;                      |----> child - duplicated PTEs, read only pages
   221                              <1> ;; 
   222                              <1> ;; AVL bit (0) of Page Table Entry is used as duplication sign 
   223                              <1> ;; 
   224                              <1> ;; AVL Bit 0 [PTE Bit 9] = 'Duplicated PTE belongs to child' sign/flag (if it is set)
   225                              <1> ;; Note: Dirty bit (PTE bit 6) may be used instead of AVL bit 0 (PTE bit 9)
   226                              <1> ;;       -while R/W bit is 0-. 
   227                              <1> ;; 
   228                              <1> ;; Duplicate page tables with writable pages (the 1st sys fork in the process):
   229                              <1> ;; # Parent's Page Table Entries are updated to point same pages as read only, 
   230                              <1> ;;   as duplicated PTE bit  -AVL bit 0, PTE bit 9- are reset/clear.
   231                              <1> ;; # Then Parent's Page Table is copied to Child's Page Table.
   232                              <1> ;; # Child's Page Table Entries are updated as duplicated child bit
   233                              <1> ;;   -AVL bit 0, PTE bit 9- is set.	  
   234                              <1> ;; 
   235                              <1> ;; Duplicate page tables with read only pages (several sys fork system calls):
   236                              <1> ;; # Parent's read only pages are copied to new child pages. 
   237                              <1> ;;   Parent's PTE attributes are not changed.
   238                              <1> ;;   (Because, there is another parent-child fork before this fork! We must not
   239                              <1> ;;    destroy/mix previous fork result).
   240                              <1> ;; # Child's Page Table Entries (which are corresponding to Parent's 
   241                              <1> ;;   read only pages) are set as writable (while duplicated PTE bit is clear). 
   242                              <1> ;; # Parent's PTEs with writable page attribute are updated to point same pages 
   243                              <1> ;;   as read only, (while) duplicated PTE bit is reset (clear).
   244                              <1> ;; # Parent's Page Table Entries (with writable page attribute) are duplicated 
   245                              <1> ;;   as Child's Page Table Entries without copying actual page.
   246                              <1> ;; # Child 's Page Table Entries (which are corresponding to Parent's writable 
   247                              <1> ;;   pages) are updated as duplicated PTE bit (AVL bit 0, PTE bit 9- is set.
   248                              <1> ;; 
   249                              <1> ;; !? WHAT FOR (duplication after duplication):
   250                              <1> ;; In UNIX method for sys fork (a typical 'fork' application in /etc/init)
   251                              <1> ;; program/executable code continues from specified location as child process, 
   252                              <1> ;; returns back previous code location as parent process, every child after 
   253                              <1> ;; every sys fork uses last image of code and data just prior the fork.
   254                              <1> ;; Even if the parent code changes data, the child will not see the changed data 
   255                              <1> ;; after the fork. In Retro UNIX 8086 v1, parent's process segment (32KB)
   256                              <1> ;; was copied to child's process segment (all of code and data) according to
   257                              <1> ;; original UNIX v1 which copies all of parent process code and data -core- 
   258                              <1> ;; to child space -core- but swaps that core image -of child- on to disk.
   259                              <1> ;; If I (Erdogan Tan) would use a method of to copy parent's core
   260                              <1> ;; (complete running image of parent process) to the child process; 
   261                              <1> ;; for big sizes, i would force Retro UNIX 386 v1 to spend many memory pages 
   262                              <1> ;; and times only for a sys fork. (It would excessive reservation for sys fork,
   263                              <1> ;; because sys fork usually is prior to sys exec; sys exec always establishes
   264                              <1> ;; a new/fresh core -running space-, by clearing all code/data content). 
   265                              <1> ;; 'Read Only' page flag ensures page fault handler is needed only for a few write
   266                              <1> ;; attempts between sys fork and sys exec, not more... (I say so by thinking 
   267                              <1> ;; of "/etc/init" content, specially.) sys exec will clear page tables and
   268                              <1> ;; new/fresh pages will be used to load and run new executable/program.
   269                              <1> ;; That is what for i have preferred "copy on write", "duplication" method
   270                              <1> ;; for sharing same read only pages between parent and child processes.
   271                              <1> ;; That is a pitty i have to use new private flag (AVL bit 0, "duplicated PTE 
   272                              <1> ;; belongs to child" sign) for cooperation on duplicated pages between a parent 
   273                              <1> ;; and it's child processes; otherwise parent process would destroy data belongs
   274                              <1> ;; to its child or vice versa; or some pages would remain unclaimed 
   275                              <1> ;; -deallocation problem-.
   276                              <1> ;; Note: to prevent conflicts, read only pages must not be swapped out... 
   277                              <1> ;; 
   278                              <1> ;; WHEN PARENT TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
   279                              <1> ;; # Page fault handler will do those:
   280                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
   281                              <1> ;;   - If it is reset/clear, there is a child uses same page.
   282                              <1> ;;   - Parent's read only page -previous page- is copied to a new writable page. 
   283                              <1> ;;   - Parent's PTE is updated as writable page, as unique page (AVL=0)
   284                              <1> ;;   - (Page fault handler whill check this PTE later, if child process causes to
   285                              <1> ;;     page fault due to write attempt on read only page. Of course, the previous 
   286                              <1> ;;     read only page will be converted to writable and unique page which belongs
   287                              <1> ;;     to child process.)	
   288                              <1> ;; WHEN CHILD TRIES TO WRITE IT'S READ ONLY (DUPLICATED) PAGE:
   289                              <1> ;; # Page fault handler will do those:
   290                              <1> ;;   - 'Duplicated PTE' flag (PTE bit 9) is checked (on the failed PTE).
   291                              <1> ;;   - If it is set, there is a parent uses -or was using- same page.
   292                              <1> ;;   - Same PTE address within parent's page table is checked if it has same page
   293                              <1> ;;     address or not. 
   294                              <1> ;;   - If parent's PTE has same address, child will continue with a new writable page.
   295                              <1> ;;     Parent's PTE will point to same (previous) page as writable, unique (AVL=0).	
   296                              <1> ;;   - If parent's PTE has different address, child will continue with it's 
   297                              <1> ;;     own/same page but read only flag (0) will be changed to writable flag (1) and
   298                              <1> ;;     'duplicated PTE (belongs to child)' flag/sign will be cleared/reset. 	  	
   299                              <1> ;; 
   300                              <1> ;; NOTE: When a child process is terminated, read only flags of parent's page tables
   301                              <1> ;;       will be set as writable (and unique) in case of child process was using 
   302                              <1> ;;       same pages with duplicated child PTE sign... Depending on sys fork and 
   303                              <1> ;;       duplication method details, it is not possible multiple child processes
   304                              <1> ;;       were using same page with duplicated PTEs.
   305                              <1> ;; 
   306                              <1> ;;************************************************************************************   
   307                              <1> 
   308                              <1> ;; 08/10/2014
   309                              <1> ;; 11/09/2014 - Retro UNIX 386 v1 PAGING (further) draft
   310                              <1> ;;		by Erdogan Tan (Based on KolibriOS 'memory.inc')
   311                              <1> 
   312                              <1> ;; 'allocate_page' code is derived and modified from KolibriOS
   313                              <1> ;; 'alloc_page' procedure in 'memory.inc' 
   314                              <1> ;; (25/08/2014, Revision: 5057) file 
   315                              <1> ;; by KolibriOS Team (2004-2012)
   316                              <1> 
   317                              <1> allocate_page:
   318                              <1> 	; 01/07/2015
   319                              <1> 	; 05/05/2015
   320                              <1> 	; 30/04/2015
   321                              <1> 	; 16/10/2014
   322                              <1> 	; 08/10/2014
   323                              <1> 	; 09/09/2014 (Retro UNIX 386 v1 - beginning)
   324                              <1> 	;
   325                              <1> 	; INPUT -> none
   326                              <1> 	;
   327                              <1> 	; OUTPUT ->
   328                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
   329                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is RESET)
   330                              <1> 	;
   331                              <1> 	;	CF = 1 and EAX = 0 
   332                              <1> 	; 		   if there is not a free page to be allocated	
   333                              <1> 	;
   334                              <1> 	; Modified Registers -> none (except EAX)
   335                              <1> 	;
   336 00005BD3 A1[D8890100]        <1> 	mov	eax, [free_pages]
   337 00005BD8 21C0                <1> 	and	eax, eax
   338 00005BDA 7438                <1> 	jz	short out_of_memory
   339                              <1> 	;
   340 00005BDC 53                  <1> 	push	ebx
   341 00005BDD 51                  <1> 	push	ecx
   342                              <1> 	;
   343 00005BDE BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table offset
   344 00005BE3 89D9                <1> 	mov	ecx, ebx
   345                              <1>  				     ; NOTE: 32 (first_page) is initial
   346                              <1> 				     ; value of [next_page].
   347                              <1> 				     ; It points to the first available
   348                              <1> 				     ; page block for users (ring 3) ...	
   349                              <1> 				     ; (MAT offset 32 = 1024/32)	
   350                              <1> 				     ; (at the of the first 4 MB)		
   351 00005BE5 031D[DC890100]      <1> 	add	ebx, [next_page] ; Free page searching starts from here
   352                              <1> 				 ; next_free_page >> 5
   353 00005BEB 030D[E0890100]      <1> 	add	ecx, [last_page] ; Free page searching ends here
   354                              <1> 				 ; (total_pages - 1) >> 5
   355                              <1> al_p_scan:
   356 00005BF1 39CB                <1> 	cmp	ebx, ecx
   357 00005BF3 770A                <1> 	ja	short al_p_notfound
   358                              <1> 	;
   359                              <1> 	; 01/07/2015
   360                              <1> 	; AMD64 Architecture Programmers Manual
   361                              <1> 	; Volume 3:
   362                              <1> 	; General-Purpose and System Instructions
   363                              <1> 	;
   364                              <1> 	; BSF - Bit Scan Forward
   365                              <1> 	;
   366                              <1> 	;   Searches the value in a register or a memory location
   367                              <1> 	;   (second operand) for the least-significant set bit. 
   368                              <1> 	;   If a set bit is found, the instruction clears the zero flag (ZF)
   369                              <1> 	;   and stores the index of the least-significant set bit in a destination
   370                              <1> 	;   register (first operand). If the second operand contains 0, 
   371                              <1> 	;   the instruction sets ZF to 1 and does not change the contents of the 
   372                              <1> 	;   destination register. The bit index is an unsigned offset from bit 0 
   373                              <1> 	;   of the searched value
   374                              <1> 	;
   375 00005BF5 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
   376                              <1> 			   ; Clear ZF if a bit is found set (1) and 
   377                              <1> 			   ; loads the destination with an index to
   378                              <1> 			   ; first set bit. (0 -> 31) 
   379                              <1> 			   ; Sets ZF to 1 if no bits are found set.
   380 00005BF8 7525                <1> 	jnz	short al_p_found ; ZF = 0 -> a free page has been found
   381                              <1> 			 ;
   382                              <1> 			 ; NOTE:  a Memory Allocation Table bit 
   383                              <1> 			 ;	  with value of 1 means 
   384                              <1> 			 ;	  the corresponding page is free 
   385                              <1> 			 ;	  (Retro UNIX 386 v1 feature only!)
   386 00005BFA 83C304              <1> 	add	ebx, 4
   387                              <1> 			 ; We return back for searching next page block
   388                              <1> 			 ; NOTE: [free_pages] is not ZERO; so, 
   389                              <1> 			 ;	 we always will find at least 1 free page here.
   390 00005BFD EBF2                <1>         jmp     short al_p_scan
   391                              <1> 	;
   392                              <1> al_p_notfound:
   393 00005BFF 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
   394 00005C05 890D[DC890100]      <1> 	mov	[next_page], ecx ; next/first free page = last page 
   395                              <1> 				 ; (deallocate_page procedure will change it)
   396 00005C0B 31C0                <1> 	xor	eax, eax
   397 00005C0D A3[D8890100]        <1> 	mov	[free_pages], eax ; 0
   398 00005C12 59                  <1> 	pop	ecx
   399 00005C13 5B                  <1> 	pop	ebx
   400                              <1> 	;
   401                              <1> out_of_memory:
   402 00005C14 E85B040000          <1> 	call	swap_out
   403 00005C19 7325                <1> 	jnc	short al_p_ok  ; [free_pages] = 0, re-allocation by swap_out
   404                              <1> 	;
   405 00005C1B 29C0                <1> 	sub 	eax, eax ; 0
   406 00005C1D F9                  <1> 	stc
   407 00005C1E C3                  <1> 	retn
   408                              <1> 
   409                              <1> al_p_found:
   410 00005C1F 89D9                <1> 	mov	ecx, ebx
   411 00005C21 81E900001000        <1> 	sub	ecx, MEM_ALLOC_TBL
   412 00005C27 890D[DC890100]      <1> 	mov	[next_page], ecx ; Set first free page searching start
   413                              <1> 				 ; address/offset (to the next)
   414 00005C2D FF0D[D8890100]      <1>         dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
   415                              <1> 	;
   416 00005C33 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
   417                              <1> 				 ; is copied into the Carry Flag and then cleared
   418                              <1> 				 ; in the destination.
   419                              <1> 				 ;
   420                              <1> 				 ; Reset the bit which is corresponding to the 
   421                              <1> 				 ; (just) allocated page.
   422                              <1> 	; 01/07/2015 (4*8 = 32, 1 allocation byte = 8 pages)	
   423 00005C36 C1E103              <1> 	shl	ecx, 3		 ; (page block offset * 32) + page index
   424 00005C39 01C8                <1> 	add	eax, ecx	 ; = page number
   425 00005C3B C1E00C              <1> 	shl	eax, 12		 ; physical address of the page (flat/real value)
   426                              <1> 	; EAX = physical address of memory page
   427                              <1> 	;
   428                              <1> 	; NOTE: The relevant page directory and page table entry will be updated
   429                              <1> 	;       according to this EAX value...
   430 00005C3E 59                  <1> 	pop	ecx
   431 00005C3F 5B                  <1> 	pop	ebx
   432                              <1> al_p_ok:
   433 00005C40 C3                  <1> 	retn
   434                              <1> 
   435                              <1> 
   436                              <1> make_page_dir:
   437                              <1> 	; 18/04/2015
   438                              <1> 	; 12/04/2015
   439                              <1> 	; 23/10/2014
   440                              <1> 	; 16/10/2014
   441                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   442                              <1> 	;
   443                              <1> 	; INPUT ->
   444                              <1> 	;	none
   445                              <1> 	; OUTPUT ->
   446                              <1> 	;	(EAX = 0)
   447                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   448                              <1> 	;	cf = 0 ->
   449                              <1> 	;	u.pgdir = page directory (physical) address of the current
   450                              <1> 	;		  process/user.
   451                              <1> 	;
   452                              <1> 	; Modified Registers -> EAX
   453                              <1> 	;
   454 00005C41 E88DFFFFFF          <1> 	call	allocate_page
   455 00005C46 7216                <1> 	jc	short mkpd_error
   456                              <1> 	;
   457 00005C48 A3[B8030300]        <1> 	mov	[u.pgdir], eax    ; Page dir address for current user/process
   458                              <1> 				  ; (Physical address)
   459                              <1> clear_page:
   460                              <1> 	; 18/04/2015
   461                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   462                              <1> 	;
   463                              <1> 	; INPUT ->
   464                              <1> 	;	EAX = physical address of the page
   465                              <1> 	; OUTPUT ->
   466                              <1> 	;	all bytes of the page will be cleared
   467                              <1> 	;
   468                              <1> 	; Modified Registers -> none
   469                              <1> 	;
   470 00005C4D 57                  <1> 	push	edi
   471 00005C4E 51                  <1> 	push	ecx
   472 00005C4F 50                  <1> 	push	eax
   473 00005C50 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
   474 00005C55 89C7                <1> 	mov	edi, eax
   475 00005C57 31C0                <1> 	xor	eax, eax
   476 00005C59 F3AB                <1> 	rep	stosd
   477 00005C5B 58                  <1> 	pop	eax
   478 00005C5C 59                  <1> 	pop	ecx
   479 00005C5D 5F                  <1> 	pop	edi
   480                              <1> mkpd_error:
   481                              <1> mkpt_error:
   482 00005C5E C3                  <1> 	retn
   483                              <1> 
   484                              <1> make_page_table:
   485                              <1> 	; 23/06/2015
   486                              <1> 	; 18/04/2015
   487                              <1> 	; 12/04/2015
   488                              <1> 	; 16/10/2014
   489                              <1> 	; 09/10/2014 ; (Retro UNIX 386 v1 - beginning)
   490                              <1> 	;
   491                              <1> 	; INPUT ->
   492                              <1> 	;	EBX = virtual (linear) address
   493                              <1> 	;	ECX = page table attributes (lower 12 bits)
   494                              <1> 	;	      (higher 20 bits must be ZERO)
   495                              <1> 	;	      (bit 0 must be 1)	 
   496                              <1> 	;	u.pgdir = page directory (physical) address
   497                              <1> 	; OUTPUT ->
   498                              <1> 	;	EDX = Page directory entry address
   499                              <1> 	;	EAX = Page table address
   500                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   501                              <1> 	;	cf = 0 -> page table address in the PDE (EDX)
   502                              <1> 	;
   503                              <1> 	; Modified Registers -> EAX, EDX
   504                              <1> 	;
   505 00005C5F E86FFFFFFF          <1> 	call	allocate_page
   506 00005C64 72F8                <1> 	jc	short mkpt_error
   507 00005C66 E811000000          <1> 	call	set_pde	
   508 00005C6B EBE0                <1> 	jmp	short clear_page
   509                              <1> 
   510                              <1> make_page:
   511                              <1> 	; 24/07/2015
   512                              <1> 	; 23/06/2015 ; (Retro UNIX 386 v1 - beginning)
   513                              <1> 	;
   514                              <1> 	; INPUT ->
   515                              <1> 	;	EBX = virtual (linear) address
   516                              <1> 	;	ECX = page attributes (lower 12 bits)
   517                              <1> 	;	      (higher 20 bits must be ZERO)
   518                              <1> 	;	      (bit 0 must be 1)	 
   519                              <1> 	;	u.pgdir = page directory (physical) address
   520                              <1> 	; OUTPUT ->
   521                              <1> 	;	EBX = Virtual address
   522                              <1> 	;	(EDX = PTE value)
   523                              <1> 	;	EAX = Physical address
   524                              <1> 	;	cf = 1 -> insufficient (out of) memory error
   525                              <1> 	;
   526                              <1> 	; Modified Registers -> EAX, EDX
   527                              <1> 	;
   528 00005C6D E861FFFFFF          <1> 	call	allocate_page
   529 00005C72 7207                <1> 	jc	short mkp_err
   530 00005C74 E821000000          <1> 	call	set_pte	
   531 00005C79 73D2                <1> 	jnc	short clear_page ; 18/04/2015
   532                              <1> mkp_err:
   533 00005C7B C3                  <1> 	retn
   534                              <1> 
   535                              <1> 
   536                              <1> set_pde:	; Set page directory entry (PDE)
   537                              <1> 	; 20/07/2015
   538                              <1> 	; 18/04/2015
   539                              <1> 	; 12/04/2015
   540                              <1> 	; 23/10/2014
   541                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   542                              <1> 	;
   543                              <1> 	; INPUT ->
   544                              <1> 	;	EAX = physical address
   545                              <1> 	;	      (use present value if EAX = 0)
   546                              <1> 	;	EBX = virtual (linear) address
   547                              <1> 	;	ECX = page table attributes (lower 12 bits)
   548                              <1> 	;	      (higher 20 bits must be ZERO)
   549                              <1> 	;	      (bit 0 must be 1)	 
   550                              <1> 	;	u.pgdir = page directory (physical) address
   551                              <1> 	; OUTPUT ->
   552                              <1> 	;	EDX = PDE address
   553                              <1> 	;	EAX = page table address (physical)
   554                              <1> 	;	;(CF=1 -> Invalid page address)
   555                              <1> 	;
   556                              <1> 	; Modified Registers -> EDX
   557                              <1> 	;
   558 00005C7C 89DA                <1> 	mov	edx, ebx
   559 00005C7E C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22
   560 00005C81 C1E202              <1> 	shl	edx, 2 ; offset to page directory (1024*4)
   561 00005C84 0315[B8030300]      <1> 	add	edx, [u.pgdir]
   562                              <1> 	;
   563 00005C8A 21C0                <1> 	and	eax, eax
   564 00005C8C 7506                <1> 	jnz	short spde_1
   565                              <1> 	;
   566 00005C8E 8B02                <1> 	mov	eax, [edx]  ; old PDE value
   567                              <1> 	;test	al, 1
   568                              <1> 	;jz	short spde_2
   569 00005C90 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h  ; clear lower 12 bits
   570                              <1> spde_1:
   571                              <1> 	;and	cx, 0FFFh
   572 00005C94 8902                <1> 	mov	[edx], eax
   573 00005C96 66090A              <1> 	or	[edx], cx
   574 00005C99 C3                  <1> 	retn
   575                              <1> ;spde_2: ; error
   576                              <1> ;	stc
   577                              <1> ;	retn
   578                              <1> 
   579                              <1> set_pte:	; Set page table entry (PTE)
   580                              <1> 	; 24/07/2015
   581                              <1> 	; 20/07/2015
   582                              <1> 	; 23/06/2015
   583                              <1> 	; 18/04/2015
   584                              <1> 	; 12/04/2015
   585                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   586                              <1> 	;
   587                              <1> 	; INPUT ->
   588                              <1> 	;	EAX = physical page address
   589                              <1> 	;	      (use present value if EAX = 0)
   590                              <1> 	;	EBX = virtual (linear) address
   591                              <1> 	;	ECX = page attributes (lower 12 bits)
   592                              <1> 	;	      (higher 20 bits must be ZERO)
   593                              <1> 	;	      (bit 0 must be 1)	 
   594                              <1> 	;	u.pgdir = page directory (physical) address
   595                              <1> 	; OUTPUT ->
   596                              <1> 	;	EAX = physical page address
   597                              <1> 	;	(EDX = PTE value)
   598                              <1> 	;	EBX = virtual address
   599                              <1> 	;
   600                              <1> 	;	CF = 1 -> error
   601                              <1> 	;
   602                              <1> 	; Modified Registers -> EAX, EDX
   603                              <1> 	;
   604 00005C9A 50                  <1> 	push	eax
   605 00005C9B A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; 20/07/2015
   606 00005CA0 E837000000          <1> 	call 	get_pde
   607                              <1> 		; EDX = PDE address
   608                              <1> 		; EAX = PDE value
   609 00005CA5 5A                  <1> 	pop	edx ; physical page address
   610 00005CA6 722A                <1> 	jc	short spte_err ; PDE not present
   611                              <1> 	;
   612 00005CA8 53                  <1> 	push	ebx ; 24/07/2015
   613 00005CA9 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
   614                              <1> 			    ; EDX = PT address (physical)	
   615 00005CAD C1EB0C              <1> 	shr	ebx, PAGE_SHIFT ; 12
   616 00005CB0 81E3FF030000        <1> 	and	ebx, PTE_MASK	; 03FFh
   617                              <1> 			 ; clear higher 10 bits (PD bits)
   618 00005CB6 C1E302              <1> 	shl	ebx, 2   ; offset to page table (1024*4)
   619 00005CB9 01C3                <1> 	add	ebx, eax
   620                              <1> 	;
   621 00005CBB 8B03                <1> 	mov	eax, [ebx] ; Old PTE value
   622 00005CBD A801                <1> 	test	al, 1
   623 00005CBF 740C                <1> 	jz	short spte_0
   624 00005CC1 09D2                <1> 	or	edx, edx
   625 00005CC3 750F                <1> 	jnz	short spte_1
   626 00005CC5 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 bits
   627 00005CC9 89C2                <1> 	mov	edx, eax
   628 00005CCB EB09                <1> 	jmp	short spte_2	
   629                              <1> spte_0:
   630                              <1> 	; If this PTE contains a swap (disk) address,
   631                              <1> 	; it can be updated by using 'swap_in' procedure
   632                              <1> 	; only!
   633 00005CCD 21C0                <1> 	and	eax, eax
   634 00005CCF 7403                <1> 	jz	short spte_1
   635                              <1> 	; 24/07/2015
   636                              <1> 	; swapped page ! (on disk)
   637 00005CD1 5B                  <1> 	pop	ebx
   638                              <1> spte_err:
   639 00005CD2 F9                  <1> 	stc
   640 00005CD3 C3                  <1> 	retn
   641                              <1> spte_1: 
   642 00005CD4 89D0                <1> 	mov	eax, edx
   643                              <1> spte_2:
   644 00005CD6 09CA                <1> 	or	edx, ecx
   645                              <1> 	; 23/06/2015
   646 00005CD8 8913                <1> 	mov	[ebx], edx ; PTE value in EDX
   647                              <1> 	; 24/07/2015
   648 00005CDA 5B                  <1> 	pop	ebx
   649 00005CDB C3                  <1> 	retn
   650                              <1> 
   651                              <1> get_pde:	; Get present value of the relevant PDE
   652                              <1> 	; 20/07/2015
   653                              <1> 	; 18/04/2015
   654                              <1> 	; 12/04/2015
   655                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   656                              <1> 	;
   657                              <1> 	; INPUT ->
   658                              <1> 	;	EBX = virtual (linear) address
   659                              <1> 	;	EAX = page directory (physical) address
   660                              <1> 	; OUTPUT ->
   661                              <1> 	;	EDX = Page directory entry address
   662                              <1> 	;	EAX = Page directory entry value
   663                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
   664                              <1> 	; Modified Registers -> EDX, EAX
   665                              <1> 	;
   666 00005CDC 89DA                <1> 	mov	edx, ebx
   667 00005CDE C1EA16              <1> 	shr	edx, PAGE_D_SHIFT ; 22  (12+10)
   668 00005CE1 C1E202              <1> 	shl 	edx, 2 ; offset to page directory (1024*4)
   669 00005CE4 01C2                <1> 	add	edx, eax ; page directory address (physical)
   670 00005CE6 8B02                <1> 	mov	eax, [edx]
   671 00005CE8 A801                <1> 	test	al, PDE_A_PRESENT ; page table is present or not !
   672 00005CEA 751F                <1> 	jnz	short gpte_retn
   673 00005CEC F9                  <1> 	stc
   674                              <1> gpde_retn:	
   675 00005CED C3                  <1> 	retn
   676                              <1> 
   677                              <1> get_pte:
   678                              <1> 		; Get present value of the relevant PTE
   679                              <1> 	; 29/07/2015
   680                              <1> 	; 20/07/2015
   681                              <1> 	; 18/04/2015
   682                              <1> 	; 12/04/2015
   683                              <1> 	; 10/10/2014 ; (Retro UNIX 386 v1 - beginning)
   684                              <1> 	;
   685                              <1> 	; INPUT ->
   686                              <1> 	;	EBX = virtual (linear) address
   687                              <1> 	;	EAX = page directory (physical) address
   688                              <1> 	; OUTPUT ->
   689                              <1> 	;	EDX = Page table entry address (if CF=0)
   690                              <1> 	;	      Page directory entry address (if CF=1)
   691                              <1> 	;            (Bit 0 value is 0 if PT is not present)
   692                              <1> 	;	EAX = Page table entry value (page address)
   693                              <1> 	;	CF = 1 -> PDE not present or invalid ? 
   694                              <1> 	; Modified Registers -> EAX, EDX
   695                              <1> 	;
   696 00005CEE E8E9FFFFFF          <1> 	call 	get_pde
   697 00005CF3 72F8                <1> 	jc	short gpde_retn	; page table is not present
   698                              <1> 	;jnc	short gpte_1
   699                              <1> 	;retn
   700                              <1> ;gpte_1:
   701 00005CF5 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 bits
   702 00005CF9 89DA                <1> 	mov	edx, ebx
   703 00005CFB C1EA0C              <1> 	shr	edx, PAGE_SHIFT ; 12
   704 00005CFE 81E2FF030000        <1> 	and	edx, PTE_MASK	; 03FFh
   705                              <1> 			 ; clear higher 10 bits (PD bits)
   706 00005D04 C1E202              <1> 	shl	edx, 2 ; offset from start of page table (1024*4)
   707 00005D07 01C2                <1> 	add	edx, eax
   708 00005D09 8B02                <1> 	mov	eax, [edx]
   709                              <1> gpte_retn:
   710 00005D0B C3                  <1> 	retn
   711                              <1> 
   712                              <1> deallocate_page_dir:
   713                              <1> 	; 15/09/2015
   714                              <1> 	; 05/08/2015
   715                              <1> 	; 30/04/2015
   716                              <1> 	; 28/04/2015
   717                              <1> 	; 17/10/2014
   718                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   719                              <1> 	;
   720                              <1> 	; INPUT ->
   721                              <1> 	;	EAX = PHYSICAL ADDRESS OF THE PAGE DIRECTORY (CHILD)
   722                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
   723                              <1> 	; OUTPUT ->
   724                              <1> 	;	All of page tables in the page directory
   725                              <1> 	;	and page dir's itself will be deallocated
   726                              <1> 	;	except 'read only' duplicated pages (will be converted
   727                              <1> 	;	to writable pages).
   728                              <1> 	;
   729                              <1> 	; Modified Registers -> EAX
   730                              <1> 	;
   731                              <1> 	;
   732 00005D0C 56                  <1> 	push	esi
   733 00005D0D 51                  <1> 	push	ecx
   734 00005D0E 50                  <1> 	push	eax
   735 00005D0F 89C6                <1> 	mov	esi, eax 
   736 00005D11 31C9                <1> 	xor	ecx, ecx
   737                              <1> 	; The 1st PDE points to Kernel Page Table 0 (the 1st 4MB),
   738                              <1> 	; it must not be deallocated
   739 00005D13 890E                <1> 	mov	[esi], ecx ; 0 ; clear PDE 0
   740                              <1> dapd_0:
   741 00005D15 AD                  <1> 	lodsd
   742 00005D16 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
   743 00005D18 7409                <1> 	jz	short dapd_1	
   744 00005D1A 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
   745 00005D1E E812000000          <1> 	call	deallocate_page_table			
   746                              <1> dapd_1:
   747 00005D23 41                  <1> 	inc	ecx ; page directory entry index
   748 00005D24 81F900040000        <1> 	cmp	ecx, PAGE_SIZE / 4 ; 1024
   749 00005D2A 72E9                <1> 	jb	short dapd_0
   750                              <1> dapd_2:
   751 00005D2C 58                  <1> 	pop	eax
   752 00005D2D E87F000000          <1> 	call	deallocate_page	; deallocate the page dir's itself
   753 00005D32 59                  <1> 	pop	ecx
   754 00005D33 5E                  <1> 	pop	esi
   755 00005D34 C3                  <1> 	retn
   756                              <1> 
   757                              <1> deallocate_page_table:
   758                              <1> 	; 12/07/2016
   759                              <1> 	; 19/09/2015
   760                              <1> 	; 15/09/2015
   761                              <1> 	; 05/08/2015
   762                              <1> 	; 30/04/2015
   763                              <1> 	; 28/04/2015
   764                              <1> 	; 24/10/2014
   765                              <1> 	; 23/10/2014
   766                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   767                              <1> 	;
   768                              <1> 	; INPUT ->
   769                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE PAGE TABLE
   770                              <1> 	;	EBX = PHYSICAL ADDRESS OF THE PARENT'S PAGE DIRECTORY
   771                              <1> 	;	(ECX = page directory entry index)
   772                              <1> 	; OUTPUT ->
   773                              <1> 	;	All of pages in the page table and page table's itself
   774                              <1> 	;	will be deallocated except 'read only' duplicated pages
   775                              <1> 	;	(will be converted to writable pages).
   776                              <1> 	;
   777                              <1> 	; Modified Registers -> EAX
   778                              <1> 	;
   779 00005D35 56                  <1> 	push	esi
   780 00005D36 57                  <1> 	push	edi
   781 00005D37 52                  <1> 	push	edx
   782 00005D38 50                  <1> 	push	eax ; *
   783 00005D39 89C6                <1> 	mov	esi, eax 
   784 00005D3B 31FF                <1> 	xor	edi, edi ; 0
   785                              <1> dapt_0:
   786 00005D3D AD                  <1> 	lodsd
   787 00005D3E A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
   788 00005D40 7441                <1> 	jz	short dapt_1
   789                              <1> 	;
   790 00005D42 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
   791                              <1> 				  ; (must be 1)
   792 00005D44 754C                <1> 	jnz	short dapt_3
   793                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
   794 00005D46 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
   795                              <1> 				   ; as child's page ?
   796 00005D4A 7451                <1> 	jz	short dapt_4 ; Clear PTE but don't deallocate the page!
   797                              <1> 	; check the parent's PTE value is read only & same page or not.. 
   798                              <1> 	; ECX = page directory entry index (0-1023)
   799 00005D4C 53                  <1> 	push	ebx
   800 00005D4D 51                  <1> 	push	ecx
   801 00005D4E 66C1E102            <1> 	shl	cx, 2 ; *4 
   802 00005D52 01CB                <1> 	add	ebx, ecx ; PDE offset (for the parent)
   803 00005D54 8B0B                <1> 	mov	ecx, [ebx]
   804 00005D56 F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
   805 00005D59 7435                <1> 	jz	short dapt_2	; parent process does not use this page
   806 00005D5B 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
   807                              <1> 	; EDI = page table entry index (0-1023)
   808 00005D60 89FA                <1> 	mov	edx, edi 
   809 00005D62 66C1E202            <1> 	shl	dx, 2 ; *4 
   810 00005D66 01CA                <1> 	add	edx, ecx ; PTE offset (for the parent)
   811 00005D68 8B1A                <1> 	mov	ebx, [edx]
   812 00005D6A F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
   813 00005D6D 7421                <1> 	jz	short dapt_2	; parent process does not use this page
   814 00005D6F 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
   815 00005D73 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
   816 00005D78 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
   817 00005D7A 7514                <1> 	jne	short dapt_2	; not same page
   818                              <1> 				; deallocate the child's page
   819 00005D7C 800A02              <1>         or      byte [edx], PTE_A_WRITE ; convert to writable page (parent)
   820 00005D7F 59                  <1> 	pop	ecx
   821 00005D80 5B                  <1> 	pop	ebx
   822 00005D81 EB1A                <1> 	jmp	short dapt_4
   823                              <1> dapt_1:
   824 00005D83 09C0                <1> 	or	eax, eax	; swapped page ?
   825 00005D85 741D                <1> 	jz	short dapt_5	; no
   826                              <1> 				; yes
   827 00005D87 D1E8                <1> 	shr	eax, 1
   828 00005D89 E8CA040000          <1> 	call	unlink_swap_block ; Deallocate swapped page block
   829                              <1> 				  ; on the swap disk (or in file)
   830 00005D8E EB14                <1> 	jmp	short dapt_5
   831                              <1> dapt_2:
   832 00005D90 59                  <1> 	pop	ecx
   833 00005D91 5B                  <1> 	pop	ebx
   834                              <1> dapt_3:	
   835                              <1> 	; 12/07/2016
   836 00005D92 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
   837 00005D96 7505                <1> 	jnz	short dapt_4   ; AVL bit 1 = 1, do not deallocate this page!
   838                              <1> 	;
   839                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
   840 00005D98 E814000000          <1> 	call	deallocate_page ; set the mem allocation bit of this page
   841                              <1> dapt_4:
   842 00005D9D C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
   843                              <1> dapt_5:
   844 00005DA4 47                  <1> 	inc	edi ; page table entry index
   845 00005DA5 81FF00040000        <1> 	cmp	edi, PAGE_SIZE / 4 ; 1024
   846 00005DAB 7290                <1> 	jb	short dapt_0
   847                              <1> 	;
   848 00005DAD 58                  <1> 	pop	eax ; *
   849 00005DAE 5A                  <1> 	pop	edx
   850 00005DAF 5F                  <1> 	pop	edi	
   851 00005DB0 5E                  <1> 	pop	esi
   852                              <1> 	;
   853                              <1> 	;call	deallocate_page	; deallocate the page table's itself
   854                              <1> 	;retn
   855                              <1> 
   856                              <1> deallocate_page:
   857                              <1> 	; 15/09/2015
   858                              <1> 	; 28/04/2015
   859                              <1> 	; 10/03/2015
   860                              <1> 	; 17/10/2014
   861                              <1> 	; 12/10/2014 (Retro UNIX 386 v1 - beginning)
   862                              <1> 	;
   863                              <1> 	; INPUT -> 
   864                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
   865                              <1> 	; OUTPUT ->
   866                              <1> 	;	[free_pages] is increased
   867                              <1> 	;	(corresponding MEMORY ALLOCATION TABLE bit is SET)
   868                              <1> 	;	CF = 1 if the page is already deallocated
   869                              <1> 	; 	       (or not allocated) before.  
   870                              <1> 	;
   871                              <1> 	; Modified Registers -> EAX
   872                              <1> 	;
   873 00005DB1 53                  <1> 	push	ebx
   874 00005DB2 52                  <1> 	push	edx
   875                              <1> 	;
   876 00005DB3 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; shift physical address to 
   877                              <1> 				     ; 12 bits right
   878                              <1> 				     ; to get page number
   879 00005DB6 89C2                <1> 	mov	edx, eax
   880                              <1> 	; 15/09/2015
   881 00005DB8 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
   882                              <1> 				     ; (1 allocation bit = 1 page)
   883                              <1> 				     ; (1 allocation bytes = 8 pages)
   884 00005DBB 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
   885                              <1> 				     ; (to get 32 bit position)			
   886                              <1> 	;
   887 00005DBE BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address
   888 00005DC3 01D3                <1> 	add	ebx, edx
   889 00005DC5 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
   890                              <1> 				     ; (allocation bit position)	 
   891 00005DC8 3B15[DC890100]      <1> 	cmp 	edx, [next_page]     ; is the new free page address lower
   892                              <1> 				     ; than the address in 'next_page' ?
   893                              <1> 				     ; (next/first free page value)		
   894 00005DCE 7306                <1> 	jnb	short dap_1	     ; no	
   895 00005DD0 8915[DC890100]      <1> 	mov	[next_page], edx     ; yes
   896                              <1> dap_1:
   897 00005DD6 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
   898                              <1> 				     ; set relevant bit to 1.
   899                              <1> 				     ; set CF to the previous bit value	
   900                              <1> 	;cmc			     ; complement carry flag	
   901                              <1> 	;jc	short dap_2	     ; do not increase free_pages count
   902                              <1> 				     ; if the page is already deallocated
   903                              <1> 				     ; before.	
   904 00005DD9 FF05[D8890100]      <1>         inc     dword [free_pages]
   905                              <1> dap_2:
   906 00005DDF 5A                  <1> 	pop	edx
   907 00005DE0 5B                  <1> 	pop	ebx
   908 00005DE1 C3                  <1> 	retn
   909                              <1> 
   910                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   911                              <1> ;;                                                              ;;
   912                              <1> ;; Copyright (C) KolibriOS team 2004-2012. All rights reserved. ;;
   913                              <1> ;; Distributed under terms of the GNU General Public License    ;;
   914                              <1> ;;                                                              ;;
   915                              <1> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
   916                              <1> 
   917                              <1> ;;$Revision: 5057 $
   918                              <1> 
   919                              <1> 
   920                              <1> ;;align 4
   921                              <1> ;;proc alloc_page
   922                              <1> 
   923                              <1> ;;        pushfd
   924                              <1> ;;        cli
   925                              <1> ;;        push    ebx
   926                              <1> ;;;//-
   927                              <1> ;;        cmp     [pg_data.pages_free], 1
   928                              <1> ;;        jle     .out_of_memory
   929                              <1> ;;;//-
   930                              <1> ;;
   931                              <1> ;;        mov     ebx, [page_start]
   932                              <1> ;;        mov     ecx, [page_end]
   933                              <1> ;;.l1:
   934                              <1> ;;        bsf     eax, [ebx];
   935                              <1> ;;        jnz     .found
   936                              <1> ;;        add     ebx, 4
   937                              <1> ;;        cmp     ebx, ecx
   938                              <1> ;;        jb      .l1
   939                              <1> ;;        pop     ebx
   940                              <1> ;;        popfd
   941                              <1> ;;        xor     eax, eax
   942                              <1> ;;        ret
   943                              <1> ;;.found:
   944                              <1> ;;;//-
   945                              <1> ;;        dec     [pg_data.pages_free]
   946                              <1> ;;        jz      .out_of_memory
   947                              <1> ;;;//-
   948                              <1> ;;        btr     [ebx], eax
   949                              <1> ;;        mov     [page_start], ebx
   950                              <1> ;;        sub     ebx, sys_pgmap
   951                              <1> ;;        lea     eax, [eax+ebx*8]
   952                              <1> ;;        shl     eax, 12
   953                              <1> ;;;//-       dec [pg_data.pages_free]
   954                              <1> ;;        pop     ebx
   955                              <1> ;;        popfd
   956                              <1> ;;        ret
   957                              <1> ;;;//-
   958                              <1> ;;.out_of_memory:
   959                              <1> ;;        mov     [pg_data.pages_free], 1
   960                              <1> ;;        xor     eax, eax
   961                              <1> ;;        pop     ebx
   962                              <1> ;;        popfd
   963                              <1> ;;        ret
   964                              <1> ;;;//-
   965                              <1> ;;endp
   966                              <1> 
   967                              <1> duplicate_page_dir:
   968                              <1> 	; 21/09/2015
   969                              <1> 	; 31/08/2015
   970                              <1> 	; 20/07/2015
   971                              <1> 	; 28/04/2015
   972                              <1> 	; 27/04/2015
   973                              <1> 	; 18/04/2015
   974                              <1> 	; 12/04/2015
   975                              <1> 	; 18/10/2014
   976                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
   977                              <1> 	;
   978                              <1> 	; INPUT -> 
   979                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
   980                              <1> 	;		    page directory.
   981                              <1> 	; OUTPUT ->
   982                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
   983                              <1> 	;	       page directory.
   984                              <1> 	;	(New page directory with new page table entries.)
   985                              <1> 	;	(New page tables with read only copies of the parent's
   986                              <1> 	;	pages.)
   987                              <1> 	;	EAX = 0 -> Error (CF = 1)
   988                              <1> 	;
   989                              <1> 	; Modified Registers -> none (except EAX)
   990                              <1> 	;
   991 00005DE2 E8ECFDFFFF          <1> 	call	allocate_page
   992 00005DE7 723E                <1> 	jc	short dpd_err
   993                              <1> 	;
   994 00005DE9 55                  <1> 	push	ebp ; 20/07/2015
   995 00005DEA 56                  <1> 	push	esi
   996 00005DEB 57                  <1> 	push	edi
   997 00005DEC 53                  <1> 	push	ebx
   998 00005DED 51                  <1> 	push	ecx
   999 00005DEE 8B35[B8030300]      <1> 	mov	esi, [u.pgdir]
  1000 00005DF4 89C7                <1> 	mov	edi, eax
  1001 00005DF6 50                  <1> 	push	eax ; save child's page directory address
  1002                              <1> 	; 31/08/2015
  1003                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  1004                              <1> 	; (use same system space for all user page tables) 
  1005 00005DF7 A5                  <1> 	movsd
  1006 00005DF8 BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  1007 00005DFD B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  1008                              <1> dpd_0:	
  1009 00005E02 AD                  <1> 	lodsd
  1010                              <1> 	;or	eax, eax
  1011                              <1>         ;jnz     short dpd_1
  1012 00005E03 A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  1013 00005E05 7508                <1> 	jnz	short dpd_1
  1014                              <1>  	; 20/07/2015 (virtual address at the end of the page table)	
  1015 00005E07 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  1016 00005E0D EB0F                <1> 	jmp	short dpd_2
  1017                              <1> dpd_1:	
  1018 00005E0F 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  1019 00005E13 89C3                <1> 	mov	ebx, eax
  1020                              <1> 	; EBX = Parent's page table address
  1021 00005E15 E81F000000          <1> 	call	duplicate_page_table
  1022 00005E1A 720C                <1> 	jc	short dpd_p_err
  1023                              <1> 	; EAX = Child's page table address
  1024 00005E1C 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  1025                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  1026                              <1> 			 ; (present, writable, user)
  1027                              <1> dpd_2:
  1028 00005E1E AB                  <1> 	stosd
  1029 00005E1F E2E1                <1> 	loop	dpd_0
  1030                              <1> 	;
  1031 00005E21 58                  <1> 	pop	eax  ; restore child's page directory address
  1032                              <1> dpd_3:
  1033 00005E22 59                  <1> 	pop	ecx
  1034 00005E23 5B                  <1> 	pop	ebx
  1035 00005E24 5F                  <1> 	pop	edi
  1036 00005E25 5E                  <1> 	pop	esi
  1037 00005E26 5D                  <1> 	pop	ebp ; 20/07/2015
  1038                              <1> dpd_err:
  1039 00005E27 C3                  <1> 	retn
  1040                              <1> dpd_p_err:
  1041                              <1> 	; release the allocated pages missing (recover free space)
  1042 00005E28 58                  <1> 	pop	eax  ; the new page directory address (physical)
  1043 00005E29 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  1044 00005E2F E8D8FEFFFF          <1> 	call 	deallocate_page_dir
  1045 00005E34 29C0                <1> 	sub	eax, eax ; 0
  1046 00005E36 F9                  <1> 	stc
  1047 00005E37 EBE9                <1> 	jmp	short dpd_3	
  1048                              <1> 
  1049                              <1> duplicate_page_table:
  1050                              <1> 	; 20/02/2017
  1051                              <1> 	; 21/09/2015
  1052                              <1> 	; 20/07/2015
  1053                              <1> 	; 05/05/2015
  1054                              <1> 	; 28/04/2015
  1055                              <1> 	; 27/04/2015
  1056                              <1> 	; 18/04/2015
  1057                              <1> 	; 18/10/2014
  1058                              <1> 	; 16/10/2014 (Retro UNIX 386 v1 - beginning)
  1059                              <1> 	;
  1060                              <1> 	; INPUT -> 
  1061                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  1062                              <1> 	;       20/02/2017		 
  1063                              <1> 	;	EBP = Linear address of the page (from 'duplicate_page_dir')
  1064                              <1> 	;	      (Linear address = CORE + user's virtual address) 	
  1065                              <1> 	; OUTPUT ->
  1066                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  1067                              <1> 	;	      (with 'read only' attribute of page table entries)
  1068                              <1> 	;	20/02/2017
  1069                              <1> 	;	EBP = Next linear page address (for 'duplicate_page_dir')
  1070                              <1> 	;	
  1071                              <1> 	;	CF = 1 -> error 
  1072                              <1> 	;
  1073                              <1> 	; Modified Registers -> EBP (except EAX)
  1074                              <1> 	;
  1075 00005E39 E895FDFFFF          <1> 	call	allocate_page
  1076 00005E3E 726A                <1> 	jc	short dpt_err
  1077                              <1> 	;
  1078 00005E40 50                  <1> 	push	eax ; *
  1079 00005E41 56                  <1> 	push	esi
  1080 00005E42 57                  <1> 	push	edi
  1081 00005E43 52                  <1> 	push	edx
  1082 00005E44 51                  <1> 	push	ecx
  1083                              <1> 	;
  1084 00005E45 89DE                <1> 	mov	esi, ebx
  1085 00005E47 89C7                <1> 	mov	edi, eax
  1086 00005E49 89C2                <1> 	mov	edx, eax
  1087 00005E4B 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  1088                              <1> dpt_0:
  1089 00005E51 AD                  <1> 	lodsd
  1090 00005E52 21C0                <1> 	and	eax, eax
  1091 00005E54 7444                <1> 	jz	short dpt_3
  1092 00005E56 A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  1093 00005E58 7507                <1> 	jnz	short dpt_1
  1094                              <1> 	; 20/07/2015
  1095                              <1> 	; ebp = virtual (linear) address of the memory page
  1096 00005E5A E83F050000          <1> 	call	reload_page ; 28/04/2015
  1097 00005E5F 7244                <1> 	jc	short dpt_p_err
  1098                              <1> dpt_1:
  1099                              <1> 	; 21/09/2015
  1100 00005E61 89C1                <1> 	mov	ecx, eax
  1101 00005E63 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1102 00005E67 F6C102              <1> 	test	cl, PTE_A_WRITE ; writable page ?
  1103 00005E6A 7525                <1> 	jnz	short dpt_2
  1104                              <1> 	; Read only (parent) page
  1105                              <1> 	; 	- there is a third process which uses this page -
  1106                              <1> 	; Allocate a new page for the child process
  1107 00005E6C E862FDFFFF          <1> 	call	allocate_page
  1108 00005E71 7232                <1> 	jc	short dpt_p_err
  1109 00005E73 57                  <1> 	push	edi
  1110 00005E74 56                  <1> 	push	esi
  1111 00005E75 89CE                <1> 	mov	esi, ecx
  1112 00005E77 89C7                <1> 	mov	edi, eax
  1113 00005E79 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  1114 00005E7E F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  1115 00005E80 5E                  <1> 	pop	esi
  1116 00005E81 5F                  <1> 	pop	edi
  1117                              <1> 	; 
  1118 00005E82 53                  <1> 	push	ebx
  1119 00005E83 50                  <1> 	push	eax
  1120                              <1> 	; 20/07/2015
  1121 00005E84 89EB                <1> 	mov	ebx, ebp
  1122                              <1> 	; ebx = virtual (linear) address of the memory page
  1123 00005E86 E887030000          <1> 	call	add_to_swap_queue
  1124 00005E8B 58                  <1> 	pop	eax
  1125 00005E8C 5B                  <1> 	pop	ebx
  1126                              <1> 	; 21/09/2015
  1127 00005E8D 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  1128                              <1> 		; user + writable + present page
  1129 00005E8F EB09                <1> 	jmp	short dpt_3
  1130                              <1> dpt_2:
  1131                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  1132 00005E91 0C05                <1> 	or	al, PTE_A_USER+PTE_A_PRESENT 
  1133                              <1> 		    ; (read only page!)
  1134 00005E93 8946FC              <1> 	mov	[esi-4], eax ; update parent's PTE
  1135 00005E96 660D0002            <1> 	or      ax, PTE_DUPLICATED  ; (read only page & duplicated PTE!)
  1136                              <1> dpt_3:
  1137 00005E9A AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  1138                              <1> 	;
  1139 00005E9B 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  1140                              <1> 	;
  1141 00005EA1 39D7                <1> 	cmp	edi, edx
  1142 00005EA3 72AC                <1> 	jb	short dpt_0
  1143                              <1> dpt_p_err:
  1144 00005EA5 59                  <1> 	pop	ecx
  1145 00005EA6 5A                  <1> 	pop	edx
  1146 00005EA7 5F                  <1> 	pop	edi
  1147 00005EA8 5E                  <1> 	pop	esi
  1148 00005EA9 58                  <1> 	pop	eax ; *
  1149                              <1> dpt_err:
  1150 00005EAA C3                  <1> 	retn
  1151                              <1> 
  1152                              <1> page_fault_handler:	; CPU EXCEPTION 0Eh (14) : Page Fault !
  1153                              <1> 	; 21/09/2015
  1154                              <1> 	; 19/09/2015
  1155                              <1> 	; 17/09/2015
  1156                              <1> 	; 28/08/2015
  1157                              <1> 	; 20/07/2015
  1158                              <1> 	; 28/06/2015
  1159                              <1> 	; 03/05/2015
  1160                              <1> 	; 30/04/2015
  1161                              <1> 	; 18/04/2015
  1162                              <1> 	; 12/04/2015
  1163                              <1> 	; 30/10/2014
  1164                              <1> 	; 11/09/2014
  1165                              <1> 	; 10/09/2014 (Retro UNIX 386 v1 - beginning)
  1166                              <1> 	;
  1167                              <1> 	; Note: This is not an interrupt/exception handler.
  1168                              <1> 	;	This is a 'page fault remedy' subroutine 
  1169                              <1> 	;	which will be called by standard/uniform
  1170                              <1> 	;	exception handler.
  1171                              <1> 	;
  1172                              <1> 	; INPUT -> 
  1173                              <1> 	;	[error_code] = 32 bit ERROR CODE (lower 5 bits are valid)
  1174                              <1> 	;
  1175                              <1> 	;	cr2 = the virtual (linear) address 
  1176                              <1> 	;	      which has caused to page fault (19/09/2015)
  1177                              <1> 	;
  1178                              <1> 	; OUTPUT ->
  1179                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  1180                              <1> 	;	EAX = 0 -> no error
  1181                              <1> 	;	EAX > 0 -> error code in EAX (also CF = 1)
  1182                              <1> 	;
  1183                              <1> 	; Modified Registers -> none (except EAX)
  1184                              <1> 	;	
  1185                              <1>         ;
  1186                              <1>         ; ERROR CODE:
  1187                              <1> 	;	 31  .....	4   3	2   1	0
  1188                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  1189                              <1> 	;	|   Reserved  | I | R | U | W | P |
  1190                              <1> 	;	+---+-- --+---+---+---+---+---+---+
  1191                              <1> 	;
  1192                              <1> 	; P : PRESENT -	When set, the page fault was caused by 
  1193                              <1>     	;		a page-protection violation. When not set,
  1194                              <1> 	;		it was caused by a non-present page.
  1195                              <1> 	; W : WRITE   -	When set, the page fault was caused by
  1196                              <1> 	;		a page write. When not set, it was caused
  1197                              <1> 	;		by a page read.
  1198                              <1> 	; U : USER    -	When set, the page fault was caused 
  1199                              <1> 	;		while CPL = 3. 
  1200                              <1> 	;		This does not necessarily mean that
  1201                              <1> 	;		the page fault was a privilege violation.
  1202                              <1> 	; R : RESERVD -	When set, the page fault was caused by
  1203                              <1> 	;     WRITE	reading a 1 in a reserved field.
  1204                              <1> 	; I : INSTRUC -	When set, the page fault was caused by
  1205                              <1> 	;     FETCH	an instruction fetch
  1206                              <1> 	;
  1207                              <1> 	;; x86 (32 bit) VIRTUAL ADDRESS TRANSLATION
  1208                              <1> 	;  31               22                  12 11                    0
  1209                              <1> 	; +-------------------+-------------------+-----------------------+
  1210                              <1>        	; | PAGE DIR. ENTRY # | PAGE TAB. ENTRY # |        OFFSET         |
  1211                              <1>        	; +-------------------+-------------------+-----------------------+
  1212                              <1> 	;
  1213                              <1> 
  1214                              <1> 	;; CR3 REGISTER (Control Register 3)
  1215                              <1> 	;  31                                   12             5 4 3 2   0
  1216                              <1> 	; +---------------------------------------+-------------+---+-----+
  1217                              <1>       	; |                                       |  		|P|P|     |
  1218                              <1>       	; |   PAGE DIRECTORY TABLE BASE ADDRESS   |  reserved	|C|W|rsvrd|
  1219                              <1>       	; |                                       | 		|D|T|     |
  1220                              <1>    	; +---------------------------------------+-------------+---+-----+
  1221                              <1> 	;
  1222                              <1> 	;	PWT    - WRITE THROUGH
  1223                              <1> 	;	PCD    - CACHE DISABLE		
  1224                              <1> 	;
  1225                              <1> 	;
  1226                              <1> 	;; x86 PAGE DIRECTORY ENTRY (4 KByte Page)
  1227                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1228                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1229                              <1>       	; |                                       |     | | | | |P|P|U|R| |
  1230                              <1>       	; |     PAGE TABLE BASE ADDRESS 31..12    | AVL |G|0|D|A|C|W|/|/|P|
  1231                              <1>       	; |                                       |     | | | | |D|T|S|W| |
  1232                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1233                              <1> 	;
  1234                              <1>         ;       P      - PRESENT
  1235                              <1>         ;       R/W    - READ/WRITE
  1236                              <1>         ;       U/S    - USER/SUPERVISOR
  1237                              <1> 	;	PWT    - WRITE THROUGH
  1238                              <1> 	;	PCD    - CACHE DISABLE	
  1239                              <1> 	;	A      - ACCESSED	
  1240                              <1>         ;       D      - DIRTY (IGNORED)
  1241                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  1242                              <1> 	;	G      - GLOBAL	(IGNORED) 
  1243                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1244                              <1> 	;
  1245                              <1> 	;
  1246                              <1> 	;; x86 PAGE TABLE ENTRY (4 KByte Page)
  1247                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1248                              <1> 	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1249                              <1>       	; |                                       |     | |P| | |P|P|U|R| |
  1250                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |G|A|D|A|C|W|/|/|P|
  1251                              <1>       	; |                                       |     | |T| | |D|T|S|W| |
  1252                              <1>    	; +---------------------------------------+-----+---+-+-+---+-+-+-+
  1253                              <1> 	;
  1254                              <1>         ;       P      - PRESENT
  1255                              <1>         ;       R/W    - READ/WRITE
  1256                              <1>         ;       U/S    - USER/SUPERVISOR
  1257                              <1> 	;	PWT    - WRITE THROUGH
  1258                              <1> 	;	PCD    - CACHE DISABLE	
  1259                              <1> 	;	A      - ACCESSED	
  1260                              <1>         ;       D      - DIRTY
  1261                              <1> 	;	PAT    - PAGE ATTRIBUTE TABLE INDEX (CACHE BEHAVIOR)
  1262                              <1> 	;	G      - GLOBAL	 
  1263                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1264                              <1> 	;
  1265                              <1> 	;
  1266                              <1> 	;; 80386 PAGE TABLE ENTRY (4 KByte Page)
  1267                              <1> 	;  31                                   12 11  9 8 7 6 5 4 3 2 1 0
  1268                              <1> 	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  1269                              <1>       	; |                                       |     | | | | | | |U|R| |
  1270                              <1>       	; |     PAGE FRAME BASE ADDRESS 31..12    | AVL |0|0|D|A|0|0|/|/|P|
  1271                              <1>       	; |                                       |     | | | | | | |S|W| |
  1272                              <1>       	; +---------------------------------------+-----+-+-+-+-+---+-+-+-+
  1273                              <1> 	;
  1274                              <1>         ;       P      - PRESENT
  1275                              <1>         ;       R/W    - READ/WRITE
  1276                              <1>         ;       U/S    - USER/SUPERVISOR
  1277                              <1>         ;       D      - DIRTY
  1278                              <1>         ;       AVL    - AVAILABLE FOR SYSTEMS PROGRAMMER USE
  1279                              <1> 	;
  1280                              <1>         ;       NOTE: 0 INDICATES INTEL RESERVED. DO NOT DEFINE.
  1281                              <1> 	;
  1282                              <1> 	;
  1283                              <1> 	;; Invalid Page Table Entry
  1284                              <1> 	; 31                                                           1 0
  1285                              <1>       	; +-------------------------------------------------------------+-+
  1286                              <1>       	; |                                                             | |
  1287                              <1>       	; |                          AVAILABLE                          |0|
  1288                              <1>       	; |                                                             | |
  1289                              <1>       	; +-------------------------------------------------------------+-+
  1290                              <1> 	;
  1291                              <1> 
  1292 00005EAB 53                  <1> 	push	ebx
  1293 00005EAC 52                  <1> 	push	edx
  1294 00005EAD 51                  <1> 	push	ecx
  1295                              <1> 	;
  1296                              <1> 	; 21/09/2015 (debugging)
  1297 00005EAE FF05[CC030300]      <1> 	inc	dword [u.pfcount] ; page fault count for running process
  1298 00005EB4 FF05[80050300]      <1> 	inc	dword [PF_Count] ; total page fault count	
  1299                              <1> 	; 28/06/2015
  1300                              <1> 	;mov	edx, [error_code] ; Lower 5 bits are valid
  1301 00005EBA 8A15[78050300]      <1> 	mov	dl, [error_code]
  1302                              <1> 	;
  1303 00005EC0 F6C201              <1> 	test	dl, 1	; page fault was caused by a non-present page
  1304                              <1> 			; sign
  1305 00005EC3 7422                <1> 	jz	short pfh_alloc_np
  1306                              <1> 	; 
  1307                              <1> 	; If it is not a 'write on read only page' type page fault
  1308                              <1> 	; major page fault error with minor reason must be returned without 
  1309                              <1> 	; fixing the problem. 'sys_exit with error' will be needed
  1310                              <1> 	; after return here!
  1311                              <1> 	; Page fault will be remedied, by copying page contents
  1312                              <1> 	; to newly allocated page with write permission;
  1313                              <1> 	; sys_fork -> sys_exec -> copy on write, demand paging method is 
  1314                              <1> 	; used for working with minimum possible memory usage. 
  1315                              <1> 	; sys_fork will duplicate page directory and tables of parent  
  1316                              <1> 	; process with 'read only' flag. If the child process attempts to
  1317                              <1> 	; write on these read only pages, page fault will be directed here
  1318                              <1> 	; for allocating a new page with same data/content. 
  1319                              <1> 	;
  1320                              <1> 	; IMPORTANT : Retro UNIX 386 v1 (and SINGLIX and TR-DOS)
  1321                              <1> 	; will not force to separate CODE and DATA space 
  1322                              <1> 	; in a process/program... 
  1323                              <1> 	; CODE segment/section may contain DATA!
  1324                              <1> 	; It is flat, smoth and simplest programming method already as in 
  1325                              <1> 	; Retro UNIX 8086 v1 and MS-DOS programs.
  1326                              <1> 	;	
  1327 00005EC5 F6C202              <1> 	test	dl, 2	; page fault was caused by a page write
  1328                              <1> 			; sign
  1329 00005EC8 0F84AB000000        <1>         jz      pfh_p_err
  1330                              <1> 	; 31/08/2015
  1331 00005ECE F6C204              <1> 	test	dl, 4	; page fault was caused while CPL = 3 (user mode)
  1332                              <1> 			; sign.  (U+W+P = 4+2+1 = 7)
  1333 00005ED1 0F84A2000000        <1>         jz	pfh_pv_err
  1334                              <1> 	;
  1335                              <1> 	; make a new page and copy the parent's page content
  1336                              <1> 	; as the child's new page content
  1337                              <1> 	;
  1338 00005ED7 0F20D3              <1> 	mov	ebx, cr2 ; CR2 contains the linear address 
  1339                              <1> 			 ; which has caused to page fault
  1340 00005EDA E8A2000000          <1> 	call 	copy_page
  1341 00005EDF 0F828D000000        <1>         jc      pfh_im_err ; insufficient memory
  1342                              <1> 	;
  1343 00005EE5 EB7D                <1>         jmp     pfh_cpp_ok
  1344                              <1> 	;
  1345                              <1> pfh_alloc_np:
  1346 00005EE7 E8E7FCFFFF          <1> 	call	allocate_page	; (allocate a new page)
  1347 00005EEC 0F8280000000        <1>         jc      pfh_im_err	; 'insufficient memory' error
  1348                              <1> pfh_chk_cpl:
  1349                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  1350                              <1> 		; (Lower 12 bits are ZERO, because 
  1351                              <1> 		;	the address is on a page boundary)
  1352 00005EF2 80E204              <1> 	and	dl, 4	; CPL = 3 ?
  1353 00005EF5 7505                <1> 	jnz	short pfh_um
  1354                              <1> 			; Page fault handler for kernel/system mode (CPL=0)		
  1355 00005EF7 0F20DB              <1> 	mov	ebx, cr3 ; CR3 (Control Register 3) contains physical address
  1356                              <1> 			 ; of the current/active page directory
  1357                              <1> 			 ; (Always kernel/system mode page directory, here!)
  1358                              <1> 			 ; Note: Lower 12 bits are 0. (page boundary)
  1359 00005EFA EB06                <1> 	jmp	short pfh_get_pde
  1360                              <1> 	;
  1361                              <1> pfh_um:			; Page fault handler for user/appl. mode (CPL=3)
  1362 00005EFC 8B1D[B8030300]      <1>  	mov	ebx, [u.pgdir] ; Page directory of current/active process
  1363                              <1> 			; Physical address of the USER's page directory
  1364                              <1> 			; Note: Lower 12 bits are 0. (page boundary)
  1365                              <1> pfh_get_pde:
  1366 00005F02 80CA03              <1> 	or	dl, 3	; USER + WRITE + PRESENT or SYSTEM + WRITE + PRESENT
  1367 00005F05 0F20D1              <1> 	mov	ecx, cr2 ; CR2 contains the virtual address 
  1368                              <1> 			 ; which has been caused to page fault
  1369                              <1> 			 ;
  1370 00005F08 C1E914              <1> 	shr	ecx, 20	 ; shift 20 bits right
  1371 00005F0B 80E1FC              <1> 	and	cl, 0FCh ; mask lower 2 bits to get PDE offset		
  1372                              <1> 	;
  1373 00005F0E 01CB                <1> 	add	ebx, ecx ; now, EBX points to the relevant page dir entry 
  1374 00005F10 8B0B                <1> 	mov	ecx, [ebx] ; physical (base) address of the page table 	
  1375 00005F12 F6C101              <1> 	test	cl, 1	 ; check bit 0 is set (1) or not (0).
  1376 00005F15 740B                <1> 	jz	short pfh_set_pde ; Page directory entry is not valid,
  1377                              <1> 			  	  ; set/validate page directory entry
  1378 00005F17 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  1379 00005F1C 89CB                <1> 	mov	ebx, ecx ; Physical address of the page table
  1380 00005F1E 89C1                <1> 	mov	ecx, eax ; new page address (physical) 	
  1381 00005F20 EB16                <1> 	jmp	short pfh_get_pte
  1382                              <1> pfh_set_pde:
  1383                              <1> 	;; NOTE: Page directories and page tables never be swapped out!
  1384                              <1> 	;;	 (So, we know this PDE is empty or invalid)
  1385                              <1> 	;
  1386 00005F22 08D0                <1> 	or	al, dl	 ; lower 3 bits are used as U/S, R/W, P flags
  1387 00005F24 8903                <1> 	mov	[ebx], eax ; Let's put the new page directory entry here !
  1388 00005F26 30C0                <1> 	xor	al, al	 ; clear lower (3..8) bits
  1389 00005F28 89C3                <1> 	mov	ebx, eax
  1390 00005F2A E8A4FCFFFF          <1> 	call	allocate_page	 ; (allocate a new page)
  1391 00005F2F 7241                <1> 	jc	short pfh_im_err   ; 'insufficient memory' error
  1392                              <1> pfh_spde_1:
  1393                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  1394 00005F31 89C1                <1> 	mov	ecx, eax
  1395 00005F33 E815FDFFFF          <1> 	call	clear_page ; Clear page content
  1396                              <1> pfh_get_pte:
  1397 00005F38 0F20D0              <1> 	mov	eax, cr2 ; virtual address
  1398                              <1> 			 ; which has been caused to page fault
  1399 00005F3B 89C7                <1> 	mov	edi, eax ; 20/07/2015
  1400 00005F3D C1E80C              <1> 	shr	eax, 12	 ; shift 12 bit right to get 
  1401                              <1> 			 ; higher 20 bits of the page fault address 
  1402 00005F40 25FF030000          <1> 	and	eax, 3FFh ; mask PDE# bits, the result is PTE# (0 to 1023)
  1403 00005F45 C1E002              <1> 	shl	eax, 2	; shift 2 bits left to get PTE offset
  1404 00005F48 01C3                <1> 	add	ebx, eax ; now, EBX points to the relevant page table entry 
  1405 00005F4A 8B03                <1> 	mov	eax, [ebx] ; get previous value of pte
  1406                              <1> 		; bit 0 of EAX is always 0 (otherwise we would not be here)
  1407 00005F4C 21C0                <1> 	and	eax, eax
  1408 00005F4E 7410                <1> 	jz	short pfh_gpte_1
  1409                              <1> 	; 20/07/2015
  1410 00005F50 87D9                <1> 	xchg	ebx, ecx ; new page address (physical)
  1411 00005F52 55                  <1> 	push	ebp ; 20/07/2015
  1412 00005F53 0F20D5              <1> 	mov	ebp, cr2
  1413                              <1> 		; ECX = physical address of the page table entry
  1414                              <1> 		; EBX = Memory page address (physical!)
  1415                              <1> 		; EAX = Swap disk (offset) address
  1416                              <1> 		; EBP = virtual address (page fault address)
  1417 00005F56 E8B7000000          <1> 	call	swap_in
  1418 00005F5B 5D                  <1> 	pop	ebp
  1419 00005F5C 7210                <1> 	jc      short pfh_err_retn
  1420 00005F5E 87CB                <1> 	xchg	ecx, ebx
  1421                              <1> 		; EBX = physical address of the page table entry
  1422                              <1> 		; ECX = new page
  1423                              <1> pfh_gpte_1:
  1424 00005F60 08D1                <1> 	or	cl, dl	; lower 3 bits are used as U/S, R/W, P flags
  1425 00005F62 890B                <1> 	mov	[ebx], ecx ; Let's put the new page table entry here !
  1426                              <1> pfh_cpp_ok:
  1427                              <1> 	; 20/07/2015
  1428 00005F64 0F20D3              <1> 	mov	ebx, cr2
  1429 00005F67 E8A6020000          <1> 	call 	add_to_swap_queue
  1430                              <1> 	;
  1431                              <1> 	; The new PTE (which contains the new page) will be added to 
  1432                              <1> 	; the swap queue, here. 
  1433                              <1> 	; (Later, if memory will become insufficient, 
  1434                              <1> 	; one page will be swapped out which is at the head of 
  1435                              <1> 	; the swap queue by using FIFO and access check methods.)
  1436                              <1> 	;
  1437 00005F6C 31C0                <1> 	xor	eax, eax  ; 0
  1438                              <1> 	;
  1439                              <1> pfh_err_retn:
  1440 00005F6E 59                  <1> 	pop	ecx
  1441 00005F6F 5A                  <1> 	pop	edx
  1442 00005F70 5B                  <1> 	pop	ebx
  1443 00005F71 C3                  <1> 	retn 
  1444                              <1> 	
  1445                              <1> pfh_im_err:
  1446 00005F72 B8E4000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_IM ; Error code in AX
  1447                              <1> 			; Major (Primary) Error: Page Fault
  1448                              <1> 			; Minor (Secondary) Error: Insufficient Memory !
  1449 00005F77 EBF5                <1> 	jmp	short pfh_err_retn
  1450                              <1> 
  1451                              <1> 
  1452                              <1> pfh_p_err: ; 09/03/2015
  1453                              <1> pfh_pv_err:
  1454                              <1> 	; Page fault was caused by a protection-violation
  1455 00005F79 B8E6000000          <1> 	mov	eax, ERR_MAJOR_PF + ERR_MINOR_PV ; Error code in AX
  1456                              <1> 			; Major (Primary) Error: Page Fault
  1457                              <1> 			; Minor (Secondary) Error: Protection violation !
  1458 00005F7E F9                  <1> 	stc
  1459 00005F7F EBED                <1> 	jmp	short pfh_err_retn
  1460                              <1> 
  1461                              <1> copy_page:
  1462                              <1> 	; 22/09/2015
  1463                              <1> 	; 21/09/2015
  1464                              <1> 	; 19/09/2015
  1465                              <1> 	; 07/09/2015
  1466                              <1> 	; 31/08/2015
  1467                              <1> 	; 20/07/2015
  1468                              <1> 	; 05/05/2015
  1469                              <1> 	; 03/05/2015
  1470                              <1> 	; 18/04/2015
  1471                              <1> 	; 12/04/2015
  1472                              <1> 	; 30/10/2014
  1473                              <1> 	; 18/10/2014 (Retro UNIX 386 v1 - beginning)
  1474                              <1> 	;
  1475                              <1> 	; INPUT -> 
  1476                              <1> 	;	EBX = Virtual (linear) address of source page
  1477                              <1> 	;	     (Page fault address)
  1478                              <1> 	; OUTPUT ->
  1479                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF THE ALLOCATED PAGE
  1480                              <1> 	;	(corresponding PAGE TABLE ENTRY is mapped/set)
  1481                              <1> 	;	EAX = 0 (CF = 1) 
  1482                              <1> 	;		if there is not a free page to be allocated
  1483                              <1> 	;	(page content of the source page will be copied
  1484                              <1> 	;	onto the target/new page) 	
  1485                              <1> 	;
  1486                              <1> 	; Modified Registers -> ecx, ebx (except EAX)
  1487                              <1> 	;	
  1488 00005F81 56                  <1> 	push	esi
  1489 00005F82 57                  <1> 	push	edi
  1490                              <1> 	;push	ebx
  1491                              <1> 	;push	ecx
  1492 00005F83 31F6                <1> 	xor 	esi, esi
  1493 00005F85 C1EB0C              <1> 	shr	ebx, 12 ; shift 12 bits right to get PDE & PTE numbers
  1494 00005F88 89D9                <1> 	mov	ecx, ebx ; save page fault address (as 12 bit shifted)
  1495 00005F8A C1EB08              <1> 	shr	ebx, 8	 ; shift 8 bits right and then
  1496 00005F8D 80E3FC              <1> 	and	bl, 0FCh ; mask lower 2 bits to get PDE offset	
  1497 00005F90 89DF                <1> 	mov 	edi, ebx ; save it for the parent of current process
  1498 00005F92 031D[B8030300]      <1> 	add	ebx, [u.pgdir] ; EBX points to the relevant page dir entry 
  1499 00005F98 8B03                <1> 	mov	eax, [ebx] ; physical (base) address of the page table
  1500 00005F9A 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits 	
  1501 00005F9E 89CB                <1> 	mov	ebx, ecx   ; (restore higher 20 bits of page fault address)
  1502 00005FA0 81E3FF030000        <1> 	and	ebx, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  1503 00005FA6 66C1E302            <1> 	shl	bx, 2	   ; shift 2 bits left to get PTE offset
  1504 00005FAA 01C3                <1> 	add	ebx, eax   ; EBX points to the relevant page table entry 
  1505                              <1> 	; 07/09/2015
  1506 00005FAC 66F7030002          <1>         test    word [ebx], PTE_DUPLICATED ; (Does current process share this
  1507                              <1> 				     ; read only page as a child process?)	
  1508 00005FB1 7509                <1> 	jnz	short cpp_0 ; yes
  1509 00005FB3 8B0B                <1> 	mov	ecx, [ebx] ; PTE value
  1510 00005FB5 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h  ; clear page attributes
  1511 00005FBA EB32                <1> 	jmp	short cpp_1
  1512                              <1> cpp_0:
  1513 00005FBC 89FE                <1> 	mov	esi, edi
  1514 00005FBE 0335[BC030300]      <1> 	add	esi, [u.ppgdir] ; the parent's page directory entry
  1515 00005FC4 8B06                <1> 	mov	eax, [esi] ; physical (base) address of the page table
  1516 00005FC6 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1517 00005FCA 89CE                <1> 	mov	esi, ecx   ; (restore higher 20 bits of page fault address)	
  1518 00005FCC 81E6FF030000        <1> 	and	esi, 3FFh  ; mask PDE# bits, the result is PTE# (0 to 1023)
  1519 00005FD2 66C1E602            <1> 	shl	si, 2	   ; shift 2 bits left to get PTE offset
  1520 00005FD6 01C6                <1> 	add	esi, eax   ; EDX points to the relevant page table entry  	
  1521 00005FD8 8B0E                <1> 	mov	ecx, [esi] ; PTE value of the parent process
  1522                              <1> 	; 21/09/2015
  1523 00005FDA 8B03                <1> 	mov	eax, [ebx] ; PTE value of the child process
  1524 00005FDC 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear page attributes	
  1525                              <1> 	;
  1526 00005FE0 F6C101              <1> 	test	cl, PTE_A_PRESENT ; is it a present/valid page ?
  1527 00005FE3 7424                <1> 	jz	short cpp_3 ; the parent's page is not same page  	
  1528                              <1> 	;
  1529 00005FE5 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; 0F000h ; clear page attributes
  1530 00005FEA 39C8                <1> 	cmp	eax, ecx   ; Same page?	
  1531 00005FEC 751B                <1> 	jne	short cpp_3 ; Parent page and child page are not same 
  1532                              <1> 			    ; Convert child's page to writable page
  1533                              <1> cpp_1:
  1534 00005FEE E8E0FBFFFF          <1> 	call	allocate_page
  1535 00005FF3 721A                <1> 	jc	short cpp_4 ; 'insufficient memory' error
  1536 00005FF5 21F6                <1> 	and	esi, esi    ; check ESI is valid or not
  1537 00005FF7 7405                <1> 	jz	short cpp_2
  1538                              <1> 		; Convert read only page to writable page 
  1539                              <1> 		;(for the parent of the current process)
  1540                              <1> 	;and	word [esi], PTE_A_CLEAR ; 0F000h
  1541                              <1> 	; 22/09/2015
  1542 00005FF9 890E                <1> 	mov	[esi], ecx
  1543 00005FFB 800E07              <1> 	or	byte [esi], PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER
  1544                              <1> 				 ; 1+2+4 = 7
  1545                              <1> cpp_2:
  1546 00005FFE 89C7                <1> 	mov	edi, eax ; new page address of the child process
  1547                              <1> 	; 07/09/2015
  1548 00006000 89CE                <1> 	mov	esi, ecx ; the page address of the parent process
  1549 00006002 B900040000          <1> 	mov	ecx, PAGE_SIZE / 4
  1550 00006007 F3A5                <1> 	rep	movsd ; 31/08/2015
  1551                              <1> cpp_3:		
  1552 00006009 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 1+2+4 = 7
  1553 0000600B 8903                <1> 	mov	[ebx], eax ; Update PTE
  1554 0000600D 28C0                <1> 	sub	al, al ; clear attributes
  1555                              <1> cpp_4:
  1556                              <1> 	;pop	ecx
  1557                              <1> 	;pop	ebx
  1558 0000600F 5F                  <1> 	pop	edi
  1559 00006010 5E                  <1> 	pop	esi
  1560 00006011 C3                  <1> 	retn
  1561                              <1> 
  1562                              <1> ;; 28/04/2015
  1563                              <1> ;; 24/10/2014
  1564                              <1> ;; 21/10/2014 (Retro UNIX 386 v1 - beginning)
  1565                              <1> ;; SWAP_PAGE_QUEUE (4096 bytes)
  1566                              <1> ;;
  1567                              <1> ;;   0000   0001   0002   0003   ....   1020   1021   1022   1023	
  1568                              <1> ;; +------+------+------+------+-    -+------+------+------+------+
  1569                              <1> ;; |  pg1 |  pg2 |  pg3 |  pg4 | .... |pg1021|pg1022|pg1023|pg1024|
  1570                              <1> ;; +------+------+------+------+-    -+------+------+------+------+    
  1571                              <1> ;;
  1572                              <1> ;; [swpq_last] = 0 to 4096 (step 4) -> the last position on the queue
  1573                              <1> ;;
  1574                              <1> ;; Method:
  1575                              <1> ;;	Swap page queue is a list of allocated pages with physical
  1576                              <1> ;;	addresses (system mode virtual adresses = physical addresses).
  1577                              <1> ;;	It is used for 'swap_in' and 'swap_out' procedures.
  1578                              <1> ;;	When a new page is being allocated, swap queue is updated
  1579                              <1> ;;	by 'swap_queue_shift' procedure, header of the queue (offset 0)
  1580                              <1> ;;	is checked for 'accessed' flag. If the 1st page on the queue
  1581                              <1> ;;	is 'accessed' or 'read only', it is dropped from the list;
  1582                              <1> ;;	other pages from the 2nd to the last (in [swpq_last]) shifted
  1583                              <1> ;; 	to head then the 2nd page becomes the 1st and '[swpq_last]' 
  1584                              <1> ;;	offset value becomes it's previous offset value - 4.
  1585                              <1> ;;	If the 1st page of the swap page queue is not 'accessed'	
  1586                              <1> ;;	the queue/list is not shifted.
  1587                              <1> ;;	After the queue/list shift, newly allocated page is added
  1588                              <1> ;;	to the tail of the queue at the [swpq_count*4] position.
  1589                              <1> ;;	But, if [swpq_count] > 1023, the newly allocated page
  1590                              <1> ;;	will not be added to the tail of swap page queue.  		 
  1591                              <1> ;;	
  1592                              <1> ;;	During 'swap_out' procedure, swap page queue is checked for
  1593                              <1> ;;	the first non-accessed, writable page in the list, 
  1594                              <1> ;;	from the head to the tail. The list is shifted to left 
  1595                              <1> ;;	(to the head) till a non-accessed page will be found in the list.
  1596                              <1> ;;	Then, this page	is swapped out (to disk) and then it is dropped
  1597                              <1> ;;	from the list by a final swap queue shift. [swpq_count] value
  1598                              <1> ;;	is changed. If all pages on the queue' are 'accessed', 
  1599                              <1> ;;	'insufficient memory' error will be returned ('swap_out' 
  1600                              <1> ;;	procedure will be failed)...
  1601                              <1> ;;
  1602                              <1> ;;	Note: If the 1st page of the queue is an 'accessed' page,
  1603                              <1> ;;	'accessed' flag of the page will be reset (0) and that page
  1604                              <1> ;;	(PTE) will be added to the tail of the queue after
  1605                              <1> ;;	the check, if [swpq_count] < 1023. If [swpq_count] = 1024
  1606                              <1> ;;	the queue will be rotated and the PTE in the head will be
  1607                              <1> ;;	added to the tail after resetting 'accessed' bit. 
  1608                              <1> ;;
  1609                              <1> ;;
  1610                              <1> ;;	
  1611                              <1> ;; SWAP DISK/FILE (with 4096 bytes swapped page blocks)
  1612                              <1> ;;
  1613                              <1> ;;  00000000  00000004  00000008  0000000C   ...   size-8    size-4
  1614                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+
  1615                              <1> ;; |descriptr| page(1) | page(2) | page(3) | ... |page(n-1)| page(n) |
  1616                              <1> ;; +---------+---------+---------+---------+-- --+---------+---------+    
  1617                              <1> ;;
  1618                              <1> ;; [swpd_next] = the first free block address in swapped page records
  1619                              <1> ;;    		 for next free block search by 'swap_out' procedure.
  1620                              <1> ;; [swpd_size] = swap disk/file size in sectors (512 bytes)
  1621                              <1> ;;		 NOTE: max. possible swap disk size is 1024 GB
  1622                              <1> ;; 		 (entire swap space must be accessed by using
  1623                              <1> ;;		 31 bit offset address) 
  1624                              <1> ;; [swpd_free] = free block (4096 bytes) count in swap disk/file space
  1625                              <1> ;; [swpd_start] = absolute/start address of the swap disk/file
  1626                              <1> ;;		  0 for file, or beginning sector of the swap partition
  1627                              <1> ;; [swp_drv] = logical drive description table addr. of swap disk/file
  1628                              <1> ;;
  1629                              <1> ;; 					
  1630                              <1> ;; Method:
  1631                              <1> ;;	When the memory (ram) becomes insufficient, page allocation
  1632                              <1> ;;	procedure swaps out a page from memory to the swap disk 
  1633                              <1> ;;	(partition) or swap file to get a new free page at the memory.
  1634                              <1> ;;	Swapping out is performed by using swap page queue.
  1635                              <1> ;;
  1636                              <1> ;; 	Allocation block size of swap disk/file is equal to page size
  1637                              <1> ;;	(4096 bytes). Swapping address (in sectors) is recorded
  1638                              <1> ;;	into relevant page file entry as 31 bit physical (logical)
  1639                              <1> ;;	offset address as 1 bit shifted to left for present flag (0).
  1640                              <1> ;;	Swapped page address is between 1 and swap disk/file size - 4.	  
  1641                              <1> ;;	Absolute physical (logical) address of the swapped page is 
  1642                              <1> ;;	calculated by adding offset value to the swap partition's 
  1643                              <1> ;;	start address. If the swap device (disk) is a virtual disk 
  1644                              <1> ;;	or it is a file, start address of the swap disk/volume is 0, 
  1645                              <1> ;;	and offset value is equal to absolute (physical or logical)
  1646                              <1> ;;	address/position. (It has not to be ZERO if the swap partition 
  1647                              <1> ;;	is in a partitioned virtual hard disk.) 
  1648                              <1> ;;
  1649                              <1> ;;	Note: Swap addresses are always specified/declared in sectors, 
  1650                              <1> ;;	not in bytes or	in blocks/zones/clusters (4096 bytes) as unit.
  1651                              <1> ;;
  1652                              <1> ;;	Swap disk/file allocation is mapped via 'Swap Allocation Table'
  1653                              <1> ;;	at memory as similar to 'Memory Allocation Table'.
  1654                              <1> ;;
  1655                              <1> ;;	Every bit of Swap Allocation Table repsesents one swap block
  1656                              <1> ;;	(equal to page size) respectively. Bit 0 of the S.A.T. byte 0
  1657                              <1> ;;	is reserved for swap disk/file block 0 as descriptor block
  1658                              <1> ;;	(also for compatibility with PTE). If bit value is ZERO,
  1659                              <1> ;;	it means relevant (respective) block is in use, and, 
  1660                              <1> ;;	of course, if bit value is 1, it means relevant (respective)
  1661                              <1> ;;      swap disk/file block is free.
  1662                              <1> ;;	For example: bit 1 of the byte 128 repsesents block 1025 
  1663                              <1> ;;	(128*8+1) or sector (offset) 8200 on the swap disk or
  1664                              <1> ;;	byte (offset/position) 4198400 in the swap file. 
  1665                              <1> ;;	4GB swap space is represented via 128KB Swap Allocation Table.
  1666                              <1> ;;	Initial layout of Swap Allocation Table is as follows:
  1667                              <1> ;;	------------------------------------------------------------
  1668                              <1> ;;	0111111111111111111111111 .... 11111111111111111111111111111
  1669                              <1> ;;	------------------------------------------------------------
  1670                              <1> ;;	(0 is reserved block, 1s represent free blocks respectively.)
  1671                              <1> ;;	(Note: Allocation cell/unit of the table is bit, not byte)
  1672                              <1> ;;
  1673                              <1> ;;	..............................................................
  1674                              <1> ;;
  1675                              <1> ;;	'swap_out' procedure checks 'free_swap_blocks' count at first,
  1676                              <1> ;;	then it searches Swap Allocation Table if free count is not
  1677                              <1> ;;	zero. From begining the [swpd_next] dword value, the first bit 
  1678                              <1> ;;	position with value of 1 on the table is converted to swap
  1679                              <1> ;;	disk/file offset address, in sectors (not 4096 bytes block).
  1680                              <1> ;;	'ldrv_write' procedure is called with ldrv (logical drive
  1681                              <1> ;;	number of physical swap disk or virtual swap disk)
  1682                              <1> ;;	number, sector offset (not absolute sector -LBA- number),
  1683                              <1> ;;	and sector count (8, 512*8 = 4096) and buffer adress
  1684                              <1> ;;	(memory page). That will be a direct disk write procedure.
  1685                              <1> ;;	(for preventing late memory allocation, significant waiting). 
  1686                              <1> ;;	If disk write procedure returns with error or free count of 
  1687                              <1> ;;	swap blocks is ZERO, 'swap_out' procedure will return with
  1688                              <1> ;;	'insufficient memory error' (cf=1). 
  1689                              <1> ;;
  1690                              <1> ;;	(Note: Even if free swap disk/file blocks was not zero,
  1691                              <1> ;;	any disk write error will not be fixed by 'swap_out' procedure,
  1692                              <1> ;;	in other words, 'swap_out' will not check the table for other
  1693                              <1> ;;	free blocks after a disk write error. It will return to 
  1694                              <1> ;;	the caller with error (CF=1) which means swapping is failed. 
  1695                              <1> ;;
  1696                              <1> ;;	After writing the page on to swap disk/file address/sector,
  1697                              <1> ;;	'swap_out' procesure returns with that swap (offset) sector
  1698                              <1> ;;	address (cf=0). 
  1699                              <1> ;;
  1700                              <1> ;;	..............................................................
  1701                              <1> ;;
  1702                              <1> ;;	'swap_in' procedure loads addressed (relevant) swap disk or
  1703                              <1> ;;	file sectors at specified memory page. Then page allocation
  1704                              <1> ;;	procedure updates relevant page table entry with 'present' 
  1705                              <1> ;;	attribute. If swap disk or file reading fails there is nothing
  1706                              <1> ;;	to do, except to terminate the process which is the owner of
  1707                              <1> ;;	the swapped page.
  1708                              <1> ;;
  1709                              <1> ;;	'swap_in' procedure sets the relevant/respective bit value
  1710                              <1> ;;	in the Swap Allocation Table (as free block). 'swap_in' also
  1711                              <1> ;;	updates [swpd_first] pointer if it is required.
  1712                              <1> ;;
  1713                              <1> ;;	..............................................................	 
  1714                              <1> ;;
  1715                              <1> ;;	Note: If [swap_enabled] value is ZERO, that means there is not
  1716                              <1> ;;	a swap disk or swap file in use... 'swap_in' and 'swap_out'
  1717                              <1> ;;	procedures ans 'swap page que' procedures will not be active...
  1718                              <1> ;;	'Insufficient memory' error will be returned by 'swap_out'
  1719                              <1> ;;	and 'general protection fault' will be returned by 'swap_in'
  1720                              <1> ;;	procedure, if it is called mistakenly (a wrong value in a PTE).		
  1721                              <1> ;;
  1722                              <1> 
  1723                              <1> swap_in:
  1724                              <1> 	; 31/08/2015
  1725                              <1> 	; 20/07/2015
  1726                              <1> 	; 28/04/2015
  1727                              <1> 	; 18/04/2015
  1728                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  1729                              <1> 	;
  1730                              <1> 	; INPUT -> 
  1731                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS OF THE MEMORY PAGE
  1732                              <1> 	;	EBP = VIRTUAL (LINEAR) ADDRESS (page fault address)
  1733                              <1> 	;	EAX = Offset Address for the swapped page on the
  1734                              <1> 	;	      swap disk or in the swap file.
  1735                              <1> 	;
  1736                              <1> 	; OUTPUT ->
  1737                              <1> 	;	EAX = 0 if loading at memory has been successful
  1738                              <1> 	;
  1739                              <1> 	;	CF = 1 -> swap disk reading error (disk/file not present
  1740                              <1> 	;		  or sector not present or drive not ready
  1741                              <1> 	;	     EAX = Error code
  1742                              <1> 	;	     [u.error] = EAX 
  1743                              <1> 	;		       = The last error code for the process
  1744                              <1> 	;		         (will be reset after returning to user)	  
  1745                              <1> 	;
  1746                              <1> 	; Modified Registers -> EAX
  1747                              <1> 	;
  1748                              <1> 
  1749 00006012 833D[62050300]00    <1>         cmp     dword [swp_drv], 0
  1750 00006019 7646                <1> 	jna	short swpin_dnp_err
  1751                              <1> 
  1752 0000601B 3B05[66050300]      <1> 	cmp	eax, [swpd_size]
  1753 00006021 734A                <1> 	jnb	short swpin_snp_err
  1754                              <1> 
  1755 00006023 56                  <1> 	push	esi
  1756 00006024 53                  <1> 	push	ebx
  1757 00006025 51                  <1> 	push	ecx
  1758 00006026 8B35[62050300]      <1> 	mov	esi, [swp_drv]	
  1759 0000602C B908000000          <1> 	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  1760                              <1> 		; Note: Even if corresponding physical disk's sector 
  1761                              <1> 		; size different than 512 bytes, logical disk sector
  1762                              <1> 		; size is 512 bytes and disk reading procedure
  1763                              <1> 		; will be performed for reading 4096 bytes
  1764                              <1> 		; (2*2048, 8*512). 
  1765                              <1> 	; ESI = Logical disk description table address
  1766                              <1> 	; EBX = Memory page (buffer) address (physical!)
  1767                              <1> 	; EAX = Sector adress (offset address, logical sector number)
  1768                              <1> 	; ECX = Sector count ; 8 sectors
  1769 00006031 50                  <1> 	push	eax
  1770 00006032 E8AF020000          <1> 	call	logical_disk_read
  1771 00006037 58                  <1> 	pop	eax
  1772 00006038 730C                <1> 	jnc	short swpin_read_ok
  1773                              <1> 	;
  1774 0000603A B828000000          <1> 	mov	eax, SWP_DISK_READ_ERR ; drive not ready or read error
  1775 0000603F A3[C8030300]        <1> 	mov	[u.error], eax
  1776 00006044 EB17                <1> 	jmp	short swpin_retn
  1777                              <1> 	;
  1778                              <1> swpin_read_ok:
  1779                              <1> 	; EAX = Offset address (logical sector number)
  1780 00006046 E80D020000          <1> 	call	unlink_swap_block  ; Deallocate swap block	
  1781                              <1> 	;
  1782                              <1> 	; EBX = Memory page (buffer) address (physical!)
  1783                              <1> 	; 20/07/2015
  1784 0000604B 89EB                <1> 	mov	ebx, ebp ; virtual address (page fault address)
  1785 0000604D 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  1786 00006052 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; current process number
  1787                              <1> 	; EBX = Virtual (Linear) address & process number combination
  1788 00006058 E8DB000000          <1> 	call	swap_queue_shift
  1789                              <1> 	; eax = 0 ; 10/06/2016 (if ebx input > 0, eax output = 0)
  1790                              <1> 	;sub	eax, eax  ; 0 ; Error Code = 0  (no error)
  1791                              <1> 	; zf = 1
  1792                              <1> swpin_retn:
  1793 0000605D 59                  <1> 	pop	ecx
  1794 0000605E 5B                  <1> 	pop	ebx
  1795 0000605F 5E                  <1> 	pop	esi
  1796 00006060 C3                  <1> 	retn
  1797                              <1> 
  1798                              <1> swpin_dnp_err:
  1799 00006061 B829000000          <1> 	mov	eax, SWP_DISK_NOT_PRESENT_ERR
  1800                              <1> swpin_err_retn:
  1801 00006066 A3[C8030300]        <1> 	mov	[u.error], eax
  1802 0000606B F9                  <1> 	stc
  1803 0000606C C3                  <1> 	retn
  1804                              <1> 
  1805                              <1> swpin_snp_err:
  1806 0000606D B82A000000          <1> 	mov	eax, SWP_SECTOR_NOT_PRESENT_ERR
  1807 00006072 EBF2                <1> 	jmp	short swpin_err_retn
  1808                              <1> 
  1809                              <1> swap_out:
  1810                              <1> 	; 10/06/2016
  1811                              <1> 	; 07/06/2016
  1812                              <1>         ; 23/05/2016
  1813                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
  1814                              <1> 	; 24/10/2014 - 31/08/2015 (Retro UNIX 386 v1)
  1815                              <1> 	;
  1816                              <1> 	; INPUT -> 
  1817                              <1> 	;	none
  1818                              <1> 	;
  1819                              <1> 	; OUTPUT ->
  1820                              <1> 	;	EAX = Physical page address (which is swapped out
  1821                              <1> 	;	      for allocating a new page)
  1822                              <1> 	;	CF = 1 -> swap disk writing error (disk/file not present
  1823                              <1> 	;		  or sector not present or drive not ready
  1824                              <1> 	;	     EAX = Error code
  1825                              <1> 	;	     [u.error] = EAX 
  1826                              <1> 	;		       = The last error code for the process
  1827                              <1> 	;		         (will be reset after returning to user)	  
  1828                              <1> 	;
  1829                              <1> 	; Modified Registers -> none (except EAX)
  1830                              <1> 	;
  1831 00006074 66833D[60050300]01  <1> 	cmp 	word [swpq_count], 1
  1832 0000607C 0F82AF000000        <1>         jc      swpout_im_err ; 'insufficient memory'
  1833                              <1> 
  1834                              <1>         ;cmp    dword [swp_drv], 1
  1835                              <1> 	;jc	short swpout_dnp_err ; 'swap disk/file not present'
  1836                              <1> 
  1837 00006082 833D[6A050300]01    <1>         cmp     dword [swpd_free], 1
  1838 00006089 0F828F000000        <1>         jc      swpout_nfspc_err ; 'no free space on swap disk'
  1839                              <1> 
  1840 0000608F 53                  <1> 	push	ebx ; *
  1841                              <1> swpout_1:
  1842                              <1> 	; 10/06/2016
  1843 00006090 31DB                <1> 	xor	ebx, ebx ; shift the queue and return a PTE value
  1844 00006092 E8A1000000          <1> 	call	swap_queue_shift
  1845 00006097 21C0                <1> 	and	eax, eax	; 0 = empty queue (improper entries)
  1846 00006099 0F848A000000        <1>         jz      swpout_npts_err        ; There is not any proper PTE
  1847                              <1> 				       ; pointer in the swap queue
  1848                              <1> 	; EAX = PTE value of the page
  1849                              <1> 	; EBX = PTE address of the page
  1850 0000609F 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  1851                              <1> 	;
  1852                              <1> 	; 07/06/2016
  1853                              <1> 	; 19/05/2016
  1854                              <1> 	; check this page is in timer events or not
  1855                              <1> 	
  1856                              <1> swpout_timer_page_0:
  1857 000060A3 52                  <1> 	push	edx ; **
  1858                              <1> 
  1859                              <1> 	; 07/06/2016
  1860 000060A4 803D[63960100]00    <1> 	cmp	byte [timer_events], 0 
  1861 000060AB 762F                <1> 	jna	short swpout_2
  1862                              <1> 	;
  1863 000060AD 8A15[63960100]      <1> 	mov	dl, [timer_events]
  1864                              <1> 
  1865 000060B3 51                  <1> 	push	ecx ; ***
  1866 000060B4 53                  <1> 	push	ebx ; ****
  1867 000060B5 BB[60040300]        <1> 	mov	ebx, timer_set ; beginning address of timer event
  1868                              <1> 			       ; structures 
  1869                              <1> swpout_timer_page_1:
  1870 000060BA 8A0B                <1> 	mov	cl, [ebx]
  1871 000060BC 08C9                <1> 	or	cl, cl ; 0 = free, >0 = process number
  1872 000060BE 7415                <1> 	jz	short swpout_timer_page_3
  1873 000060C0 8B4B0C              <1> 	mov	ecx, [ebx+12] ; response (signal return) address
  1874 000060C3 6681E100F0          <1> 	and	cx, PTE_A_CLEAR ; clear offset part (right 12 bits)
  1875                              <1> 				; of the response byte address, to
  1876                              <1> 				; get beginning of the page address)
  1877 000060C8 39C8                <1> 	cmp	eax, ecx
  1878 000060CA 7505                <1> 	jne	short swpout_timer_page_2 ; not same page
  1879                              <1> 	
  1880                              <1> 	; !same page!
  1881                              <1> 	;
  1882                              <1> 	; NOTE: // 19/05/2016 // - TRDOS 386 feature only ! -
  1883                              <1> 	; This page will be used by the kernel to put timer event
  1884                              <1> 	; response (signal return) byte at the requested address;
  1885                              <1> 	; in order to prevent a possible wrong write (while
  1886                              <1> 	; this page is swapped out) on physical memory,
  1887                              <1> 	; we must protect this page against to be swapped out!
  1888                              <1> 	;
  1889 000060CC 5B                  <1> 	pop	ebx ; ****
  1890 000060CD 59                  <1> 	pop	ecx ; ***
  1891 000060CE 5A                  <1> 	pop	edx ; **
  1892 000060CF EBBF                <1> 	jmp	short swpout_1	; do not swap out this page !
  1893                              <1>  
  1894                              <1> swpout_timer_page_2:
  1895                              <1> 	; 07/06/2016
  1896 000060D1 FECA                <1> 	dec	dl
  1897 000060D3 7405                <1> 	jz	short swpout_timer_page_4
  1898                              <1> swpout_timer_page_3:
  1899                              <1> 	;cmp	ebx, timer_set + 240 ; last timer event (15*16) 
  1900                              <1> 	;jnb	short swpout_timer_page_4
  1901 000060D5 83C310              <1> 	add	ebx, 16
  1902 000060D8 EBE0                <1> 	jmp	short swpout_timer_page_1	
  1903                              <1> 
  1904                              <1> swpout_timer_page_4:
  1905 000060DA 5B                  <1> 	pop	ebx ; ****
  1906 000060DB 59                  <1> 	pop	ecx ; ***
  1907                              <1> swpout_2:
  1908 000060DC 89DA                <1> 	mov	edx, ebx	       ; Page table entry address	
  1909 000060DE 89C3                <1> 	mov	ebx, eax	       ; Buffer (Page) Address				
  1910                              <1> 	;
  1911 000060E0 E8A6010000          <1> 	call	link_swap_block
  1912 000060E5 7304                <1> 	jnc	short swpout_3	       ; It may not be needed here	
  1913                              <1> 				       ; because [swpd_free] value
  1914                              <1> 				       ; was checked at the beginging. 	
  1915 000060E7 5A                  <1> 	pop	edx ; **
  1916 000060E8 5B                  <1> 	pop	ebx ; *
  1917 000060E9 EB33                <1> 	jmp	short swpout_nfspc_err 
  1918                              <1> swpout_3:
  1919 000060EB A900000080          <1> 	test	eax, 80000000h ; test bit 31 (this may not be needed!)
  1920 000060F0 752C                <1> 	jnz	short swpout_nfspc_err  ; 10/06/2016 (bit 31 = 1 !)
  1921                              <1> 	;	
  1922 000060F2 56                  <1> 	push	esi ; **
  1923 000060F3 51                  <1> 	push	ecx ; ***
  1924 000060F4 50                  <1> 	push	eax ; sector address ; (31 bit !, bit 31 = 0)
  1925 000060F5 8B35[62050300]      <1> 	mov	esi, [swp_drv]	
  1926 000060FB B908000000          <1> 	mov	ecx, PAGE_SIZE / LOGIC_SECT_SIZE  ; 8 !
  1927                              <1> 		; Note: Even if corresponding physical disk's sector 
  1928                              <1> 		; size different than 512 bytes, logical disk sector
  1929                              <1> 		; size is 512 bytes and disk writing procedure
  1930                              <1> 		; will be performed for writing 4096 bytes
  1931                              <1> 		; (2*2048, 8*512). 
  1932                              <1> 	; ESI = Logical disk description table address
  1933                              <1> 	; EBX = Buffer (Page) address
  1934                              <1> 	; EAX = Sector adress (offset address, logical sector number)
  1935                              <1> 	; ECX = Sector count ; 8 sectors
  1936                              <1> 	; edx = PTE address
  1937 00006100 E8E2010000          <1> 	call	logical_disk_write
  1938                              <1> 	; edx = PTE address
  1939 00006105 59                  <1> 	pop	ecx ; sector address	
  1940 00006106 730C                <1> 	jnc	short swpout_write_ok
  1941                              <1> 	;
  1942                              <1> 	;; call	unlink_swap_block ; this block must be left as 'in use'
  1943                              <1> swpout_dw_err:
  1944 00006108 B82C000000          <1> 	mov	eax, SWP_DISK_WRITE_ERR ; drive not ready or write error
  1945 0000610D A3[C8030300]        <1> 	mov	[u.error], eax
  1946 00006112 EB06                <1> 	jmp	short swpout_retn
  1947                              <1> 	;
  1948                              <1> swpout_write_ok:
  1949                              <1> 	; EBX = Buffer (page) address
  1950                              <1> 	; EDX = Page Table Entry address
  1951                              <1> 	; ECX = Swap disk sector (file block) address (31 bit)
  1952 00006114 D1E1                <1> 	shl 	ecx, 1  ; 31 bit sector address from bit 1 to bit 31 
  1953 00006116 890A                <1> 	mov 	[edx], ecx 
  1954                              <1> 		; bit 0 = 0 (swapped page)
  1955 00006118 89D8                <1> 	mov	eax, ebx
  1956                              <1> swpout_retn:
  1957 0000611A 59                  <1> 	pop	ecx ; ***
  1958 0000611B 5E                  <1> 	pop	esi ; **
  1959 0000611C 5B                  <1> 	pop	ebx ; *
  1960 0000611D C3                  <1> 	retn
  1961                              <1> 
  1962                              <1> ;swpout_dnp_err:
  1963                              <1> ;	mov	eax, SWP_DISK_NOT_PRESENT_ERR ; disk not present
  1964                              <1> ;	jmp	short swpout_err_retn
  1965                              <1> swpout_nfspc_err:
  1966 0000611E B82B000000          <1> 	mov	eax, SWP_NO_FREE_SPACE_ERR ; no free space
  1967                              <1> swpout_err_retn:
  1968 00006123 A3[C8030300]        <1> 	mov	[u.error], eax
  1969                              <1> 	;stc
  1970 00006128 C3                  <1> 	retn
  1971                              <1> swpout_npts_err:
  1972 00006129 B82D000000          <1> 	mov	eax, SWP_NO_PAGE_TO_SWAP_ERR
  1973 0000612E 5B                  <1> 	pop	ebx
  1974 0000612F EBF2                <1> 	jmp	short swpout_err_retn
  1975                              <1> swpout_im_err:
  1976 00006131 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; insufficient (out of) memory
  1977 00006136 EBEB                <1> 	jmp	short swpout_err_retn
  1978                              <1> 
  1979                              <1> swap_queue_shift:
  1980                              <1> 	; 26/03/2017
  1981                              <1> 	; 10/06/2016
  1982                              <1> 	; 09/06/2016 - TRDOS 386 (TRDOS v2.0)
  1983                              <1> 	; 23/10/2014 - 20/07/2015 (Retro UNIX 386 v1)
  1984                              <1> 	;
  1985                              <1> 	; INPUT ->
  1986                              <1> 	;	EBX = Virtual (linear) address (bit 12 to 31) 
  1987                              <1> 	;	      and process number combination (bit 0 to 11)
  1988                              <1> 	;	EBX = 0 -> shift/drop from the head (offset 0)
  1989                              <1> 	;	
  1990                              <1> 	; OUTPUT ->
  1991                              <1> 	;	If EBX input > 0 
  1992                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  1993                              <1> 	; 	   from the tail to the head, up to entry offset
  1994                              <1> 	; 	   which points to EBX input value or nothing
  1995                              <1> 	;	   to do if EBX value is not found on the queue.
  1996                              <1> 	;	   (The entry -with EBX value- will be removed
  1997                              <1> 	;	   from the queue if it is found.)
  1998                              <1> 	;
  1999                              <1> 	;	   EAX = 0		
  2000                              <1> 	;
  2001                              <1> 	;	If EBX input = 0
  2002                              <1> 	;	   the queue will be shifted 4 bytes (dword),
  2003                              <1> 	; 	   from the tail to the head, if the PTE address
  2004                              <1> 	;	   which is pointed in head of the queue is marked
  2005                              <1> 	;	   as "accessed" or it is marked as "non present".
  2006                              <1> 	;	   (If "accessed" flag of the PTE -which is pointed
  2007                              <1> 	;	   in the head- is set -to 1-, it will be reset
  2008                              <1> 	;	   -to 0- and then, the queue will be rotated 
  2009                              <1> 	;	   -without dropping pointer of the PTE from 
  2010                              <1> 	;	   the queue- for 4 bytes on head to tail direction.
  2011                              <1> 	;	   Pointer in the head will be moved into the tail,
  2012                              <1> 	;	   other PTEs will be shifted on head direction.)
  2013                              <1> 	;
  2014                              <1> 	;	   Swap queue will be shifted up to the first
  2015                              <1> 	;	   'present' or 'non accessed' page will be found
  2016                              <1> 	;	   (as pointed) on the queue head (then it will be
  2017                              <1>         ;          removed/dropped from the queue).
  2018                              <1> 	;
  2019                              <1> 	;	   EAX (> 0) = PTE value of the page which is
  2020                              <1> 	;		 (it's pointer -virtual address-) dropped
  2021                              <1> 	;		 (removed) from swap queue.
  2022                              <1> 	;	   EBX = PTE address of the page (if EAX > 0)
  2023                              <1> 	;	         which is (it's pointer -virtual address-)
  2024                              <1> 	;		 dropped (removed) from swap queue.
  2025                              <1> 	;
  2026                              <1> 	;	   EAX = 0 -> empty swap queue ! 
  2027                              <1> 	;
  2028                              <1> 	; Modified Registers -> EAX, EBX
  2029                              <1> 	;
  2030 00006138 0FB705[60050300]    <1> 	movzx   eax, word [swpq_count]  ; Max. 1024
  2031 0000613F 6621C0              <1> 	and	ax, ax
  2032 00006142 7431                <1> 	jz	short swpqs_retn
  2033 00006144 57                  <1> 	push	edi
  2034 00006145 56                  <1> 	push	esi
  2035 00006146 51                  <1> 	push	ecx
  2036 00006147 BE00E00800          <1> 	mov	esi, swap_queue
  2037 0000614C 89C1                <1> 	mov	ecx, eax
  2038 0000614E 09DB                <1> 	or	ebx, ebx
  2039 00006150 7424                <1> 	jz	short swpqs_7
  2040                              <1> swpqs_1:
  2041 00006152 AD                  <1> 	lodsd
  2042 00006153 39D8                <1> 	cmp	eax, ebx
  2043 00006155 7406                <1> 	je	short swpqs_2
  2044 00006157 E2F9                <1> 	loop	swpqs_1
  2045                              <1> 	; 10/06/2016
  2046 00006159 29C0                <1> 	sub	eax, eax 
  2047 0000615B EB15                <1> 	jmp	short swpqs_6
  2048                              <1> swpqs_2:
  2049 0000615D 89F7                <1> 	mov	edi, esi
  2050 0000615F 83EF04              <1> 	sub 	edi, 4
  2051                              <1> swpqs_3:
  2052 00006162 66FF0D[60050300]    <1> 	dec	word [swpq_count]
  2053 00006169 7403                <1> 	jz	short swpqs_5
  2054                              <1> swpqs_4:
  2055 0000616B 49                  <1> 	dec 	ecx
  2056 0000616C F3A5                <1> 	rep	movsd	; shift up (to the head)
  2057                              <1> swpqs_5:
  2058 0000616E 31C0                <1> 	xor	eax, eax
  2059 00006170 8907                <1> 	mov	[edi], eax
  2060                              <1> swpqs_6:
  2061 00006172 59                  <1> 	pop	ecx
  2062 00006173 5E                  <1> 	pop	esi
  2063 00006174 5F                  <1> 	pop	edi
  2064                              <1> swpqs_retn:
  2065 00006175 C3                  <1> 	retn		
  2066                              <1> swpqs_7:
  2067 00006176 89F7                <1> 	mov	edi, esi ; head
  2068 00006178 AD                  <1> 	lodsd
  2069                              <1> 	; 20/07/2015
  2070 00006179 89C3                <1> 	mov	ebx, eax
  2071 0000617B 81E300F0FFFF        <1> 	and	ebx, ~PAGE_OFF ; ~0FFFh 
  2072                              <1> 		      ; ebx = virtual address (at page boundary)	
  2073 00006181 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 0FFFh
  2074                              <1> 		      ; ax = process number (1 to 4095)
  2075 00006186 3A05[B3030300]      <1> 	cmp	al, [u.uno]
  2076                              <1> 		; Max. 16 (nproc) processes for Retro UNIX 386 v1
  2077 0000618C 7507                <1> 	jne	short swpqs_8
  2078 0000618E A1[B8030300]        <1> 	mov	eax, [u.pgdir]
  2079 00006193 EB28                <1> 	jmp	short swpqs_9
  2080                              <1> swpqs_8:
  2081                              <1> 	; 09/06/2016
  2082 00006195 80B8[AF000300]00    <1> 	cmp	byte [eax+p.stat-1], 0
  2083 0000619C 76C4                <1> 	jna	short swpqs_3     ; free (or terminated) process
  2084 0000619E 80B8[AF000300]02    <1> 	cmp	byte [eax+p.stat-1], 2 ; waiting
  2085 000061A5 77BB                <1> 	ja	short swpqs_3 	  ; zombie (3) or undefined ?	
  2086                              <1> 
  2087                              <1> 	;shl	ax, 2
  2088 000061A7 C0E002              <1> 	shl	al, 2
  2089 000061AA 8B80[BC000300]      <1> 	mov 	eax, [eax+p.upage-4]
  2090 000061B0 09C0                <1> 	or	eax, eax
  2091 000061B2 74AE                <1> 	jz	short swpqs_3 ; invalid upage
  2092 000061B4 83C05C              <1> 	add	eax, u.pgdir - user
  2093                              <1> 			 ; u.pgdir value for the process
  2094                              <1> 			 ; is in [eax]
  2095 000061B7 8B00                <1> 	mov	eax, [eax]
  2096 000061B9 21C0                <1> 	and	eax, eax
  2097 000061BB 74A5                <1> 	jz	short swpqs_3 ; invalid page directory
  2098                              <1> swpqs_9:
  2099 000061BD 52                  <1> 	push	edx
  2100                              <1> 	; eax = page directory
  2101                              <1> 	; ebx = virtual address
  2102 000061BE E82BFBFFFF          <1> 	call	get_pte
  2103 000061C3 89D3                <1> 	mov	ebx, edx	; PTE address
  2104 000061C5 5A                  <1> 	pop	edx
  2105                              <1> 	; 10/06/2016
  2106 000061C6 723A                <1> 	jc	short swpqs_13 ; empty PDE
  2107                              <1> 	; EAX = PTE value
  2108 000061C8 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0 = 1
  2109 000061CA 7436                <1> 	jz	short swpqs_13  ; Drop non-present page
  2110                              <1> 			        ; from the queue (head)
  2111 000061CC A802                <1> 	test	al, PTE_A_WRITE	; bit 1 = 0 (read only)
  2112 000061CE 7432                <1> 	jz	short swpqs_13  ; Drop read only page
  2113                              <1> 			        ; from the queue (head) 	
  2114                              <1> 	;test	al, PTE_A_ACCESS ; bit 5 = 1 (Accessed)
  2115                              <1> 	;jnz	short swpqs_11  ; present
  2116                              <1> 			        ; accessed page
  2117 000061D0 0FBAF005            <1>         btr     eax, PTE_A_ACCESS_BIT ; reset 'accessed' bit
  2118 000061D4 7210                <1> 	jc	short swpqs_11  ; accessed page
  2119                              <1> 
  2120 000061D6 49                  <1> 	dec	ecx
  2121 000061D7 66890D[60050300]    <1> 	mov	[swpq_count], cx
  2122 000061DE 7402                <1>         jz      short swpqs_10
  2123                              <1> 		; esi = head + 4
  2124                              <1> 		; edi = head
  2125 000061E0 F3A5                <1> 	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  2126                              <1> swpqs_10:
  2127 000061E2 890F                <1> 	mov	[edi], ecx ; 0
  2128 000061E4 EB8C                <1> 	jmp	short swpqs_6 ; 26/03/2017
  2129                              <1> 
  2130                              <1> swpqs_11:
  2131 000061E6 8903                <1> 	mov	[ebx], eax     ; save changed attribute
  2132                              <1> 	; Rotation (head -> tail)
  2133 000061E8 49                  <1> 	dec	ecx     ; entry count -> last entry number		
  2134 000061E9 74F7                <1> 	jz	short swpqs_10
  2135                              <1> 		; esi = head + 4
  2136                              <1> 		; edi = head
  2137 000061EB 8B07                <1> 	mov	eax, [edi] ; 20/07/2015
  2138 000061ED F3A5                <1> 	rep	movsd	 ; n = 1 to k-1, [n - 1] = [n]
  2139 000061EF 8907                <1> 	mov	[edi], eax ; head -> tail ; [k] = [1]
  2140                              <1> 
  2141 000061F1 668B0D[60050300]    <1> 	mov	cx, [swpq_count]
  2142                              <1> 
  2143                              <1> swpqs_12:
  2144 000061F8 BE00E00800          <1> 	mov	esi, swap_queue ; head
  2145 000061FD E974FFFFFF          <1>         jmp     swpqs_7
  2146                              <1> 
  2147                              <1> swpqs_13:
  2148 00006202 49                  <1> 	dec	ecx
  2149 00006203 66890D[60050300]    <1> 	mov	[swpq_count], cx
  2150 0000620A 0F845EFFFFFF        <1>         jz      swpqs_5
  2151 00006210 EBE6                <1> 	jmp	short swpqs_12
  2152                              <1> 
  2153                              <1> add_to_swap_queue:
  2154                              <1> ; temporary - 16/09/2015
  2155 00006212 C3                  <1> retn
  2156                              <1> 	; 20/02/2017
  2157                              <1> 	; 20/07/2015
  2158                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2159                              <1> 	;
  2160                              <1> 	; Adds new page to swap queue
  2161                              <1> 	; (page directories and page tables must not be added
  2162                              <1> 	; to swap queue)	
  2163                              <1> 	;
  2164                              <1> 	; INPUT ->
  2165                              <1> 	;	EBX = Linear (Virtual) addr for current process
  2166                              <1> 	;	[u.uno]
  2167                              <1> 	;	20/02/2017
  2168                              <1> 	;	(Linear address = CORE + user's virtual address)
  2169                              <1> 	;
  2170                              <1> 	; OUTPUT ->
  2171                              <1> 	;	EAX = [swpq_count]
  2172                              <1> 	;	      (after the PTE has been added)
  2173                              <1> 	;	EAX = 0 -> Swap queue is full, (1024 entries)
  2174                              <1> 	;	      the PTE could not be added.
  2175                              <1> 	;
  2176                              <1> 	; Modified Registers -> EAX
  2177                              <1> 	;
  2178 00006213 53                  <1> 	push	ebx
  2179 00006214 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  2180 00006219 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; current process number
  2181 0000621F E814FFFFFF          <1> 	call	swap_queue_shift ; drop from the queue if
  2182                              <1> 				 ; it is already on the queue
  2183                              <1> 		; then add it to the tail of the queue
  2184 00006224 0FB705[60050300]    <1> 	movzx	eax, word [swpq_count]
  2185 0000622B 663D0004            <1> 	cmp	ax, 1024
  2186 0000622F 7205                <1> 	jb	short atsq_1
  2187 00006231 6629C0              <1> 	sub	ax, ax
  2188 00006234 5B                  <1> 	pop	ebx
  2189 00006235 C3                  <1> 	retn
  2190                              <1> atsq_1:
  2191 00006236 56                  <1> 	push	esi
  2192 00006237 BE00E00800          <1> 	mov	esi, swap_queue
  2193 0000623C 6621C0              <1> 	and	ax, ax
  2194 0000623F 740A                <1> 	jz	short atsq_2
  2195 00006241 66C1E002            <1> 	shl	ax, 2	; convert to offset
  2196 00006245 01C6                <1> 	add	esi, eax
  2197 00006247 66C1E802            <1> 	shr	ax, 2
  2198                              <1> atsq_2:
  2199 0000624B 6640                <1> 	inc	ax
  2200 0000624D 891E                <1> 	mov	[esi], ebx ; Virtual address + [u.uno] combination
  2201 0000624F 66A3[60050300]      <1> 	mov	[swpq_count], ax
  2202 00006255 5E                  <1> 	pop	esi
  2203 00006256 5B                  <1> 	pop	ebx
  2204 00006257 C3                  <1> 	retn
  2205                              <1> 
  2206                              <1> unlink_swap_block:
  2207                              <1> 	; 15/09/2015
  2208                              <1> 	; 30/04/2015
  2209                              <1> 	; 18/04/2015
  2210                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2211                              <1> 	;
  2212                              <1> 	; INPUT -> 
  2213                              <1> 	;	EAX = swap disk/file offset address
  2214                              <1> 	;	      (bit 1 to bit 31)
  2215                              <1> 	; OUTPUT ->
  2216                              <1> 	;	[swpd_free] is increased
  2217                              <1> 	;	(corresponding SWAP DISK ALLOC. TABLE bit is SET)
  2218                              <1> 	;
  2219                              <1> 	; Modified Registers -> EAX
  2220                              <1> 	;
  2221 00006258 53                  <1> 	push	ebx
  2222 00006259 52                  <1> 	push	edx
  2223                              <1> 	;
  2224 0000625A C1E804              <1> 	shr	eax, SECTOR_SHIFT+1  ;3+1 ; shift sector address to 
  2225                              <1> 				     ; 3 bits right
  2226                              <1> 				     ; to get swap block/page number
  2227 0000625D 89C2                <1> 	mov	edx, eax
  2228                              <1> 	; 15/09/2015
  2229 0000625F C1EA03              <1> 	shr	edx, 3		     ; to get offset to S.A.T.
  2230                              <1> 				     ; (1 allocation bit = 1 page)
  2231                              <1> 				     ; (1 allocation bytes = 8 pages)
  2232 00006262 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2233                              <1> 				     ; (to get 32 bit position)			
  2234                              <1> 	;
  2235 00006265 BB00000D00          <1> 	mov	ebx, swap_alloc_table ; Swap Allocation Table address
  2236 0000626A 01D3                <1> 	add	ebx, edx
  2237 0000626C 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only
  2238                              <1> 				     ; (allocation bit position)	 
  2239 0000626F 3B05[6E050300]      <1> 	cmp 	eax, [swpd_next]     ; is the new free block addr. lower
  2240                              <1> 				     ; than the address in 'swpd_next' ?
  2241                              <1> 				     ; (next/first free block value)		
  2242 00006275 7305                <1> 	jnb	short uswpbl_1	     ; no	
  2243 00006277 A3[6E050300]        <1> 	mov	[swpd_next], eax     ; yes	
  2244                              <1> uswpbl_1:
  2245 0000627C 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate block
  2246                              <1> 				     ; set relevant bit to 1.
  2247                              <1> 				     ; set CF to the previous bit value	
  2248 0000627F F5                  <1> 	cmc			     ; complement carry flag	
  2249 00006280 7206                <1> 	jc	short uswpbl_2	     ; do not increase swfd_free count
  2250                              <1> 				     ; if the block is already deallocated
  2251                              <1> 				     ; before.	
  2252 00006282 FF05[6A050300]      <1>         inc     dword [swpd_free]
  2253                              <1> uswpbl_2:
  2254 00006288 5A                  <1> 	pop	edx
  2255 00006289 5B                  <1> 	pop	ebx
  2256 0000628A C3                  <1> 	retn
  2257                              <1> 
  2258                              <1> link_swap_block:
  2259                              <1> 	; 01/07/2015
  2260                              <1> 	; 18/04/2015
  2261                              <1> 	; 24/10/2014 (Retro UNIX 386 v1 - beginning)
  2262                              <1> 	;
  2263                              <1> 	; INPUT -> none
  2264                              <1> 	;
  2265                              <1> 	; OUTPUT ->
  2266                              <1> 	;	EAX = OFFSET ADDRESS OF THE ALLOCATED BLOCK (4096 bytes)
  2267                              <1> 	;	      in sectors (corresponding 
  2268                              <1> 	;	      SWAP DISK ALLOCATION TABLE bit is RESET)
  2269                              <1> 	;
  2270                              <1> 	;	CF = 1 and EAX = 0 
  2271                              <1> 	; 		   if there is not a free block to be allocated	
  2272                              <1> 	;
  2273                              <1> 	; Modified Registers -> none (except EAX)
  2274                              <1> 	;
  2275                              <1> 
  2276                              <1> 	;mov	eax, [swpd_free]
  2277                              <1> 	;and	eax, eax
  2278                              <1> 	;jz	short out_of_swpspc
  2279                              <1> 	;
  2280 0000628B 53                  <1> 	push	ebx
  2281 0000628C 51                  <1> 	push	ecx
  2282                              <1> 	;
  2283 0000628D BB00000D00          <1> 	mov	ebx, swap_alloc_table ; Swap Allocation Table offset
  2284 00006292 89D9                <1> 	mov	ecx, ebx
  2285 00006294 031D[6E050300]      <1> 	add	ebx, [swpd_next] ; Free block searching starts from here
  2286                              <1> 				 ; next_free_swap_block >> 5
  2287 0000629A 030D[72050300]      <1> 	add	ecx, [swpd_last] ; Free block searching ends here
  2288                              <1> 				 ; (total_swap_blocks - 1) >> 5
  2289                              <1> lswbl_scan:
  2290 000062A0 39CB                <1> 	cmp	ebx, ecx
  2291 000062A2 770A                <1> 	ja	short lswbl_notfound
  2292                              <1> 	;
  2293 000062A4 0FBC03              <1> 	bsf	eax, [ebx] ; Scans source operand for first bit set (1).
  2294                              <1> 			   ; Clears ZF if a bit is found set (1) and 
  2295                              <1> 			   ; loads the destination with an index to
  2296                              <1> 			   ; first set bit. (0 -> 31) 
  2297                              <1> 			   ; Sets ZF to 1 if no bits are found set.
  2298                              <1> 	; 01/07/2015
  2299 000062A7 751C                <1> 	jnz	short lswbl_found ; ZF = 0 -> a free block has been found
  2300                              <1> 			 ;
  2301                              <1> 			 ; NOTE:  a Swap Disk Allocation Table bit 
  2302                              <1> 			 ;	  with value of 1 means 
  2303                              <1> 			 ;	  the corresponding page is free 
  2304                              <1> 			 ;	  (Retro UNIX 386 v1 feaure only!)
  2305 000062A9 83C304              <1> 	add	ebx, 4
  2306                              <1> 			 ; We return back for searching next page block
  2307                              <1> 			 ; NOTE: [swpd_free] is not ZERO; so, 
  2308                              <1> 			 ;	 we always will find at least 1 free block here.
  2309 000062AC EBF2                <1> 	jmp    	short lswbl_scan
  2310                              <1> 	;
  2311                              <1> lswbl_notfound:	
  2312 000062AE 81E900000D00        <1> 	sub	ecx, swap_alloc_table
  2313 000062B4 890D[6E050300]      <1> 	mov	[swpd_next], ecx ; next/first free page = last page 
  2314                              <1> 				 ; (unlink_swap_block procedure will change it)
  2315 000062BA 31C0                <1> 	xor	eax, eax
  2316 000062BC A3[6A050300]        <1> 	mov	[swpd_free], eax
  2317 000062C1 F9                  <1> 	stc
  2318                              <1> lswbl_ok:
  2319 000062C2 59                  <1> 	pop	ecx
  2320 000062C3 5B                  <1> 	pop	ebx
  2321 000062C4 C3                  <1> 	retn
  2322                              <1> 	;
  2323                              <1> ;out_of_swpspc:
  2324                              <1> ;	stc
  2325                              <1> ;	retn
  2326                              <1> 
  2327                              <1> lswbl_found:
  2328 000062C5 89D9                <1> 	mov	ecx, ebx
  2329 000062C7 81E900000D00        <1> 	sub	ecx, swap_alloc_table
  2330 000062CD 890D[6E050300]      <1> 	mov	[swpd_next], ecx ; Set first free block searching start
  2331                              <1> 				 ; address/offset (to the next)
  2332 000062D3 FF0D[6A050300]      <1>         dec     dword [swpd_free] ; 1 block has been allocated (X = X-1) 
  2333                              <1> 	;
  2334 000062D9 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  2335                              <1> 				 ; is copied into the Carry Flag and then cleared
  2336                              <1> 				 ; in the destination.
  2337                              <1> 				 ;
  2338                              <1> 				 ; Reset the bit which is corresponding to the 
  2339                              <1> 				 ; (just) allocated block.
  2340 000062DC C1E105              <1> 	shl	ecx, 5		 ; (block offset * 32) + block index
  2341 000062DF 01C8                <1> 	add	eax, ecx	 ; = block number
  2342 000062E1 C1E003              <1> 	shl	eax, SECTOR_SHIFT ; 3, sector (offset) address of the block
  2343                              <1> 				 ; 1 block =  8 sectors
  2344                              <1> 	;
  2345                              <1> 	; EAX = offset address of swap disk/file sector (beginning of the block)
  2346                              <1> 	;
  2347                              <1> 	; NOTE: The relevant page table entry will be updated
  2348                              <1> 	;       according to this EAX value...
  2349                              <1> 	;
  2350 000062E4 EBDC                <1> 	jmp	short lswbl_ok
  2351                              <1> 
  2352                              <1> logical_disk_read:
  2353                              <1> 	; 20/07/2015
  2354                              <1> 	; 09/03/2015 (temporary code here)
  2355                              <1> 	;
  2356                              <1> 	; INPUT ->
  2357                              <1> 	; 	ESI = Logical disk description table address
  2358                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  2359                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  2360                              <1> 	; 	ECX = Sector count
  2361                              <1> 	;
  2362                              <1> 	;
  2363 000062E6 C3                  <1> 	retn
  2364                              <1> 
  2365                              <1> logical_disk_write:
  2366                              <1> 	; 20/07/2015
  2367                              <1> 	; 09/03/2015 (temporary code here)
  2368                              <1> 	;
  2369                              <1> 	; INPUT ->
  2370                              <1> 	; 	ESI = Logical disk description table address
  2371                              <1> 	; 	EBX = Memory page (buffer) address (physical!)
  2372                              <1> 	; 	EAX = Sector adress (offset address, logical sector number)
  2373                              <1> 	; 	ECX = Sector count
  2374                              <1> 	;
  2375 000062E7 C3                  <1> 	retn
  2376                              <1> 
  2377                              <1> get_physical_addr:
  2378                              <1> 	; 26/03/2017
  2379                              <1> 	; 20/02/2017
  2380                              <1> 	; 27/05/2016 - TRDOS 386 (TRDOS v2.0)
  2381                              <1> 	; 18/10/2015
  2382                              <1> 	; 29/07/2015
  2383                              <1> 	; 20/07/2015
  2384                              <1> 	; 04/06/2015
  2385                              <1> 	; 20/05/2015
  2386                              <1> 	; 28/04/2015
  2387                              <1> 	; 18/04/2015
  2388                              <1> 	; Get physical address
  2389                              <1> 	;     (allocates a new page for user if it is not present)
  2390                              <1> 	;	
  2391                              <1> 	; (This subroutine is needed for mapping user's virtual 
  2392                              <1> 	; (buffer) address to physical address (of the buffer).)
  2393                              <1> 	; ('sys write', 'sys read' system calls...)
  2394                              <1> 	;
  2395                              <1> 	; INPUT ->
  2396                              <1> 	;	EBX = virtual address
  2397                              <1> 	;	u.pgdir = page directory (physical) address
  2398                              <1> 	;
  2399                              <1> 	; OUTPUT ->
  2400                              <1> 	;	EAX = physical address 
  2401                              <1> 	;	EBX = linear address	
  2402                              <1> 	;	EDX = physical address of the page frame
  2403                              <1> 	;	      (with attribute bits)
  2404                              <1> 	;	ECX = byte count within the page frame
  2405                              <1> 	;
  2406                              <1> 	; Modified Registers -> EAX, EBX, ECX, EDX
  2407                              <1> 	;
  2408 000062E8 81C300004000        <1> 	add	ebx, CORE ; 18/10/2015
  2409                              <1> get_physical_addr_x: ; 27/05/2016
  2410 000062EE A1[B8030300]        <1> 	mov	eax, [u.pgdir]
  2411 000062F3 E8F6F9FFFF          <1> 	call	get_pte
  2412                              <1> 		; EDX = Page table entry address (if CF=0)
  2413                              <1> 	        ;       Page directory entry address (if CF=1)
  2414                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  2415                              <1> 		; EAX = Page table entry value (page address)
  2416                              <1> 		;	CF = 1 -> PDE not present or invalid ? 
  2417 000062F8 731C                <1> 	jnc	short gpa_1
  2418                              <1> 	;
  2419 000062FA E8D4F8FFFF          <1> 	call	allocate_page
  2420 000062FF 7248                <1> 	jc	short gpa_im_err  ; 'insufficient memory' error
  2421                              <1> gpa_0:
  2422 00006301 E847F9FFFF          <1> 	call 	clear_page
  2423                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  2424 00006306 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  2425                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  2426                              <1> 			   ; (user, writable, present page)	
  2427 00006308 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  2428 0000630A A1[B8030300]        <1> 	mov	eax, [u.pgdir]	
  2429 0000630F E8DAF9FFFF          <1> 	call	get_pte
  2430 00006314 7233                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  2431                              <1> gpa_1:
  2432                              <1> 	; EAX = PTE value, EDX = PTE address
  2433 00006316 A801                <1> 	test 	al, PTE_A_PRESENT
  2434 00006318 751F                <1> 	jnz	short gpa_3 ; 26/03/2017
  2435 0000631A 09C0                <1> 	or	eax, eax
  2436 0000631C 7456                <1> 	jz	short gpa_7  ; Allocate a new page
  2437                              <1> 	; 20/07/2015
  2438 0000631E 55                  <1> 	push	ebp
  2439 0000631F 89DD                <1> 	mov	ebp, ebx ; virtual (linear) address
  2440                              <1> 	; reload swapped page
  2441 00006321 E878000000          <1> 	call	reload_page ; 28/04/2015
  2442 00006326 5D                  <1> 	pop	ebp
  2443 00006327 724A                <1> 	jc	short gpa_retn
  2444                              <1> gpa_2:
  2445                              <1> 	; 26/03/2017
  2446                              <1> 	; 20/02/2017
  2447                              <1> 	; If a page will contain a Signal Response Byte
  2448                              <1> 	; it must not be swapped out, because
  2449                              <1> 	; timer service or irq callback service
  2450                              <1> 	; will write a signal return/response byte 
  2451                              <1> 	; directly by using physical address of Signal
  2452                              <1> 	; Response Byte.(Even if process is not running,
  2453                              <1> 	; or it is running with swapped out pages.)
  2454                              <1> 	;
  2455                              <1> 	; 'no_page_swap' will be set by 'systimer' or
  2456                              <1> 	; 'syscalbac' sistem functions/calls. (*)
  2457                              <1> 	;
  2458 00006329 803D[A29B0100]00    <1> 	cmp	byte [no_page_swap], 0
  2459 00006330 761D                <1> 	jna	short gpa_4 ; this page can be swapped out
  2460                              <1> 	; this page must not be swapped out
  2461                              <1> 	; but 'no_page_swap' must be reset here
  2462                              <1> 	; imediately for other callers (*)
  2463                              <1> 	; (otherwise, swap queue would not be long enough) 
  2464 00006332 E84B000000          <1> 	call	gpa_8 ; 26/03/2017
  2465 00006337 EB1D                <1> 	jmp	short gpa_5
  2466                              <1> gpa_3: 
  2467                              <1> 	; 26/03/2017
  2468 00006339 803D[A29B0100]00    <1> 	cmp	byte [no_page_swap], 0
  2469 00006340 7618                <1> 	jna	short gpa_6 ; this page can be swapped out
  2470 00006342 E83B000000          <1> 	call	gpa_8
  2471 00006347 EB11                <1> 	jmp	short gpa_6
  2472                              <1> 
  2473                              <1> gpa_im_err:	
  2474 00006349 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  2475                              <1> 				  ; Major error = 0 (No protection fault)	
  2476 0000634E C3                  <1> 	retn
  2477                              <1> gpa_4:
  2478                              <1> 	; 20/07/2015
  2479                              <1> 	; 20/05/2015
  2480                              <1> 	; add this page to swap queue
  2481 0000634F 50                  <1> 	push	eax 
  2482                              <1> 	; EBX = Linear (CORE+virtual) address ; 20/02/2017 
  2483 00006350 E8BDFEFFFF          <1> 	call 	add_to_swap_queue
  2484 00006355 58                  <1> 	pop	eax
  2485                              <1> gpa_5:
  2486                              <1> 		; PTE address in EDX
  2487                              <1> 		; virtual address in EBX
  2488                              <1> 	; EAX = memory page address
  2489 00006356 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_USER + PTE_A_WRITE
  2490                              <1> 				  ; present flag, bit 0 = 1
  2491                              <1> 				  ; user flag, bit 2 = 1	
  2492                              <1> 				  ; writable flag, bit 1 = 1
  2493 00006358 8902                <1> 	mov	[edx], eax  ; Update PTE value
  2494                              <1> gpa_6:
  2495                              <1> 	; 18/10/2015
  2496 0000635A 89D9                <1> 	mov	ecx, ebx
  2497 0000635C 81E1FF0F0000        <1> 	and	ecx, PAGE_OFF
  2498 00006362 89C2                <1> 	mov 	edx, eax
  2499 00006364 662500F0            <1> 	and	ax, PTE_A_CLEAR
  2500 00006368 01C8                <1> 	add	eax, ecx
  2501 0000636A F7D9                <1> 	neg	ecx ; 1 -> -1 (0FFFFFFFFh), 4095 (0FFFh) -> -4095
  2502 0000636C 81C100100000        <1> 	add	ecx, PAGE_SIZE
  2503 00006372 F8                  <1> 	clc
  2504                              <1> gpa_retn:
  2505 00006373 C3                  <1> 	retn
  2506                              <1> gpa_7:	
  2507 00006374 E85AF8FFFF          <1> 	call	allocate_page
  2508 00006379 72CE                <1> 	jc	short gpa_im_err ; 'insufficient memory' error
  2509 0000637B E8CDF8FFFF          <1> 	call	clear_page
  2510 00006380 EBA7                <1> 	jmp	short gpa_2
  2511                              <1> 
  2512                              <1> gpa_8: ; 26/03/2017
  2513 00006382 C605[A29B0100]00    <1> 	mov	byte [no_page_swap], 0
  2514 00006389 53                  <1> 	push	ebx
  2515 0000638A 50                  <1> 	push	eax ; 26/03/2017
  2516 0000638B 6681E300F0          <1>         and     bx, ~PAGE_OFF ; ~0FFFh ; reset bits, 0 to 11
  2517 00006390 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; current process number
  2518 00006396 E89DFDFFFF          <1> 	call	swap_queue_shift ; drop from the queue if
  2519                              <1> 				 ; it is already on the queue
  2520 0000639B 58                  <1> 	pop	eax ; 26/03/2017
  2521 0000639C 5B                  <1> 	pop	ebx
  2522 0000639D C3                  <1> 	retn
  2523                              <1> 
  2524                              <1> reload_page:
  2525                              <1> 	; 20/07/2015
  2526                              <1> 	; 28/04/2015 (Retro UNIX 386 v1 - beginning)
  2527                              <1> 	;
  2528                              <1> 	; Reload (Restore) swapped page at memory
  2529                              <1> 	;
  2530                              <1> 	; INPUT -> 
  2531                              <1> 	;	EBP = Virtual (linear) memory address
  2532                              <1> 	;	EAX = PTE value (swap disk sector address)
  2533                              <1> 	;	(Swap disk sector address = bit 1 to bit 31 of EAX)	
  2534                              <1> 	; OUTPUT ->
  2535                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS OF RELOADED PAGE
  2536                              <1> 	;
  2537                              <1> 	;	CF = 1 and EAX = error code
  2538                              <1> 	;
  2539                              <1> 	; Modified Registers -> none (except EAX)
  2540                              <1> 	;
  2541 0000639E D1E8                <1> 	shr	eax, 1   ; Convert PTE value to swap disk address 
  2542 000063A0 53                  <1> 	push	ebx      ;
  2543 000063A1 89C3                <1> 	mov	ebx, eax ; Swap disk (offset) address	
  2544 000063A3 E82BF8FFFF          <1> 	call	allocate_page
  2545 000063A8 720C                <1> 	jc	short rlp_im_err
  2546 000063AA 93                  <1> 	xchg 	eax, ebx	
  2547                              <1> 	; EBX = Physical memory (page) address
  2548                              <1> 	; EAX = Swap disk (offset) address
  2549                              <1> 	; EBP = Virtual (linear) memory address
  2550 000063AB E862FCFFFF          <1> 	call	swap_in
  2551 000063B0 720B                <1> 	jc	short rlp_swp_err  ; (swap disk/file read error)
  2552 000063B2 89D8                <1> 	mov	eax, ebx	
  2553                              <1> rlp_retn:
  2554 000063B4 5B                  <1> 	pop	ebx
  2555 000063B5 C3                  <1> 	retn
  2556                              <1> 	
  2557                              <1> rlp_im_err:	
  2558 000063B6 B804000000          <1> 	mov	eax, ERR_MINOR_IM ; Insufficient memory (minor) error!
  2559                              <1> 				  ; Major error = 0 (No protection fault)	
  2560 000063BB EBF7                <1> 	jmp	short rlp_retn
  2561                              <1> 
  2562                              <1> rlp_swp_err:
  2563 000063BD B828000000          <1> 	mov 	eax, SWP_DISK_READ_ERR ; Swap disk read error !
  2564 000063C2 EBF0                <1> 	jmp	short rlp_retn
  2565                              <1> 
  2566                              <1> 
  2567                              <1> copy_page_dir:
  2568                              <1> 	; 19/09/2015
  2569                              <1> 	; temporary - 07/09/2015
  2570                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  2571                              <1> 	;
  2572                              <1> 	; INPUT -> 
  2573                              <1> 	;	[u.pgdir] = PHYSICAL (real/flat) ADDRESS of the parent's
  2574                              <1> 	;		    page directory.
  2575                              <1> 	; OUTPUT ->
  2576                              <1> 	;	EAX =  PHYSICAL (real/flat) ADDRESS of the child's
  2577                              <1> 	;	       page directory.
  2578                              <1> 	;	(New page directory with new page table entries.)
  2579                              <1> 	;	(New page tables with read only copies of the parent's
  2580                              <1> 	;	pages.)
  2581                              <1> 	;	EAX = 0 -> Error (CF = 1)
  2582                              <1> 	;
  2583                              <1> 	; Modified Registers -> none (except EAX)
  2584                              <1> 	;
  2585 000063C4 E80AF8FFFF          <1> 	call	allocate_page
  2586 000063C9 723E                <1> 	jc	short cpd_err
  2587                              <1> 	;
  2588 000063CB 55                  <1> 	push	ebp ; 20/07/2015
  2589 000063CC 56                  <1> 	push	esi
  2590 000063CD 57                  <1> 	push	edi
  2591 000063CE 53                  <1> 	push	ebx
  2592 000063CF 51                  <1> 	push	ecx
  2593 000063D0 8B35[B8030300]      <1> 	mov	esi, [u.pgdir]
  2594 000063D6 89C7                <1> 	mov	edi, eax
  2595 000063D8 50                  <1> 	push	eax ; save child's page directory address
  2596                              <1> 	; copy PDE 0 from the parent's page dir to the child's page dir
  2597                              <1> 	; (use same system space for all user page tables) 
  2598 000063D9 A5                  <1> 	movsd
  2599 000063DA BD00004000          <1> 	mov	ebp, 1024*4096 ; pass the 1st 4MB (system space)
  2600 000063DF B9FF030000          <1> 	mov	ecx, (PAGE_SIZE / 4) - 1 ; 1023
  2601                              <1> cpd_0:	
  2602 000063E4 AD                  <1> 	lodsd
  2603                              <1> 	;or	eax, eax
  2604                              <1>         ;jnz     short cpd_1
  2605 000063E5 A801                <1> 	test	al, PDE_A_PRESENT ;  bit 0 =  1
  2606 000063E7 7508                <1> 	jnz	short cpd_1
  2607                              <1>  	; (virtual address at the end of the page table)	
  2608 000063E9 81C500004000        <1> 	add	ebp, 1024*4096 ; page size * PTE count
  2609 000063EF EB0F                <1> 	jmp	short cpd_2
  2610                              <1> cpd_1:	
  2611 000063F1 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear attribute bits
  2612 000063F5 89C3                <1> 	mov	ebx, eax
  2613                              <1> 	; EBX = Parent's page table address
  2614 000063F7 E81F000000          <1> 	call	copy_page_table
  2615 000063FC 720C                <1> 	jc	short cpd_p_err
  2616                              <1> 	; EAX = Child's page table address
  2617 000063FE 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  2618                              <1> 			 ; set bit 0, bit 1 and bit 2 to 1
  2619                              <1> 			 ; (present, writable, user)
  2620                              <1> cpd_2:
  2621 00006400 AB                  <1> 	stosd
  2622 00006401 E2E1                <1> 	loop	cpd_0
  2623                              <1> 	;
  2624 00006403 58                  <1> 	pop	eax  ; restore child's page directory address
  2625                              <1> cpd_3:
  2626 00006404 59                  <1> 	pop	ecx
  2627 00006405 5B                  <1> 	pop	ebx
  2628 00006406 5F                  <1> 	pop	edi
  2629 00006407 5E                  <1> 	pop	esi
  2630 00006408 5D                  <1> 	pop	ebp
  2631                              <1> cpd_err:
  2632 00006409 C3                  <1> 	retn
  2633                              <1> cpd_p_err:
  2634                              <1> 	; release the allocated pages missing (recover free space)
  2635 0000640A 58                  <1> 	pop	eax  ; the new page directory address (physical)
  2636 0000640B 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; parent's page directory address 
  2637 00006411 E8F6F8FFFF          <1> 	call 	deallocate_page_dir
  2638 00006416 29C0                <1> 	sub	eax, eax ; 0
  2639 00006418 F9                  <1> 	stc
  2640 00006419 EBE9                <1> 	jmp	short cpd_3	
  2641                              <1> 
  2642                              <1> copy_page_table:
  2643                              <1> 	; 19/09/2015
  2644                              <1> 	; temporary - 07/09/2015
  2645                              <1> 	; 07/09/2015 (Retro UNIX 386 v1 - beginning)
  2646                              <1> 	;
  2647                              <1> 	; INPUT -> 
  2648                              <1> 	;	EBX = PHYSICAL (real/flat) ADDRESS of the parent's page table.
  2649                              <1> 	;	EBP = page table entry index (from 'copy_page_dir')
  2650                              <1> 	; OUTPUT ->
  2651                              <1> 	;	EAX = PHYSICAL (real/flat) ADDRESS of the child's page table.
  2652                              <1> 	;	EBP = (recent) page table index (for 'add_to_swap_queue')	
  2653                              <1> 	;	CF = 1 -> error 
  2654                              <1> 	;
  2655                              <1> 	; Modified Registers -> EBP (except EAX)
  2656                              <1> 	;
  2657 0000641B E8B3F7FFFF          <1> 	call	allocate_page
  2658 00006420 725A                <1> 	jc	short cpt_err
  2659                              <1> 	;
  2660 00006422 50                  <1> 	push	eax ; *
  2661                              <1> 	;push 	ebx
  2662 00006423 56                  <1> 	push	esi
  2663 00006424 57                  <1> 	push	edi
  2664 00006425 52                  <1> 	push	edx
  2665 00006426 51                  <1> 	push	ecx
  2666                              <1> 	;
  2667 00006427 89DE                <1> 	mov	esi, ebx
  2668 00006429 89C7                <1> 	mov	edi, eax
  2669 0000642B 89C2                <1> 	mov	edx, eax
  2670 0000642D 81C200100000        <1> 	add	edx, PAGE_SIZE 	
  2671                              <1> cpt_0:
  2672 00006433 AD                  <1> 	lodsd
  2673 00006434 A801                <1> 	test	al, PTE_A_PRESENT ;  bit 0 =  1
  2674 00006436 750B                <1> 	jnz	short cpt_1
  2675 00006438 21C0                <1> 	and	eax, eax
  2676 0000643A 7430                <1> 	jz	short cpt_2
  2677                              <1> 	; ebp = virtual (linear) address of the memory page
  2678 0000643C E85DFFFFFF          <1> 	call	reload_page ; 28/04/2015
  2679 00006441 7234                <1> 	jc	short cpt_p_err
  2680                              <1> cpt_1:
  2681 00006443 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; clear attribute bits
  2682 00006447 89C1                <1> 	mov	ecx, eax
  2683                              <1> 	; Allocate a new page for the child process
  2684 00006449 E885F7FFFF          <1> 	call	allocate_page
  2685 0000644E 7227                <1> 	jc	short cpt_p_err
  2686 00006450 57                  <1> 	push	edi
  2687 00006451 56                  <1> 	push	esi
  2688 00006452 89CE                <1> 	mov	esi, ecx
  2689 00006454 89C7                <1> 	mov	edi, eax
  2690 00006456 B900040000          <1> 	mov	ecx, PAGE_SIZE/4
  2691 0000645B F3A5                <1> 	rep	movsd	; copy page (4096 bytes)
  2692 0000645D 5E                  <1> 	pop	esi
  2693 0000645E 5F                  <1> 	pop	edi
  2694                              <1> 	; 
  2695 0000645F 53                  <1> 	push	ebx
  2696 00006460 50                  <1> 	push	eax
  2697 00006461 89EB                <1> 	mov	ebx, ebp
  2698                              <1> 	; ebx = virtual address of the memory page
  2699 00006463 E8AAFDFFFF          <1> 	call	add_to_swap_queue
  2700 00006468 58                  <1> 	pop	eax
  2701 00006469 5B                  <1> 	pop	ebx
  2702                              <1> 	;
  2703                              <1> 	;or	ax, PTE_A_USER+PTE_A_PRESENT 
  2704 0000646A 0C07                <1> 	or	al, PTE_A_USER+PTE_A_WRITE+PTE_A_PRESENT 
  2705                              <1> cpt_2:
  2706 0000646C AB                  <1> 	stosd  ; EDI points to child's PTE  	 
  2707                              <1> 	;
  2708 0000646D 81C500100000        <1> 	add	ebp, 4096 ; 20/07/2015 (next page)
  2709                              <1> 	;
  2710 00006473 39D7                <1> 	cmp	edi, edx
  2711 00006475 72BC                <1> 	jb	short cpt_0
  2712                              <1> cpt_p_err:
  2713 00006477 59                  <1> 	pop	ecx
  2714 00006478 5A                  <1> 	pop	edx
  2715 00006479 5F                  <1> 	pop	edi
  2716 0000647A 5E                  <1> 	pop	esi
  2717                              <1> 	;pop	ebx
  2718 0000647B 58                  <1> 	pop	eax ; *
  2719                              <1> cpt_err:
  2720 0000647C C3                  <1> 	retn
  2721                              <1> 
  2722                              <1> allocate_memory_block:
  2723                              <1> 	; 01/05/2017
  2724                              <1> 	; 28/04/2017
  2725                              <1> 	; 25/04/2017
  2726                              <1> 	; 01/04/2016, 02/04/2016, 03/04/2016
  2727                              <1> 	; 13/03/2016, 14/03/2016
  2728                              <1> 	; 12/03/2016 (TRDOS 386 = TRDOS v2.0)
  2729                              <1> 	; Allocating contiguous memory pages (in the kernel's memory space)
  2730                              <1> 	;
  2731                              <1> 	; INPUT -> 
  2732                              <1> 	;	EAX = Beginning address (physical)
  2733                              <1> 	;	EAX = 0 -> Allocate memory block from the first proper aperture	
  2734                              <1> 	;	ECX = Number of bytes to be allocated
  2735                              <1> 	;
  2736                              <1> 	; OUTPUT ->
  2737                              <1> 	; 	1) cf = 0 -> successful
  2738                              <1> 	;	EAX = Beginning (physical) address of the allocated memory block
  2739                              <1> 	;	ECX = Number of allocated bytes (rounded up to page borders) 
  2740                              <1> 	;	2) cf = 1 -> unsuccessful
  2741                              <1> 	;	 2.1) If EAX > 0 -> 
  2742                              <1> 	;	      (Number of requested pages is more than # of free pages
  2743                              <1> 	;	       but contiguous free pages -the aperture- is not enough!)	   	
  2744                              <1> 	;	      EAX = Beginning address of available aperture
  2745                              <1> 	;		    (one of all aperture with max. aperture size/length)		
  2746                              <1> 	;	      ECX = Size of available aperture (memory block) in bytes
  2747                              <1> 	;	 2.2) If EAX = 0 -> Out of memory error 
  2748                              <1> 	;	            (number of free pages is less than requested number)
  2749                              <1> 	;	      ECX = Total number of free bytes (free pages * 4096) 
  2750                              <1> 	;		    (It is not number of contiguous free bytes)	
  2751                              <1> 	;
  2752                              <1> 	; (Modified Registers -> EAX, ECX)
  2753                              <1> 	;
  2754                              <1> 	; PURPOSE: Loading a file at memory for copying or running etc.
  2755                              <1> 	; If this procedure returns with cf is set, ECX contains maximum
  2756                              <1> 	; available space and EAX contains the beginning address of it.
  2757                              <1> 	; If EAX has zero, ECX contains total number of free bytes.
  2758                              <1> 	; If requested block has been successfully allocated (by rounding up to
  2759                              <1> 	; the last page border), it must be deallocated later by using
  2760                              <1> 	; 'deallocate_memory_block' procedure.    
  2761                              <1> 
  2762 0000647D 52                  <1> 	push	edx ; *
  2763 0000647E BAFF0F0000          <1> 	mov	edx, PAGE_SIZE - 1   ; 4095
  2764 00006483 01D0                <1> 	add	eax, edx
  2765 00006485 01D1                <1> 	add	ecx, edx
  2766 00006487 C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  2767                              <1> 
  2768                              <1> 	; ECX = number of contiguous pages to be allocated
  2769 0000648A 8B15[D8890100]      <1> 	mov	edx, [free_pages]
  2770                              <1> 	; 01/05/2017
  2771                              <1> 	;or	ecx, ecx
  2772                              <1> 	;jz	short amb3
  2773                              <1> 	; If ECX=0, set cf to 1 and return with max. available mem block size
  2774                              <1> 
  2775 00006490 39D1                <1> 	cmp	ecx, edx
  2776 00006492 7760                <1> 	ja	short amb_3
  2777                              <1> 
  2778 00006494 C1E80C              <1> 	shr	eax, PAGE_SHIFT      ; 12
  2779                              <1> 
  2780 00006497 89C2                <1> 	mov	edx, eax 	     ; page number
  2781 00006499 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  2782                              <1> 				     ; (1 allocation bit = 1 page)
  2783                              <1> 				     ; (1 allocation bytes = 8 pages)
  2784 0000649C 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2785                              <1> 				     ; (to get 32 bit position)	
  2786 0000649F 53                  <1> 	push	ebx ; **
  2787                              <1> amb_0:
  2788 000064A0 890D[8C950100]      <1> 	mov	[mem_ipg_count], ecx ; initial (reset) value of page count
  2789 000064A6 890D[90950100]      <1> 	mov	[mem_pg_count], ecx
  2790 000064AC 31C9                <1> 	xor	ecx, ecx ; 0
  2791 000064AE 890D[94950100]      <1> 	mov	[mem_aperture], ecx ; 0
  2792 000064B4 890D[98950100]      <1> 	mov	[mem_max_aperture], ecx ; 0
  2793                              <1> 	
  2794 000064BA BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL   ; Memory Allocation Table address.
  2795 000064BF 3B15[DC890100]      <1> 	cmp	edx, [next_page]     ; Is the beginning page address lower
  2796                              <1> 				     ; than the address in 'next_page' ?
  2797                              <1> 				     ; (the first/next free page of user space)		
  2798 000064C5 7208                <1> 	jb	short amb_1
  2799 000064C7 3B15[E0890100]      <1> 	cmp 	edx, [last_page]     ; is the beginning page address higher
  2800                              <1> 				     ; than the address in 'last_page' ?
  2801                              <1> 				     ; (end of the memory)		
  2802 000064CD 7606                <1> 	jna	short amb_2	     ; no	
  2803                              <1> amb_1:
  2804 000064CF 8B15[DC890100]      <1> 	mov	edx, [next_page]     ; M.A.T. offset (1 M.A.T. byte = 8 pages)
  2805                              <1> amb_2:
  2806 000064D5 01D3                <1> 	add	ebx, edx
  2807                              <1> 
  2808                              <1> 	; 28/04/2017
  2809                              <1> 	;xor	ecx, ecx
  2810 000064D7 0FBC0B              <1> 	bsf	ecx, [ebx]	     ; 0 to 31
  2811 000064DA 89D0                <1> 	mov	eax, edx
  2812 000064DC C1E003              <1> 	shl	eax, 3		     ; *8	
  2813 000064DF 01C8                <1> 	add	eax, ecx	     ; beginning page number
  2814                              <1> 
  2815 000064E1 A3[9C950100]        <1> 	mov	[mem_pg_pos], eax    ; beginning page no (for curr. mem. aperture)
  2816 000064E6 A3[A0950100]        <1>  	mov	[mem_max_pg_pos], eax ; beginning page no for max. mem. aperture
  2817                              <1> 
  2818 000064EB 83E01F              <1> 	and	eax, 1Fh	     ; lower 5 bits only (0 to 31)
  2819                              <1> 				     ; (allocation bit position)	 
  2820 000064EE 750E                <1> 	jnz	short amb_4	     ; 0
  2821 000064F0 B120                <1> 	mov	cl, 32
  2822 000064F2 EB4B                <1> 	jmp	short amb_10
  2823                              <1> 
  2824                              <1> amb_3:	; out_of_memory
  2825 000064F4 31C0                <1> 	xor	eax, eax ; 0
  2826 000064F6 89D1                <1> 	mov	ecx, edx ; free pages
  2827 000064F8 C1E10C              <1> 	shl	ecx, PAGE_SHIFT
  2828 000064FB 5A                  <1> 	pop	edx ; *
  2829 000064FC F9                  <1> 	stc
  2830 000064FD C3                  <1> 	retn	
  2831                              <1> amb_4:
  2832 000064FE 8B13                <1> 	mov	edx, [ebx]
  2833 00006500 88C1                <1> 	mov	cl, al ; 1 to 31
  2834 00006502 D3EA                <1> 	shr	edx, cl
  2835 00006504 89D0                <1> 	mov	eax, edx
  2836                              <1> amb_5:
  2837 00006506 D1E8                <1> 	shr	eax, 1 ; (***)
  2838 00006508 7317                <1> 	jnc	short amb_7
  2839 0000650A FF05[94950100]      <1> 	inc	dword [mem_aperture]
  2840 00006510 FF0D[90950100]      <1> 	dec	dword [mem_pg_count]
  2841 00006516 7470                <1> 	jz	short amb_15
  2842                              <1> amb_6:
  2843                              <1> 	; 28/04/2017
  2844 00006518 FEC1                <1> 	inc	cl
  2845 0000651A 80F920              <1> 	cmp	cl, 32
  2846 0000651D 730D                <1> 	jnb	short amb_9
  2847 0000651F EBE5                <1> 	jmp	short amb_5
  2848                              <1> amb_7:
  2849 00006521 50                  <1> 	push	eax ; (***) allocation bits (in shifted status)
  2850 00006522 E81B010000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  2851 00006527 58                  <1> 	pop	eax ; (***)
  2852 00006528 EBEE                <1> 	jmp	short amb_6
  2853                              <1> amb_8:
  2854                              <1> 	; 28/04/2017
  2855 0000652A B120                <1> 	mov	cl, 32
  2856                              <1> amb_9:
  2857 0000652C 89DA                <1> 	mov	edx, ebx
  2858 0000652E 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL
  2859 00006534 3B15[E0890100]      <1> 	cmp	edx, [last_page]
  2860 0000653A 7336                <1> 	jnb	short amb_14 ; contiguous pages not enough
  2861 0000653C 83C304              <1> 	add	ebx, 4
  2862                              <1> amb_10:
  2863 0000653F 8B03                <1> 	mov	eax, [ebx]
  2864 00006541 21C0                <1> 	and 	eax, eax
  2865 00006543 7408                <1>         jz      short amb_11 ; there is not a free page bit in this alloc dword
  2866 00006545 40                  <1> 	inc	eax ; 0FFFFFFFFh -> 0
  2867 00006546 740C                <1> 	jz	short amb_12 ; all of bits are set (32 free pages)
  2868 00006548 48                  <1> 	dec	eax
  2869 00006549 28C9                <1> 	sub	cl, cl ; 0
  2870 0000654B EBB9                <1> 	jmp	short amb_5
  2871                              <1> amb_11:
  2872 0000654D E8F0000000          <1> 	call	amb_26 ; set maximum memory aperture (free memory block size)
  2873 00006552 EBD8                <1> 	jmp	short amb_9	
  2874                              <1> amb_12:
  2875 00006554 390D[90950100]      <1> 	cmp	[mem_pg_count], ecx ; 32
  2876 0000655A 7306                <1> 	jnb	short amb_13
  2877 0000655C 8B0D[90950100]      <1> 	mov	ecx, [mem_pg_count]
  2878                              <1> amb_13:
  2879 00006562 010D[94950100]      <1> 	add	[mem_aperture], ecx
  2880 00006568 290D[90950100]      <1> 	sub	[mem_pg_count], ecx
  2881 0000656E 7618                <1> 	jna	short amb_15
  2882 00006570 EBBA                <1> 	jmp	short amb_9 ; 01/05/2017
  2883                              <1> amb_14:
  2884 00006572 E8CB000000          <1> 	call	amb_26 ; 28/04/2017
  2885 00006577 A1[A0950100]        <1> 	mov	eax, [mem_max_pg_pos] ; begin address of max. mem aperture	
  2886 0000657C 8B0D[98950100]      <1> 	mov	ecx, [mem_max_aperture] ; max. (largest) memory aperture
  2887 00006582 F9                  <1> 	stc
  2888 00006583 E9AF000000          <1>         jmp     amb_25
  2889                              <1> 
  2890                              <1> amb_15: ; OK !
  2891 00006588 A1[9C950100]        <1> 	mov	eax, [mem_pg_pos]    ; Beginning address as page number
  2892 0000658D 8B0D[94950100]      <1> 	mov	ecx, [mem_aperture]  ; Free contiguous page count (>=1)
  2893                              <1> amb_16:
  2894                              <1> 	; allocate contiguous memory pages (via memory allocation table bits)
  2895 00006593 89C2                <1> 	mov	edx, eax
  2896                              <1> 	; 25/04/2017
  2897 00006595 C1EA03              <1> 	shr	edx, 3		 ; 8 pages in one allocation byte
  2898 00006598 80E2FC              <1> 	and	dl, 0FCh	 ; clear lower 2 bits
  2899                              <1> 				 ; (for dword/32bit positioning)	
  2900                              <1> 
  2901 0000659B BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  2902 000065A0 01D3                <1> 	add	ebx, edx
  2903 000065A2 83E01F              <1> 	and	eax, 1Fh ; 31
  2904                              <1> 	; 03/04/2016
  2905 000065A5 BA20000000          <1> 	mov	edx, 32
  2906 000065AA 28C2                <1> 	sub	dl, al
  2907 000065AC 39CA                <1> 	cmp	edx, ecx	 ; ecx >= 1
  2908 000065AE 7602                <1> 	jna	short amb_17
  2909 000065B0 89CA                <1> 	mov	edx, ecx
  2910                              <1> amb_17:
  2911 000065B2 29D1                <1> 	sub	ecx, edx
  2912 000065B4 51                  <1> 	push	ecx ; ***
  2913 000065B5 89D1                <1> 	mov	ecx, edx
  2914                              <1> amb_18:		
  2915 000065B7 0FB303              <1> 	btr	[ebx], eax	 ; The destination bit indexed by the source value
  2916                              <1> 				 ; is copied into the Carry Flag and then cleared
  2917                              <1> 				 ; in the destination.
  2918 000065BA FF0D[D8890100]      <1> 	dec     dword [free_pages] ; 1 page has been allocated (X = X-1) 
  2919 000065C0 49                  <1> 	dec	ecx
  2920 000065C1 7404                <1> 	jz	short amb_19
  2921 000065C3 FEC0                <1> 	inc	al
  2922 000065C5 EBF0                <1> 	jmp	short amb_18
  2923                              <1> amb_19:	
  2924 000065C7 59                  <1> 	pop	ecx ; ***
  2925 000065C8 21C9                <1> 	and	ecx, ecx ; 0 ?
  2926 000065CA 741E                <1> 	jz	short amb_22	
  2927                              <1> 	; 01/04/2016
  2928 000065CC B020                <1> 	mov	al, 32
  2929                              <1> amb_20:
  2930 000065CE 83C304              <1> 	add	ebx, 4
  2931 000065D1 39C1                <1> 	cmp	ecx, eax ; 32
  2932 000065D3 7305                <1> 	jnb	short amb_21
  2933                              <1> 	; ECX < 32
  2934 000065D5 28C0                <1> 	sub	al, al ; 0
  2935 000065D7 50                  <1> 	push	eax ; 0 ***
  2936 000065D8 EBDD                <1> 	jmp	short amb_18
  2937                              <1> amb_21:
  2938 000065DA 2905[D8890100]      <1> 	sub	[free_pages], eax   ; [free_pages] = [free_pages] - 32
  2939 000065E0 C70300000000        <1> 	mov	dword [ebx], 0	    ; reset 32 bits
  2940 000065E6 29C1                <1> 	sub	ecx, eax ; 32
  2941 000065E8 75E4                <1> 	jnz	short amb_20
  2942                              <1> amb_22:
  2943 000065EA A1[9C950100]        <1> 	mov	eax, [mem_pg_pos]   ; Beginning address as page number
  2944 000065EF 8B0D[94950100]      <1> 	mov	ecx, [mem_aperture] ; Free contiguous page count
  2945                              <1> 	; [next_page] update
  2946 000065F5 89C2                <1> 	mov	edx, eax
  2947                              <1> 	; 03/04/2016
  2948 000065F7 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  2949                              <1> 				     ; (1 allocation bit = 1 page)
  2950                              <1> 				     ; (1 allocation bytes = 8 pages)
  2951 000065FA 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  2952                              <1> 				     ; (to get 32 bit position)	
  2953 000065FD 3B15[DC890100]      <1> 	cmp	edx, [next_page] ; first free page pointer offset
  2954 00006603 7732                <1> 	ja	short amb_25
  2955 00006605 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  2956 0000660A 833C1300            <1> 	cmp	dword [ebx+edx], 0
  2957 0000660E 7721                <1> 	ja	short amb_24
  2958 00006610 89C2                <1> 	mov	edx, eax
  2959 00006612 01CA                <1> 	add	edx, ecx
  2960 00006614 C1EA03              <1> 	shr	edx, 3
  2961 00006617 80E2FC              <1> 	and	dl, 0FCh
  2962                              <1> amb_23:
  2963 0000661A 833C1300            <1> 	cmp	dword [ebx+edx], 0
  2964 0000661E 7711                <1> 	ja	short amb_24
  2965 00006620 83C204              <1> 	add	edx, 4
  2966 00006623 3B15[E0890100]      <1> 	cmp	edx, [last_page]    ; last page pointer offset
  2967 00006629 76EF                <1> 	jna	short amb_23
  2968 0000662B 8B15[E4890100]      <1> 	mov	edx, [first_page]   ; (for) beginning of user's space
  2969                              <1> amb_24:
  2970 00006631 8915[DC890100]      <1> 	mov	[next_page], edx
  2971                              <1> amb_25:
  2972 00006637 9C                  <1> 	pushf
  2973 00006638 C1E00C              <1> 	shl	eax, PAGE_SHIFT	     ; convert to phy. address in bytes
  2974 0000663B C1E10C              <1> 	shl	ecx, PAGE_SHIFT	     ; convert to byte counts
  2975 0000663E 9D                  <1> 	popf
  2976 0000663F 5B                  <1> 	pop	ebx ; **
  2977 00006640 5A                  <1> 	pop	edx ; *
  2978 00006641 C3                  <1> 	retn
  2979                              <1> 
  2980                              <1> amb_26:	; set maximum free memory aperture (free memory block size) 
  2981 00006642 89DA                <1> 	mov	edx, ebx ; current address
  2982 00006644 81EA00001000        <1> 	sub	edx, MEM_ALLOC_TBL ; MAT beginning address
  2983                              <1> 	; 02/04/2016 
  2984 0000664A C1E203              <1> 	shl	edx, 3 ; MAT byte offset * 8 = page number base
  2985 0000664D 01CA                <1> 	add	edx, ecx ; current page number (ecx = 0 to 32)
  2986                              <1> 	;
  2987 0000664F A1[94950100]        <1> 	mov	eax, [mem_aperture]
  2988 00006654 21C0                <1> 	and	eax, eax
  2989 00006656 7421                <1>         jz      short amb_27
  2990 00006658 C705[94950100]0000- <1>         mov     dword [mem_aperture], 0
  2990 00006660 0000                <1>
  2991 00006662 3B05[98950100]      <1> 	cmp	eax, [mem_max_aperture]
  2992 00006668 760F                <1> 	jna	short amb_27
  2993 0000666A A3[98950100]        <1> 	mov	[mem_max_aperture], eax
  2994                              <1> 	; 25/04/2017
  2995 0000666F A1[9C950100]        <1> 	mov	eax, [mem_pg_pos]
  2996                              <1> 	; EAX = Beginning page number of the max. aperture 
  2997 00006674 A3[A0950100]        <1> 	mov	[mem_max_pg_pos], eax
  2998                              <1> amb_27: 
  2999 00006679 8915[9C950100]      <1> 	mov	[mem_pg_pos], edx ; current page
  3000                              <1> 
  3001 0000667F A1[8C950100]        <1> 	mov	eax, [mem_ipg_count] ; initial (reset) value of page count
  3002 00006684 A3[90950100]        <1> 	mov	[mem_pg_count], eax
  3003                              <1> 
  3004 00006689 C3                  <1> 	retn
  3005                              <1> 
  3006                              <1> deallocate_memory_block:
  3007                              <1> 	; 03/04/2016
  3008                              <1> 	; 14/03/2016 (TRDOS 386 = TRDOS v2.0)
  3009                              <1> 	; Deallocating contiguous memory pages (in the kernel's memory space)
  3010                              <1> 	;
  3011                              <1> 	; INPUT -> 
  3012                              <1> 	;	EAX = Beginning address (physical)
  3013                              <1> 	;	ECX = Number of bytes to be deallocated
  3014                              <1> 	;
  3015                              <1> 	; OUTPUT ->
  3016                              <1> 	;	Memory Allocation Table bits will be updated
  3017                              <1> 	;	[free_pages] will be changed (increased)
  3018                              <1> 	;
  3019                              <1> 	; (Modified Registers -> EAX, ECX)
  3020                              <1> 	;
  3021                              <1> 	; PURPOSE: Unloading/Freeing a file -or an allocated memory block- 
  3022                              <1> 	; at memory after copying, running, saving, reading, writing etc.
  3023                              <1> 	;
  3024                              <1> 
  3025 0000668A 52                  <1> 	push	edx ; *
  3026 0000668B 53                  <1> 	push	ebx ; **
  3027                              <1> 
  3028 0000668C C1E80C              <1> 	shr	eax, PAGE_SHIFT	     ; 12
  3029 0000668F C1E90C              <1> 	shr	ecx, PAGE_SHIFT	     ; 12
  3030                              <1> 
  3031                              <1> 	; EAX = Beginning page number
  3032                              <1> 	; ECX = Number of contiguous pages to be deallocated
  3033                              <1> damb_0:
  3034                              <1> 	; deallocate contiguous memory pages (via memory allocation table bits)
  3035 00006692 89C2                <1> 	mov	edx, eax
  3036 00006694 C1EA03              <1> 	shr	edx, 3		     ; to get offset to M.A.T.
  3037                              <1> 				     ; (1 allocation bit = 1 page)
  3038                              <1> 				     ; (1 allocation bytes = 8 pages)
  3039 00006697 80E2FC              <1> 	and	dl, 0FCh 	     ; clear lower 2 bits
  3040                              <1> 				     ; (to get 32 bit position)	
  3041 0000669A 3B15[DC890100]      <1> 	cmp	edx, [next_page] ; next free page
  3042 000066A0 7306                <1> 	jnb	short damb_1
  3043 000066A2 8915[DC890100]      <1> 	mov	[next_page], edx
  3044                              <1> damb_1:
  3045 000066A8 BB00001000          <1> 	mov	ebx, MEM_ALLOC_TBL
  3046 000066AD 01D3                <1> 	add	ebx, edx
  3047 000066AF 83E01F              <1> 	and	eax, 1Fh ; 31
  3048                              <1> 
  3049                              <1> 	; 03/04/2016
  3050 000066B2 BA20000000          <1> 	mov	edx, 32
  3051 000066B7 28C2                <1> 	sub	dl, al
  3052 000066B9 39CA                <1> 	cmp	edx, ecx
  3053 000066BB 7602                <1> 	jna	short damb_2
  3054 000066BD 89CA                <1> 	mov	edx, ecx
  3055                              <1> damb_2:
  3056 000066BF 29D1                <1> 	sub	ecx, edx
  3057 000066C1 51                  <1> 	push	ecx ; ***
  3058 000066C2 89D1                <1> 	mov	ecx, edx
  3059                              <1> damb_3:		
  3060 000066C4 0FAB03              <1> 	bts	[ebx], eax	     ; unlink/release/deallocate page
  3061                              <1> 				     ; set relevant bit to 1.
  3062                              <1> 				     ; set CF to the previous bit value	
  3063 000066C7 FF05[D8890100]      <1> 	inc     dword [free_pages]   ; 1 page has been deallocated (X = X+1) 
  3064 000066CD 49                  <1> 	dec	ecx
  3065 000066CE 7404                <1> 	jz	short damb_4
  3066 000066D0 FEC0                <1> 	inc	al
  3067 000066D2 EBF0                <1> 	jmp	short damb_3
  3068                              <1> damb_4:	
  3069 000066D4 59                  <1> 	pop	ecx ; ***
  3070 000066D5 21C9                <1> 	and	ecx, ecx ; 0 ?
  3071 000066D7 741E                <1> 	jz	short damb_7
  3072                              <1> 	; 03/04/2016
  3073 000066D9 B020                <1> 	mov	al, 32
  3074                              <1> damb_5:
  3075 000066DB 83C304              <1> 	add	ebx, 4
  3076 000066DE 39C1                <1> 	cmp	ecx, eax ; 32
  3077 000066E0 7305                <1> 	jnb	short damb_6
  3078                              <1> 	; ECX < 32
  3079 000066E2 28C0                <1> 	sub	al, al ; 0
  3080 000066E4 50                  <1> 	push	eax ; 0 ***
  3081 000066E5 EBDD                <1> 	jmp	short damb_3
  3082                              <1> damb_6:
  3083 000066E7 0105[D8890100]      <1> 	add	[free_pages], eax ; [free_pages] = [free_pages] + 32
  3084 000066ED C703FFFFFFFF        <1> 	mov	dword [ebx], 0FFFFFFFFh ; set 32 bits
  3085 000066F3 29C1                <1> 	sub	ecx, eax ; 32
  3086 000066F5 75E4                <1> 	jnz	short damb_5
  3087                              <1> damb_7:
  3088 000066F7 5B                  <1> 	pop	ebx ; **
  3089 000066F8 5A                  <1> 	pop	edx ; *
  3090 000066F9 C3                  <1> 	retn
  3091                              <1> 
  3092                              <1> direct_memory_access:
  3093                              <1> 	; 22/07/2017
  3094                              <1> 	; 12/05/2017
  3095                              <1> 	; 16/07/2016
  3096                              <1> 	; 12/07/2016 (TRDOS 386 = TRDOS v2.0)
  3097                              <1> 	; This processure will be called to map
  3098                              <1> 	; user's (ring 3) page tables to access phsical
  3099                              <1> 	; (flat/linear) memory addresses, directly (without
  3100                              <1> 	;  kernel's data transfer functions).
  3101                              <1> 	; 
  3102                              <1> 	; Purpose: Video memory access and shared memory access.
  3103                              <1> 	;
  3104                              <1> 	; INPUT -> 
  3105                              <1> 	;	EAX = Beginning address (physical).
  3106                              <1> 	;	EBX = User's buffer address ; 12/05/2017
  3107                              <1> 	;	ECX = Number of contiguous pages to be mapped.
  3108                              <1> 	; OUTPUT ->
  3109                              <1> 	;	User's page directory and pages tables
  3110                              <1> 	;	will be updated.
  3111                              <1> 	;	
  3112                              <1> 	;	If an old page table entry has valid page address, 
  3113                              <1> 	;	that page will be deallocated just before PTE will
  3114                              <1> 	;	be changed for direct (1 to 1) memory page access.
  3115                              <1> 	;
  3116                              <1> 	;	If old PTE value points to a swapped page,
  3117                              <1>         ;       that page (block) will be unlinked on swap disk. 
  3118                              <1> 	;
  3119                              <1> 	;	Newly allocated pages (except page tables) will not
  3120                              <1> 	;	be applied to Memory Allocation Table.
  3121                              <1> 	;	AVL bit 1 (PTE bit 10) of page table entry will be
  3122                              <1> 	;	used to indicate shared (direct) memory page; then,
  3123                              <1> 	;	this page will not be deallocated later during
  3124                              <1> 	;	process termination. (Memory Allocation Table and
  3125                              <1> 	;	free memory count will not be affected.
  3126                              <1> 	;	(Except deallocating page table's itself.)
  3127                              <1> 	;	
  3128                              <1> 	;      CF = 1 -> error (EAX = error code)
  3129                              <1> 	;      CF = 0 -> success (EAX = beginning address)
  3130                              <1> 	;
  3131                              <1> 	;; (Modified Registers -> none)
  3132                              <1> 	; Modified registers: ebp, edx, ecx, ebx, esi, edi	
  3133                              <1> 	;
  3134                              <1> 
  3135                              <1> 	;push	ebp
  3136                              <1> 	;push	ebx
  3137                              <1> 	;push	ecx
  3138                              <1> 	;push	edx
  3139 000066FA 662500F0            <1> 	and	ax, PTE_A_CLEAR ; clear page offset
  3140 000066FE 50                  <1> 	push	eax
  3141                              <1> 	;and	ecx, ecx ; page count
  3142                              <1> 	;jz	dmem_acc_7  ; 'insufficient memory' error
  3143 000066FF 89C5                <1> 	mov	ebp, eax
  3144 00006701 81C300004000        <1> 	add	ebx, CORE ; 12/05/2017
  3145                              <1> dmem_acc_0: 
  3146 00006707 891D[8CA00100]      <1> 	mov	[base_addr], ebx ; 12/05/2017
  3147 0000670D A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; page dir address (physical)
  3148 00006712 E8D7F5FFFF          <1> 	call	get_pte
  3149                              <1> 		; EDX = Page table entry address (if CF=0)
  3150                              <1> 	        ;       Page directory entry address (if CF=1)
  3151                              <1> 		;       (Bit 0 value is 0 if PT is not present)
  3152                              <1> 		; EAX = Page table entry value (page address)
  3153                              <1> 		;	CF = 1 -> PDE not present or invalid ? 	
  3154 00006717 7324                <1> 	jnc	short dmem_acc_1
  3155                              <1> 	;
  3156 00006719 E8B5F4FFFF          <1> 	call	allocate_page
  3157 0000671E 0F82AB000000        <1>         jc      dmem_acc_7  ; 'insufficient memory' error
  3158                              <1> 	;
  3159 00006724 E824F5FFFF          <1> 	call 	clear_page
  3160                              <1> 	; EAX = Physical (base) address of the allocated (new) page
  3161 00006729 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER ; 4+2+1 = 7
  3162                              <1> 			   ; lower 3 bits are used as U/S, R/W, P flags
  3163                              <1> 			   ; (user, writable, present page)	
  3164 0000672B 8902                <1> 	mov	[edx], eax ; Let's put the new page directory entry here !
  3165 0000672D A1[B8030300]        <1> 	mov	eax, [u.pgdir]	
  3166 00006732 E8B7F5FFFF          <1> 	call	get_pte
  3167 00006737 0F8292000000        <1>         jc      dmem_acc_7 ; 'insufficient memory' error
  3168                              <1> dmem_acc_1:
  3169                              <1> 	; EAX = PTE value, EDX = PTE address
  3170 0000673D A801                <1> 	test 	al, PTE_A_PRESENT
  3171 0000673F 750D                <1> 	jnz	short dmem_acc_2
  3172 00006741 09C0                <1> 	or	eax, eax
  3173 00006743 7468                <1> 	jz	short dmem_acc_6   ; Change PTE
  3174 00006745 D1E8                <1> 	shr	eax, 1		; swap disk block (8 sectors) address
  3175                              <1> 	; unlink swap disk block
  3176 00006747 E80CFBFFFF          <1> 	call	unlink_swap_block
  3177 0000674C EB5F                <1> 	jmp	short dmem_acc_6
  3178                              <1> 
  3179                              <1> dmem_acc_2:
  3180 0000674E A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3181                              <1> 				  ; (must be 1)
  3182 00006750 7550                <1> 	jnz	short dmem_acc_4
  3183                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3184 00006752 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3185                              <1> 				   ; as child's page ?
  3186 00006756 7455                <1> 	jz	short dmem_acc_5 ; Change PTE but don't deallocate the page!
  3187                              <1> 
  3188                              <1> 	;push	edi
  3189                              <1> 	;push	esi
  3190                              <1> 
  3191 00006758 51                  <1> 	push	ecx
  3192                              <1> 	;push	ebx
  3193 00006759 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; parent's page dir address (physical)
  3194                              <1> 	
  3195                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3196 0000675F 89EF                <1> 	mov	edi, ebp
  3197 00006761 C1EF16              <1> 	shr	edi, PAGE_D_SHIFT ; 22
  3198                              <1> 	; EDI = page directory entry index (0-1023)
  3199 00006764 89EE                <1> 	mov	esi, ebp
  3200 00006766 C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; 12	
  3201 00006769 81E6FF030000        <1> 	and	esi, PTE_MASK
  3202                              <1> 	; ESI = page table entry index (0-1023)
  3203                              <1> 
  3204 0000676F 66C1E702            <1> 	shl	di, 2 ; * 4
  3205 00006773 01FB                <1> 	add	ebx, edi ; PDE offset (for the parent)
  3206 00006775 8B0F                <1> 	mov	ecx, [edi]
  3207 00006777 F6C101              <1> 	test	cl, PDE_A_PRESENT ; present (valid) or not ?
  3208 0000677A 7425                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  3209 0000677C 6681E100F0          <1> 	and	cx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3210 00006781 66C1E602            <1> 	shl	si, 2 ; *4 
  3211 00006785 01CE                <1> 	add	esi, ecx ; PTE offset (for the parent)
  3212 00006787 8B1E                <1> 	mov	ebx, [esi]
  3213 00006789 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3214 0000678C 7413                <1> 	jz	short dmem_acc_3	; parent process does not use this page
  3215 0000678E 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3216 00006792 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3217 00006797 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3218 00006799 7506                <1> 	jne	short dmem_acc_3	; not same page
  3219                              <1> 				; deallocate the child's page
  3220 0000679B 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  3221                              <1> 	;pop	ebx
  3222 0000679E 59                  <1> 	pop	ecx
  3223 0000679F EB0C                <1> 	jmp	short dmem_acc_5
  3224                              <1> dmem_acc_3:
  3225                              <1> 	;pop	ebx
  3226 000067A1 59                  <1> 	pop	ecx
  3227                              <1> dmem_acc_4:	
  3228 000067A2 66A90004            <1> 	test	ax, PTE_SHARED ; shared or direct memory access indicator
  3229 000067A6 7505                <1> 	jnz	short dmem_acc_5   ; AVL bit 1 = 1, do not deallocate this page!
  3230                              <1> 	;
  3231                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3232 000067A8 E804F6FFFF          <1> 	call	deallocate_page
  3233                              <1> dmem_acc_5:
  3234                              <1> 	;pop	esi
  3235                              <1> 	;pop	edi
  3236                              <1> dmem_acc_6:
  3237 000067AD 89E8                <1> 	mov	eax, ebp ; physical page (offset=0) address
  3238                              <1> 	; EAX = memory page address
  3239                              <1> 	; EDX = PTE entry address (physical)
  3240 000067AF 660D0704            <1> 	or	ax, PTE_A_PRESENT+PTE_A_USER+PTE_A_WRITE+PTE_SHARED
  3241                              <1> 			; present flag, bit 0 = 1
  3242                              <1> 			; user flag, bit 2 = 1	
  3243                              <1> 			; writable flag, bit 1 = 1
  3244                              <1> 			; direct memory access flag, bit 10 = 1
  3245                              <1> 			; (This page must not be deallocated!)
  3246 000067B3 8902                <1> 	mov	[edx], eax  ; Update PTE value
  3247 000067B5 49                  <1> 	dec	ecx ; remain count of contiguous pages
  3248 000067B6 741E                <1> 	jz	short dmem_acc_8
  3249 000067B8 81C500100000        <1> 	add	ebp, PAGE_SIZE ; next physical page address
  3250                              <1> 	; 22/07/2017
  3251                              <1> 	;mov	eax, ebp
  3252                              <1> 	; 12/05/2017
  3253 000067BE 8B1D[8CA00100]      <1> 	mov	ebx, [base_addr] ; linear address (virtual+CORE)
  3254 000067C4 81C300100000        <1> 	add	ebx, PAGE_SIZE	; next linear address
  3255 000067CA E938FFFFFF          <1>         jmp     dmem_acc_0
  3256                              <1> dmem_acc_7:  ; ERROR ! 
  3257 000067CF C7042404000000      <1> 	mov	dword [esp], ERR_MINOR_IM 
  3258                              <1> 		; Insufficient memory (minor) error!
  3259                              <1> 		; Major error = 0 (No protection fault)	
  3260                              <1> 	; cf = 1
  3261                              <1> dmem_acc_8:
  3262 000067D6 58                  <1> 	pop	eax
  3263                              <1> 	;pop	edx
  3264                              <1> 	;pop	ecx
  3265                              <1> 	;pop	ebx
  3266                              <1> 	;pop	ebp
  3267 000067D7 C3                  <1> 	retn
  3268                              <1> 
  3269                              <1> deallocate_user_pages:
  3270                              <1> 	; 20/05/2017
  3271                              <1> 	; 15/05/2017
  3272                              <1> 	; 20/02/2017
  3273                              <1> 	; 19/02/2017 (TRDOS 386 = TRDOS v2.0)
  3274                              <1> 	;
  3275                              <1> 	; Deallocate virtually contiguous user pages (memory block)
  3276                              <1> 	; (caller: 'sysdalloc' system call)
  3277                              <1> 	;
  3278                              <1> 	; INPUT ->
  3279                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
  3280                              <1> 	;	ECX = byte count
  3281                              <1> 	;	[u.pgdir] = user's page directory
  3282                              <1> 	;	[u.ppdir] = parent's page directory
  3283                              <1> 	;
  3284                              <1> 	; OUTPUT ->
  3285                              <1> 	;    If CF = 0 	
  3286                              <1> 	;	EAX = Deallocated memory bytes
  3287                              <1> 	;	  (Even if shared or read only pages will not be
  3288                              <1> 	;	   deallocated on M.A.T., this byte count will be
  3289                              <1> 	;	   returned as virtually deallocated bytes; in fact
  3290                              <1> 	;	   virtually deallocated user pages * 4096.) 
  3291                              <1> 	;	EBX = Virtual address (as rounded up)
  3292                              <1> 	;    If CF = 1    	
  3293                              <1> 	;	EAX = 0 (there is not any deallocated pages)
  3294                              <1> 	;
  3295                              <1> 	; Note: Empty page tables will not be deallocated!!!
  3296                              <1> 	;     (they will be deallocated at process termination stage)
  3297                              <1> 	;
  3298                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
  3299                              <1> 	;
  3300 000067D8 89DE                <1> 	mov	esi, ebx
  3301 000067DA 89F7                <1> 	mov	edi, esi
  3302 000067DC 01CF                <1> 	add	edi, ecx
  3303 000067DE 81C6FF0F0000        <1> 	add	esi, PAGE_SIZE - 1  ; 4095 (round up)	
  3304 000067E4 C1EE0C              <1> 	shr	esi, PAGE_SHIFT
  3305 000067E7 C1EF0C              <1> 	shr	edi, PAGE_SHIFT
  3306 000067EA 89F8                <1> 	mov	eax, edi ; end page
  3307 000067EC 29F0                <1> 	sub	eax, esi ; end page - start page
  3308 000067EE 0F86D5000000        <1> 	jna	da_u_pd_err  ; < 1
  3309 000067F4 89F3                <1> 	mov	ebx, esi
  3310 000067F6 C1E30C              <1> 	shl	ebx, PAGE_SHIFT ; virtual address (as rounded up)
  3311 000067F9 53                  <1> 	push	ebx ; *
  3312 000067FA 89C1                <1> 	mov	ecx, eax ; page count
  3313 000067FC C1E00C              <1> 	shl	eax, PAGE_SHIFT ; byte count as adjusted
  3314 000067FF 50                  <1> 	push	eax ; **
  3315 00006800 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
  3316 00006806 81C600040000        <1>  	add	esi, CORE/PAGE_SIZE 
  3317 0000680C 89F7                <1> 	mov	edi, esi
  3318 0000680E 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry in the page table
  3319 00006814 57                  <1> 	push	edi ; *** ; PTE index (of page directory)
  3320 00006815 C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
  3321 00006818 89F2                <1> 	mov	edx, esi 
  3322                              <1> 	; EDX = PDE index
  3323 0000681A C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
  3324 0000681D 01DE                <1> 	add	esi, ebx ; add page directory address
  3325                              <1> da_u_pd_1:
  3326 0000681F AD                  <1> 	lodsd
  3327                              <1> 	;
  3328 00006820 89F5                <1> 	mov	ebp, esi ; 20/02/2017
  3329                              <1> 	; EBP = next PDE address
  3330                              <1> 	;
  3331 00006822 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  3332 00006824 0F8494000000        <1> 	jz	da_u_pd_3 ; 20/05/2017	
  3333 0000682A 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3334                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
  3335 0000682E 8B3C24              <1> 	mov	edi, [esp] ; ***
  3336                              <1> 	; EDI = PTE index (of complete page directory)
  3337                              <1> 	;and	edi, PTE_MASK ; PTE entry in the page table
  3338 00006831 C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
  3339 00006834 89FE                <1> 	mov	esi, edi ; PTE offset in page table (0-4092)
  3340 00006836 01C6                <1> 	add	esi, eax ; now, esi points to requested PTE
  3341                              <1> da_u_pt_0:
  3342 00006838 AD                  <1> 	lodsd
  3343 00006839 A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  3344 0000683B 743F                <1> 	jz	short da_u_pt_1
  3345                              <1> 	;
  3346 0000683D A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3347                              <1> 				  ; (must be 1)
  3348 0000683F 7549                <1> 	jnz	short da_u_pt_3
  3349                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3350 00006841 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3351                              <1> 				   ; as child's page ?
  3352 00006845 744E                <1> 	jz	short da_u_pt_4 ; Clear PTE but don't deallocate the page!
  3353                              <1> 	;
  3354                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3355                              <1> 	; EDX = page directory entry index (0-1023)
  3356 00006847 52                  <1> 	push	edx ; ****
  3357                              <1> 	; EDI = page table entry offset (0-4092)
  3358 00006848 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  3359 0000684E 66C1E202            <1> 	shl	dx, 2 ; *4 
  3360 00006852 01D3                <1> 	add	ebx, edx ; PDE address (for the parent)
  3361 00006854 8B13                <1> 	mov	edx, [ebx] ; page table address
  3362 00006856 F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
  3363 00006859 742E                <1> 	jz	short da_u_pt_2	; parent process does not use this page
  3364 0000685B 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3365                              <1> 	; EDI = page table entry offset (0-4092)
  3366 00006860 01D7                <1> 	add	edi, edx	; PTE address (for the parent)
  3367 00006862 8B1F                <1> 	mov	ebx, [edi]
  3368 00006864 F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3369 00006867 7420                <1> 	jz	short da_u_pt_2	; parent process does not use this page
  3370 00006869 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3371 0000686D 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3372 00006872 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3373 00006874 7513                <1> 	jne	short da_u_pt_2	; not same page
  3374                              <1> 				; deallocate the child's page
  3375 00006876 800F02              <1>         or      byte [edi], PTE_A_WRITE ; convert to writable page (parent)
  3376 00006879 5A                  <1> 	pop	edx ; ****
  3377 0000687A EB19                <1> 	jmp	short da_u_pt_4
  3378                              <1> da_u_pt_1:
  3379 0000687C 09C0                <1> 	or	eax, eax	; swapped page ?
  3380 0000687E 741C                <1> 	jz	short da_u_pt_5	; no
  3381                              <1> 				; yes
  3382 00006880 D1E8                <1> 	shr	eax, 1
  3383 00006882 E8D1F9FFFF          <1> 	call	unlink_swap_block ; Deallocate swapped page block
  3384                              <1> 				  ; on the swap disk (or in file)
  3385 00006887 EB13                <1> 	jmp	short da_u_pt_5
  3386                              <1> da_u_pt_2:
  3387 00006889 5A                  <1> 	pop	edx ; ****
  3388                              <1> da_u_pt_3:
  3389 0000688A 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
  3390 0000688E 7505                <1> 	jnz	short da_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
  3391                              <1> 	;
  3392                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3393 00006890 E81CF5FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  3394                              <1> da_u_pt_4:
  3395 00006895 C746FC00000000      <1> 	mov	dword [esi-4], 0 ; clear/reset PTE (child, dupl. as parent)
  3396                              <1> da_u_pt_5:
  3397                              <1> 	; 20/05/2017
  3398 0000689C 58                  <1> 	pop	eax ; *** PTE index (of page directory)
  3399 0000689D 49                  <1> 	dec	ecx ; remain page count
  3400 0000689E 7426                <1> 	jz	short da_u_pd_4
  3401 000068A0 40                  <1> 	inc	eax ; next PTE
  3402 000068A1 6625FF03            <1> 	and	ax, PTE_MASK ; PTE entry index in the page table
  3403 000068A5 50                  <1> 	push	eax ; *** (save again)
  3404                              <1> 	;mov	edi, eax
  3405                              <1> 	;and 	di, PTE_MASK
  3406                              <1> 	;cmp	edi, PAGE_SIZE / 4 ; 1024
  3407                              <1> 	;jnb	short da_u_pd_2
  3408 000068A6 89C7                <1> 	mov	edi, eax
  3409 000068A8 C1E702              <1> 	shl	edi, 2 ; convert index to dword offset
  3410                              <1> 	;test	ax, PTE_MASK ; 3FFh
  3411 000068AB 09C0                <1> 	or	eax, eax
  3412 000068AD 7589                <1> 	jnz	short da_u_pt_0 ; 1-1023
  3413                              <1> da_u_pd_2:
  3414 000068AF 42                  <1> 	inc	edx
  3415                              <1> 	; 20/05/2017
  3416 000068B0 6681E2FF03          <1> 	and	dx, PTE_MASK  ; 3FFh
  3417 000068B5 740F                <1> 	jz	short da_u_pd_4  ; 0 (1024)
  3418                              <1> 	;cmp	edx, 1024
  3419                              <1> 	;jnb	short da_u_pd_4
  3420 000068B7 89EE                <1> 	mov	esi, ebp ; 20/02/2017
  3421 000068B9 E961FFFFFF          <1> 	jmp	da_u_pd_1
  3422                              <1> da_u_pd_3:
  3423                              <1> 	; 15/05/2017 (empty page directory entry)
  3424 000068BE 81E900040000        <1> 	sub	ecx, 1024
  3425 000068C4 77E9                <1> 	ja	short da_u_pd_2 ; 20/05/2017
  3426                              <1> da_u_pd_4:
  3427 000068C6 58                  <1> 	pop	eax ; **
  3428 000068C7 5B                  <1> 	pop	ebx ; *
  3429 000068C8 C3                  <1> 	retn
  3430                              <1> 
  3431                              <1> da_u_pd_err:
  3432 000068C9 31C0                <1> 	xor	eax, eax
  3433 000068CB F9                  <1> 	stc	
  3434 000068CC C3                  <1> 	retn
  3435                              <1> 
  3436                              <1> allocate_user_pages:
  3437                              <1> 	; 20/05/2017
  3438                              <1> 	; 01/05/2017, 02/05/2017, 15/05/2017
  3439                              <1> 	; 04/03/2017
  3440                              <1> 	; 20/02/2017 (TRDOS 386 = TRDOS v2.0)
  3441                              <1> 	;
  3442                              <1> 	; Allocate physically contiguous user pages (memory block)
  3443                              <1> 	; (caller: 'sysalloc' system call)
  3444                              <1> 	;
  3445                              <1> 	; Note: This procedure does not alloc a page's itself
  3446                              <1> 	;	(page bit) on Memory Allocation Table.
  3447                              <1> 	;	(allocate_memory_block is needed before this proc)
  3448                              <1> 	;
  3449                              <1> 	; INPUT ->
  3450                              <1> 	;	EAX = PHYSICAL ADDRESS (beginning address)
  3451                              <1> 	;	EBX = VIRTUAL ADDRESS (beginning address)
  3452                              <1> 	;	ECX = byte count (>=4096)
  3453                              <1> 	;	[u.pgdir] = user's page directory
  3454                              <1> 	;	
  3455                              <1> 	;	Note: All addresses are (must be) already adjusted
  3456                              <1> 	;	to page	borders, otherwise, lower 12bits of addresses
  3457                              <1> 	;	and byte count would be truncated.
  3458                              <1> 	;
  3459                              <1> 	; OUTPUT ->
  3460                              <1> 	;	none
  3461                              <1> 	;
  3462                              <1> 	;	CF = 1 -> insufficient memory error
  3463                              <1> 	;
  3464                              <1> 	; Note: All pages will be allocated in physical page order 
  3465                              <1> 	;	from the beginning page address. 
  3466                              <1> 	;	* A new page table will be added to the page dir
  3467                              <1> 	;	  when the requested PDE is invalid.
  3468                              <1> 	;	* Those pages will not be added to swap queue
  3469                              <1> 	;	  because main purpose of this allocation is to
  3470                              <1> 	;	  set a direct memory access (DMA controller) buffer.
  3471                              <1> 	;	 (Swapping out a page in a DMA buffer would be wrong!)
  3472                              <1> 	;	* Previous content of page tables (PTEs) would be
  3473                              <1> 	;	  (should be) deallocated before entering this
  3474                              <1> 	;	  procedure. So, new page table entries (PTEs)
  3475                              <1> 	;	  directly will be written without checking
  3476                              <1> 	;	  their previous content.	
  3477                              <1> 	;	* Only solution to increase free memory by removing
  3478                              <1> 	;	  that non-swappable memory block is to terminate
  3479                              <1> 	;	  the process or to wait until the process will 
  3480                              <1> 	;	  deallocate that memory block as itself. ('sysdalloc')
  3481                              <1> 	;	  (No problem, if the process does not grab all of
  3482                              <1> 	;	  -very big amount of- free memory by using
  3483                              <1> 	;	  'sysalloc' system call!?)
  3484                              <1> 	;	  (Even if the process has grabbed all of free memory, 
  3485                              <1> 	;	  no problem if the process is not running in 
  3486                              <1> 	;	  multitasking mode. No problem in multitasking
  3487                              <1> 	;	  mode if there is not another process which is running
  3488                              <1> 	;	  or waiting or sleeping for an event as it's pages
  3489                              <1> 	;	  are swapped-out. But a new process can not start to
  3490                              <1> 	;	  run if all of free memory has beeen allocated 
  3491                              <1> 	;	  by running processes. Deallocation -'sysdalloc'- 
  3492                              <1> 	;	  or terminate a running process is needed 
  3493                              <1> 	;	  in order to run a new process.) 
  3494                              <1> 	;
  3495                              <1> 	; Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP
  3496                              <1> 	;
  3497                              <1> 
  3498                              <1> 	; 01/05/2017
  3499 000068CD 662500F0            <1> 	and	ax, ~PAGE_OFF
  3500 000068D1 6681E300F0          <1> 	and	bx, ~PAGE_OFF
  3501                              <1> 	; 02/05/2017 
  3502 000068D6 BD00F0FFFF          <1> 	mov	ebp, 0FFFFF000h ; 4 Giga Bytes - 4096 Bytes (for Stack)
  3503 000068DB C1E90C              <1> 	shr	ecx, PAGE_SHIFT ; page count
  3504 000068DE 83F901              <1> 	cmp	ecx, 1
  3505 000068E1 7251                <1> 	jb	short a_u_im_retn
  3506 000068E3 89C2                <1> 	mov	edx, eax
  3507 000068E5 01CA                <1> 	add	edx, ecx
  3508 000068E7 724B                <1> 	jc	short a_u_im_retn
  3509 000068E9 39D5                <1> 	cmp	ebp, edx
  3510 000068EB 7247                <1> 	jb	short a_u_im_retn
  3511 000068ED 89DA                <1> 	mov	edx, ebx
  3512 000068EF 81C200004000        <1> 	add	edx, CORE
  3513 000068F5 723D                <1> 	jc	short a_u_im_retn	
  3514 000068F7 01CA                <1> 	add	edx, ecx
  3515 000068F9 7239                <1> 	jc	short a_u_im_retn
  3516 000068FB 39D5                <1> 	cmp	ebp, edx
  3517 000068FD 7235                <1> 	jb	short a_u_im_retn
  3518                              <1> 	;
  3519 000068FF 89C5                <1> 	mov	ebp, eax ; physical address
  3520 00006901 89DE                <1> 	mov	esi, ebx
  3521 00006903 81C600004000        <1> 	add	esi, CORE ; start of user's memory (4M) 
  3522 00006909 C1EE0C              <1> 	shr	esi, PAGE_SHIFT ; higher 20 bits of the linear address
  3523                              <1> 	;shr	ecx, PAGE_SHIFT ; page count
  3524 0000690C 8B1D[B8030300]      <1> 	mov	ebx, [u.pgdir] ; physical addr of user's page dir
  3525 00006912 89F7                <1> 	mov	edi, esi
  3526 00006914 81E7FF030000        <1> 	and	edi, PTE_MASK ; PTE entry index in the page table
  3527 0000691A 57                  <1> 	push	edi  ; * ; PTE index (in page directory)
  3528 0000691B C1EE0A              <1> 	shr	esi, PAGE_D_SHIFT - PAGE_SHIFT ; 22-12=10
  3529 0000691E 89F2                <1> 	mov	edx, esi 
  3530                              <1> 	; EDX = PDE index
  3531 00006920 C1E602              <1> 	shl	esi, 2 ; convert PDE index to dword offset
  3532 00006923 01DE                <1> 	add	esi, ebx ; add page directory address
  3533                              <1> a_u_pd_0:
  3534 00006925 AD                  <1> 	lodsd
  3535                              <1> 	;
  3536 00006926 89F3                <1> 	mov	ebx, esi ; next PDE address
  3537                              <1> 	;
  3538 00006928 A801                <1> 	test	al, PDE_A_PRESENT ; bit 0, present flag (must be 1)
  3539 0000692A 7513                <1> 	jnz	short a_u_pd_2
  3540                              <1> 	;
  3541                              <1> 	; empty PDE (it does not point to valid page table address)
  3542 0000692C E8A2F2FFFF          <1> 	call	allocate_page  ; (allocate a new page table)
  3543 00006931 7302                <1> 	jnc	short a_u_pd_1 ; OK... now, we have a new page table.
  3544                              <1> 	; cf = 1
  3545                              <1> 	; There is not a free memory page to allocate a new page table !!!
  3546 00006933 5E                  <1> 	pop	esi ; *
  3547                              <1> a_u_im_retn:
  3548 00006934 C3                  <1> 	retn	; return to 'sysalloc' with 'insufficient memory' error
  3549                              <1> 	;
  3550                              <1> a_u_pd_1: ; clear the new page table content 
  3551                              <1> 	; EAX = Physical (base) address of the new page table
  3552 00006935 E813F3FFFF          <1> 	call	clear_page ; Clear page content
  3553                              <1> 	;
  3554 0000693A 0C07                <1> 	or	al, PDE_A_PRESENT + PDE_A_WRITE + PDE_A_USER
  3555                              <1> 		 ; set bit 0, bit 1 and bit 2 to 1
  3556                              <1> 		 ; (present, writable, user)
  3557 0000693C 8946FC              <1> 	mov	[esi-4], eax
  3558                              <1> a_u_pd_2:
  3559 0000693F 662500F0            <1> 	and	ax, PDE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3560                              <1> 	; EAX = PHYSICAL (flat) ADDRESS OF THE PAGE TABLE
  3561 00006943 8B3C24              <1> 	mov	edi, [esp] ; *
  3562                              <1> 	; EDI = PTE index (of page directory)
  3563                              <1> 	;and	edi, PTE_MASK ; PTE entry index in the page table	
  3564                              <1> 	; EBX = next PDE address
  3565 00006946 89FE                <1> 	mov	esi, edi ; PTE index in page table (0-1023)
  3566 00006948 C1E702              <1> 	shl	edi, 2 ; convert PTE index to dword offset
  3567 0000694B 01C7                <1> 	add	edi, eax ; now, edi points to requested PTE
  3568                              <1> a_u_pt_0:
  3569                              <1> 	; 02/05/2017
  3570 0000694D 8B07                <1> 	mov	eax, [edi]
  3571                              <1> 	;
  3572 0000694F A801                <1> 	test	al, PTE_A_PRESENT ; bit 0, present flag (must be 1)
  3573 00006951 7445                <1> 	jz	short a_u_pt_1
  3574                              <1> 	;
  3575 00006953 A802                <1> 	test	al, PTE_A_WRITE   ; bit 1, writable (r/w) flag
  3576                              <1> 				  ; (must be 1)
  3577 00006955 7550                <1> 	jnz	short a_u_pt_3
  3578                              <1> 	; Read only -duplicated- page (belongs to a parent or a child)
  3579 00006957 66A90002            <1>         test    ax, PTE_DUPLICATED ; Was this page duplicated 
  3580                              <1> 				   ; as child's page ?
  3581 0000695B 7455                <1> 	jz	short a_u_pt_4	; Clear PTE but don't deallocate the page!
  3582                              <1> 	;
  3583                              <1> 	; check the parent's PTE value is read only & same page or not.. 
  3584                              <1> 	; EDX = page directory entry index (0-1023)
  3585 0000695D 52                  <1> 	push	edx ; **
  3586 0000695E 53                  <1> 	push	ebx ; ***
  3587                              <1> 	; ESI = page table entry index (0-1023)
  3588                              <1> 	;push	esi ; **** ; 20/05/2017
  3589 0000695F 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
  3590 00006965 66C1E202            <1> 	shl	dx, 2 ; *4 
  3591 00006969 01D3                <1> 	add	ebx, edx ; PTE address,0 (for the parent)
  3592 0000696B 8B13                <1> 	mov	edx, [ebx] ; page table address
  3593 0000696D F6C201              <1> 	test	dl, PDE_A_PRESENT ; present (valid) or not ?
  3594 00006970 7433                <1> 	jz	short a_u_pt_2	; parent process does not use this page
  3595 00006972 6681E200F0          <1> 	and	dx, PDE_A_CLEAR ; 0F000h ; Clear attribute bits
  3596 00006977 66C1E602            <1> 	shl	si, 2 ; *4
  3597                              <1> 	; ESI = page table entry offset (0-4092)
  3598 0000697B 01D6                <1> 	add	esi, edx	; PTE address (for the parent)
  3599 0000697D 8B1E                <1> 	mov	ebx, [esi]
  3600 0000697F F6C301              <1> 	test	bl, PTE_A_PRESENT ; present or not ?
  3601 00006982 7421                <1> 	jz	short a_u_pt_2	; parent process does not use this page
  3602 00006984 662500F0            <1> 	and	ax, PTE_A_CLEAR ; 0F000h ; Clear attribute bits 
  3603 00006988 6681E300F0          <1> 	and	bx, PTE_A_CLEAR ; 0F000h ; Clear attribute bits
  3604 0000698D 39D8                <1> 	cmp	eax, ebx	; parent's and child's pages are same ?
  3605 0000698F 7514                <1> 	jne	short a_u_pt_2	; not same page
  3606                              <1> 				; deallocate the child's page
  3607 00006991 800E02              <1>         or      byte [esi], PTE_A_WRITE ; convert to writable page (parent)
  3608                              <1> 	;pop	esi ; **** ; 20/05/2017
  3609 00006994 5B                  <1> 	pop	ebx ; ***
  3610 00006995 5A                  <1> 	pop	edx ; **
  3611 00006996 EB1A                <1> 	jmp	short a_u_pt_4
  3612                              <1> a_u_pt_1:
  3613 00006998 09C0                <1> 	or	eax, eax	; swapped page ?
  3614 0000699A 7416                <1> 	jz	short a_u_pt_4	; no
  3615                              <1> 				; yes
  3616 0000699C D1E8                <1> 	shr	eax, 1
  3617 0000699E E8B5F8FFFF          <1> 	call	unlink_swap_block ; Deallocate swapped page block
  3618                              <1> 				  ; on the swap disk (or in file)
  3619 000069A3 EB0D                <1> 	jmp	short a_u_pt_4
  3620                              <1> a_u_pt_2:
  3621                              <1> 	;pop	esi ; **** ; 20/05/2017
  3622 000069A5 5B                  <1> 	pop	ebx ; ***
  3623 000069A6 5A                  <1> 	pop	edx ; **
  3624                              <1> a_u_pt_3:
  3625 000069A7 66A90004            <1> 	test	ax, PTE_SHARED	; shared or direct memory access indicator
  3626 000069AB 7505                <1> 	jnz	short a_u_pt_4	; AVL bit 1 = 1, do not deallocate this page!
  3627                              <1> 	;
  3628                              <1> 	;and	ax, PTE_A_CLEAR ; 0F000h ; clear lower 12 (attribute) bits
  3629 000069AD E8FFF3FFFF          <1> 	call	deallocate_page ; set the mem allocation bit of this page
  3630                              <1> 	;
  3631                              <1> a_u_pt_4:
  3632 000069B2 89E8                <1> 	mov	eax, ebp ; physical address
  3633 000069B4 0C07                <1> 	or	al, PTE_A_PRESENT + PTE_A_WRITE + PTE_A_USER ; 04/03/2017
  3634 000069B6 AB                  <1> 	stosd
  3635 000069B7 5E                  <1> 	pop	esi ; * ; 20/05/2017
  3636 000069B8 49                  <1> 	dec	ecx ; remain page count
  3637 000069B9 7417                <1> 	jz	short a_u_pd_5
  3638 000069BB 81C500100000        <1> 	add	ebp, PAGE_SIZE
  3639 000069C1 46                  <1> 	inc	esi ; next PTE (index)
  3640                              <1> 	; 20/05/2017
  3641                              <1> 	;cmp	esi, PAGE_SIZE/4 ; 1024
  3642                              <1> 	;jb	short a_u_pt_0
  3643 000069C2 6681E6FF03          <1> 	and	si, PTE_MASK ; 3FFh (0 to 1023)
  3644 000069C7 56                  <1> 	push	esi ; *
  3645 000069C8 7583                <1> 	jnz	short a_u_pt_0 ; > 0 (<1024)
  3646                              <1> a_u_pd_3:
  3647 000069CA 42                  <1> 	inc	edx
  3648                              <1> ;	cmp	edx, 1024
  3649                              <1> ;	jnb	short a_u_pd_4 ; 02/05/2017 (error!, ecx > 0)
  3650 000069CB 89DE                <1> 	mov	esi, ebx ; the next PDE address
  3651 000069CD E953FFFFFF          <1> 	jmp	a_u_pd_0
  3652                              <1> a_u_pd_4:
  3653                              <1> 	; 02/05/2017
  3654                              <1> ;	stc
  3655                              <1> a_u_pd_5:
  3656                              <1> 	; 20/05/2017
  3657                              <1> 	;pop	edi ; *
  3658 000069D2 C3                  <1> 	retn
  3659                              <1> 
  3660                              <1> allocate_lfb_pages_for_kernel:
  3661                              <1> 	; 15/12/2020
  3662                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
  3663                              <1> 	; Set kernel page tables for linear frame buffer 
  3664                              <1> 	; (this procedure will be called by kernel only)
  3665                              <1> 	;
  3666                              <1> 	; Input:
  3667                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
  3668                              <1>  	;	[LFB_SIZE] = linear frame buffer size in bytes
  3669                              <1> 	; Output:
  3670                              <1> 	;	none
  3671                              <1> 	;	cf = 1 -> error
  3672                              <1> 	;
  3673                              <1> 	; Modified registers: eax, ecx, edx, edi
  3674                              <1> 
  3675 000069D3 8B3D[2C120300]      <1> 	mov	edi, [LFB_ADDR]
  3676 000069D9 8B15[30120300]      <1> 	mov	edx, [LFB_SIZE]
  3677                              <1> 
  3678 000069DF C1EF16              <1> 	shr	edi, 22	; convert address to page number
  3679                              <1> 			; and then convert it to PDE entry offset
  3680                              <1> 			; (1 PDE is for 4MB, 22 bit shift)
  3681                              <1> 
  3682 000069E2 66C1E702            <1> 	shl	di, 2	; * 4 for offset 
  3683                              <1> 
  3684                              <1> 	;add	edx, 4095
  3685 000069E6 C1EA0C              <1> 	shr	edx, 12	; convert LFB size to LFB page count
  3686                              <1> 	
  3687 000069E9 89D1                <1> 	mov	ecx, edx ; * ; LFB page count
  3688                              <1> 
  3689 000069EB 81C1FF030000        <1> 	add	ecx, 1023 ; page count + 1023
  3690 000069F1 C1E90A              <1> 	shr	ecx, 10 ; convert to page directory entry count	
  3691                              <1> 			; (page table count)
  3692 000069F4 51                  <1> 	push	ecx ; **
  3693 000069F5 C1E10C              <1> 	shl	ecx, 12 ; convert to byte count
  3694                              <1> 
  3695 000069F8 31C0                <1> 	xor	eax, eax ; first available pages
  3696                              <1> 	
  3697                              <1> 	; allocate contiguous memory block for these kernel pages
  3698                              <1> 	
  3699 000069FA E87EFAFFFF          <1> 	call	allocate_memory_block
  3700                              <1> 	; eax = start address of (contiguous) memory block
  3701 000069FF 59                  <1> 	pop	ecx ; ** ; PDE count
  3702 00006A00 7301                <1> 	jnc	short a_lfb_k_1
  3703                              <1> 	; error (cf=1)
  3704 00006A02 C3                  <1> 	retn
  3705                              <1> a_lfb_k_1:
  3706                              <1> 	; Allocate (new) page tables in kernel's page directory
  3707 00006A03 51                  <1> 	push	ecx ; PDE (page table) count
  3708 00006A04 50                  <1> 	push	eax ; start address of contiguous memory pages
  3709                              <1> 		    ; (at page boundary)	
  3710                              <1> 	; edi = 1st page directory entry offset
  3711 00006A05 033D[D0890100]      <1> 	add	edi, [k_page_dir] ; Kernel's Page Dir Address
  3712                              <1> a_lfb_k_2:
  3713 00006A0B 660D0304            <1> 	or	ax, PDE_A_PRESENT + PDE_A_WRITE + PDE_EXTERNAL
  3714                              <1> 				; supervisor + read&write + present 	
  3715                              <1> 				; + external memory block (LFB)
  3716 00006A0F AB                  <1> 	stosd
  3717 00006A10 0500100000          <1> 	add	eax, 4096
  3718 00006A15 E2F4                <1> 	loop	a_lfb_k_2
  3719                              <1> 	
  3720 00006A17 5F                  <1> 	pop	edi ; start addr of contiguous memory pages
  3721 00006A18 59                  <1> 	pop	ecx ; page table (PDE) count
  3722                              <1> 
  3723                              <1> 	; Allocate pages in (new) kernel page tables
  3724                              <1> 	
  3725                              <1> 	; (Note: page tables are contiguous in pyhsical memory)
  3726 00006A19 C1E10A              <1> 	shl	ecx, 10 ; * 1024, convert to (total) PTE count 
  3727                              <1> 	
  3728 00006A1C A1[2C120300]        <1> 	mov	eax, [LFB_ADDR]
  3729                              <1> 	; edx = LFB page count
  3730                              <1> 	;and	ax, ~4095  ; lw of LFB address is 0
  3731                              <1> a_lfb_k_3:	
  3732 00006A21 660D0304            <1> 	or	ax, PTE_A_PRESENT + PTE_A_WRITE + PTE_EXTERNAL
  3733                              <1> 				; supervisor + read&write + present 	
  3734                              <1> 				; + external memory block (LFB)
  3735 00006A25 AB                  <1> 	stosd
  3736 00006A26 4A                  <1> 	dec	edx
  3737 00006A27 7408                <1> 	jz	short a_lfb_k_4 ; LFB size has been completed (!?)
  3738 00006A29 0500100000          <1> 	add	eax, 4096	
  3739 00006A2E E2F1                <1> 	loop	a_lfb_k_3
  3740                              <1> 
  3741 00006A30 C3                  <1> 	retn
  3742                              <1> 	
  3743                              <1> a_lfb_k_4:
  3744                              <1> 	; clear PTEs for empty/free pages 
  3745                              <1> 	; 	(if there are after LFB !?)
  3746 00006A31 31C0                <1> 	xor	eax, eax ; clear page table entry (empty)
  3747 00006A33 F3AB                <1> 	rep	stosd
  3748 00006A35 C3                  <1> 	retn
  3749                              <1> 
  3750                              <1> ;deallocate_lfb_pages_for_kernel:
  3751                              <1> 	; 15/12/2020
  3752                              <1> 	; 14/12/2020 - TRDOS 386 v2.0.3
  3753                              <1> 	; Reset/Release kernel page tables
  3754                              <1> 	;	 which are used for linear frame buffer 
  3755                              <1> 	; (this procedure will be called by kernel only)
  3756                              <1> 	;
  3757                              <1> 	; Input:
  3758                              <1> 	;	[LFB_ADDR] = linear frame buffer base address
  3759                              <1>  	;	[FFB_SIZE] = linear frame buffer size in bytes
  3760                              <1> 	; Output:
  3761                              <1> 	;	none
  3762                              <1> 	;
  3763                              <1> 	; Modified registers: eax, ecx, edi
  3764                              <1> 
  3765                              <1> 	;mov	edi, [LFB_ADDR]
  3766                              <1> 	;mov	ecx, [LFB_SIZE]
  3767                              <1> 	;
  3768                              <1> 	;shr	edi, 22	; convert address to page number
  3769                              <1> 	;		; and then convert it to PDE entry offset
  3770                              <1> 	;		; (1 PDE is for 4MB, 22 bit shift)
  3771                              <1> 	;
  3772                              <1> 	;shl	di, 2	; * 4 for offset 
  3773                              <1> 	;
  3774                              <1> 	;;add	ecx, 4095
  3775                              <1> 	;shr	ecx, 12	; convert LFB size to page count  
  3776                              <1> 	;
  3777                              <1> 	;add	ecx, 1023 ; page count + 1023
  3778                              <1> 	;shr	ecx, 10 ; convert to page directory entry count	
  3779                              <1> 	;		; (page table count)
  3780                              <1> 	;push	ecx ; *
  3781                              <1> 	;shl	ecx, 12 ; convert to byte count
  3782                              <1> 	;
  3783                              <1> 	;xor	eax, eax ; first available pages
  3784                              <1> 	;
  3785                              <1> 	;; deallocate contiguous memory block for kernel pages
  3786                              <1> 	;
  3787                              <1> 	;call	deallocate_memory_block
  3788                              <1> 	;
  3789                              <1> 	;pop	ecx ; * ; PDE count
  3790                              <1> 	;
  3791                              <1> 	;; Release/Free PDEs (page tables) in kernel's page dir
  3792                              <1> 	;; edi = 1st page directory entry offset
  3793                              <1> 	;add	edi, [k_page_dir] ; Kernel's Page Dir Address
  3794                              <1> 	;sub	eax, eax ; clear (also invalidate)
  3795                              <1> 	;rep	stosd
  3796                              <1> 	;
  3797                              <1> 	;retn
  3798                              <1> 
  3799                              <1> ; /// End Of MEMORY MANAGEMENT FUNCTIONS ///
  3800                              <1> 
  3801                              <1> ;; Data:
  3802                              <1> 
  3803                              <1> ; 09/03/2015
  3804                              <1> ;swpq_count: dw 0 ; count of pages on the swap que
  3805                              <1> ;swp_drv:    dd 0 ; logical drive description table address of the swap drive/disk
  3806                              <1> ;swpd_size:  dd 0 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  3807                              <1> ;swpd_free:  dd 0 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  3808                              <1> ;swpd_next:  dd 0 ; next free page block
  3809                              <1> ;swpd_last:  dd 0 ; last swap page block
  2888                                  %include 'timer.s'   ; 17/01/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - timer.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 15/01/2017
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 17/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ;
    15                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
    16                              <1> ; ****************************************************************************
    17                              <1> 
    18                              <1> ; TRDOS 386  (TRDOS v2.0) Kernel - TIMER & REAL TIME CLOCK (BIOS) FUNCTIONS
    19                              <1> 
    20                              <1> ; IBM PC-AT BIOS Source Code ('BIOS2.ASM')
    21                              <1> ; TITLE BIOS2 ---- 06/10/85 BIOS INTERRUPT ROUTINES
    22                              <1> 
    23                              <1> ;
    24                              <1> ; ///////// TIMER (& REAL TIME CLOCK) FUNCTIONS ///////////////
    25                              <1> 
    26                              <1> int1Ah:
    27                              <1> 	; 29/01/2016
    28                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
    29 00006A36 9C                  <1> 	pushfd
    30 00006A37 0E                  <1> 	push 	cs
    31 00006A38 E801000000          <1> 	call 	TIME_OF_DAY_1
    32 00006A3D C3                  <1> 	retn
    33                              <1> 
    34                              <1> ;--- INT  1A H -- (TIME OF DAY) -------------------------------------------------
    35                              <1> ;       THIS BIOS ROUTINE ALLOWS THE CLOCKS TO BE SET OR READ			:
    36                              <1> ;										:
    37                              <1> ; PARAMETERS:									:
    38                              <1> ;     (AH) = 00H  READ THE CURRENT SETTING AND RETURN WITH,			:
    39                              <1> ;                      (CX) = HIGH PORTION OF COUNT				:
    40                              <1> ;                      (DX) = LOW PORTION OF COUNT				:
    41                              <1> ;                      (AL) = 0 TIMER HAS NOT PASSED 24 HOURS SINCE LAST READ	:
    42                              <1> ;                             1 IF ON ANOTHER DAY. (RESET TO ZERO AFTER READ)	:
    43                              <1> ;										:
    44                              <1> ;     (AH) = 01H  SET THE CURRENT CLOCK USING,					:
    45                              <1> ;		     (CX) = HIGH PORTION OF COUNT				:
    46                              <1> ;		     (DX) = LOW PORTION OF COUNT.				:
    47                              <1> ;										:
    48                              <1> ;               NOTE: COUNTS OCCUR AT THE RATE OF 1193180/65536 COUNTS/SECOND	:
    49                              <1> ;                            (OR ABOUT 18.2 PER SECOND -- SEE EQUATES)		:
    50                              <1> ;										:
    51                              <1> ;     (AH) = 02H  READ THE REAL TIME CLOCK AND RETURN WITH,			:
    52                              <1> ;                      (CH) = HOURS IN BCD (00-23)				:
    53                              <1> ;                      (CL) = MINUTES IN BCD (00-59)				:
    54                              <1> ;                      (DH) = SECONDS IN BCD (00-59)				:
    55                              <1> ;                      (DL) = DAYLIGHT SAVINGS ENABLE (00-01)			:
    56                              <1> ;										:
    57                              <1> ;     (AH) = 03H  SET THE REAL TIME CLOCK USING,				:
    58                              <1> ;                     (CH) = HOURS IN BCD (00-23)				:
    59                              <1> ;                     (CL) = MINUTES IN BCD (00-59)				:
    60                              <1> ;                     (DH) = SECONDS IN BCD (00-59)				:
    61                              <1> ;                     (DL) = 01 IF DAYLIGHT SAVINGS ENABLE OPTION, ELSE 00.	:
    62                              <1> ;										:
    63                              <1> ;             NOTE: (DL) = 00 IF DAYLIGHT SAVINGS TIME ENABLE IS NOT ENABLED.	:
    64                              <1> ;                   (DL) = 01 ENABLES TWO SPECIAL UPDATES THE LAST SUNDAY IN	:
    65                              <1> ;	           APRIL   (1:59:59 --> 3:00:00 AM) AND THE LAST SUNDAY IN	:
    66                              <1> ;                   OCTOBER (1:59:59 --> 1:00:00 AM) THE FIRST TIME.		:
    67                              <1> ;										:
    68                              <1> ;     (AH) = 04H  READ THE DATE FROM THE REAL TIME CLOCK AND RETURN WITH,	:
    69                              <1> ;                      (CH) = CENTURY IN BCD (19 OR 20)				:
    70                              <1> ;                      (CL) = YEAR IN BCD (00-99)				:
    71                              <1> ;                      (DH) = MONTH IN BCD (01-12)				:
    72                              <1> ;                      (DL) = DAY IN BCD (01-31).				:
    73                              <1> ;										:
    74                              <1> ;     (AH) = 05H  SET THE DATE INTO THE REAL TIME CLOCK USING,			:
    75                              <1> ;                     (CH) = CENTURY IN BCD (19 OR 20)				:
    76                              <1> ;                     (CL) = YEAR IN BCD (00-99)				:
    77                              <1> ;                     (DH) = MONTH IN BCD (01-12)				:
    78                              <1> ;                     (DL) = DAY IN BCD (01-31).				:
    79                              <1> ;										:
    80                              <1> ;     (AH) = 06H  SET THE ALARM TO INTERRUPT AT SPECIFIED TIME,			:
    81                              <1> ;                     (CH) = HOURS IN BCD (00-23 (OR FFH))			:
    82                              <1> ;                     (CL) = MINUTES IN BCD (00-59 (OR FFH))			:
    83                              <1> ;                     (DH) = SECONDS IN BCD (00-59 (OR FFH))			:
    84                              <1> ;										:
    85                              <1> ;     (AH) = 07H  RESET THE ALARM INTERRUPT FUNCTION.				:
    86                              <1> ;										:
    87                              <1> ; NOTES: FOR ALL RETURNS CY= 0 FOR SUCCESSFUL OPERATION.			:
    88                              <1> ;        FOR (AH)= 2, 4, 6 - CARRY FLAG SET IF REAL TIME CLOCK NOT OPERATING.	:
    89                              <1> ;        FOR (AH)= 6 - CARRY FLAG SET IF ALARM ALREADY ENABLED. 		:
    90                              <1> ;        FOR THE ALARM FUNCTION (AH = 6) THE USER MUST SUPPLY A ROUTINE AND	:
    91                              <1> ;         INTERCEPT THE CORRECT ADDRESS IN THE VECTOR TABLE FOR INTERRUPT 4AH.	:
    92                              <1> ;         USE 0FFH FOR ANY "DO NOT CARE" POSITION FOR INTERVAL INTERRUPTS.	:
    93                              <1> ;        INTERRUPTS ARE DISABLED DURING DATA MODIFICATION. 			:
    94                              <1> ;        AH & AL ARE RETURNED MODIFIED AND NOT DEFINED EXCEPT WHERE INDICATED.	:
    95                              <1> ;--------------------------------------------------------------------------------
    96                              <1> 
    97                              <1> ; 15/01/2017
    98                              <1> ; 14/01/2017
    99                              <1> ; 07/01/2017
   100                              <1> ; 02/01/2017
   101                              <1> ; 29/05/2016
   102                              <1> ; 29/01/2016
   103                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   104                              <1> 
   105                              <1> ; 29/05/2016
   106                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   107                              <1> int35h:  ; Date/Time functions
   108                              <1> 
   109                              <1> TIME_OF_DAY_1:
   110                              <1> 	;sti				; INTERRUPTS BACK ON
   111                              <1> 	; 29/05/2016
   112 00006A3E 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
   113                              <1> 	;
   114 00006A43 80FC08              <1> 	cmp	ah, (RTC_TBE-RTC_TB)/4	; CHECK IF COMMAND IN VALID RANGE (0-7)
   115 00006A46 F5                  <1> 	cmc				; COMPLEMENT CARRY FOR ERROR EXIT
   116                              <1> 	; (*) jc short TIME_9		; EXIT WITH CARRY = 1 IF NOT VALID
   117 00006A47 721A                <1> 	jc	short _TIME_9 ; 29/05/2016
   118                              <1> 
   119 00006A49 1E                  <1> 	push	ds
   120 00006A4A 56                  <1> 	push	esi
   121 00006A4B 66BE1000            <1> 	mov	si, KDATA		; kernel data segment
   122 00006A4F 8EDE                <1> 	mov	ds, si
   123                              <1> 
   124                              <1> 	;;15/01/2017
   125                              <1> 	; 14/01/2017
   126                              <1> 	; 02/01/2017
   127                              <1> 	;;mov	byte [intflg], 35h	; date & time interrupt 
   128                              <1> 	;sti
   129                              <1> 	;
   130 00006A51 C0E402              <1> 	shl	ah, 2			; convert function to dword offset
   131 00006A54 0FB6F4              <1> 	movzx	esi, ah			; PLACE INTO ADDRESSING REGISTER
   132                              <1> 	;cli				; NO INTERRUPTS DURING TIME FUNCTIONS
   133 00006A57 FF96[696A0000]      <1> 	call	[esi+RTC_TB]		; VECTOR TO FUNCTION REQUESTED WITH CY=0
   134                              <1> 					; RETURN WITH CARRY FLAG SET FOR RESULT
   135                              <1> 	;sti				; INTERRUPTS BACK ON
   136 00006A5D B400                <1> 	mov	ah, 0			; CLEAR (AH) TO ZERO
   137 00006A5F 5E                  <1> 	pop	esi			; RECOVER USERS REGISTER
   138 00006A60 1F                  <1> 	pop	ds			; RECOVER USERS SEGMENT SELECTOR
   139                              <1> 
   140                              <1> 	;;15/01/2017
   141                              <1> 	; 02/01/2017
   142                              <1> 	;;mov	byte [ss:intflg], 0 ; 07/01/2017
   143                              <1> 
   144                              <1> ;TIME_9:
   145                              <1> 					; RETURN WITH CY= 0 IF NO ERROR
   146                              <1> 	; (*) 29/05/2016
   147                              <1> 	; (*) retf 4 ; skip eflags on stack
   148 00006A61 7305                <1> 	jnc	short _TIME_10
   149                              <1> _TIME_9:
   150                              <1> 	; 29/05/2016 -set carry flag on stack-
   151                              <1> 	; [esp] = EIP
   152                              <1> 	; [esp+4] = CS
   153                              <1> 	; [esp+8] = E-FLAGS
   154 00006A63 804C240801          <1> 	or	byte [esp+8], 1	 ; set carry bit of eflags register
   155                              <1> 	; [esp+12] = ESP (user)
   156                              <1> 	; [esp+16] = SS (User)
   157                              <1> _TIME_10:
   158 00006A68 CF                  <1> 	iretd
   159                              <1> 	
   160                              <1> 	; (*) 29/05/2016 - 'ref 4' intruction causes to stack fault
   161                              <1> 	; (OUTER-PRIVILEGE-LEVEL)
   162                              <1> 	; INTEL 80386 PROGRAMMER'S REFERENCE MANUAL 1986
   163                              <1> 	; // RETF instruction:
   164                              <1> 	;
   165                              <1> 	; IF OperandMode=32 THEN
   166                              <1>  	;    Load CS:EIP from stack;
   167                              <1>  	;    Set CS RPL to CPL;
   168                              <1>  	;    Increment eSP by 8 plus the immediate offset if it exists;
   169                              <1>  	;    Load SS:eSP from stack;
   170                              <1>  	; ELSE (* OperandMode=16 *)
   171                              <1>  	;    Load CS:IP from stack;
   172                              <1>  	;    Set CS RPL to CPL;
   173                              <1>  	;    Increment eSP by 4 plus the immediate offset if it exists;
   174                              <1> 	;    Load SS:eSP from stack;
   175                              <1>  	; FI;
   176                              <1> 	;
   177                              <1> 	; //					
   178                              <1> 					; ROUTINE VECTOR TABLE (AH)=
   179                              <1> RTC_TB:
   180 00006A69 [896A0000]          <1> 	dd	RTC_00			; 0 = READ CURRENT CLOCK COUNT
   181 00006A6D [9C6A0000]          <1> 	dd	RTC_10			; 1 = SET CLOCK COUNT
   182 00006A71 [AA6A0000]          <1> 	dd	RTC_20			; 2 = READ THE REAL TIME CLOCK TIME
   183 00006A75 [D96A0000]          <1> 	dd	RTC_30			; 3 = SET REAL TIME CLOCK TIME
   184 00006A79 [1B6B0000]          <1> 	dd	RTC_40			; 4 = READ THE REAL TIME CLOCK DATE
   185 00006A7D [486B0000]          <1> 	dd	RTC_50			; 5 = SET REAL TIME CLOCK DATE
   186 00006A81 [956B0000]          <1> 	dd	RTC_60			; 6 = SET THE REAL TIME CLOCK ALARM
   187 00006A85 [E86B0000]          <1> 	dd	RTC_70			; 7 = RESET ALARM
   188                              <1> 
   189                              <1> RTC_TBE	equ	$
   190                              <1> 
   191                              <1> RTC_00:				; READ TIME COUNT
   192 00006A89 A0[548A0100]        <1> 	mov	al, [TIMER_OFL]		; GET THE OVERFLOW FLAG
   193 00006A8E C605[548A0100]00    <1> 	mov	byte [TIMER_OFL], 0	; AND THEN RESET THE OVERFLOW FLAG
   194 00006A95 8B0D[508A0100]      <1>         mov     ecx, [TIMER_LH]         ; GET COUNT OF TIME
   195 00006A9B C3                  <1> 	retn
   196                              <1> 
   197                              <1> RTC_10:				; SET TIME COUNT
   198 00006A9C 890D[508A0100]      <1>         mov     [TIMER_LH], ecx         ; SET TIME COUNT
   199 00006AA2 C605[548A0100]00    <1> 	mov	byte [TIMER_OFL], 0	; RESET OVERFLOW FLAG
   200 00006AA9 C3                  <1> 	retn				; RETURN WITH NO CARRY
   201                              <1> 
   202                              <1> RTC_20:				; GET RTC TIME
   203 00006AAA E8EB010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   204 00006AAF 7227                <1> 	jc	short RTC_29		; EXIT IF ERROR (CY= 1)
   205                              <1> 
   206 00006AB1 B000                <1> 	mov	al, CMOS_SECONDS	; SET ADDRESS OF SECONDS
   207 00006AB3 E8FD010000          <1> 	call	CMOS_READ		; GET SECONDS
   208 00006AB8 88C6                <1> 	mov	dh, al			; SAVE
   209 00006ABA B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   210 00006ABC E8F4010000          <1> 	call	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
   211 00006AC1 2401                <1> 	and	al, 00000001b		; MASK FOR VALID DSE BIT
   212 00006AC3 88C2                <1> 	mov	dl, al			; SET [DL] TO ZERO FOR NO DSE BIT
   213 00006AC5 B002                <1> 	mov	al, CMOS_MINUTES	; SET ADDRESS OF MINUTES
   214 00006AC7 E8E9010000          <1> 	call	CMOS_READ		; GET MINUTES
   215 00006ACC 88C1                <1> 	mov	cl, al			; SAVE
   216 00006ACE B004                <1>         mov     al, CMOS_HOURS          ; SET ADDRESS OF HOURS
   217 00006AD0 E8E0010000          <1> 	call	CMOS_READ		; GET HOURS
   218 00006AD5 88C5                <1> 	mov	ch, al			; SAVE
   219 00006AD7 F8                  <1> 	clc				; SET CY= 0
   220                              <1> RTC_29:
   221 00006AD8 C3                  <1> 	retn				; RETURN WITH RESULT IN CARRY FLAG
   222                              <1> 
   223                              <1> RTC_30:				; SET RTC TIME
   224 00006AD9 E8BC010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   225 00006ADE 7305                <1> 	jnc	short RTC_35		; GO AROUND IF CLOCK OPERATING
   226 00006AE0 E817010000          <1> 	call	RTC_STA			; ELSE TRY INITIALIZING CLOCK
   227                              <1> RTC_35:
   228 00006AE5 88F4                <1> 	mov	ah, dh			; GET TIME BYTE - SECONDS
   229 00006AE7 B000                <1> 	mov	al, CMOS_SECONDS	; ADDRESS SECONDS
   230 00006AE9 E8E0010000          <1> 	call	CMOS_WRITE		; UPDATE SECONDS
   231 00006AEE 88CC                <1> 	mov	ah, cl			; GET TIME BYTE - MINUTES
   232 00006AF0 B002                <1> 	mov	al, CMOS_MINUTES	; ADDRESS MINUTES
   233 00006AF2 E8D7010000          <1> 	call	CMOS_WRITE		; UPDATE MINUTES
   234 00006AF7 88EC                <1> 	mov	ah, ch			; GET TIME BYTE - HOURS
   235 00006AF9 B004                <1> 	mov	al, CMOS_HOURS		; ADDRESS HOURS
   236 00006AFB E8CE010000          <1> 	call	CMOS_WRITE		; UPDATE ADDRESS
   237                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   238                              <1> 	;mov	ah, al
   239 00006B00 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   240 00006B04 E8AC010000          <1> 	call	CMOS_READ		; READ CURRENT TIME
   241 00006B09 2462                <1> 	and	al, 01100010b		; MASK FOR VALID BIT POSITIONS
   242 00006B0B 0C02                <1> 	or	al, 00000010b		; TURN ON 24 HOUR MODE
   243 00006B0D 80E201              <1> 	and	dl, 00000001b		; USE ONLY THE DSE BIT
   244 00006B10 08D0                <1> 	or	al, dl			; GET DAY LIGHT SAVINGS TIME BIT (OSE)
   245 00006B12 86E0                <1> 	xchg	ah, al			; PLACE IN WORK REGISTER AND GET ADDRESS
   246 00006B14 E8B5010000          <1> 	call	CMOS_WRITE		; SET NEW ALARM SITS
   247 00006B19 F8                  <1> 	clc				; SET CY= 0
   248 00006B1A C3                  <1> 	retn				; RETURN WITH CY= 0
   249                              <1> 
   250                              <1> RTC_40:				; GET RTC DATE
   251 00006B1B E87A010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   252 00006B20 7225                <1> 	jc	short RTC_49		; EXIT IF ERROR (CY= 1)
   253                              <1> 
   254 00006B22 B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH
   255 00006B24 E88C010000          <1> 	call	CMOS_READ		; READ DAY OF MONTH
   256 00006B29 88C2                <1> 	mov	dl, al			; SAVE
   257 00006B2B B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH
   258 00006B2D E883010000          <1> 	call	CMOS_READ		; READ MONTH
   259 00006B32 88C6                <1> 	mov	dh, al			; SAVE
   260 00006B34 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR
   261 00006B36 E87A010000          <1> 	call	CMOS_READ		; READ YEAR
   262 00006B3B 88C1                <1> 	mov	cl, al			; SAVE
   263 00006B3D B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY LOCATION
   264 00006B3F E871010000          <1> 	call	CMOS_READ		; GET CENTURY BYTE
   265 00006B44 88C5                <1> 	mov	ch, al			; SAVE
   266 00006B46 F8                  <1> 	clc				; SET CY=0
   267                              <1> RTC_49:
   268 00006B47 C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAG
   269                              <1> 
   270                              <1> RTC_50:				; SET RTC DATE
   271 00006B48 E84D010000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   272 00006B4D 7305                <1> 	jnc	short RTC_55		; GO AROUND IF NO ERROR
   273 00006B4F E8A8000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
   274                              <1> RTC_55:
   275 00006B54 66B80600            <1> 	mov	ax, CMOS_DAY_WEEK	; ADDRESS OF DAY OF WEEK BYTE
   276 00006B58 E871010000          <1> 	call	CMOS_WRITE		; LOAD ZEROS TO DAY OF WEEK
   277 00006B5D 88D4                <1> 	mov	ah, dl			; GET DAY OF MONTH BYTE
   278 00006B5F B007                <1> 	mov	al, CMOS_DAY_MONTH	; ADDRESS DAY OF MONTH BYTE
   279 00006B61 E868010000          <1> 	call	CMOS_WRITE		; WRITE OF DAY OF MONTH REGISTER
   280 00006B66 88F4                <1> 	mov	ah, dh			; GET MONTH
   281 00006B68 B008                <1> 	mov	al, CMOS_MONTH		; ADDRESS MONTH BYTE
   282 00006B6A E85F010000          <1> 	call	CMOS_WRITE		; WRITE MONTH REGISTER
   283 00006B6F 88CC                <1> 	mov	ah, cl			; GET YEAR BYTE
   284 00006B71 B009                <1> 	mov	al, CMOS_YEAR		; ADDRESS YEAR REGISTER
   285 00006B73 E856010000          <1> 	call	CMOS_WRITE		; WRITE YEAR REGISTER
   286 00006B78 88EC                <1> 	mov	ah, ch			; GET CENTURY BYTE
   287 00006B7A B032                <1> 	mov	al, CMOS_CENTURY	; ADDRESS CENTURY BYTE
   288 00006B7C E84D010000          <1> 	call	CMOS_WRITE		; WRITE CENTURY LOCATION
   289                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   290                              <1> 	;mov	ah, al
   291 00006B81 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   292 00006B85 E82B010000          <1> 	call	CMOS_READ		; READ WIRRENT SETTINGS
   293 00006B8A 247F                <1> 	and	al, 07Fh		; CLEAR 'SET BIT'
   294 00006B8C 86E0                <1> 	xchg	ah, al			; MOVE TO WORK REGISTER
   295 00006B8E E83B010000          <1> 	call	CMOS_WRITE		; AND START CLOCK UPDATING
   296 00006B93 F8                  <1> 	clc				; SET CY= 0
   297 00006B94 C3                  <1> 	retn				; RETURN CY=0
   298                              <1> 
   299                              <1> RTC_60:				; SET RTC ALARM
   300 00006B95 B00B                <1> 	mov	al, CMOS_REG_B		; ADDRESS ALARM
   301 00006B97 E819010000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
   302 00006B9C A820                <1> 	test	al, 20h			; CHECK FOR ALARM ALREADY ENABLED
   303 00006B9E F9                  <1> 	stc				; SET CARRY IN CASE OF ERROR
   304 00006B9F 7542                <1> 	jnz	short RTC_69		; ERROR EXIT IF ALARM SET
   305 00006BA1 E8F4000000          <1> 	call	UPD_IPR			; CHECK FOR UPDATE IN PROCESS
   306 00006BA6 7305                <1> 	jnc	short RTC_65		; SKIP INITIALIZATION IF NO ERROR
   307 00006BA8 E84F000000          <1> 	call	RTC_STA			; ELSE INITIALIZE CLOCK
   308                              <1> RTC_65:	
   309 00006BAD 88F4                <1> 	mov	ah, dh			; GET SECONDS BYTE
   310 00006BAF B001                <1> 	mov	al, CMOS_SEC_ALARM	; ADDRESS THE SECONDS ALARM REGISTER
   311 00006BB1 E818010000          <1> 	call	CMOS_WRITE		; INSERT SECONDS
   312 00006BB6 88CC                <1> 	mov	ah, cl			; GET MINUTES PARAMETER
   313 00006BB8 B003                <1> 	mov	al, CMOS_MIN_ALARM	; ADDRESS MINUTES ALARM REGISTER
   314 00006BBA E80F010000          <1> 	call	CMOS_WRITE		; INSERT MINUTES
   315 00006BBF 88EC                <1> 	mov	ah, ch			; GET HOURS PARAMETER
   316 00006BC1 B005                <1> 	mov	al, CMOS_HR_ALARM	; ADDRESS HOUR ALARM REGISTER
   317 00006BC3 E806010000          <1> 	call	CMOS_WRITE		; INSERT HOURS
   318 00006BC8 E4A1                <1> 	in	al, INTB01		; READ SECOND INTERRUPT MASK REGISTER
   319 00006BCA 24FE                <1> 	and	al, 0FEh		; ENABLE ALARM TIMER BIT (CY= 0)
   320 00006BCC E6A1                <1> 	out	INTB01, al		; WRITE UPDATED MASK
   321                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   322                              <1> 	;mov	ah, al
   323 00006BCE 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257
   324 00006BD2 E8DE000000          <1> 	call	CMOS_READ		; READ CURRENT ALARM REGISTER
   325 00006BD7 247F                <1> 	and	al, 07Fh		; ENSURE SET BIT TURNED OFF
   326 00006BD9 0C20                <1> 	or	al, 20h			; TURN ON ALARM ENABLE
   327 00006BDB 86E0                <1> 	xchg	ah, al			; MOVE MASK TO OUTPUT REGISTER
   328 00006BDD E8EC000000          <1> 	call	CMOS_WRITE		; WRITE NEW ALARM MASK
   329 00006BE2 F8                  <1> 	clc				; SET CY= 0
   330                              <1> RTC_69:
   331 00006BE3 66B80000            <1> 	mov	ax, 0			; CLEAR AX REGISTER
   332 00006BE7 C3                  <1> 	retn				; RETURN WITH RESULTS IN CARRY FLAC
   333                              <1> 
   334                              <1> RTC_70:				; RESET ALARM
   335                              <1> 	;mov	al, CMOS_REG_B		; ADDRESS ALARM REGISTER
   336                              <1> 	;mov	ah, al
   337 00006BE8 66B80B0B            <1> 	mov	ax, CMOS_REG_B * 257	; ADDRESS ALARM REGISTER (TO BOTH AH,AL)
   338 00006BEC E8C4000000          <1> 	call	CMOS_READ		; READ ALARM REGISTER
   339 00006BF1 2457                <1> 	and	al, 57h			; TURN OFF ALARM ENABLE
   340 00006BF3 86E0                <1> 	xchg	ah, al			; SAVE DATA AND RECOVER ADDRESS
   341 00006BF5 E8D4000000          <1> 	call	CMOS_WRITE		; RESTORE NEW VALUE
   342 00006BFA F8                  <1> 	clc				; SET CY= 0
   343 00006BFB C3                  <1> 	retn				; RETURN WITH NO CARRY
   344                              <1> 
   345                              <1> RTC_STA:			; INITIALIZE REAL TIME CLOCK
   346                              <1> 	;mov	al, CMOS_REG_A		; ADDRESS REGISTER A AND LOAD DATA MASK		
   347                              <1> 	;mov	ah, 26h
   348 00006BFC 66B80A26            <1> 	mov	ax, (26h*100h)+CMOS_REG_A
   349 00006C00 E8C9000000          <1> 	call	CMOS_WRITE		; INITIALIZE STATUS REGISTER A
   350                              <1> 	;mov	al, CMOS_REG_B		; SET "SET BIT" FOR CLOCK INITIALIZATION	
   351                              <1> 	;mov	ah, 82h
   352 00006C05 66B80B82            <1> 	mov	ax, (82h*100h)+CMOS_REG_B
   353 00006C09 E8C0000000          <1> 	call	CMOS_WRITE		; AND 24 HOUR MODE TO REGISTER B
   354 00006C0E B00C                <1> 	mov	al, CMOS_REG_C		; ADDRESS REGISTER C
   355 00006C10 E8A0000000          <1> 	call	CMOS_READ		; READ REGISTER C TO INITIALIZE
   356 00006C15 B00D                <1> 	mov	al, CMOS_REG_D		; ADDRESS REGISTER D
   357 00006C17 E899000000          <1> 	call	CMOS_READ		; READ REGISTER D TO INITIALIZE
   358 00006C1C C3                  <1> 	retn
   359                              <1> 
   360                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   361                              <1> 
   362                              <1> ;--- HARDWARE INT  70 H -- ( IRQ LEVEL  8) --------------------------------------
   363                              <1> ; ALARM INTERRUPT HANDLER (RTC)							:
   364                              <1> ;       THIS ROUTINE HANDLES THE PERIODIC AND ALARM INTERRUPTS FROM THE CMOS	:
   365                              <1> ;       TIMER. INPUT FREQUENCY IS 1.024 KHZ OR APPROXIMATELY 1024 INTERRUPTS	:
   366                              <1> ;       EVERY SECOND FOR THE PERIODIC INTERRUPT. FOR THE ALARM FUNCTION,	:
   367                              <1> ;       THE INTERRUPT WILL OCCUR AT THE DESIGNATED TIME.			:
   368                              <1> ;										:
   369                              <1> ;       INTERRUPTS ARE ENABLED WHEN THE EVENT OR ALARM FUNCTION IS ACTIVATED.	:
   370                              <1> ;       FOR THE EVENT INTERRUPT, THE HANDLER WILL DECREMENT THE WAIT COUNTER	:
   371                              <1> ;       AND WHEN IT EXPIRES WILL SET THE DESIGNATED LOCATION TO 80H. FOR	:
   372                              <1> ;       THE ALARM INTERRUPT. THE USER MUST PROVIDE A ROUTINE TO INTERCEPT	:
   373                              <1> ;       THE CORRECT ADDRESS FROM THE VECTOR TABLE INVOKED BY INTERRUPT 4AH	:
   374                              <1> ;       PRIOR TO SETTING THE REAL TIME CLOCK ALARM (INT 1AH, AH= 06H).		:
   375                              <1> ;--------------------------------------------------------------------------------
   376                              <1> 
   377                              <1> RTC_A_INT: ; 07/01/2017
   378                              <1> ;RTC_INT:				; ALARM INTERRUPT
   379 00006C1D 1E                  <1> 	push	ds			; LEAVE INTERRUPTS DISABLED
   380 00006C1E 50                  <1> 	push	eax			; SAVE REGISTERS
   381 00006C1F 57                  <1> 	push	edi
   382                              <1> RTC_I_1:				; CHECK FOR SECOND INTERRUPT
   383 00006C20 66B88C8B            <1> 	mov	ax, 256*(CMOS_REG_B+NMI)+CMOS_REG_C+NMI ; ALARM AND STATUS
   384 00006C24 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM FLAG MASK ADDRESS
   385 00006C26 90                  <1> 	nop				; I/O DELAY
   386 00006C27 EB00                <1> 	jmp	short $+2
   387 00006C29 E471                <1> 	in	al, CMOS_DATA		; READ AND RESET INTERRUPT REQUEST FLAGS
   388 00006C2B A860                <1> 	test	al, 01100000b		; CHECK FOR EITHER INTERRUPT PENDING
   389 00006C2D 745D                <1> 	jz	short	RTC_I_9		; EXIT IF NOT A VALID RTC INTERRUPT
   390                              <1> 
   391 00006C2F 86E0                <1> 	xchg	ah, al			; SAVE FLAGS AND GET ENABLE ADDRESS
   392 00006C31 E670                <1> 	out	CMOS_PORT, al		; WRITE ALARM ENABLE MASK ADDRESS
   393 00006C33 90                  <1> 	nop				; I/O DELAY
   394 00006C34 EB00                <1> 	jmp	short $+2	
   395 00006C36 E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ALARM ENABLE MASK
   396 00006C38 20E0                <1> 	and	al, ah			; ALLOW ONLY SOURCES THAT ARE ENABLED
   397 00006C3A A840                <1> 	test	al, 01000000b		; CHECK FOR PERIODIC INTERRUPT
   398 00006C3C 743B                <1> 	jz	short RTC_I_5		; SKIP IF NOT A PERIODIC INTERRUPT
   399                              <1> 
   400                              <1> ;-----	DECREMENT WAIT COUNT BY INTERRUPT INTERVAL
   401                              <1> 
   402 00006C3E 66BF1000            <1> 	mov	di, KDATA		; kernel data segment
   403 00006C42 8EDF                <1> 	mov	ds, di
   404                              <1> 	
   405 00006C44 812D[488A0100]D003- <1> 	sub	dword [RTC_LH], 976	; DECREMENT COUNT BY 1/1024
   405 00006C4C 0000                <1>
   406 00006C4E 7329                <1> 	jnc	short RTC_I_5		; SKIP TILL 32 BIT WORD LESS THAN ZERO
   407                              <1> 
   408                              <1> ;-----	TURN OFF PERIODIC INTERRUPT ENABLE
   409                              <1> 
   410 00006C50 6650                <1> 	push	ax			; SAVE INTERRUPT FLAG MASK
   411 00006C52 66B88B8B            <1> 	mov	ax, 257*(CMOS_REG_B+NMI) ; INTERRUPT ENABLE REGISTER
   412 00006C56 E670                <1> 	out	CMOS_PORT, al		; WRITE ADDRESS TO CMOS CLOCK
   413 00006C58 90                  <1> 	nop				; I/O DELAY
   414 00006C59 EB00                <1> 	jmp	short $+2
   415 00006C5B E471                <1> 	in	al, CMOS_DATA		; READ CURRENT ENABLES
   416 00006C5D 24BF                <1> 	and	al, 0BFh		; TURN OFF PIE
   417 00006C5F 86C4                <1> 	xchg	al, ah			; GET CMOS ADDRESS AND SAVE VALUE
   418 00006C61 E670                <1> 	out	CMOS_PORT, al		; ADDRESS REGISTER B
   419 00006C63 86C4                <1> 	xchg	al, ah			; GET NEW INTERRUPT ENABLE MASK
   420 00006C65 E671                <1> 	out	CMOS_DATA, al		; SET MASK IN INTERRUPT ENABLE REGISTER
   421 00006C67 C605[4C8A0100]00    <1> 	mov	byte [RTC_WAIT_FLAG], 0	; SET FUNCTION ACTIVE FLAG OFF
   422 00006C6E 8B3D[4D8A0100]      <1> 	mov	edi, [USER_FLAG]	; SET UP (DS:DI) TO POINT TO USER FLAG
   423 00006C74 C60780              <1> 	mov	byte [edi], 80h		; TURN ON USERS FLAG
   424 00006C77 6658                <1> 	pop	ax			; GET INTERRUPT SOURCE BACK
   425                              <1> RTC_I_5:
   426 00006C79 A820                <1> 	test	al, 00100000b		; TEST FOR ALARM INTERRUPT
   427 00006C7B 740D                <1> 	jz	short RTC_I_7		; SKIP USER INTERRUPT CALL IF NOT ALARM
   428                              <1> 
   429 00006C7D B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
   430 00006C7F E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
   431 00006C81 FB                  <1> 	sti				; INTERRUPTS BACK ON NOW
   432 00006C82 52                  <1> 	push	edx
   433 00006C83 E8D2C00000          <1> 	call	INT4Ah			; TRANSFER TO USER ROUTINE
   434 00006C88 5A                  <1> 	pop	edx
   435 00006C89 FA                  <1> 	cli				; BLOCK INTERRUPT FOR RETRY
   436                              <1> RTC_I_7:				; RESTART ROUTINE TO HANDLE DELAYED
   437 00006C8A EB94                <1> 	jmp	short RTC_I_1		;  ENTRY AND SECOND EVENT BEFORE DONE
   438                              <1> 
   439                              <1> RTC_I_9:				; EXIT - NO PENDING INTERRUPTS
   440 00006C8C B00D                <1> 	mov	al, CMOS_REG_D		; POINT TO DEFAULT READ ONLY REGISTER
   441 00006C8E E670                <1> 	out	CMOS_PORT, al		; ENABLE NMI AND CMOS ADDRESS TO DEFAULT
   442 00006C90 B020                <1> 	mov	al, EOI			; END OF INTERRUPT MASK TO 8259 - 2
   443 00006C92 E6A0                <1> 	out	INTB00, al		; TO 8259 - 2
   444 00006C94 E620                <1> 	out	INTA00,	al		; TO 8259 - 1
   445 00006C96 5F                  <1> 	pop	edi			; RESTORE REGISTERS
   446 00006C97 58                  <1> 	pop	eax
   447 00006C98 1F                  <1> 	pop	ds
   448 00006C99 CF                  <1> 	iretd				; END OF INTERRUPT
   449                              <1> 
   450                              <1> 	
   451                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0)
   452                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
   453                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (bios2.asm)
   454                              <1> UPD_IPR:				; WAIT TILL UPDATE NOT IN PROGRESS
   455 00006C9A 51                  <1> 	push	ecx
   456                              <1> 
   457                              <1> 	; 29/05/2016
   458 00006C9B B968110000          <1> 	mov	ecx, ((1984+244)*4)/2	; AWARD BIOS 1999, ATIME.ASM		
   459                              <1> 					; 'WAITCPU_CK_UD_STAT'
   460                              <1> 					; (244Us + 1984Us)
   461                              <1> 					; (assume each read takes
   462                              <1> 					;  2 microseconds).
   463                              <1> 	;mov	ecx, 65535		
   464                              <1> 		;mov cx, 800		; SET TIMEOUT LOOP COUNT (= 800)	
   465                              <1> UPD_10:
   466 00006CA0 B00A                <1> 	mov	al, CMOS_REG_A		; ADDRESS STATUS REGISTER A
   467 00006CA2 FA                  <1> 	cli				; NO TIMER INTERRUPTS DURING UPDATES
   468 00006CA3 E80D000000          <1> 	call	CMOS_READ		; READ UPDATE IN PROCESS FLAG
   469 00006CA8 A880                <1> 	test	al, 80h			; IF UIP BIT IS ON ( CANNOT READ TIME )
   470 00006CAA 7406                <1> 	jz	short UPD_90		; EXIT WITH CY= 0 IF CAN READ CLOCK NOW
   471 00006CAC FB                  <1> 	sti				; ALLOW INTERRUPTS WHILE WAITING
   472 00006CAD E2F1                <1> 	loop	UPD_10			; LOOP TILL READY OR TIMEOUT
   473 00006CAF 31C0                <1> 	xor	eax, eax		; CLEAR RESULTS IF ERROR
   474                              <1> 		; xor ax, ax
   475 00006CB1 F9                  <1> 	stc				; SET CARRY FOR ERROR
   476                              <1> UPD_90:
   477 00006CB2 59                  <1> 	pop	ecx			; RESTORE CALLERS REGISTER
   478 00006CB3 FA                  <1> 	cli				; INTERRUPTS OFF DURING SET
   479 00006CB4 C3                  <1> 	retn				; RETURN WITH CY FLAG SET
   480                              <1> 
   481                              <1> 
   482                              <1> 	; 29/05/2016 - TRDOS 386 (TRDOS v2.0) 
   483                              <1> 	; 22/08/2014 (Retro UNIX 386 v1)
   484                              <1> 	; IBM PC/AT BIOS source code ----- 10/06/85 (test4.asm)
   485                              <1> 
   486                              <1> ;--- CMOS_READ -----------------------------------------------------------------
   487                              <1> ;		READ BYTE FROM CMOS_SYSTEM CLOCK CONFIGURATION TABLE	       :
   488                              <1> ;									       :
   489                              <1> ; INPUT: (AL)=	CMOS_TABLE ADDRESS TO BE READ				       :
   490                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
   491                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO READ		       :
   492                              <1> ;									       :
   493                              <1> ; OUTPUT: (AL)	VALUE AT LOCATION (AL) MOVED INTO (AL). IF BIT 7 OF (AL) WAS   :
   494                              <1> ;		ON THEN NMI LEFT DISABLED, DURING THE CMOS READ BOTH NMI AND   :
   495                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
   496                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
   497                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
   498                              <1> ;		ONLY THE (AL) REGISTER AND THE NMI STATE IS CHANGED.	       :
   499                              <1> ;-------------------------------------------------------------------------------
   500                              <1> 
   501                              <1> CMOS_READ:
   502 00006CB5 9C                  <1> 	pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
   503 00006CB6 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
   504 00006CB8 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
   505 00006CB9 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
   506 00006CBB FA                  <1> 	cli				; DISABLE INTERRUPTS
   507 00006CBC E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
   508                              <1> 	; 29/05/2016
   509                              <1> 	;nop				; I/O DELAY
   510 00006CBE E6EB                <1> 	out	0ebh,al	; NEWIODELAY ; AWARD BIOS 1999, ATIME.ASM
   511                              <1> 	;
   512 00006CC0 E471                <1> 	in	al, CMOS_DATA		; READ THE REQUESTED CMOS LOCATION
   513 00006CC2 6650                <1> 	push	ax			; SAVE (AH) REGISTER VALUE AND CMOS BYTE
   514                              <1> 	; 15/03/2015 ; IBM PC/XT Model 286 BIOS source code 
   515                              <1> 		     ; ----- 10/06/85 (test4.asm)
   516 00006CC4 B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2 	; GET ADDRESS OF DEFAULT LOCATION
   517                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
   518 00006CC6 D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
   519 00006CC8 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
   520 00006CCA 6658                <1> 	pop	ax			; RESTORE (AH) AND (AL), CMOS BYTE
   521 00006CCC 9D                  <1> 	popf	
   522 00006CCD C3                  <1> 	retn				; RETURN WITH FLAGS RESTORED
   523                              <1> 
   524                              <1> ; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   525                              <1> 
   526                              <1> ;--- CMOS_WRITE ----------------------------------------------------------------
   527                              <1> ;	WRITE BYTE TO CMOS SYSTEM CLOCK CONFIGURATION TABLE		       :
   528                              <1> ;									       :
   529                              <1> ; INPUT: (AL)=	CMOS TABLE ADDRESS TO BE WRITTEN TO			       :
   530                              <1> ;		BIT    7 = 0 FOR NMI ENABLED AND 1 FOR NMI DISABLED ON EXIT    :
   531                              <1> ;		BITS 6-0 = ADDRESS OF TABLE LOCATION TO WRITE		       :
   532                              <1> ;	 (AH)=	NEW VALUE TO BE PLACED IN THE ADDRESSED TABLE LOCATION	       :
   533                              <1> ;									       :
   534                              <1> ; OUTPUT:	VALUE IN (AH) PLACED IN LOCATION (AL) WITH NMI LEFT DISABLED   :
   535                              <1> ;		IF BIT 7 OF (AL) IS ON, DURING THE CMOS UPDATE BOTH NMI AND    :
   536                              <1> ;		NORMAL INTERRUPTS ARE DISABLED TO PROTECT CMOS DATA INTEGRITY. :
   537                              <1> ;		THE CMOS ADDRESS REGISTER IS POINTED TO A DEFAULT VALUE AND    :
   538                              <1> ;		THE INTERRUPT FLAG RESTORED TO THE ENTRY STATE ON RETURN.      :
   539                              <1> ;		ONLY THE CMOS LOCATION AND THE NMI STATE IS CHANGED.	       :
   540                              <1> ;-------------------------------------------------------------------------------
   541                              <1> 
   542                              <1> CMOS_WRITE:				; WRITE (AH) TO LOCATION (AL)
   543 00006CCE 9C                  <1> 	pushf				; SAVE INTERRUPT ENABLE STATUS AND FLAGS
   544 00006CCF 6650                <1> 	push	ax			; SAVE WORK REGISTER VALUES
   545 00006CD1 D0C0                <1> 	rol	al, 1			; MOVE NMI BIT TO LOW POSITION
   546 00006CD3 F9                  <1> 	stc				; FORCE NMI BIT ON IN CARRY FLAG
   547 00006CD4 D0D8                <1> 	rcr	al, 1			; HIGH BIT ON TO DISABLE NMI - OLD IN CY
   548 00006CD6 FA                  <1> 	cli				; DISABLE INTERRUPTS
   549 00006CD7 E670                <1> 	out	CMOS_PORT, al		; ADDRESS LOCATION AND DISABLE NMI
   550 00006CD9 88E0                <1> 	mov	al, ah			; GET THE DATA BYTE TO WRITE
   551 00006CDB E671                <1> 	out	CMOS_DATA, al		; PLACE IN REQUESTED CMOS LOCATION
   552 00006CDD B01E                <1> 	mov	al, CMOS_SHUT_DOWN*2	; GET ADDRESS OF DEFAULT LOCATION
   553                              <1> 	;mov	al, CMOS_REG_D*2 	; GET ADDRESS OF DEFAULT LOCATION
   554 00006CDF D0D8                <1> 	rcr	al, 1			; PUT ORIGINAL NMI MASK BIT INTO ADDRESS
   555 00006CE1 E670                <1> 	out	CMOS_PORT, al		; SET DEFAULT TO READ ONLY REGISTER
   556 00006CE3 90                  <1> 	nop				; I/O DELAY
   557 00006CE4 E471                <1> 	in	al, CMOS_DATA		; OPEN STANDBY LATCH
   558 00006CE6 6658                <1> 	pop	ax			; RESTORE WORK REGISTERS
   559 00006CE8 9D                  <1> 	popf
   560 00006CE9 C3                  <1> 	retn
   561                              <1> 
   562                              <1> ; /// End Of TIMER FUNCTIONS ///
  2889                                  
  2890 00006CEA 90<rept>                Align 16
  2891                                  
  2892                                  gdt:	; Global Descriptor Table
  2893                                  	; 02/12/2020
  2894                                  	; (30/07/2015, conforming cs)
  2895                                  	; (26/03/2015)
  2896                                  	; (24/03/2015, tss)
  2897                                  	; (19/03/2015)
  2898                                  	; (29/12/2013)
  2899                                  	;
  2900 00006CF0 0000000000000000        	dw 0, 0, 0, 0		; NULL descriptor
  2901                                  gdt_kcode:
  2902                                  	; 18/08/2014
  2903                                  			; 8h kernel code segment, base = 00000000h		
  2904                                  	;dw 0FFFFh, 0, 9E00h, 00CFh	; KCODE  ; 30/12/2016	 
  2905 00006CF8 FFFF0000009ACF00        	dw 0FFFFh, 0, 9A00h, 00CFh	; KCODE
  2906                                  gdt_kdata:
  2907                                  			; 10h kernel data segment, base = 00000000h	
  2908 00006D00 FFFF00000092CF00        	dw 0FFFFh, 0, 9200h, 00CFh	; KDATA
  2909                                  gdt_ucode:
  2910                                  			; 1Bh user code segment, base address = 400000h ; CORE
  2911                                  	;dw 0FBFFh, 0, 0FE40h, 00CFh	; UCODE  ; 30/12/2016	
  2912 00006D08 FFFB000040FACF00        	dw 0FBFFh, 0, 0FA40h, 00CFh	; UCODE
  2913                                  gdt_udata: 
  2914                                  			; 23h user data segment, base address = 400000h ; CORE
  2915 00006D10 FFFB000040F2CF00        	dw 0FBFFh, 0, 0F240h, 00CFh	; UDATA
  2916                                  gdt_tss:
  2917                                  			; Task State Segment
  2918 00006D18 6700                    	dw 0067h ; Limit = 103 ; (104-1, tss size = 104 byte, 
  2919                                  			       ;  no IO permission in ring 3)
  2920                                  gdt_tss0:
  2921 00006D1A 0000                    	dw 0  ; TSS base address, bits 0-15 
  2922                                  gdt_tss1:
  2923 00006D1C 00                      	db 0  ; TSS base address, bits 16-23 
  2924                                  	      		; 49h	
  2925 00006D1D E9                      	db 11101001b ; 0E9h => P=1/DPL=11/0/1/0/B/1 --> B = Task is busy (1)
  2926 00006D1E 00                      	db 0 ; G/0/0/AVL/LIMIT=0000 ; (Limit bits 16-19 = 0000) (G=0, 1 byte)
  2927                                  gdt_tss2:
  2928 00006D1F 00                      	db 0  ; TSS base address, bits 24-31 
  2929                                  
  2930                                  	; 30/11/2020
  2931                                  	; 29/11/2020 - TRDOS v2.0.3
  2932                                  	; VESA VBE3 VIDE BIOS 32 BIT PMI SEGMENTS (16 bit segments)
  2933                                  			; 30h ; VBE3CS
  2934                                  _vbe3_CS:  ; vesa vbe3 bios uses this as code seg (same addr with _vbe3_DS)
  2935                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/C/R/A = 9Ah, 16 bit
  2936 00006D20 FFFF0000009A0000        	dw 0FFFFh, 0, 9A00h, 0 ; Note: base addr will be initialized
  2937                                  			; 38h ; VBE3BDS
  2938                                  _vbe3_BDS: ; vesa vbe3 bios uses this as equivalent of rombios data segment
  2939                                  	; limit = 1536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2940 00006D28 FF05000000920000        	dw 05FFh, 0, 9200h, 0 ; Note: base addr will be initialized	
  2941                                  			; 40h ; VBE3A000 
  2942                                  _A0000Sel: ; VGA default video memory address
  2943                                  	; limit = 65536, base addr = 0A0000h, 16 bit
  2944 00006D30 FFFF00000A920000        	dw 0FFFFh, 0, 920Ah, 0
  2945                                  			; 48h ; VBE3B000 
  2946                                  _B0000Sel: ; MDA (monochrome) video memory address
  2947                                  	; limit = 65536, base addr = 0B0000h, 16 bit
  2948 00006D38 FFFF00000B920000        	dw 0FFFFh, 0, 920Bh, 0
  2949                                  			; 50h ; VBE3B800 
  2950                                  _B8000Sel: ; CGA video memory address
  2951                                  	; limit = 32768, base addr = 0B8000h, 16 bit
  2952 00006D40 FF7F00800B920000        	dw 07FFFh, 8000h, 920Bh, 0
  2953                                  			; 58h ; VBE3DS 
  2954                                  _vbe3_DS: ; vesa vbe3 bios uses this as data seg (CodeSegSel in PMInfoBlock)
  2955                                  	; limit = 65536, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2956 00006D48 FFFF000000920000        	dw 0FFFFh, 0, 9200h, 0 ; Note: base addr will be initialized
  2957                                  			; 60h ; VBE3SS   
  2958                                  _vbe3_SS: ; kernel's stack segment but 16 bit version (same stack addr)
  2959                                  	; limit = 1024, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2960 00006D50 FF03000000920000        	dw 03FFh, 0, 9200h, 0 ; Note: base addr will be initialized
  2961                                  			; 68h ; VBE3ES 	
  2962                                  _vbe3_ES: ; extra 16 bit segment points to buffers in kernel's mem space
  2963                                  	; limit = 2048, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2964 00006D58 FF07000000920000        	dw 07FFh, 0, 9200h,0 ; Note: base addr will be initialized
  2965                                  			; 70h ; KODE16	
  2966                                  _16bit_CS: ; 16 bit code segment points to kernel's far return addr
  2967                                  	; limit = 16M, base addr = 0, P/DPL/1/Type/E/W/A = 92h, 16 bit
  2968 00006D60 FFFF0000009AFF00        	dw 0FFFFh, 0, 9A00h, 00FFh ; Note: base addr will be initialized
  2969                                  
  2970                                  gdt_end:
  2971                                  	;; 9Eh = 1001 1110b (GDT byte 5) P=1/DPL=00/1/TYPE=1110, 
  2972                                  					;; Type= 1 (code)/C=1/R=1/A=0
  2973                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2974                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
  2975                                  
  2976                                  	;; 9Ah = 1001 1010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  2977                                  					;; Type= 1 (code)/C=0/R=1/A=0
  2978                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2979                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  2980                                  
  2981                                  	;; 92h = 1001 0010b (GDT byte 5) P=1/DPL=00/1/TYPE=1010, 
  2982                                  					;; Type= 0 (data)/E=0/W=1/A=0
  2983                                  		; P= Present, DPL=0=ring 0,  1= user (0= system)
  2984                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  2985                                  		; W= Writeable, A= Accessed
  2986                                  
  2987                                  	;; FEh = 1111 1110b (GDT byte 5) P=1/DPL=11/1/TYPE=1110, 
  2988                                  					;; Type= 1 (code)/C=1/R=1/A=0
  2989                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  2990                                  		; 1= Code C= Conforming, R= Readable, A = Accessed
  2991                                  	
  2992                                  	;; FAh = 1111 1010b (GDT byte 5) P=1/DPL=11/1/TYPE=1010, 
  2993                                  					;; Type= 1 (code)/C=0/R=1/A=0
  2994                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  2995                                  		; 1= Code C= non-Conforming, R= Readable, A = Accessed
  2996                                  
  2997                                  	;; F2h = 1111 0010b (GDT byte 5) P=1/DPL=11/1/TYPE=0010, 
  2998                                  					;; Type= 0 (data)/E=0/W=1/A=0
  2999                                  		; P= Present, DPL=3=ring 3,  1= user (0= system)
  3000                                  		; 0= Data E= Expansion direction (1= down, 0= up)
  3001                                  	
  3002                                  	;; CFh = 1100 1111b (GDT byte 6) G=1/B=1/0/AVL=0, Limit=1111b (3)
  3003                                  
  3004                                  		;; Limit = FFFFFh (=> FFFFFh+1= 100000h) // bits 0-15, 48-51 //
  3005                                  		;	 = 100000h * 1000h (G=1) = 4GB
  3006                                  		;; Limit = FFBFFh (=> FFBFFh+1= FFC00h) // bits 0-15, 48-51 //
  3007                                  		;	 = FFC00h * 1000h (G=1) = 4GB - 4MB
  3008                                  		; G= Granularity (1= 4KB), B= Big (32 bit), 
  3009                                  		; AVL= Available to programmers	
  3010                                  
  3011                                  gdtd:
  3012 00006D68 7700                            dw gdt_end - gdt - 1    ; Limit (size)
  3013 00006D6A [F06C0000]                      dd gdt			; Address of the GDT
  3014                                  
  3015                                  	; 20/08/2014
  3016                                  idtd:
  3017 00006D6E 7F02                            dw idt_end - idt - 1    ; Limit (size)
  3018 00006D70 [E8860100]                      dd idt			; Address of the IDT
  3019                                  
  3020                                  ; 20/02/2017
  3021                                  ;;; 11/03/2015
  3022                                  %include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - diskdata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 24/01/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskdata.inc (11/03/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKDATA.INC
    20                              <1> ; Last Modification: 11/03/2015
    21                              <1> ;	(Initialized Disk Parameters Data section for 'DISKIO.INC') 
    22                              <1> ;
    23                              <1> 
    24                              <1> ;----------------------------------------
    25                              <1> ;	80286 INTERRUPT LOCATIONS	:
    26                              <1> ;	REFERENCED BY POST & BIOS	:
    27                              <1> ;----------------------------------------
    28                              <1> 
    29 00006D74 [D76D0000]          <1> DISK_POINTER:	dd	MD_TBL6		; Pointer to Diskette Parameter Table
    30                              <1> 
    31                              <1> ; IBM PC-XT Model 286 source code ORGS.ASM (06/10/85) - 14/12/2014
    32                              <1> ;----------------------------------------------------------------
    33                              <1> ; DISK_BASE							:
    34                              <1> ;	THIS IS THE SET OF PARAMETERS REQUIRED FOR		:
    35                              <1> ;	DISKETTE OPERATION. THEY ARE POINTED AT BY THE		:
    36                              <1> ;	DATA VARIABLE @DISK_POINTER. TO MODIFY THE PARAMETERS,	:
    37                              <1> ;	BUILD ANOTHER PARAMETER BLOCK AND POINT AT IT		:
    38                              <1> ;----------------------------------------------------------------
    39                              <1> 
    40                              <1> ;DISK_BASE:	
    41                              <1> ;	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
    42                              <1> ;	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
    43                              <1> ;	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
    44                              <1> ;	DB	2		; 512 BYTES/SECTOR
    45                              <1> ;	;DB	15		; EOT (LAST SECTOR ON TRACK)
    46                              <1> ;	db	18		; (EOT for 1.44MB diskette)
    47                              <1> ;	DB	01BH		; GAP LENGTH
    48                              <1> ;	DB	0FFH		; DTL
    49                              <1> ;	;DB	054H		; GAP LENGTH FOR FORMAT
    50                              <1> ;	db	06ch		; (for 1.44MB dsikette)
    51                              <1> ;	DB	0F6H		; FILL BYTE FOR FORMAT
    52                              <1> ;	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
    53                              <1> ;	DB	8		; MOTOR START TIME (1/8 SECONDS)
    54                              <1> 
    55                              <1> ;----------------------------------------
    56                              <1> ;	ROM BIOS DATA AREAS		:
    57                              <1> ;----------------------------------------
    58                              <1> 
    59                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
    60                              <1> 
    61                              <1> ;@EQUIP_FLAG	DW	?		; INSTALLED HARDWARE FLAGS
    62                              <1> 
    63                              <1> ;----------------------------------------
    64                              <1> ;	DISKETTE DATA AREAS		:
    65                              <1> ;----------------------------------------
    66                              <1> 
    67                              <1> ;@SEEK_STATUS	DB	?		; DRIVE RECALIBRATION STATUS
    68                              <1> ;					; BIT 3-0 = DRIVE 3-0 RECALIBRATION
    69                              <1> ;					; BEFORE NEXT SEEK IF BIT IS = 0
    70                              <1> ;@MOTOR_STATUS	DB	?		; MOTOR STATUS
    71                              <1> ;					; BIT 3-0 = DRIVE 3-0 CURRENTLY RUNNING
    72                              <1> ;					; BIT 7 = CURRENT OPERATION IS A WRITE
    73                              <1> ;@MOTOR_COUNT	DB	?		; TIME OUT COUNTER FOR MOTOR(S) TURN OFF
    74                              <1> ;@DSKETTE_STATUS DB	?		; RETURN CODE STATUS BYTE
    75                              <1> ;					; CMD_BLOCK  IN STACK FOR DISK OPERATION
    76                              <1> ;@NEC_STATUS	DB	7 DUP(?)	; STATUS BYTES FROM DISKETTE OPERATION
    77                              <1> 
    78                              <1> ;----------------------------------------
    79                              <1> ;	POST AND BIOS WORK DATA AREA	:
    80                              <1> ;----------------------------------------
    81                              <1> 
    82                              <1> ;@INTR_FLAG	DB	?		; FLAG INDICATING AN INTERRUPT HAPPENED
    83                              <1> 
    84                              <1> ;----------------------------------------
    85                              <1> ;	TIMER DATA AREA 		:
    86                              <1> ;----------------------------------------
    87                              <1> 
    88                              <1> ; 17/12/2014  (IRQ 0 - INT 08H)
    89                              <1> ;TIMER_LOW	equ	46Ch		; Timer ticks (counter)  @ 40h:006Ch
    90                              <1> ;TIMER_HIGH	equ	46Eh		; (18.2 timer ticks per second)
    91                              <1> ;TIMER_OFL	equ	470h		; Timer - 24 hours flag  @ 40h:0070h
    92                              <1> 
    93                              <1> ;----------------------------------------
    94                              <1> ;	ADDITIONAL MEDIA DATA		:
    95                              <1> ;----------------------------------------
    96                              <1> 
    97                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
    98                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
    99                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
   100                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
   101                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
   102                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
   103                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
   104                              <1> 
   105                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
   106                              <1> 
   107                              <1> ;--------------------------------------------------------
   108                              <1> ;	DRIVE TYPE TABLE				:
   109                              <1> ;--------------------------------------------------------
   110                              <1> 		; 16/02/2015 (unix386.s, 32 bit modifications)
   111                              <1> DR_TYPE:
   112 00006D78 01                  <1> 		DB	01		;DRIVE TYPE, MEDIA TABLE
   113                              <1>                 ;DW      MD_TBL1
   114 00006D79 [966D0000]          <1> 		dd	MD_TBL1
   115 00006D7D 82                  <1> 		DB	02+BIT7ON
   116                              <1> 		;DW      MD_TBL2
   117 00006D7E [A36D0000]          <1>                 dd      MD_TBL2
   118 00006D82 02                  <1> DR_DEFAULT:	DB	02
   119                              <1>                 ;DW      MD_TBL3
   120 00006D83 [B06D0000]          <1> 		dd      MD_TBL3
   121 00006D87 03                  <1> 		DB	03
   122                              <1>                 ;DW      MD_TBL4
   123 00006D88 [BD6D0000]          <1> 		dd      MD_TBL4
   124 00006D8C 84                  <1> 		DB	04+BIT7ON
   125                              <1>                 ;DW      MD_TBL5
   126 00006D8D [CA6D0000]          <1> 		dd      MD_TBL5
   127 00006D91 04                  <1> 		DB	04
   128                              <1>                 ;DW      MD_TBL6
   129 00006D92 [D76D0000]          <1> 		dd      MD_TBL6
   130                              <1> DR_TYPE_E       equ $                   ; END OF TABLE
   131                              <1> ;DR_CNT		EQU	(DR_TYPE_E-DR_TYPE)/3
   132                              <1> DR_CNT		equ	(DR_TYPE_E-DR_TYPE)/5
   133                              <1> ;--------------------------------------------------------
   134                              <1> ;	MEDIA/DRIVE PARAMETER TABLES			:
   135                              <1> ;--------------------------------------------------------
   136                              <1> ;--------------------------------------------------------
   137                              <1> ;	360 KB MEDIA IN 360 KB DRIVE			:
   138                              <1> ;--------------------------------------------------------
   139                              <1> MD_TBL1:        
   140 00006D96 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   141 00006D97 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   142 00006D98 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   143 00006D99 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   144 00006D9A 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   145 00006D9B 2A                  <1> 	DB	02AH		; GAP LENGTH
   146 00006D9C FF                  <1> 	DB	0FFH		; DTL
   147 00006D9D 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   148 00006D9E F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   149 00006D9F 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   150 00006DA0 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   151 00006DA1 27                  <1> 	DB	39		; MAX. TRACK NUMBER
   152 00006DA2 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
   153                              <1> ;--------------------------------------------------------
   154                              <1> ;	360 KB MEDIA IN 1.2 MB DRIVE			:
   155                              <1> ;--------------------------------------------------------
   156                              <1> MD_TBL2:        
   157 00006DA3 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   158 00006DA4 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   159 00006DA5 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   160 00006DA6 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   161 00006DA7 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   162 00006DA8 2A                  <1> 	DB	02AH		; GAP LENGTH
   163 00006DA9 FF                  <1> 	DB	0FFH		; DTL
   164 00006DAA 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   165 00006DAB F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   166 00006DAC 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   167 00006DAD 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   168 00006DAE 27                  <1> 	DB	39		; MAX. TRACK NUMBER
   169 00006DAF 40                  <1> 	DB	RATE_300	; DATA TRANSFER RATE
   170                              <1> ;--------------------------------------------------------
   171                              <1> ;	1.2 MB MEDIA IN 1.2 MB DRIVE			:
   172                              <1> ;--------------------------------------------------------
   173                              <1> MD_TBL3:
   174 00006DB0 DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   175 00006DB1 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   176 00006DB2 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   177 00006DB3 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   178 00006DB4 0F                  <1> 	DB	15		; EOT (LAST SECTOR ON TRACK)
   179 00006DB5 1B                  <1> 	DB	01BH		; GAP LENGTH
   180 00006DB6 FF                  <1> 	DB	0FFH		; DTL
   181 00006DB7 54                  <1> 	DB	054H		; GAP LENGTH FOR FORMAT
   182 00006DB8 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   183 00006DB9 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   184 00006DBA 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   185 00006DBB 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   186 00006DBC 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
   187                              <1> ;--------------------------------------------------------
   188                              <1> ;	720 KB MEDIA IN 720 KB DRIVE			:
   189                              <1> ;--------------------------------------------------------
   190                              <1> MD_TBL4:
   191 00006DBD DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   192 00006DBE 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   193 00006DBF 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   194 00006DC0 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   195 00006DC1 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   196 00006DC2 2A                  <1> 	DB	02AH		; GAP LENGTH
   197 00006DC3 FF                  <1> 	DB	0FFH		; DTL
   198 00006DC4 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   199 00006DC5 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   200 00006DC6 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   201 00006DC7 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   202 00006DC8 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   203 00006DC9 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
   204                              <1> ;--------------------------------------------------------
   205                              <1> ;	720 KB MEDIA IN 1.44 MB DRIVE			:
   206                              <1> ;--------------------------------------------------------
   207                              <1> MD_TBL5:
   208 00006DCA DF                  <1> 	DB	11011111B	; SRT=D, HD UNLOAD=0F - 1ST SPECIFY BYTE
   209 00006DCB 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   210 00006DCC 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   211 00006DCD 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   212 00006DCE 09                  <1> 	DB	09		; EOT (LAST SECTOR ON TRACK)
   213 00006DCF 2A                  <1> 	DB	02AH		; GAP LENGTH
   214 00006DD0 FF                  <1> 	DB	0FFH		; DTL
   215 00006DD1 50                  <1> 	DB	050H		; GAP LENGTH FOR FORMAT
   216 00006DD2 F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   217 00006DD3 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   218 00006DD4 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   219 00006DD5 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   220 00006DD6 80                  <1> 	DB	RATE_250	; DATA TRANSFER RATE
   221                              <1> ;--------------------------------------------------------
   222                              <1> ;	1.44 MB MEDIA IN 1.44 MB DRIVE			:
   223                              <1> ;--------------------------------------------------------
   224                              <1> MD_TBL6:
   225 00006DD7 AF                  <1> 	DB	10101111B	; SRT=A, HD UNLOAD=0F - 1ST SPECIFY BYTE
   226 00006DD8 02                  <1> 	DB	2		; HD LOAD=1, MODE=DMA - 2ND SPECIFY BYTE
   227 00006DD9 25                  <1> 	DB	MOTOR_WAIT	; WAIT TIME AFTER OPERATION TILL MOTOR OFF
   228 00006DDA 02                  <1> 	DB	2		; 512 BYTES/SECTOR
   229 00006DDB 12                  <1> 	DB	18		; EOT (LAST SECTOR ON TRACK)
   230 00006DDC 1B                  <1> 	DB	01BH		; GAP LENGTH
   231 00006DDD FF                  <1> 	DB	0FFH		; DTL
   232 00006DDE 6C                  <1> 	DB	06CH		; GAP LENGTH FOR FORMAT
   233 00006DDF F6                  <1> 	DB	0F6H		; FILL BYTE FOR FORMAT
   234 00006DE0 0F                  <1> 	DB	15		; HEAD SETTLE TIME (MILLISECONDS)
   235 00006DE1 08                  <1> 	DB	8		; MOTOR START TIME (1/8 SECONDS)
   236 00006DE2 4F                  <1> 	DB	79		; MAX. TRACK NUMBER
   237 00006DE3 00                  <1> 	DB	RATE_500	; DATA TRANSFER RATE
   238                              <1> 
   239                              <1> 
   240                              <1> ; << diskette.inc >>
   241                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   242                              <1> ;
   243                              <1> ;----------------------------------------
   244                              <1> ;	ROM BIOS DATA AREAS		:
   245                              <1> ;----------------------------------------
   246                              <1> 
   247                              <1> ;DATA		SEGMENT AT 40H		; ADDRESS= 0040:0000
   248                              <1> 
   249                              <1> ;----------------------------------------
   250                              <1> ;	FIXED DISK DATA AREAS		:
   251                              <1> ;----------------------------------------
   252                              <1> 
   253                              <1> ;DISK_STATUS1:	DB	0		; FIXED DISK STATUS
   254                              <1> ;HF_NUM:		DB	0		; COUNT OF FIXED DISK DRIVES
   255                              <1> ;CONTROL_BYTE:	DB	0		; HEAD CONTROL BYTE
   256                              <1> ;@PORT_OFF	DB	?		;  RESERVED (PORT OFFSET)
   257                              <1> 
   258                              <1> ;----------------------------------------
   259                              <1> ;	ADDITIONAL MEDIA DATA		:
   260                              <1> ;----------------------------------------
   261                              <1> 
   262                              <1> ;@LASTRATE	DB	?		; LAST DISKETTE DATA RATE SELECTED
   263                              <1> ;HF_STATUS	DB	0		; STATUS REGISTER
   264                              <1> ;HF_ERROR	DB	0		; ERROR REGISTER
   265                              <1> ;HF_INT_FLAG	DB	0		; FIXED DISK INTERRUPT FLAG
   266                              <1> ;HF_CNTRL	DB	0		; COMBO FIXED DISK/DISKETTE CARD BIT 0=1
   267                              <1> ;@DSK_STATE	DB	?		; DRIVE 0 MEDIA STATE
   268                              <1> ;		DB	?		; DRIVE 1 MEDIA STATE
   269                              <1> ;		DB	?		; DRIVE 0 OPERATION START STATE
   270                              <1> ;		DB	?		; DRIVE 1 OPERATION START STATE
   271                              <1> ;@DSK_TRK	DB	?		; DRIVE 0 PRESENT CYLINDER
   272                              <1> ;		DB	?		; DRIVE 1 PRESENT CYLINDER
   273                              <1> 
   274                              <1> ;DATA		ENDS			; END OF BIOS DATA SEGMENT
   275                              <1> ;
   276                              <1> ; +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
   277                              <1> 
   278                              <1> ERR_TBL:
   279 00006DE4 E0                  <1> 	db	NO_ERR
   280 00006DE5 024001BB            <1> 	db	BAD_ADDR_MARK,BAD_SEEK,BAD_CMD,UNDEF_ERR
   281 00006DE9 04BB100A            <1> 	db	RECORD_NOT_FND,UNDEF_ERR,BAD_ECC,BAD_SECTOR
   282                              <1> 
   283                              <1> ; 17/12/2014 (mov ax, [cfd])
   284                              <1> ; 11/12/2014
   285 00006DED 00                  <1> cfd:		db 0			; current floppy drive (for GET_PARM)
   286                              <1> ; 17/12/2014				; instead of 'DISK_POINTER'
   287 00006DEE 01                  <1> pfd:		db 1			; previous floppy drive (for GET_PARM)
   288                              <1> 					; (initial value of 'pfd 
   289                              <1> 					; must be different then 'cfd' value
   290                              <1> 					; to force updating/initializing
   291                              <1> 					; current drive parameters) 
   292 00006DEF 90                  <1> align 2
   293                              <1> 
   294 00006DF0 F001                <1> HF_PORT:	dw 	1F0h  ; Default = 1F0h
   295                              <1> 			      ; (170h)
   296 00006DF2 F603                <1> HF_REG_PORT:	dw	3F6h  ; HF_PORT + 206h
   297                              <1> 
   298                              <1> ; 05/01/2015 
   299 00006DF4 00                  <1> hf_m_s:         db      0     ; (0 = Master, 1 = Slave)
   300                              <1> 
   301                              <1> ; *****************************************************************************
  3023                                  
  3024 00006DF5 90                      Align 2
  3025                                  
  3026                                  ; 04/11/2014 (Retro UNIX 386 v1)
  3027 00006DF6 0000                    mem_1m_1k:   dw 0  ; Number of contiguous KB between
  3028                                                       ; 1 and 16 MB, max. 3C00h = 15 MB.
  3029 00006DF8 0000                    mem_16m_64k: dw 0  ; Number of contiguous 64 KB blocks
  3030                                  		   ; between 16 MB and 4 GB.
  3031                                  
  3032                                  ; 12/11/2014 (Retro UNIX 386 v1)
  3033 00006DFA 00                      boot_drv:    db 0 ; boot drive number (physical)
  3034                                  ; 24/11/2014
  3035 00006DFB 00                      drv:	     db 0 
  3036 00006DFC 00                      last_drv:    db 0 ; last hdd
  3037 00006DFD 00                      hdc:         db 0  ; number of hard disk drives
  3038                                  		     ; (present/detected)
  3039                                  
  3040                                  ; 24/11/2014 (Retro UNIX 386 v1)
  3041                                  ; Physical drive type & flags
  3042 00006DFE 00                      fd0_type:    db 0  ; floppy drive type
  3043 00006DFF 00                      fd1_type:    db 0  ; 4 = 1.44 Mb, 80 track, 3.5" (18 spt)
  3044                                  		     ; 6 = 2.88 Mb, 80 track, 3.5" (36 spt)
  3045                                  		     ; 3 = 720 Kb, 80 track, 3.5" (9 spt)
  3046                                  		     ; 2 = 1.2 Mb, 80 track, 5.25" (15 spt)
  3047                                  		     ; 1 = 360 Kb, 40 track, 5.25" (9 spt)		
  3048 00006E00 00                      hd0_type:    db 0  ; EDD status for hd0 (bit 7 = present flag)
  3049 00006E01 00                      hd1_type:    db 0  ; EDD status for hd1 (bit 7 = present flag)
  3050 00006E02 00                      hd2_type:    db 0  ; EDD status for hd2 (bit 7 = present flag)
  3051 00006E03 00                      hd3_type:    db 0  ; EDD status for hd3 (bit 7 = present flag)
  3052                                  		     ; bit 0 - Fixed disk access subset supported
  3053                                  		     ; bit 1 - Drive locking and ejecting
  3054                                  		     ; bit 2 - Enhanced disk drive support
  3055                                  		     ; bit 3 = Reserved (64 bit EDD support)
  3056                                  		     ; (If bit 0 is '1' Retro UNIX 386 v1
  3057                                  		     ; will interpret it as 'LBA ready'!)
  3058                                  
  3059                                  ; 11/03/2015 - 10/07/2015
  3060 00006E04 000000000000000000-     drv.cylinders: dw 0,0,0,0,0,0,0
  3060 00006E0D 0000000000         
  3061 00006E12 000000000000000000-     drv.heads:     dw 0,0,0,0,0,0,0
  3061 00006E1B 0000000000         
  3062 00006E20 000000000000000000-     drv.spt:       dw 0,0,0,0,0,0,0
  3062 00006E29 0000000000         
  3063 00006E2E 000000000000000000-     drv.size:      dd 0,0,0,0,0,0,0
  3063 00006E37 000000000000000000-
  3063 00006E40 000000000000000000-
  3063 00006E49 00                 
  3064 00006E4A 00000000000000          drv.status:    db 0,0,0,0,0,0,0
  3065 00006E51 00000000000000          drv.error:     db 0,0,0,0,0,0,0	
  3066                                  
  3067                                  Align 2
  3068                                  
  3069                                  ;;; 11/03/2015
  3070                                  %include 'kybdata.s'	; KEYBOARD (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - kybdata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 17/01/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 17/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; kybdata.inc (11/03/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - KYBDATA.INC
    20                              <1> ; Last Modification: 11/03/2015
    21                              <1> ;		 (Data Section for 'KEYBOARD.INC')	
    22                              <1> ;
    23                              <1> ; ///////// KEYBOARD DATA ///////////////
    24                              <1> 
    25                              <1> ; 05/12/2014
    26                              <1> ; 04/12/2014 (derived from pc-xt-286 bios source code -1986-) 
    27                              <1> ; 03/06/86  KEYBOARD BIOS
    28                              <1> 
    29                              <1> ;---------------------------------------------------------------------------------
    30                              <1> ;	KEY IDENTIFICATION SCAN TABLES
    31                              <1> ;---------------------------------------------------------------------------------
    32                              <1> 
    33                              <1> ;-----	TABLES FOR ALT CASE ------------
    34                              <1> ;-----	ALT-INPUT-TABLE 
    35 00006E58 524F50514B          <1> K30:	db	82,79,80,81,75
    36 00006E5D 4C4D474849          <1> 	db	76,77,71,72,73		; 10 NUMBER ON KEYPAD
    37                              <1> ;-----	SUPER-SHIFT-TABLE 
    38 00006E62 101112131415        <1> 	db	16,17,18,19,20,21	; A-Z TYPEWRITER CHARS
    39 00006E68 161718191E1F        <1> 	db	22,23,24,25,30,31
    40 00006E6E 202122232425        <1> 	db	32,33,34,35,36,37
    41 00006E74 262C2D2E2F30        <1> 	db	38,44,45,46,47,48
    42 00006E7A 3132                <1> 	db	49,50
    43                              <1> 
    44                              <1> ;-----	TABLE OF SHIFT KEYS AND MASK VALUES
    45                              <1> ;-----	KEY_TABLE 
    46 00006E7C 52                  <1> _K6:    db      INS_KEY                 ; INSERT KEY
    47 00006E7D 3A4546381D          <1> 	db	CAPS_KEY,NUM_KEY,SCROLL_KEY,ALT_KEY,CTL_KEY
    48 00006E82 2A36                <1>         db      LEFT_KEY,RIGHT_KEY
    49                              <1> _K6L    equ     $-_K6
    50                              <1> 
    51                              <1> ;-----	MASK_TABLE
    52 00006E84 80                  <1> _K7:    db      INS_SHIFT               ; INSERT MODE SHIFT
    53 00006E85 4020100804          <1> 	db	CAPS_SHIFT,NUM_SHIFT,SCROLL_SHIFT,ALT_SHIFT,CTL_SHIFT
    54 00006E8A 0201                <1> 	db	LEFT_SHIFT,RIGHT_SHIFT
    55                              <1> 
    56                              <1> ;-----	TABLES FOR CTRL CASE		;---- CHARACTERS ------
    57 00006E8C 1BFF00FFFFFF        <1> _K8:	db	27,-1,0,-1,-1,-1	; Esc, 1, 2, 3, 4, 5
    58 00006E92 1EFFFFFFFF1F        <1> 	db 	30,-1,-1,-1,-1,31	; 6, 7, 8, 9, 0, -
    59 00006E98 FF7FFF111705        <1> 	db	-1,127,-1,17,23,5	; =, Bksp, Tab, Q, W, E
    60 00006E9E 12141915090F        <1> 	db	18,20,25,21,9,15	; R, T, Y, U, I, O
    61 00006EA4 101B1D0AFF01        <1> 	db	16,27,29,10,-1,1	; P, [, ], Enter, Ctrl, A
    62 00006EAA 13040607080A        <1> 	db	19,4,6,7,8,10		; S, D, F, G, H, J
    63 00006EB0 0B0CFFFFFFFF        <1> 	db	11,12,-1,-1,-1,-1	; K, L, :, ', `, LShift
    64 00006EB6 1C1A18031602        <1> 	db	28,26,24,3,22,2		; Bkslash, Z, X, C, V, B
    65 00006EBC 0E0DFFFFFFFF        <1> 	db	14,13,-1,-1,-1,-1	; N, M, ,, ., /, RShift
    66 00006EC2 96FF20FF            <1> 	db	150,-1,' ',-1		; *, ALT, Spc, CL
    67                              <1> 	;				;----- FUNCTIONS ------		
    68 00006EC6 5E5F60616263        <1> 	db 	94,95,96,97,98,99	; F1 - F6
    69 00006ECC 64656667FFFF        <1> 	db	100,101,102,103,-1,-1	; F7 - F10, NL, SL
    70 00006ED2 778D848E738F        <1> 	db	119,141,132,142,115,143	; Home, Up, PgUp, -, Left, Pad5
    71 00006ED8 749075917692        <1> 	db 	116,144,117,145,118,146 ; Right, +, End, Down, PgDn, Ins
    72 00006EDE 93FFFFFF898A        <1> 	db	147,-1,-1,-1,137,138	; Del, SysReq, Undef, WT, F11, F12
    73                              <1> 
    74                              <1> ;-----	TABLES FOR LOWER CASE ----------
    75 00006EE4 1B3132333435363738- <1> K10:	db 	27,'1234567890-=',8,9
    75 00006EED 39302D3D0809        <1>
    76 00006EF3 71776572747975696F- <1> 	db 	'qwertyuiop[]',13,-1,'asdfghjkl;',39
    76 00006EFC 705B5D0DFF61736466- <1>
    76 00006F05 67686A6B6C3B27      <1>
    77 00006F0C 60FF5C7A786376626E- <1> 	db	96,-1,92,'zxcvbnm,./',-1,'*',-1,' ',-1
    77 00006F15 6D2C2E2FFF2AFF20FF  <1>
    78                              <1> ;-----	LC TABLE SCAN
    79 00006F1E 3B3C3D3E3F          <1> 	db	59,60,61,62,63		; BASE STATE OF F1 - F10
    80 00006F23 4041424344          <1> 	db	64,65,66,67,68
    81 00006F28 FFFF                <1> 	db	-1,-1			; NL, SL
    82                              <1> 
    83                              <1> ;-----	KEYPAD TABLE
    84 00006F2A 474849FF4BFF        <1> K15:	db	71,72,73,-1,75,-1	; BASE STATE OF KEYPAD KEYS
    85 00006F30 4DFF4F50515253      <1> 	db	77,-1,79,80,81,82,83
    86 00006F37 FFFF5C8586          <1> 	db	-1,-1,92,133,134	; SysRq, Undef, WT, F11, F12
    87                              <1> 
    88                              <1> ;-----	TABLES FOR UPPER CASE ----------
    89 00006F3C 1B21402324255E262A- <1> K11:	db 	27,'!@#$%',94,'&*()_+',8,0
    89 00006F45 28295F2B0800        <1>
    90 00006F4B 51574552545955494F- <1> 	db 	'QWERTYUIOP{}',13,-1,'ASDFGHJKL:"'
    90 00006F54 507B7D0DFF41534446- <1>
    90 00006F5D 47484A4B4C3A22      <1>
    91 00006F64 7EFF7C5A584356424E- <1> 	db	126,-1,'|ZXCVBNM<>?',-1,'*',-1,' ',-1
    91 00006F6D 4D3C3E3FFF2AFF20FF  <1>
    92                              <1> ;-----	UC TABLE SCAN
    93 00006F76 5455565758          <1> K12:	db	84,85,86,87,88		; SHIFTED STATE OF F1 - F10
    94 00006F7B 595A5B5C5D          <1> 	db	89,90,91,92,93
    95 00006F80 FFFF                <1> 	db	-1,-1			; NL, SL
    96                              <1> 
    97                              <1> ;-----	NUM STATE TABLE
    98 00006F82 3738392D3435362B31- <1> K14:	db 	'789-456+1230.'		; NUMLOCK STATE OF KEYPAD KEYS
    98 00006F8B 3233302E            <1>
    99                              <1> 	;
   100 00006F8F FFFF7C8788          <1> 	db	-1,-1,124,135,136	; SysRq, Undef, WT, F11, F12
   101                              <1> 
   102                              <1> ; 26/08/2014
   103                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (03/03/2014)
   104                              <1> ; Derived from IBM "pc-at" 
   105                              <1> ; rombios source code (06/10/1985)
   106                              <1> ; 'dseg.inc'
   107                              <1> 
   108                              <1> ;---------------------------------------;
   109                              <1> ;	SYSTEM DATA AREA		;
   110                              <1> ;----------------------------------------
   111 00006F94 00                  <1> BIOS_BREAK	db	0		; BIT 7=1 IF BREAK KEY HAS BEEN PRESSED
   112                              <1> 
   113                              <1> ;----------------------------------------
   114                              <1> ;	KEYBOARD DATA AREAS		;
   115                              <1> ;----------------------------------------
   116                              <1> 
   117 00006F95 00                  <1> KB_FLAG		db	0		; KEYBOARD SHIFT STATE AND STATUS FLAGS
   118 00006F96 00                  <1> KB_FLAG_1	db	0		; SECOND BYTE OF KEYBOARD STATUS
   119 00006F97 00                  <1> KB_FLAG_2	db	0		; KEYBOARD LED FLAGS
   120 00006F98 00                  <1> KB_FLAG_3	db	0		; KEYBOARD MODE STATE AND TYPE FLAGS
   121 00006F99 00                  <1> ALT_INPUT	db	0		; STORAGE FOR ALTERNATE KEY PAD ENTRY
   122 00006F9A [AA6F0000]          <1> BUFFER_START	dd	KB_BUFFER 	; OFFSET OF KEYBOARD BUFFER START
   123 00006F9E [CA6F0000]          <1> BUFFER_END	dd	KB_BUFFER + 32	; OFFSET OF END OF BUFFER
   124 00006FA2 [AA6F0000]          <1> BUFFER_HEAD	dd	KB_BUFFER 	; POINTER TO HEAD OF KEYBOARD BUFFER
   125 00006FA6 [AA6F0000]          <1> BUFFER_TAIL	dd	KB_BUFFER 	; POINTER TO TAIL OF KEYBOARD BUFFER
   126                              <1> ; ------	HEAD = TAIL	INDICATES THAT THE BUFFER IS EMPTY
   127 00006FAA 0000<rept>          <1> KB_BUFFER	times	16 dw 0		; ROOM FOR 16 SCAN CODE ENTRIES
   128                              <1> 
   129                              <1> ; /// End Of KEYBOARD DATA ///
  3071                                  %include 'vidata.s'	; VIDEO (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vidata.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 24/11/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; vidata.inc (11/03/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-AT' BIOS source code (1985) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - VIDATA.S
    20                              <1> ; Last Modification: 11/03/2015
    21                              <1> ;		    (Data section for 'VIDEO.INC')	
    22                              <1> ;
    23                              <1> ; ///////// VIDEO DATA ///////////////
    24                              <1> 
    25                              <1> ;----------------------------------------
    26                              <1> ;	VIDEO DISPLAY DATA AREA		;
    27                              <1> ;----------------------------------------
    28 00006FCA 03                  <1> CRT_MODE:	db	3	; CURRENT DISPLAY MODE (TYPE)
    29 00006FCB 29                  <1> CRT_MODE_SET:	db	29h	; CURRENT SETTING OF THE 3X8 REGISTER
    30                              <1> 				; (29h default setting for video mode 3)
    31                              <1> 				; Mode Select register Bits
    32                              <1> 				;   BIT 0 - 80x25 (1), 40x25 (0)
    33                              <1> 				;   BIT 1 - ALPHA (0), 320x200 GRAPHICS (1)
    34                              <1> 				;   BIT 2 - COLOR (0), BW (1)
    35                              <1> 				;   BIT 3 - Video Sig. ENABLE (1), DISABLE (0)
    36                              <1> 				;   BIT 4 - 640x200 B&W Graphics Mode (1)
    37                              <1> 				;   BIT 5 - ALPHA mode BLINKING (1)
    38                              <1> 				;   BIT 6, 7 - Not Used
    39                              <1> 
    40                              <1> ; Mode 0 - 2Ch = 101100b	; 40x25 text, 16 gray colors
    41                              <1> ; Mode 1 - 28h = 101000b	; 40x25 text, 16 fore colors, 8 back colors
    42                              <1> ; Mode 2 - 2Dh = 101101b	; 80x25 text, 16 gray colors	
    43                              <1> ; Mode 3 - 29h = 101001b	; 80x25 text, 16 fore color, 8 back color
    44                              <1> ; Mode 4 - 2Ah = 101010b	; 320x200 graphics, 4 colors
    45                              <1> ; Mode 5 - 2Eh = 101110b	; 320x200 graphics, 4 gray colors
    46                              <1> ; Mode 6 - 1Eh = 011110b	; 640x200 graphics, 2 colors
    47                              <1> ; Mode 7 - 29h = 101001b	; 80x25 text, black & white colors
    48                              <1> ; Mode & 37h = Video signal OFF
    49                              <1> 
    50                              <1> ; 24/06/2016
    51 00006FCC 50                  <1> CRT_COLS:	db	80	; Number of columns
    52                              <1> 
    53                              <1> ; 01/07/2016
    54 00006FCD 00                  <1> CRT_PALETTE:	db 	0	; Current palette setting
    55                              <1> 
    56                              <1> ; 03/07/2016
    57 00006FCE 10                  <1> CHAR_HEIGHT:	db	16	; Default character height
    58 00006FCF 60                  <1> VGA_VIDEO_CTL:	db	60h	; ROM BIOS DATA AREA Offset 87h
    59 00006FD0 F9                  <1> VGA_SWITCHES:	db 	0F9h	; Feature Bit Switches (the basic screen)
    60 00006FD1 51                  <1> VGA_MODESET_CTL: db	051h	; Basic mode set options (VGA video flags)
    61                              <1> 				; ROM BIOS DATA AREA Offset 89h
    62                              <1> 				; Bit 7, 4 : Mode
    63                              <1> 				;	  01 : 400-line mode
    64                              <1> 				; Bit 6	: Display switch enabled = 1			
    65                              <1> 				; Bit 5	: Reserved = 0
    66                              <1> 				; Bit 3	: Default palette loading 
    67                              <1> 				;	  disabled = 0
    68                              <1> 				; Bit 2 : Color monitor = 0
    69                              <1> 				; Bit 1 = Gray scale summing 
    70                              <1> 				;	  disabled = 0
    71                              <1> 				; Bit 0 = VGA active = 1
    72 00006FD2 19                  <1> VGA_ROWS:	db	25
    73                              <1> 
    74                              <1> ; 16/01/2016
    75                              <1> chr_attrib:  ; Character color/attributes for video pages (0 to 7)
    76 00006FD3 0707070707070707    <1> 	db	07h, 07h, 07h, 07h, 07h, 07h, 07h, 07h
    77                              <1> ; 30/01/2016
    78                              <1> vmode:
    79 00006FDB 0303030303030303    <1> 	db	3,3,3,3,3,3,3,3 ; video modes for pseudo screens 
    80                              <1> 
    81                              <1> CURSOR_MODE: ; cursor start (ch) = 14, cursor end (cl) = 15
    82 00006FE3 0F0E                <1> 	db	15, 14 ; 07/07/2016 - TRDOS 386 (TRDOS v2.0)
    83                              <1> 
    84                              <1> ;align 4
    85                              <1> ;VGA_BASE: ; 26/07/2016
    86                              <1> ;	dd	 0B8000h  ; (Mode < 0Dh) or 0A0000h (mode >= 0Dh)
    87                              <1> 
    88 00006FE5 90                  <1> align 2
    89                              <1> 
    90                              <1> vga_modes:
    91                              <1> 	; 25/07/2016
    92                              <1> 	; 09/07/2016
    93                              <1> 	; 03/07/2016
    94                              <1> 	; valid (implemented) video modes (>7, extension to IBM PC CGA modes)
    95 00006FE6 0302010007040506    <1> 	db 	03h, 02h, 01h, 00h, 07h, 04h, 05h, 06h
    96                              <1> vga_g_modes: ; 31/07/2016
    97 00006FEE 13F0126A0D0E1011    <1> 	db	13h, 0F0h, 12h, 6Ah, 0Dh, 0Eh, 10h, 11h
    98                              <1> vga_mode_count equ $ - vga_modes
    99                              <1> vga_g_mode_count equ $ - vga_g_modes
   100                              <1> 
   101                              <1> vga_mode_tbl_ptr:
   102                              <1> 	; 25/07/2016
   103 00006FF6 [56700000]          <1> 	dd	vga_mode_03h
   104 00006FFA [56700000]          <1> 	dd	vga_mode_03h ; mode 02h -> mode 03h 
   105 00006FFE [96700000]          <1> 	dd	vga_mode_01h
   106 00007002 [96700000]          <1> 	dd	vga_mode_01h ; mode 00h -> mode 01h
   107                              <1> 	;dd	vga_mode_07h
   108 00007006 [56700000]          <1> 	dd	vga_mode_03h ; mode 07h -> mode 03h
   109 0000700A [D6700000]          <1> 	dd	vga_mode_04h
   110 0000700E [D6700000]          <1> 	dd	vga_mode_04h ; mode 05h -> mode 04h	
   111 00007012 [16710000]          <1> 	dd	vga_mode_06h
   112 00007016 [56710000]          <1> 	dd	vga_mode_13h
   113 0000701A [96710000]          <1> 	dd	vga_mode_F0h
   114 0000701E [D6710000]          <1> 	dd	vga_mode_12h
   115 00007022 [16720000]          <1> 	dd	vga_mode_6Ah
   116 00007026 [56720000]          <1> 	dd	vga_mode_0Dh
   117 0000702A [96720000]          <1> 	dd	vga_mode_0Eh
   118 0000702E [D6720000]          <1> 	dd	vga_mode_10h
   119 00007032 [16730000]          <1> 	dd	vga_mode_11h	
   120                              <1> 
   121                              <1> vga_memmodel: 
   122                              <1> 	; 25/07/2016
   123                              <1> 	; 07/07/2016
   124                              <1> 	CTEXT	equ 0
   125                              <1> 	;MTEXT	equ 1
   126                              <1> 	MTEXT	equ 0 ; mode 07h -> mode 03h
   127                              <1> 	CGA	equ 2
   128                              <1> 	LINEAR8 equ 5
   129                              <1> 	PLANAR4	equ 4
   130                              <1> 	PLANAR1	equ 3
   131 00007036 0000000000020202    <1> 	db	CTEXT, CTEXT, CTEXT, CTEXT, MTEXT, CGA, CGA, CGA
   132                              <1> vga_g_memmodel: ; 31/07/2016
   133 0000703E 0504040404040403    <1> 	db	LINEAR8, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR4, PLANAR1
   134                              <1> ;vga_pixbits:
   135                              <1> ;	; 25/07/2016
   136                              <1> ;	; 08/07/2016
   137                              <1> ;	db 	4, 4, 4, 4, 4, 2, 2, 1, 8, 4, 4, 4, 4, 4, 4, 1
   138                              <1> vga_dac_s:
   139 00007046 020202020001010103- <1> 	db	2, 2, 2, 2, 0, 1, 1, 1, 3, 3, 2, 2, 1, 1, 2, 2  
   139 0000704F 03020201010202      <1>
   140                              <1> 						; (vgatables.h, VGAMODES, dac) 
   141                              <1> 						; 17/11/2020
   142                              <1> vga_params:
   143                              <1> 	; 23/11/2020
   144                              <1> 	; 16/11/2020
   145                              <1> 	; 09/11/2020, 10/11/2020, 11/11/2020 (TRDOS 386 v2.0.3)
   146                              <1> 	; 25/07/2016 
   147                              <1> 	; 19/07/2016
   148                              <1> 	; 03/07/2016
   149                              <1> 	; derived from 'Plex86/Bochs VGABios' source code
   150                              <1> 	; vgabios-0.7a (2011)
   151                              <1> 	; by the LGPL VGABios Developers Team (2001-2008)
   152                              <1> 	; 'vgatables.h'
   153                              <1> 	; Oracle VirtualBox 5.0.24 VGABios Source Code
   154                              <1> 	; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
   155                              <1> 
   156                              <1> 	; 09/11/2020
   157                              <1> 	; Block Structure of Video Parameter Table
   158                              <1> 	;
   159                              <1> 	; Offset	# Bytes		Contents
   160                              <1> 	;
   161                              <1> 	;  0		1		# columns
   162                              <1> 	;  1		1  		# rows - 1 
   163                              <1> 	;  2		1		Pixels/character
   164                              <1> 	;  3-4		2		Page length		
   165                              <1> 	;  5-8		4		Sequencer Registers
   166                              <1> 	;  9		1		Miscellaneous Register	
   167                              <1> 	;  10-34	25		CRTC Registers
   168                              <1> 	;  35-54	20		Attribute Registers
   169                              <1> 	;  55-63	9		Graphics Controller Registers
   170                              <1> 	;
   171                              <1> 	; Ref: Programmer's Guide to EGA, VGA, and Super VGA cards
   172                              <1> 	; (Richard F. Ferraro, 1994)  
   173                              <1> 
   174                              <1> 	;
   175                              <1> vga_mode_03h:  ; mode 03h, 80*25 text, CGA colors
   176                              <1> 	; 11/11/2020
   177 00007056 5018100010          <1>  	db	80, 24, 16, 00h, 10h ; tw, th-1, ch, slength (5)
   178 0000705B 00030002            <1>  	db	00h, 03h, 00h, 02h ; sequ regs (4)
   179 0000705F 67                  <1>  	db	67h	; misc reg (1)
   180 00007060 5F4F50825581BF1F    <1>  	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
   181                              <1>  	; 09/11/2020
   182                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   183 00007068 004F                <1> 	db	00h, 4Fh
   184                              <1> vga_p_cm_pos equ $ - vga_mode_03h
   185 0000706A 0D0E00000000        <1> 	db	0Dh, 0Eh, 00h, 00h, 00h, 00h
   186 00007070 9C8E8F281F96B9A3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 1Fh, 96h, 0B9h, 0A3h
   187 00007078 FF                  <1> 	db	0FFh	; crtc_regs (25)
   188 00007079 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   189 00007081 38393A3B3C3D3E3F    <1>  	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   190                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
   191 00007089 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
   192 0000708D 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs (9)
   193                              <1> 	; 09/11/2020
   194                              <1> 	;db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 00h, 0FFh ; grdc regs (9)
   195                              <1> vga_mode_01h:	; mode 01h, 40*25 text, CGA colors
   196 00007096 2818100008          <1> 	db	40, 24, 16, 00h, 08h ; tw, th-1, ch, slength
   197 0000709B 08030002            <1> 	db	08h, 03h, 00h, 02h  ; sequ regs
   198 0000709F 67                  <1> 	db	67h	; misc reg
   199 000070A0 2D2728902BA0BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 0A0h, 0BFh, 1Fh
   200 000070A8 004F0D0E00000000    <1> 	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
   201 000070B0 9C8E8F141F96B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 1Fh, 96h, 0B9h, 0A3h
   202 000070B8 FF                  <1> 	db	0FFh	; crtc_regs
   203 000070B9 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   204 000070C1 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   205                              <1>  	;db	0Ch, 00h, 0Fh, 08h  ; actl regs (20)
   206 000070C9 0C000F00            <1> 	db	0Ch, 00h, 0Fh, 00h  ; 19/11/2020
   207 000070CD 0000000000100E0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 10h, 0Eh, 0Fh, 0FFh ; grdc regs
   208                              <1> ;vga_mode_07h:	; mode 07h, 80*25 text, mono color
   209                              <1> ;	db	80, 24, 16, 00h, 10h  ; tw, th-1, ch, slength
   210                              <1> ;	db	00h, 03h, 00h, 02h ; sequ regs
   211                              <1> ;	db	66h	; misc reg
   212                              <1> ;	db	5Fh, 4Fh, 50h, 82h, 55h, 81h, 0BFh, 1Fh
   213                              <1> ;	db	00h, 4Fh, 0Dh, 0Eh, 00h, 00h, 00h, 00h
   214                              <1> ;	db	9Ch, 8Eh, 8Fh, 28h, 0Fh, 96h, 0B9h, 0A3h
   215                              <1> ;	db	0FFh	; crtc regs
   216                              <1> ;	db	00h, 08h, 08h, 08h, 08h, 08h, 08h, 08h
   217                              <1> ;	db	10h, 18h, 18h, 18h, 18h, 18h, 18h, 18h
   218                              <1> ;	db	0Eh, 00h, 0Fh, 08h  ; actl regs
   219                              <1> ;	db	00h, 00h, 00h, 00h, 00h, 10h, 0Ah, 0Fh, 0FFh ; grdc regs
   220                              <1> vga_mode_04h:	; 320*200 graphics, 4 colors, CGA
   221                              <1> 	; 11/11/2020
   222 000070D6 2818080040          <1> 	db	40, 24, 8, 00h, 40h ; tw, th-1, ch, slength
   223 000070DB 09030002            <1> 	db	09h, 03h, 00h, 02h ; sequ regs
   224 000070DF 63                  <1> 	db	63h	; misc reg
   225 000070E0 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
   226 000070E8 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
   227 000070F0 9C8E8F140096B9A2    <1> 	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0A2h
   228 000070F8 FF                  <1> 	db	0FFh	; crtc_regs
   229 000070F9 0013151702040607    <1> 	db	00h, 13h, 15h, 17h, 02h, 04h, 06h, 07h
   230 00007101 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   231 00007109 01000300            <1> 	db	01h, 00h, 03h, 00h ; actl regs
   232 0000710D 0000000000300F0FFF  <1> 	db 	00h, 00h, 00h, 00h, 00h, 30h, 0Fh, 0Fh, 0FFh ; grdc regs
   233                              <1> vga_mode_06h:	; 640*200 graphics, 2 colors, CGA
   234                              <1> 	; 11/11/2020
   235 00007116 5018080040          <1> 	db	80, 24, 8, 00h, 40h   ;	tw, th-1, ch, slength
   236 0000711B 01010006            <1> 	db	01h, 01h, 00h, 06h ; sequ regs
   237 0000711F 63                  <1> 	db	63h	; misc reg
   238 00007120 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   239 00007128 00C1000000000000    <1> 	db	00h, 0C1h, 00h, 00h, 00h, 00h, 00h, 00h
   240 00007130 9C8E8F280096B9C2    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0C2h
   241 00007138 FF                  <1> 	db	0FFh	; crtc regs
   242 00007139 0017171717171717    <1> 	db	00h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
   243 00007141 1717171717171717    <1> 	db	17h, 17h, 17h, 17h, 17h, 17h, 17h, 17h
   244 00007149 01000100            <1> 	db	01h, 00h, 01, 00h  ; actl regs
   245 0000714D 0000000000000D0FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 0Dh, 0Fh, 0FFh ; grdc regs
   246                              <1> vga_mode_13h:  ; mode 13h, 300*200, 256 colors, linear
   247                              <1> 	; 11/11/2020
   248                              <1> 	;db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength (5)
   249                              <1> 	; 23/11/2020 - 10/11/2020
   250 00007156 28180800FA          <1> 	db 	40, 24, 8, 00h, 0FAh ; tw, th-1, ch, slength (5)
   251 0000715B 010F000E            <1> 	db	01h, 0Fh, 00h, 0Eh ; sequ regs (4)
   252 0000715F 63                  <1> 	db	63h	; misc reg (1)
   253 00007160 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh 
   254 00007168 0041000000000000    <1> 	db 	00h, 041h, 00h, 00h, 00h, 00h, 00h, 00h
   255 00007170 9C8E8F284096B9A3    <1> 	db	9Ch, 8Eh, 8Fh, 28h, 40h, 96h, 0B9h, 0A3h
   256 00007178 FF                  <1> 	db	0FFh	; crtc regs (25)
   257 00007179 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   258 00007181 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
   259 00007189 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs (20)
   260                              <1> 	; 10/11/2020
   261                              <1>  	;db	41h, 01h, 0Fh, 13h  ; actl regs (20) 
   262 0000718D 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs (9)
   263                              <1> vga_mode_setl equ $ - vga_mode_13h  ; = 64
   264                              <1> vga_mode_F0h:  ; mode X ; 320*240, 256 colors, planar
   265 00007196 2818080000          <1> 	db 	40, 24, 8, 00h, 00h ; tw, th-1, ch, slength
   266 0000719B 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   267 0000719F E3                  <1> 	db	0E3h	; misc reg
   268 000071A0 5F4F508254800D3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Dh, 3Eh 
   269 000071A8 0041000000000000    <1>  	db 	00h, 41h, 00h, 00h, 00h, 00h, 00h, 00h
   270 000071B0 EAACDF2800E706E3    <1> 	db	0EAh, 0ACh, 0DFh, 28h, 00h, 0E7h, 06h, 0E3h
   271 000071B8 FF                  <1> 	db	0FFh	; crtc regs (25)
   272 000071B9 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   273 000071C1 08090A0B0C0D0E0F    <1>  	db	08h, 09h, 0Ah, 0Bh, 0Ch, 0Dh, 0Eh, 0Fh
   274 000071C9 41000F00            <1>  	db	41h, 00h, 0Fh, 00h  ; actl regs
   275 000071CD 000000000040050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 40h, 05h, 0Fh, 0FFh ; grdc regs
   276                              <1> vga_mode_12h:  ; mode 12h, 640*480, 16 colors, planar
   277                              <1> 	; 11/11/2020
   278                              <1>  	;db 	80, 29, 16, 0, 0 ; tw, th-1, ch, slength
   279                              <1> 	; 09/11/2020
   280 000071D6 501D1000A0          <1>  	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
   281 000071DB 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   282 000071DF E3                  <1> 	db 	0E3h	; misc reg
   283 000071E0 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
   284                              <1> 	; 09/11/2020
   285                              <1> 	;db	5Fh, 4Fh, 50h, 82h, 53h, 9Fh, 0Bh, 3Eh
   286 000071E8 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   287 000071F0 EA8CDF2800E704E3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
   288                              <1> 	; 09/11/2020
   289                              <1>  	;db	0E9h, 8Bh, 0DFh, 28h, 00h, 0E7h, 04h, 0E3h
   290 000071F8 FF                  <1> 	db	0FFh	; crtc regs
   291 000071F9 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   292 00007201 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   293 00007209 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   294 0000720D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   295                              <1> vga_mode_6Ah:  ; mode 6Ah, 800*600, 16 colors, planar
   296                              <1> 	; 11/11/2020
   297 00007216 6424100000          <1>  	db 	100, 36, 16, 00h, 00h ; tw, th-1, ch, slength
   298 0000721B 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   299 0000721F E3                  <1> 	db 	0E3h	; misc reg
   300 00007220 7F6363836B1B72F0    <1> 	db	7Fh, 63h, 63h, 83h, 6Bh, 1Bh, 72h, 0F0h
   301 00007228 0060000000000000    <1> 	db	00h, 60h, 00h, 00h, 00h, 00h, 00h, 00h
   302 00007230 598D5732005773E3    <1>  	db	59h, 8Dh, 57h, 32h, 00h, 57h, 73h, 0E3h
   303 00007238 FF                  <1> 	db	0FFh	; crtc regs
   304 00007239 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   305 00007241 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   306 00007249 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   307 0000724D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   308                              <1> vga_mode_0Dh:  ; mode 0Dh, 320*200, 16 colors, planar
   309 00007256 2818080020          <1>  	db 	40, 24, 8, 00h, 20h ; tw, th-1, ch, slength
   310 0000725B 090F0006            <1> 	db	09h, 0Fh, 00h, 06h ; sequ regs
   311 0000725F 63                  <1> 	db 	63h	; misc reg
   312 00007260 2D2728902B80BF1F    <1> 	db	2Dh, 27h, 28h, 90h, 2Bh, 80h, 0BFh, 1Fh
   313 00007268 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
   314 00007270 9C8E8F140096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 14h, 00h, 96h, 0B9h, 0E3h
   315 00007278 FF                  <1> 	db	0FFh	; crtc regs
   316 00007279 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   317 00007281 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   318 00007289 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   319 0000728D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   320                              <1> vga_mode_0Eh:  ; mode 0Eh, 640*200, 16 colors, planar
   321 00007296 5018080040          <1>  	db 	80, 24, 8, 00h, 40h ; tw, th-1, ch, slength
   322 0000729B 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   323 0000729F 63                  <1> 	db 	63h	; misc reg
   324 000072A0 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   325 000072A8 00C0000000000000    <1> 	db	00h, 0C0h, 00h, 00h, 00h, 00h, 00h, 00h
   326 000072B0 9C8E8F280096B9E3    <1>  	db	9Ch, 8Eh, 8Fh, 28h, 00h, 96h, 0B9h, 0E3h
   327 000072B8 FF                  <1> 	db	0FFh	; crtc regs
   328 000072B9 0001020304050607    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 06h, 07h
   329 000072C1 1011121314151617    <1> 	db	10h, 11h, 12h, 13h, 14h, 15h, 16h, 17h
   330 000072C9 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   331 000072CD 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   332                              <1> vga_mode_10h: ; mode 10h, 640*350, 16 colors, planar
   333 000072D6 50180E0080          <1>  	db 	80, 24, 14, 00h, 80h ; tw, th-1, ch, slength
   334 000072DB 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   335 000072DF A3                  <1> 	db 	0A3h	; misc reg
   336 000072E0 5F4F50825480BF1F    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0BFh, 1Fh
   337 000072E8 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   338 000072F0 83855D280F63BAE3    <1>  	db	83h, 85h, 5Dh, 28h, 0Fh, 63h, 0BAh, 0E3h
   339 000072F8 FF                  <1> 	db	0FFh	; crtc regs
   340 000072F9 0001020304051407    <1> 	db	00h, 01h, 02h, 03h, 04h, 05h, 14h, 07h
   341 00007301 38393A3B3C3D3E3F    <1> 	db	38h, 39h, 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh
   342 00007309 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   343 0000730D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   344                              <1> vga_mode_11h: ; mode 11h, 640*480, mono color, planar
   345                              <1>  	; 11/11/2020
   346 00007316 501D1000A0          <1> 	db 	80, 29, 16, 00h, 0A0h ; tw, th-1, ch, slength
   347 0000731B 010F0006            <1> 	db	01h, 0Fh, 00h, 06h ; sequ regs
   348 0000731F E3                  <1> 	db 	0E3h	; misc reg
   349 00007320 5F4F508254800B3E    <1> 	db	5Fh, 4Fh, 50h, 82h, 54h, 80h, 0Bh, 3Eh
   350 00007328 0040000000000000    <1> 	db	00h, 40h, 00h, 00h, 00h, 00h, 00h, 00h
   351 00007330 EA8CDF2800E704C3    <1>  	db	0EAh, 8Ch, 0DFh, 28h, 00h, 0E7h, 04h, 0C3h ; 11/11/2020
   352 00007338 FF                  <1> 	db	0FFh	; crtc regs
   353 00007339 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
   354 00007341 003F003F003F003F    <1> 	db	00h, 3Fh, 00h, 3Fh, 00h, 3Fh, 00h, 3Fh
   355 00007349 01000F00            <1> 	db	01h, 00h, 0Fh, 00h  ; actl regs
   356 0000734D 000000000000050FFF  <1> 	db	00h, 00h, 00h, 00h, 00h, 00h, 05h, 0Fh, 0FFh ; grdc regs
   357                              <1> end_of_vga_params:
   358                              <1> 
   359                              <1> ; /// End Of VIDEO DATA ///
   360                              <1> 
   361                              <1> ; 23/11/2020
   362                              <1> ; VBE 2 BOCHS/QEMU emulator extensions 
   363                              <1> ;	for TRDOS 386 v2 kernel (video bios)  
   364                              <1> 
   365                              <1> ; vbetables.h by Volker Rupper (02/01/2020)
   366                              <1> 
   367                              <1> b_vbe_modes:
   368                              <1> 	;/* standard VESA modes */	
   369 00007356 0001800290010800    <1> 	dw 100h,  640, 400,  8
   370 0000735E 01018002E0010800    <1> 	dw 101h,  640, 480,  8
   371 00007366 0301200358020800    <1> 	dw 103h,  800, 600,  8
   372 0000736E 0501000400030800    <1> 	dw 105h, 1024, 768,  8
   373 00007376 0E014001C8001000    <1> 	dw 10Eh,  320, 200, 16
   374 0000737E 0F014001C8001800    <1> 	dw 10Fh,  320, 200, 24
   375 00007386 11018002E0011000    <1> 	dw 111h,  640, 480, 16
   376 0000738E 12018002E0011800    <1> 	dw 112h,  640, 480, 24
   377 00007396 1401200358021000    <1> 	dw 114h,  800, 600, 16
   378 0000739E 1501200358021800    <1> 	dw 115h,  800, 600, 24
   379 000073A6 1701000400031000    <1> 	dw 117h, 1024, 768, 16
   380 000073AE 1801000400031800    <1> 	dw 118h, 1024, 768, 24
   381                              <1> 
   382                              <1> ;/* BOCHS/PLEX86 'own' mode numbers */
   383 000073B6 40014001C8002000    <1> 	dw 140h,  320,  200, 32
   384 000073BE 4101800290012000    <1> 	dw 141h,  640,  400, 32
   385 000073C6 42018002E0012000    <1> 	dw 142h,  640,  480, 32
   386 000073CE 4301200358022000    <1> 	dw 143h,  800,  600, 32
   387 000073D6 4401000400032000    <1> 	dw 144h, 1024,  768, 32
   388 000073DE 46014001C8000800    <1> 	dw 146h,  320,  200,  8
   389 000073E6 8D010005D0021000    <1> 	dw 18Dh, 1280,  720, 16
   390 000073EE 8E010005D0021800    <1> 	dw 18Eh, 1280,  720, 24
   391 000073F6 8F010005D0022000    <1> 	dw 18Fh, 1280,  720, 32
   392 000073FE 9001800738041000    <1> 	dw 190h, 1920, 1080, 16
   393 00007406 9101800738041800    <1> 	dw 191h, 1920, 1080, 24
   394 0000740E 9201800738042000    <1> 	dw 192h, 1920, 1080, 32
   395                              <1> 
   396                              <1> end_of_b_vbe_modes:
   397                              <1> 
   398                              <1> MA1 equ VBE_MODE_ATTRIBUTE_SUPPORTED
   399                              <1> MA2 equ VBE_MODE_ATTRIBUTE_EXTENDED_INFO_AVAILABLE
   400                              <1> MA3 equ VBE_MODE_ATTRIBUTE_COLOR_MODE
   401                              <1> MA4 equ VBE_MODE_ATTRIBUTE_LINEAR_FRAME_BUFFER_MODE
   402                              <1> MA5 equ	VBE_MODE_ATTRIBUTE_GRAPHICS_MODE
   403                              <1> 
   404                              <1> MODE_ATTRIBUTES equ MA1|MA2|MA3|MA4|MA5
   405                              <1> 
   406                              <1> WA1 equ VBE_WINDOW_ATTRIBUTE_RELOCATABLE
   407                              <1> WA2 equ	VBE_WINDOW_ATTRIBUTE_READABLE
   408                              <1> WA3 equ VBE_WINDOW_ATTRIBUTE_WRITEABLE
   409                              <1> 
   410                              <1> WINA_ATTRIBUTES equ WA1|WA2|WA3
   411                              <1> 
   412                              <1> ; 24/11/2020
   413                              <1> 
   414                              <1> %if 0
   415                              <1> 
   416                              <1> MODE_INFO_LIST: 
   417                              <1> 
   418                              <1> ; 24/11/2020
   419                              <1> ; '%if 0' disables 24 mode info tables here, until %endif 
   420                              <1> ; ('set_mode_info_list' will set only 1 list for selected mode)
   421                              <1> ; (Purpose: To save about 1 KB kernel size by removing fixed data)
   422                              <1> 
   423                              <1> 			dw	0100h ; 640x400x8 
   424                              <1> ModeAttributes1: 	dw	MODE_ATTRIBUTES
   425                              <1> WinAAttributes1: 	db	WINA_ATTRIBUTES
   426                              <1> WinBAttributes1: 	db	0
   427                              <1> WinGranularity1: 	dw	VBE_DISPI_BANK_SIZE_KB
   428                              <1> WinSize1: 		dw	VBE_DISPI_BANK_SIZE_KB
   429                              <1> WinASegment1:		dw	VGAMEM_GRAPH
   430                              <1> WinBSegment1:		dw	0000h
   431                              <1> WinFuncPtr1:		dd	0
   432                              <1> BytesPerScanLine1: 	dw	640
   433                              <1> XResolution1:		dw	640
   434                              <1> YResolution1:		dw	400
   435                              <1> XCharSize1:		db	8
   436                              <1> YCharSize1:		db	16
   437                              <1> NumberOfPlanes1: 	db	1
   438                              <1> BitsPerPixel1:		db	8
   439                              <1> NumberOfBanks1:		db	4
   440                              <1> MemoryModel1:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   441                              <1> BankSize1:		db	0
   442                              <1> NumberOfImagePages1: 	db	64
   443                              <1> Reserved_page1:		db	0
   444                              <1> RedMaskSize1:		db	0
   445                              <1> RedFieldPosition1: 	db	0
   446                              <1> GreenMaskSize1:		db	0
   447                              <1> GreenFieldPosition1: 	db	0
   448                              <1> BlueMaskSize1:		db	0
   449                              <1> BlueFieldPosition1: 	db	0
   450                              <1> RsvdMaskSize1: 		db	0
   451                              <1> RsvdFieldPosition1: 	db	0
   452                              <1> DirectColorModeInfo1: 	db	0
   453                              <1> PhysBasePtr1:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   454                              <1> OffScreenMemOffset1: 	dd	0
   455                              <1> OffScreenMemSize1: 	dw	0
   456                              <1> LinBytesPerScanLine1: 	dw	640
   457                              <1> BnkNumberOfPages1: 	db	0
   458                              <1> LinNumberOfPages1: 	db	0
   459                              <1> LinRedMaskSize1:	db	0
   460                              <1> LinRedFieldPosition1: 	db	0
   461                              <1> LinGreenMaskSize1: 	db	0
   462                              <1> LinGreenFieldPosition1: db	0
   463                              <1> LinBlueMaskSize1: 	db	0
   464                              <1> LinBlueFieldPosition1: 	db	0
   465                              <1> LinRsvdMaskSize1: 	db	0
   466                              <1> LinRsvdFieldPosition1: 	db	0
   467                              <1> MaxPixelClock1:		dd	0
   468                              <1> 
   469                              <1> 			dw	0101h ; 640x480x8
   470                              <1> ModeAttributes2: 	dw	MODE_ATTRIBUTES
   471                              <1> WinAAttributes2: 	db	WINA_ATTRIBUTES
   472                              <1> WinBAttributes2: 	db	0
   473                              <1> WinGranularity2: 	dw	VBE_DISPI_BANK_SIZE_KB
   474                              <1> WinSize2: 		dw	VBE_DISPI_BANK_SIZE_KB
   475                              <1> WinASegment2:		dw	VGAMEM_GRAPH
   476                              <1> WinBSegment2:		dw	0000h
   477                              <1> WinFuncPtr2:		dd	0
   478                              <1> BytesPerScanLine2:	dw	640
   479                              <1> XResolution2:		dw	640
   480                              <1> YResolution2:		dw	480
   481                              <1> XCharSize2:		db	8
   482                              <1> YCharSize2:		db	16
   483                              <1> NumberOfPlanes2:	db	1
   484                              <1> BitsPerPixel2:		db	8
   485                              <1> NumberOfBanks2:		db	5
   486                              <1> MemoryModel2:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   487                              <1> BankSize2:		db	0
   488                              <1> NumberOfImagePages2:	db	53
   489                              <1> Reserved_page2:		db	0
   490                              <1> RedMaskSize2:		db	0
   491                              <1> RedFieldPosition2:	db	0
   492                              <1> GreenMaskSize2:		db	0
   493                              <1> GreenFieldPosition2:	db	0
   494                              <1> BlueMaskSize2:		db	0
   495                              <1> BlueFieldPosition2:	db	0
   496                              <1> RsvdMaskSize2:		db	0
   497                              <1> RsvdFieldPosition2:	db	0
   498                              <1> DirectColorModeInfo2:	db	0
   499                              <1> PhysBasePtr2:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   500                              <1> OffScreenMemOffset2:	dd	0
   501                              <1> OffScreenMemSize2:	dw	0
   502                              <1> LinBytesPerScanLine2:	dw	640
   503                              <1> BnkNumberOfPages2: 	db	0
   504                              <1> LinNumberOfPages2: 	db	0
   505                              <1> LinRedMaskSize2:	db	0
   506                              <1> LinRedFieldPosition2: 	db	0
   507                              <1> LinGreenMaskSize2: 	db	0
   508                              <1> LinGreenFieldPosition2: db	0
   509                              <1> LinBlueMaskSize2: 	db	0
   510                              <1> LinBlueFieldPosition2: 	db	0
   511                              <1> LinRsvdMaskSize2: 	db	0
   512                              <1> LinRsvdFieldPosition2: 	db	0
   513                              <1> MaxPixelClock2:		dd	0
   514                              <1> 			
   515                              <1> 			dw	0103h ; 800x600x8
   516                              <1> ModeAttributes3: 	dw	MODE_ATTRIBUTES
   517                              <1> WinAAttributes3: 	db	WINA_ATTRIBUTES
   518                              <1> WinBAttributes3: 	db	0
   519                              <1> WinGranularity3: 	dw	VBE_DISPI_BANK_SIZE_KB
   520                              <1> WinSize3: 		dw	VBE_DISPI_BANK_SIZE_KB
   521                              <1> WinASegment3:		dw	VGAMEM_GRAPH
   522                              <1> WinBSegment3:		dw	0000h
   523                              <1> WinFuncPtr3:		dd	0
   524                              <1> BytesPerScanLine3:	dw	800
   525                              <1> XResolution3:		dw	800
   526                              <1> YResolution3:		dw	600
   527                              <1> XCharSize3:		db	8
   528                              <1> YCharSize3:		db	16
   529                              <1> NumberOfPlanes3:	db	1
   530                              <1> BitsPerPixel3:		db	8
   531                              <1> NumberOfBanks3:		db	8
   532                              <1> MemoryModel3:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   533                              <1> BankSize3:		db	0
   534                              <1> NumberOfImagePages3:	db	33
   535                              <1> Reserved_page3:		db	0
   536                              <1> RedMaskSize3:		db	0
   537                              <1> RedFieldPosition3:	db	0
   538                              <1> GreenMaskSize3:		db	0
   539                              <1> GreenFieldPosition3:	db	0
   540                              <1> BlueMaskSize3:		db	0
   541                              <1> BlueFieldPosition3:	db	0
   542                              <1> RsvdMaskSize3:		db	0
   543                              <1> RsvdFieldPosition3:	db	0
   544                              <1> DirectColorModeInfo3:	db	0
   545                              <1> PhysBasePtr3:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   546                              <1> OffScreenMemOffset3:	dd	0
   547                              <1> OffScreenMemSize3:	dw	0
   548                              <1> LinBytesPerScanLine3:	dw	800
   549                              <1> BnkNumberOfPages3: 	db	0
   550                              <1> LinNumberOfPages3: 	db	0
   551                              <1> LinRedMaskSize3:	db	0
   552                              <1> LinRedFieldPosition3: 	db	0
   553                              <1> LinGreenMaskSize3: 	db	0
   554                              <1> LinGreenFieldPosition: 	db	0
   555                              <1> LinBlueMaskSize: 	db	0
   556                              <1> LinBlueFieldPosition: 	db	0
   557                              <1> LinRsvdMaskSize: 	db	0
   558                              <1> LinRsvdFieldPosition: 	db	0
   559                              <1> MaxPixelClock:		dd	0
   560                              <1> 			
   561                              <1> 			dw	0105h ; 1024x768x8
   562                              <1> ModeAttributes4: 	dw	MODE_ATTRIBUTES
   563                              <1> WinAAttributes4: 	db	WINA_ATTRIBUTES
   564                              <1> WinBAttributes4: 	db	0
   565                              <1> WinGranularity4: 	dw	VBE_DISPI_BANK_SIZE_KB
   566                              <1> WinSize4: 		dw	VBE_DISPI_BANK_SIZE_KB
   567                              <1> WinASegment4:		dw	VGAMEM_GRAPH
   568                              <1> WinBSegment4:		dw	0000h
   569                              <1> WinFuncPtr4:		dd	0
   570                              <1> BytesPerScanLine4:	dw	1024
   571                              <1> XResolution4:		dw	1024
   572                              <1> YResolution4:		dw	768
   573                              <1> XCharSize4:		db	8
   574                              <1> YCharSize4:		db	16
   575                              <1> NumberOfPlanes4:	db	1
   576                              <1> BitsPerPixel4:		db	8
   577                              <1> NumberOfBanks4:		db	12
   578                              <1> MemoryModel4:		db	VBE_MEMORYMODEL_PACKED_PIXEL
   579                              <1> BankSize4:		db	0
   580                              <1> NumberOfImagePages4:	db	20
   581                              <1> Reserved_page4:		db	0
   582                              <1> RedMaskSize4:		db	0
   583                              <1> RedFieldPosition4:	db	0
   584                              <1> GreenMaskSize4:		db	0
   585                              <1> GreenFieldPosition4:	db	0
   586                              <1> BlueMaskSize4:		db	0
   587                              <1> BlueFieldPosition4:	db	0
   588                              <1> RsvdMaskSize4:		db	0
   589                              <1> RsvdFieldPosition4:	db	0
   590                              <1> DirectColorModeInfo4:	db	0
   591                              <1> PhysBasePtr4:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   592                              <1> OffScreenMemOffset4:	dd	0
   593                              <1> OffScreenMemSize4:	dw	0
   594                              <1> LinBytesPerScanLine4:	dw	1024
   595                              <1> BnkNumberOfPages4: 	db	0
   596                              <1> LinNumberOfPages4: 	db	0
   597                              <1> LinRedMaskSize4:	db	0
   598                              <1> LinRedFieldPosition4: 	db	0
   599                              <1> LinGreenMaskSize4: 	db	0
   600                              <1> LinGreenFieldPosition4: db	0
   601                              <1> LinBlueMaskSize4: 	db	0
   602                              <1> LinBlueFieldPosition4: 	db	0
   603                              <1> LinRsvdMaskSize4: 	db	0
   604                              <1> LinRsvdFieldPosition4: 	db	0
   605                              <1> MaxPixelClock4:		dd	0
   606                              <1> 
   607                              <1> 			dw	010Eh ; 320x200x16
   608                              <1> ModeAttributes5: 	dw	MODE_ATTRIBUTES
   609                              <1> WinAAttributes5: 	db	WINA_ATTRIBUTES
   610                              <1> WinBAttributes5: 	db	0
   611                              <1> WinGranularity5: 	dw	VBE_DISPI_BANK_SIZE_KB
   612                              <1> WinSize5: 		dw	VBE_DISPI_BANK_SIZE_KB
   613                              <1> WinASegment5:		dw	VGAMEM_GRAPH
   614                              <1> WinBSegment5:		dw	0000h
   615                              <1> WinFuncPtr5:		dd	0
   616                              <1> BytesPerScanLine5:	dw	640
   617                              <1> XResolution5:		dw	320
   618                              <1> YResolution5:		dw	200
   619                              <1> XCharSize5:		db	8
   620                              <1> YCharSize5:		db	16
   621                              <1> NumberOfPlanes5:	db	1
   622                              <1> BitsPerPixel5:		db	16
   623                              <1> NumberOfBanks5:		db	2
   624                              <1> MemoryModel5:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   625                              <1> BankSize5:		db	0
   626                              <1> NumberOfImagePages5:	db	130
   627                              <1> Reserved_page5:		db	0
   628                              <1> RedMaskSize5:		db	5
   629                              <1> RedFieldPosition5:	db	11
   630                              <1> GreenMaskSize5:		db	6
   631                              <1> GreenFieldPosition5:	db	5
   632                              <1> BlueMaskSize5:		db	5
   633                              <1> BlueFieldPosition5:	db	0
   634                              <1> RsvdMaskSize5:		db	0
   635                              <1> RsvdFieldPosition5:	db	0
   636                              <1> DirectColorModeInfo5:	db	0
   637                              <1> PhysBasePtr5:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   638                              <1> OffScreenMemOffset5:	dd	0
   639                              <1> OffScreenMemSize5:	dw	0
   640                              <1> LinBytesPerScanLine5:	dw	640
   641                              <1> BnkNumberOfPages5: 	db	0
   642                              <1> LinNumberOfPages5: 	db	0
   643                              <1> LinRedMaskSize5:	db	5
   644                              <1> LinRedFieldPosition5:	db	11
   645                              <1> LinGreenMaskSize5:	db	6
   646                              <1> LinGreenFieldPosition5:	db	5
   647                              <1> LinBlueMaskSize5:	db	5
   648                              <1> LinBlueFieldPosition5:	db	0
   649                              <1> LinRsvdMaskSize5:	db	0
   650                              <1> LinRsvdFieldPosition5:	db	0
   651                              <1> MaxPixelClock5:		dd	0
   652                              <1> 	
   653                              <1> 			dw	010Fh ; 320x200x24
   654                              <1> ModeAttributes6: 	dw	MODE_ATTRIBUTES
   655                              <1> WinAAttributes6: 	db	WINA_ATTRIBUTES
   656                              <1> WinBAttributes6: 	db	0
   657                              <1> WinGranularity6: 	dw	VBE_DISPI_BANK_SIZE_KB
   658                              <1> WinSize6: 		dw	VBE_DISPI_BANK_SIZE_KB
   659                              <1> WinASegment6:		dw	VGAMEM_GRAPH
   660                              <1> WinBSegment6:		dw	0000h
   661                              <1> WinFuncPtr6:		dd	0
   662                              <1> BytesPerScanLine6:	dw	960
   663                              <1> XResolution6:		dw	320
   664                              <1> YResolution6:		dw	200
   665                              <1> XCharSize6:		db	8
   666                              <1> YCharSize6:		db	16
   667                              <1> NumberOfPlanes6:	db	1
   668                              <1> BitsPerPixel6:		db	24
   669                              <1> NumberOfBanks6:		db	3
   670                              <1> MemoryModel6:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   671                              <1> BankSize6:		db	0
   672                              <1> NumberOfImagePages6:	db	86
   673                              <1> Reserved_page6:		db	0
   674                              <1> RedMaskSize6:		db	8
   675                              <1> RedFieldPosition6:	db	16
   676                              <1> GreenMaskSize6:		db	8
   677                              <1> GreenFieldPosition6:	db	8
   678                              <1> BlueMaskSize6:		db	8
   679                              <1> BlueFieldPosition6:	db	0
   680                              <1> RsvdMaskSize6:		db	0
   681                              <1> RsvdFieldPosition6:	db	0
   682                              <1> DirectColorModeInfo6:	db	0
   683                              <1> PhysBasePtr6:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   684                              <1> OffScreenMemOffset6:	dd	0
   685                              <1> OffScreenMemSize6:	dw	0
   686                              <1> LinBytesPerScanLine6:	dw	960
   687                              <1> BnkNumberOfPages6: 	db	0
   688                              <1> LinNumberOfPages6: 	db	0
   689                              <1> LinRedMaskSize6:	db	8
   690                              <1> LinRedFieldPosition6:	db	16
   691                              <1> LinGreenMaskSize6:	db	8
   692                              <1> LinGreenFieldPosition6:	db	8
   693                              <1> LinBlueMaskSize6:	db	8
   694                              <1> LinBlueFieldPosition6:	db	0
   695                              <1> LinRsvdMaskSize6:	db	0
   696                              <1> LinRsvdFieldPosition6:	db	0
   697                              <1> MaxPixelClock6:		dd	0
   698                              <1> 	
   699                              <1> 			dw	0111h ; 640x480x16
   700                              <1> ModeAttributes7: 	dw	MODE_ATTRIBUTES
   701                              <1> WinAAttributes7: 	db	WINA_ATTRIBUTES
   702                              <1> WinBAttributes7: 	db	0
   703                              <1> WinGranularity7: 	dw	VBE_DISPI_BANK_SIZE_KB
   704                              <1> WinSize7: 		dw	VBE_DISPI_BANK_SIZE_KB
   705                              <1> WinASegment7:		dw	VGAMEM_GRAPH
   706                              <1> WinBSegment7:		dw	0000h
   707                              <1> WinFuncPtr7:		dd	0
   708                              <1> BytesPerScanLine7:	dw	1280
   709                              <1> XResolution7:		dw	640
   710                              <1> YResolution7:		dw	480
   711                              <1> XCharSize7:		db	8
   712                              <1> YCharSize7:		db	16
   713                              <1> NumberOfPlanes7:	db	1
   714                              <1> BitsPerPixel7:		db	16
   715                              <1> NumberOfBanks7:		db	10
   716                              <1> MemoryModel7:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   717                              <1> BankSize7:		db	0
   718                              <1> NumberOfImagePages7:	db	26
   719                              <1> Reserved_page7:		db	0
   720                              <1> RedMaskSize7:		db	5
   721                              <1> RedFieldPosition7:	db	11
   722                              <1> GreenMaskSize7:		db	6
   723                              <1> GreenFieldPosition7:	db	5
   724                              <1> BlueMaskSize7:		db	5
   725                              <1> BlueFieldPosition7:	db	0
   726                              <1> RsvdMaskSize7:		db	0
   727                              <1> RsvdFieldPosition7:	db	0
   728                              <1> DirectColorModeInfo7:	db	0
   729                              <1> PhysBasePtr7:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
   730                              <1> OffScreenMemOffset7:	dd	0
   731                              <1> OffScreenMemSize7:	dw	0
   732                              <1> LinBytesPerScanLine7:	dw	1280
   733                              <1> BnkNumberOfPages7: 	db	0
   734                              <1> LinNumberOfPages7: 	db	0
   735                              <1> LinRedMaskSize7:	db	5
   736                              <1> LinRedFieldPosition7:	db	11
   737                              <1> LinGreenMaskSize7:	db	6
   738                              <1> LinGreenFieldPosition7:	db	5
   739                              <1> LinBlueMaskSize7:	db	5
   740                              <1> LinBlueFieldPosition7:	db	0
   741                              <1> LinRsvdMaskSize7:	db	0
   742                              <1> LinRsvdFieldPosition7:	db	0
   743                              <1> MaxPixelClock7:		dd	0
   744                              <1> 
   745                              <1> 			dw	0112h ; 640x480x24
   746                              <1> ModeAttributes8: 	dw	MODE_ATTRIBUTES
   747                              <1> WinAAttributes8: 	db	WINA_ATTRIBUTES
   748                              <1> WinBAttributes8: 	db	0
   749                              <1> WinGranularity8: 	dw	VBE_DISPI_BANK_SIZE_KB
   750                              <1> WinSize8: 		dw	VBE_DISPI_BANK_SIZE_KB
   751                              <1> WinASegment8:		dw	VGAMEM_GRAPH
   752                              <1> WinBSegment8:		dw	0000h
   753                              <1> WinFuncPtr8:		dd	0
   754                              <1> BytesPerScanLine8:	dw	1920
   755                              <1> XResolution8:		dw	640
   756                              <1> YResolution8:		dw	480
   757                              <1> XCharSize8:		db	8
   758                              <1> YCharSize8:		db	16
   759                              <1> NumberOfPlanes8:	db	1
   760                              <1> BitsPerPixel8:		db	24
   761                              <1> NumberOfBanks8:		db	15
   762                              <1> MemoryModel8:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   763                              <1> BankSize8:		db	0
   764                              <1> NumberOfImagePages8:	db	17
   765                              <1> Reserved_page8:		db	0
   766                              <1> RedMaskSize8:		db	8
   767                              <1> RedFieldPosition8:	db	16
   768                              <1> GreenMaskSize8:		db	8
   769                              <1> GreenFieldPosition8:	db	8
   770                              <1> BlueMaskSize8:		db	8
   771                              <1> BlueFieldPosition8:	db	0
   772                              <1> RsvdMaskSize8:		db	0
   773                              <1> RsvdFieldPosition8:	db	0
   774                              <1> DirectColorModeInfo8:	db	0
   775                              <1> PhysBasePtr8:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   776                              <1> OffScreenMemOffset8:	dd	0
   777                              <1> OffScreenMemSize8:	dw	0
   778                              <1> LinBytesPerScanLine8:	dw	1920
   779                              <1> BnkNumberOfPages8: 	db	0
   780                              <1> LinNumberOfPages8: 	db	0
   781                              <1> LinRedMaskSize8:	db	8
   782                              <1> LinRedFieldPosition8:	db	16
   783                              <1> LinGreenMaskSize8:	db	8
   784                              <1> LinGreenFieldPosition8:	db	8
   785                              <1> LinBlueMaskSize8:	db	8
   786                              <1> LinBlueFieldPosition8:	db	0
   787                              <1> LinRsvdMaskSize8:	db	0
   788                              <1> LinRsvdFieldPosition8:	db	0
   789                              <1> MaxPixelClock8:		dd	0
   790                              <1> 
   791                              <1> 			dw	0114h ; 800x600x16
   792                              <1> ModeAttributes9: 	dw	MODE_ATTRIBUTES
   793                              <1> WinAAttributes9: 	db	WINA_ATTRIBUTES
   794                              <1> WinBAttributes9: 	db	0
   795                              <1> WinGranularity9: 	dw	VBE_DISPI_BANK_SIZE_KB
   796                              <1> WinSize9: 		dw	VBE_DISPI_BANK_SIZE_KB
   797                              <1> WinASegment9:		dw	VGAMEM_GRAPH
   798                              <1> WinBSegment9:		dw	0000h
   799                              <1> WinFuncPtr9:		dd	0
   800                              <1> BytesPerScanLine9:	dw	1600
   801                              <1> XResolution9:		dw	800
   802                              <1> YResolution9:		dw	600
   803                              <1> XCharSize9:		db	8
   804                              <1> YCharSize9:		db	16
   805                              <1> NumberOfPlanes9:	db	1
   806                              <1> BitsPerPixel9:		db	16
   807                              <1> NumberOfBanks9:		db	15
   808                              <1> MemoryModel9:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   809                              <1> BankSize9:		db	0
   810                              <1> NumberOfImagePages9:	db	16
   811                              <1> Reserved_page9:		db	0
   812                              <1> RedMaskSize9:		db	5
   813                              <1> RedFieldPosition9:	db	11
   814                              <1> GreenMaskSize9:		db	6
   815                              <1> GreenFieldPosition9:	db	5
   816                              <1> BlueMaskSize9:		db	5
   817                              <1> BlueFieldPosition9:	db	0
   818                              <1> RsvdMaskSize9:		db	0
   819                              <1> RsvdFieldPosition9:	db	0
   820                              <1> DirectColorModeInfo9:	db	0
   821                              <1> PhysBasePtr9:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   822                              <1> OffScreenMemOffset9:	dd	0
   823                              <1> OffScreenMemSize9:	dw	0
   824                              <1> LinBytesPerScanLine9:	dw	1600
   825                              <1> BnkNumberOfPages9: 	db	0
   826                              <1> LinNumberOfPages9: 	db	0
   827                              <1> LinRedMaskSize9:	db	5
   828                              <1> LinRedFieldPosition9:	db	11
   829                              <1> LinGreenMaskSize9:	db	6
   830                              <1> LinGreenFieldPosition9:	db	5
   831                              <1> LinBlueMaskSize9:	db	5
   832                              <1> LinBlueFieldPosition9:	db	0
   833                              <1> LinRsvdMaskSize9:	db	0
   834                              <1> LinRsvdFieldPosition9:	db	0
   835                              <1> MaxPixelClock9:		dd	0
   836                              <1> 	
   837                              <1> 			dw	0115h ; 800x600x24
   838                              <1> ModeAttributes10: 	dw	MODE_ATTRIBUTES
   839                              <1> WinAAttributes10: 	db	WINA_ATTRIBUTES
   840                              <1> WinBAttributes10: 	db	0
   841                              <1> WinGranularity10: 	dw	VBE_DISPI_BANK_SIZE_KB
   842                              <1> WinSize10: 		dw	VBE_DISPI_BANK_SIZE_KB
   843                              <1> WinASegment10:		dw	VGAMEM_GRAPH
   844                              <1> WinBSegment10:		dw	0000h
   845                              <1> WinFuncPtr10:		dd	0
   846                              <1> BytesPerScanLine10:	dw	2400
   847                              <1> XResolution10:		dw	800
   848                              <1> YResolution10:		dw	600
   849                              <1> XCharSize10:		db	8
   850                              <1> YCharSize10:		db	16
   851                              <1> NumberOfPlanes10:	db	1
   852                              <1> BitsPerPixel10:		db	24
   853                              <1> NumberOfBanks10:	db	22
   854                              <1> MemoryModel10:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   855                              <1> BankSize10:		db	0
   856                              <1> NumberOfImagePages10:	db	10
   857                              <1> Reserved_page10:	db	0
   858                              <1> RedMaskSize10:		db	8
   859                              <1> RedFieldPosition10:	db	16
   860                              <1> GreenMaskSize10:	db	8
   861                              <1> GreenFieldPosition10:	db	8
   862                              <1> BlueMaskSize10:		db	8
   863                              <1> BlueFieldPosition10:	db	0
   864                              <1> RsvdMaskSize10:		db	0
   865                              <1> RsvdFieldPosition10:	db	0
   866                              <1> DirectColorModeInfo10:	db	0
   867                              <1> PhysBasePtr10:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   868                              <1> OffScreenMemOffset10:	dd	0
   869                              <1> OffScreenMemSize10:	dw	0
   870                              <1> LinBytesPerScanLine10:	dw	2400
   871                              <1> BnkNumberOfPages10: 	db	0
   872                              <1> LinNumberOfPages10: 	db	0
   873                              <1> LinRedMaskSize10:	db	8
   874                              <1> LinRedFieldPosition10:	db	16
   875                              <1> LinGreenMaskSize10:	db	8
   876                              <1> LinGreenFieldPosition10:db	8
   877                              <1> LinBlueMaskSize10:	db	8
   878                              <1> LinBlueFieldPosition10:	db	0
   879                              <1> LinRsvdMaskSize10:	db	0
   880                              <1> LinRsvdFieldPosition10:	db	0
   881                              <1> MaxPixelClock10:	dd	0
   882                              <1> 
   883                              <1> 			dw	0117h ; 1024x768x16
   884                              <1> ModeAttributes11: 	dw	MODE_ATTRIBUTES
   885                              <1> WinAAttributes11: 	db	WINA_ATTRIBUTES
   886                              <1> WinBAttributes11: 	db	0
   887                              <1> WinGranularity11: 	dw	VBE_DISPI_BANK_SIZE_KB
   888                              <1> WinSize11: 		dw	VBE_DISPI_BANK_SIZE_KB
   889                              <1> WinASegment11:		dw	VGAMEM_GRAPH
   890                              <1> WinBSegment11:		dw	0000h
   891                              <1> WinFuncPtr11:		dd	0
   892                              <1> BytesPerScanLine11:	dw	2048
   893                              <1> XResolution11:		dw	1024
   894                              <1> YResolution11:		dw	768
   895                              <1> XCharSize11:		db	8
   896                              <1> YCharSize11:		db	16
   897                              <1> NumberOfPlanes11:	db	1
   898                              <1> BitsPerPixel11:		db	16
   899                              <1> NumberOfBanks11:	db	24
   900                              <1> MemoryModel11:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   901                              <1> BankSize11:		db	0
   902                              <1> NumberOfImagePages11:	db	9
   903                              <1> Reserved_page11:	db	0
   904                              <1> RedMaskSize11:		db	5
   905                              <1> RedFieldPosition11:	db	11
   906                              <1> GreenMaskSize11:	db	6
   907                              <1> GreenFieldPosition11:	db	5
   908                              <1> BlueMaskSize11:		db	5
   909                              <1> BlueFieldPosition11:	db	0
   910                              <1> RsvdMaskSize11:		db	0
   911                              <1> RsvdFieldPosition11:	db	0
   912                              <1> DirectColorModeInfo11:	db	0
   913                              <1> PhysBasePtr11:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
   914                              <1> OffScreenMemOffset11:	dd	0
   915                              <1> OffScreenMemSize11:	dw	0
   916                              <1> LinBytesPerScanLine11:	dw	2048
   917                              <1> BnkNumberOfPages11: 	db	0
   918                              <1> LinNumberOfPages11: 	db	0
   919                              <1> LinRedMaskSize11:	db	5
   920                              <1> LinRedFieldPosition11:	db	11
   921                              <1> LinGreenMaskSize11:	db	6
   922                              <1> LinGreenFieldPosition11:db	5
   923                              <1> LinBlueMaskSize11:	db	5
   924                              <1> LinBlueFieldPosition11:	db	0
   925                              <1> LinRsvdMaskSize11:	db	0
   926                              <1> LinRsvdFieldPosition11:	db	0
   927                              <1> MaxPixelClock11:	dd	0
   928                              <1> 
   929                              <1> 			dw	0118h ; 1024x768x24
   930                              <1> ModeAttributes12: 	dw	MODE_ATTRIBUTES
   931                              <1> WinAAttributes12: 	db	WINA_ATTRIBUTES
   932                              <1> WinBAttributes12: 	db	0
   933                              <1> WinGranularity12: 	dw	VBE_DISPI_BANK_SIZE_KB
   934                              <1> WinSize12: 		dw	VBE_DISPI_BANK_SIZE_KB
   935                              <1> WinASegment12:		dw	VGAMEM_GRAPH
   936                              <1> WinBSegment12:		dw	0000h
   937                              <1> WinFuncPtr12:		dd	0
   938                              <1> BytesPerScanLine12:	dw	3072
   939                              <1> XResolution12:		dw	1024
   940                              <1> YResolution12:		dw	768
   941                              <1> XCharSize12:		db	8
   942                              <1> YCharSize12:		db	16
   943                              <1> NumberOfPlanes12:	db	1
   944                              <1> BitsPerPixel12:		db	24
   945                              <1> NumberOfBanks12:	db	36
   946                              <1> MemoryModel12:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   947                              <1> BankSize12:		db	0
   948                              <1> NumberOfImagePages12:	db	6
   949                              <1> Reserved_page12:	db	0
   950                              <1> RedMaskSize12:		db	8
   951                              <1> RedFieldPosition12:	db	16
   952                              <1> GreenMaskSize12:	db	8
   953                              <1> GreenFieldPosition12:	db	8
   954                              <1> BlueMaskSize12:		db	8
   955                              <1> BlueFieldPosition12:	db	0
   956                              <1> RsvdMaskSize12:		db	0
   957                              <1> RsvdFieldPosition12:	db	0
   958                              <1> DirectColorModeInfo12:	db	0
   959                              <1> PhysBasePtr12:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
   960                              <1> OffScreenMemOffset12:	dd	0
   961                              <1> OffScreenMemSize12:	dw	0
   962                              <1> LinBytesPerScanLine12:	dw	3072
   963                              <1> BnkNumberOfPages12: 	db	0
   964                              <1> LinNumberOfPages12: 	db	0
   965                              <1> LinRedMaskSize12:	db	8
   966                              <1> LinRedFieldPosition12:	db	16
   967                              <1> LinGreenMaskSize12:	db	8
   968                              <1> LinGreenFieldPosition12:db	8
   969                              <1> LinBlueMaskSize12:	db	8
   970                              <1> LinBlueFieldPosition12:	db	0
   971                              <1> LinRsvdMaskSize12:	db	0
   972                              <1> LinRsvdFieldPosition12:	db	0
   973                              <1> MaxPixelClock12:	dd	0
   974                              <1> 
   975                              <1> 			dw	0140h ; 320x200x32
   976                              <1> ModeAttributes13: 	dw	MODE_ATTRIBUTES
   977                              <1> WinAAttributes13: 	db	WINA_ATTRIBUTES
   978                              <1> WinBAttributes13: 	db	0
   979                              <1> WinGranularity13: 	dw	VBE_DISPI_BANK_SIZE_KB
   980                              <1> WinSize13: 		dw	VBE_DISPI_BANK_SIZE_KB
   981                              <1> WinASegment13:		dw	VGAMEM_GRAPH
   982                              <1> WinBSegment13:		dw	0000h
   983                              <1> WinFuncPtr13:		dd	0
   984                              <1> BytesPerScanLine13:	dw	1280
   985                              <1> XResolution13:		dw	320
   986                              <1> YResolution13:		dw	200
   987                              <1> XCharSize13:		db	8
   988                              <1> YCharSize13:		db	16
   989                              <1> NumberOfPlanes13:	db	1
   990                              <1> BitsPerPixel13:		db	32
   991                              <1> NumberOfBanks13:	db	4
   992                              <1> MemoryModel13:		db	VBE_MEMORYMODEL_DIRECT_COLOR
   993                              <1> BankSize13:		db	0
   994                              <1> NumberOfImagePages13:	db	64
   995                              <1> Reserved_page13:	db	0
   996                              <1> RedMaskSize13:		db	8
   997                              <1> RedFieldPosition13:	db	16
   998                              <1> GreenMaskSize13:	db	8
   999                              <1> GreenFieldPosition13:	db	8
  1000                              <1> BlueMaskSize13:		db	8
  1001                              <1> BlueFieldPosition13:	db	0
  1002                              <1> RsvdMaskSize13:		db	8
  1003                              <1> RsvdFieldPosition13:	db	24
  1004                              <1> DirectColorModeInfo13:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1005                              <1> PhysBasePtr13:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1006                              <1> OffScreenMemOffset13:	dd	0
  1007                              <1> OffScreenMemSize13:	dw	0
  1008                              <1> LinBytesPerScanLine13:	dw	1280
  1009                              <1> BnkNumberOfPages13: 	db	0
  1010                              <1> LinNumberOfPages13: 	db	0
  1011                              <1> LinRedMaskSize13:	db	8
  1012                              <1> LinRedFieldPosition13:	db	16
  1013                              <1> LinGreenMaskSize13:	db	8
  1014                              <1> LinGreenFieldPosition13:db	8
  1015                              <1> LinBlueMaskSize13:	db	8
  1016                              <1> LinBlueFieldPosition13:	db	0
  1017                              <1> LinRsvdMaskSize13:	db	8
  1018                              <1> LinRsvdFieldPosition13:	db	24
  1019                              <1> MaxPixelClock13:	dd	0
  1020                              <1> 
  1021                              <1> 			dw	0141h ; 640x400x32
  1022                              <1> ModeAttributes14: 	dw	MODE_ATTRIBUTES
  1023                              <1> WinAAttributes14: 	db	WINA_ATTRIBUTES
  1024                              <1> WinBAttributes14: 	db	0
  1025                              <1> WinGranularity14: 	dw	VBE_DISPI_BANK_SIZE_KB
  1026                              <1> WinSize14: 		dw	VBE_DISPI_BANK_SIZE_KB
  1027                              <1> WinASegment14:		dw	VGAMEM_GRAPH
  1028                              <1> WinBSegment14:		dw	0000h
  1029                              <1> WinFuncPtr14:		dd	0
  1030                              <1> BytesPerScanLine14:	dw	2560
  1031                              <1> XResolution14:		dw	640
  1032                              <1> YResolution14:		dw	400
  1033                              <1> XCharSize14:		db	8
  1034                              <1> YCharSize14:		db	16
  1035                              <1> NumberOfPlanes14:	db	1
  1036                              <1> BitsPerPixel14:		db	32
  1037                              <1> NumberOfBanks14:	db	16
  1038                              <1> MemoryModel14:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1039                              <1> BankSize14:		db	0
  1040                              <1> NumberOfImagePages14:	db	15
  1041                              <1> Reserved_page14:	db	0
  1042                              <1> RedMaskSize14:		db	8
  1043                              <1> RedFieldPosition14:	db	16
  1044                              <1> GreenMaskSize14:	db	8
  1045                              <1> GreenFieldPosition14:	db	8
  1046                              <1> BlueMaskSize14:		db	8
  1047                              <1> BlueFieldPosition14:	db	0
  1048                              <1> RsvdMaskSize14:		db	8
  1049                              <1> RsvdFieldPosition14:	db	24
  1050                              <1> DirectColorModeInfo14:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1051                              <1> PhysBasePtr14:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1052                              <1> OffScreenMemOffset14:	dd  	0
  1053                              <1> OffScreenMemSize14:	dw	0
  1054                              <1> LinBytesPerScanLine14:	dw	2560
  1055                              <1> BnkNumberOfPages14: 	db	0
  1056                              <1> LinNumberOfPages14: 	db	0
  1057                              <1> LinRedMaskSize14:	db	8
  1058                              <1> LinRedFieldPosition14:	db	16
  1059                              <1> LinGreenMaskSize14:	db	8
  1060                              <1> LinGreenFieldPosition14:db	8
  1061                              <1> LinBlueMaskSize14:	db	8
  1062                              <1> LinBlueFieldPosition14:	db	0
  1063                              <1> LinRsvdMaskSize14:	db	8
  1064                              <1> LinRsvdFieldPosition14:	db	24
  1065                              <1> MaxPixelClock14:	dd	0
  1066                              <1> 
  1067                              <1> 			dw	0142 ; 640x480x32
  1068                              <1> ModeAttributes15: 	dw	MODE_ATTRIBUTES
  1069                              <1> WinAAttributes15: 	db	WINA_ATTRIBUTES
  1070                              <1> WinBAttributes15: 	db	0
  1071                              <1> WinGranularity15: 	dw	VBE_DISPI_BANK_SIZE_KB
  1072                              <1> WinSize15: 		dw	VBE_DISPI_BANK_SIZE_KB
  1073                              <1> WinASegment15:		dw	VGAMEM_GRAPH
  1074                              <1> WinBSegment15:		dw	0000h
  1075                              <1> WinFuncPtr15:		dd	0
  1076                              <1> BytesPerScanLine15:	dw	2560
  1077                              <1> XResolution15:		dw	640
  1078                              <1> YResolution15:		dw	480
  1079                              <1> XCharSize15:		db	8
  1080                              <1> YCharSize15:		db	16
  1081                              <1> NumberOfPlanes15:	db	1
  1082                              <1> BitsPerPixel15:		db	32
  1083                              <1> NumberOfBanks15:	db	19
  1084                              <1> MemoryModel15:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1085                              <1> BankSize15:		db	0
  1086                              <1> NumberOfImagePages15:	db	12
  1087                              <1> Reserved_page15:	db	0
  1088                              <1> RedMaskSize15:		db	8
  1089                              <1> RedFieldPosition15:	db	16
  1090                              <1> GreenMaskSize15:	db	8
  1091                              <1> GreenFieldPosition15:	db	8
  1092                              <1> BlueMaskSize15:		db	8
  1093                              <1> BlueFieldPosition15:	db	0
  1094                              <1> RsvdMaskSize15:		db	8
  1095                              <1> RsvdFieldPosition15:	db	24
  1096                              <1> DirectColorModeInfo15:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
  1097                              <1> PhysBasePtr15:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  1098                              <1> OffScreenMemOffset15:	dd	0
  1099                              <1> OffScreenMemSize15:	dw	0
  1100                              <1> LinBytesPerScanLine15:	dw	2560
  1101                              <1> BnkNumberOfPages15: 	db	0
  1102                              <1> LinNumberOfPages15: 	db	0
  1103                              <1> LinRedMaskSize15:	db	8
  1104                              <1> LinRedFieldPosition15:	db	16
  1105                              <1> LinGreenMaskSize15:	db	8
  1106                              <1> LinGreenFieldPosition15:db	8
  1107                              <1> LinBlueMaskSize15:	db	8
  1108                              <1> LinBlueFieldPosition15:	db	0
  1109                              <1> LinRsvdMaskSize15:	db	8
  1110                              <1> LinRsvdFieldPosition15:	db	24
  1111                              <1> MaxPixelClock15:	dd	0
  1112                              <1> 
  1113                              <1> 			dw	0143h ; 800x600x32
  1114                              <1> ModeAttributes16: 	dw	MODE_ATTRIBUTES
  1115                              <1> WinAAttributes16: 	db	WINA_ATTRIBUTES
  1116                              <1> WinBAttributes16: 	db	0
  1117                              <1> WinGranularity16: 	dw	VBE_DISPI_BANK_SIZE_KB
  1118                              <1> WinSize16: 		dw	VBE_DISPI_BANK_SIZE_KB
  1119                              <1> WinASegment16:		dw	VGAMEM_GRAPH
  1120                              <1> WinBSegment16:		dw	0000h
  1121                              <1> WinFuncPtr16:		dd	0
  1122                              <1> BytesPerScanLine16:	dw	3200
  1123                              <1> XResolution16:		dw	800
  1124                              <1> YResolution16:		dw	600
  1125                              <1> XCharSize16:		db	8
  1126                              <1> YCharSize16:		db	16
  1127                              <1> NumberOfPlanes16:	db	1
  1128                              <1> BitsPerPixel16:		db	32
  1129                              <1> NumberOfBanks16:	db	30
  1130                              <1> MemoryModel16:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1131                              <1> BankSize16:		db	0
  1132                              <1> NumberOfImagePages16:	db	7
  1133                              <1> Reserved_page16:	db	0
  1134                              <1> RedMaskSize16:		db	8
  1135                              <1> RedFieldPosition16:	db	16
  1136                              <1> GreenMaskSize16:	db	8
  1137                              <1> GreenFieldPosition16:	db	8
  1138                              <1> BlueMaskSize16:		db	8
  1139                              <1> BlueFieldPosition16:	db	0
  1140                              <1> RsvdMaskSize16:		db	8
  1141                              <1> RsvdFieldPosition16:	db	24
  1142                              <1> DirectColorModeInfo16:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE,
  1143                              <1> PhysBasePtr16:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS,
  1144                              <1> OffScreenMemOffset16:	dd	0
  1145                              <1> OffScreenMemSize16:	dw	0
  1146                              <1> LinBytesPerScanLine16:	dw	3200
  1147                              <1> BnkNumberOfPages16: 	db	0
  1148                              <1> LinNumberOfPages16: 	db	0
  1149                              <1> LinRedMaskSize16:	db	8
  1150                              <1> LinRedFieldPosition16:	db	16
  1151                              <1> LinGreenMaskSize16:	db	8
  1152                              <1> LinGreenFieldPosition16:db	8
  1153                              <1> LinBlueMaskSize16:	db	8
  1154                              <1> LinBlueFieldPosition16:	db	0
  1155                              <1> LinRsvdMaskSize16:	db	8
  1156                              <1> LinRsvdFieldPosition16:	db	24
  1157                              <1> MaxPixelClock16:	dd	0
  1158                              <1> 	
  1159                              <1> 			dw	0144h ; 1024x768x32
  1160                              <1> ModeAttributes17: 	dw	MODE_ATTRIBUTES
  1161                              <1> WinAAttributes17: 	db	WINA_ATTRIBUTES
  1162                              <1> WinBAttributes17: 	db	0
  1163                              <1> WinGranularity17: 	dw	VBE_DISPI_BANK_SIZE_KB
  1164                              <1> WinSize17: 		dw	VBE_DISPI_BANK_SIZE_KB
  1165                              <1> WinASegment17:		dw	VGAMEM_GRAPH
  1166                              <1> WinBSegment17:		dw	0000h
  1167                              <1> WinFuncPtr17:		dd	0
  1168                              <1> BytesPerScanLine17:	dw	4096
  1169                              <1> XResolution17:		dw	1024
  1170                              <1> YResolution17:		dw	768
  1171                              <1> XCharSize17:		db	8
  1172                              <1> YCharSize17:		db	16
  1173                              <1> NumberOfPlanes17:	db	1
  1174                              <1> BitsPerPixel17:		db	32
  1175                              <1> NumberOfBanks17:	db	48
  1176                              <1> MemoryModel17:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1177                              <1> BankSize17:		db	0
  1178                              <1> NumberOfImagePages17:	db	4
  1179                              <1> Reserved_page17:	db	0
  1180                              <1> RedMaskSize17:		db	8
  1181                              <1> RedFieldPosition17:	db	16
  1182                              <1> GreenMaskSize17:	db	8
  1183                              <1> GreenFieldPosition17:	db	8
  1184                              <1> BlueMaskSize17:		db	8
  1185                              <1> BlueFieldPosition17:	db	0
  1186                              <1> RsvdMaskSize17:		db	8
  1187                              <1> RsvdFieldPosition17:	db	24
  1188                              <1> DirectColorModeInfo17:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1189                              <1> PhysBasePtr17:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1190                              <1> OffScreenMemOffset17:	dd	0
  1191                              <1> OffScreenMemSize17:	dw	0
  1192                              <1> LinBytesPerScanLine17:	dw	4096
  1193                              <1> BnkNumberOfPages17: 	db	0
  1194                              <1> LinNumberOfPages17: 	db	0
  1195                              <1> LinRedMaskSize17:	db	8
  1196                              <1> LinRedFieldPosition17:	db	16
  1197                              <1> LinGreenMaskSize17:	db	8
  1198                              <1> LinGreenFieldPosition17:db	8
  1199                              <1> LinBlueMaskSize17:	db	8
  1200                              <1> LinBlueFieldPosition17:	db	0
  1201                              <1> LinRsvdMaskSize17:	db	8
  1202                              <1> LinRsvdFieldPosition17:	db	24
  1203                              <1> MaxPixelClock17:	dd	0
  1204                              <1> 	
  1205                              <1> 			dw	0146h ; 320x200x8
  1206                              <1> ModeAttributes18: 	dw	MODE_ATTRIBUTES
  1207                              <1> WinAAttributes18: 	db	WINA_ATTRIBUTES
  1208                              <1> WinBAttributes18: 	db	0
  1209                              <1> WinGranularity18: 	dw	VBE_DISPI_BANK_SIZE_KB
  1210                              <1> WinSize18: 		dw	VBE_DISPI_BANK_SIZE_KB
  1211                              <1> WinASegment18:		dw	VGAMEM_GRAPH
  1212                              <1> WinBSegment18:		dw	0000h
  1213                              <1> WinFuncPtr18:		dd	0
  1214                              <1> BytesPerScanLine18:	dw	320
  1215                              <1> XResolution18:		dw	320
  1216                              <1> YResolution18:		dw	200
  1217                              <1> XCharSize18:		db	8
  1218                              <1> YCharSize18:		db	16
  1219                              <1> NumberOfPlanes18:	db	1
  1220                              <1> BitsPerPixel18:		db	8
  1221                              <1> NumberOfBanks18:	db	1
  1222                              <1> MemoryModel18:		db	VBE_MEMORYMODEL_PACKED_PIXEL
  1223                              <1> BankSize18:		db	0
  1224                              <1> NumberOfImagePages18:	db	255 ; 261 in vbetables.h (03/01/2020) !
  1225                              <1> Reserved_page18:	db	0
  1226                              <1> RedMaskSize18:		db	0
  1227                              <1> RedFieldPosition18:	db	0
  1228                              <1> GreenMaskSize18:	db	0
  1229                              <1> GreenFieldPosition18:	db	0
  1230                              <1> BlueMaskSize18:		db	0
  1231                              <1> BlueFieldPosition18:	db	0
  1232                              <1> RsvdMaskSize18:		db	0
  1233                              <1> RsvdFieldPosition18:	db	0
  1234                              <1> DirectColorModeInfo18:	db	0
  1235                              <1> PhysBasePtr18:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1236                              <1> OffScreenMemOffset18:	dd	0
  1237                              <1> OffScreenMemSize18:	dw	0
  1238                              <1> LinBytesPerScanLine18:	dw	320
  1239                              <1> BnkNumberOfPages18: 	db	0
  1240                              <1> LinNumberOfPages18: 	db	0
  1241                              <1> LinRedMaskSize18:	db	0
  1242                              <1> LinRedFieldPosition18: 	db	0
  1243                              <1> LinGreenMaskSize18: 	db	0
  1244                              <1> LinGreenFieldPosition18:db	0
  1245                              <1> LinBlueMaskSize18: 	db	0
  1246                              <1> LinBlueFieldPosition18: db	0
  1247                              <1> LinRsvdMaskSize18: 	db	0
  1248                              <1> LinRsvdFieldPosition18: db	0
  1249                              <1> MaxPixelClock18:	dd	0
  1250                              <1> 
  1251                              <1> 			dw	018Dh ; 1280x720x16
  1252                              <1> ModeAttributes19: 	dw	MODE_ATTRIBUTES
  1253                              <1> WinAAttributes19: 	db	WINA_ATTRIBUTES
  1254                              <1> WinBAttributes19: 	db	0
  1255                              <1> WinGranularity19: 	dw	VBE_DISPI_BANK_SIZE_KB
  1256                              <1> WinSize19: 		dw	VBE_DISPI_BANK_SIZE_KB
  1257                              <1> WinASegment19:		dw	VGAMEM_GRAPH
  1258                              <1> WinBSegment19:		dw	0000h
  1259                              <1> WinFuncPtr19:		dd	0
  1260                              <1> BytesPerScanLine19:	dw	2560
  1261                              <1> XResolution19:		dw	1280
  1262                              <1> YResolution19:		dw	720
  1263                              <1> XCharSize19:		db	8
  1264                              <1> YCharSize19:		db	16
  1265                              <1> NumberOfPlanes19:	db	1
  1266                              <1> BitsPerPixel19:		db	16
  1267                              <1> NumberOfBanks19:	db	29
  1268                              <1> MemoryModel19:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1269                              <1> BankSize19:		db	0
  1270                              <1> NumberOfImagePages19:	db	8
  1271                              <1> Reserved_page19:	db	0
  1272                              <1> RedMaskSize19:		db	5
  1273                              <1> RedFieldPosition19:	db	11
  1274                              <1> GreenMaskSize19:	db	6
  1275                              <1> GreenFieldPosition19:	db	5
  1276                              <1> BlueMaskSize19:		db	5
  1277                              <1> BlueFieldPosition19:	db	0
  1278                              <1> RsvdMaskSize19:		db	0
  1279                              <1> RsvdFieldPosition19:	db	0
  1280                              <1> DirectColorModeInfo19:	db	0
  1281                              <1> PhysBasePtr19:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1282                              <1> OffScreenMemOffset19:	dd	0
  1283                              <1> OffScreenMemSize19:	dw	0
  1284                              <1> LinBytesPerScanLine19:	dw	2560
  1285                              <1> BnkNumberOfPages19: 	db	0
  1286                              <1> LinNumberOfPages19: 	db	0
  1287                              <1> LinRedMaskSize19:	db	5
  1288                              <1> LinRedFieldPosition19:	db	11
  1289                              <1> LinGreenMaskSize19:	db	6
  1290                              <1> LinGreenFieldPosition19:db	5
  1291                              <1> LinBlueMaskSize19:	db	5
  1292                              <1> LinBlueFieldPosition19:	db	0
  1293                              <1> LinRsvdMaskSize19:	db	0
  1294                              <1> LinRsvdFieldPosition19:	db	0
  1295                              <1> MaxPixelClock19:	dd	0
  1296                              <1> 
  1297                              <1> 			dw	018Eh ; 1280x720x24
  1298                              <1> ModeAttributes20: 	dw	MODE_ATTRIBUTES
  1299                              <1> WinAAttributes20: 	db	WINA_ATTRIBUTES
  1300                              <1> WinBAttributes20: 	db	0
  1301                              <1> WinGranularity20: 	dw	VBE_DISPI_BANK_SIZE_KB
  1302                              <1> WinSize20: 		dw	VBE_DISPI_BANK_SIZE_KB
  1303                              <1> WinASegment20:		dw	VGAMEM_GRAPH
  1304                              <1> WinBSegment20:		dw	0000h
  1305                              <1> WinFuncPtr20:		dd	0
  1306                              <1> BytesPerScanLine20:	dw	3840
  1307                              <1> XResolution20:		dw	1280
  1308                              <1> YResolution20:		dw	720
  1309                              <1> XCharSize20:		db	8
  1310                              <1> YCharSize20:		db	16
  1311                              <1> NumberOfPlanes20:	db	1
  1312                              <1> BitsPerPixel20:		db	24
  1313                              <1> NumberOfBanks20:	db	43
  1314                              <1> MemoryModel20:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1315                              <1> BankSize20:		db	0
  1316                              <1> NumberOfImagePages20:	db	5
  1317                              <1> Reserved_page20:	db	0
  1318                              <1> RedMaskSize20:		db	8
  1319                              <1> RedFieldPosition20:	db	16
  1320                              <1> GreenMaskSize20:	db	8
  1321                              <1> GreenFieldPosition20:	db	8
  1322                              <1> BlueMaskSize20:		db	8
  1323                              <1> BlueFieldPosition20:	db	0
  1324                              <1> RsvdMaskSize20:		db	0
  1325                              <1> RsvdFieldPosition20:	db	0
  1326                              <1> DirectColorModeInfo20:	db	0
  1327                              <1> PhysBasePtr20:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1328                              <1> OffScreenMemOffset20:	dd	0
  1329                              <1> OffScreenMemSize20:	dw	0
  1330                              <1> LinBytesPerScanLine20:	dw	3840
  1331                              <1> BnkNumberOfPages20: 	db	0
  1332                              <1> LinNumberOfPages20: 	db	0
  1333                              <1> LinRedMaskSize20:	db	8
  1334                              <1> LinRedFieldPosition20:	db	16
  1335                              <1> LinGreenMaskSize20:	db	8
  1336                              <1> LinGreenFieldPosition20:db	8
  1337                              <1> LinBlueMaskSize20:	db	8
  1338                              <1> LinBlueFieldPosition20:	db	0
  1339                              <1> LinRsvdMaskSize20:	db	0
  1340                              <1> LinRsvdFieldPosition20:	db	0
  1341                              <1> MaxPixelClock20:	dd	0
  1342                              <1> 	
  1343                              <1> 			dw	018Fh ; 1280x720x32
  1344                              <1> ModeAttributes21: 	dw	MODE_ATTRIBUTES
  1345                              <1> WinAAttributes21: 	db	WINA_ATTRIBUTES
  1346                              <1> WinBAttributes21: 	db	0
  1347                              <1> WinGranularity21: 	dw	VBE_DISPI_BANK_SIZE_KB
  1348                              <1> WinSize21: 		dw	VBE_DISPI_BANK_SIZE_KB
  1349                              <1> WinASegment21:		dw	VGAMEM_GRAPH
  1350                              <1> WinBSegment21:		dw	0000h
  1351                              <1> WinFuncPtr21:		dd	0
  1352                              <1> BytesPerScanLine21:	dw	5120
  1353                              <1> XResolution21:		dw	1280
  1354                              <1> YResolution21:		dw	720
  1355                              <1> XCharSize21:		db	8
  1356                              <1> YCharSize21:		db	16
  1357                              <1> NumberOfPlanes21:	db	1
  1358                              <1> BitsPerPixel21:		db	32
  1359                              <1> NumberOfBanks21:	db	57
  1360                              <1> MemoryModel21:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1361                              <1> BankSize21:		db	0
  1362                              <1> NumberOfImagePages21:	db	3
  1363                              <1> Reserved_page21:	db	0
  1364                              <1> RedMaskSize21:		db	8
  1365                              <1> RedFieldPosition21:	db	16
  1366                              <1> GreenMaskSize21:	db	8
  1367                              <1> GreenFieldPosition21:	db	8
  1368                              <1> BlueMaskSize21:		db	8
  1369                              <1> BlueFieldPosition21:	db	0
  1370                              <1> RsvdMaskSize21:		db	8
  1371                              <1> RsvdFieldPosition21:	db	24
  1372                              <1> DirectColorModeInfo21:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1373                              <1> PhysBasePtr21:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1374                              <1> OffScreenMemOffset21:	dd	0
  1375                              <1> OffScreenMemSize21:	dw	0
  1376                              <1> LinBytesPerScanLine21:	dw	5120
  1377                              <1> BnkNumberOfPages21: 	db	0
  1378                              <1> LinNumberOfPages21: 	db	0
  1379                              <1> LinRedMaskSize21:	db	8
  1380                              <1> LinRedFieldPosition21:	db	16
  1381                              <1> LinGreenMaskSize21:	db	8
  1382                              <1> LinGreenFieldPosition21:db	8
  1383                              <1> LinBlueMaskSize21:	db	8
  1384                              <1> LinBlueFieldPosition21:	db	0
  1385                              <1> LinRsvdMaskSize21:	db	8
  1386                              <1> LinRsvdFieldPosition21:	db	24
  1387                              <1> MaxPixelClock21:	dd	0
  1388                              <1> 			
  1389                              <1> 			dw	0190h ; 1920x1080x16
  1390                              <1> ModeAttributes22: 	dw	MODE_ATTRIBUTES
  1391                              <1> WinAAttributes22: 	db	WINA_ATTRIBUTES
  1392                              <1> WinBAttributes22: 	db	0
  1393                              <1> WinGranularity22: 	dw	VBE_DISPI_BANK_SIZE_KB
  1394                              <1> WinSize22: 		dw	VBE_DISPI_BANK_SIZE_KB
  1395                              <1> WinASegment22:		dw	VGAMEM_GRAPH
  1396                              <1> WinBSegment22:		dw	0000h
  1397                              <1> WinFuncPtr22:		dd	0
  1398                              <1> BytesPerScanLine22:	dw	3840
  1399                              <1> XResolution22:		dw	1920
  1400                              <1> YResolution22:		dw	1080
  1401                              <1> XCharSize22:		db	8
  1402                              <1> YCharSize22:		db	16
  1403                              <1> NumberOfPlanes22:	db	1
  1404                              <1> BitsPerPixel22:		db	16
  1405                              <1> NumberOfBanks22:	db	64
  1406                              <1> MemoryModel22:		db	VBE_MEMORYMODEL_DIRECT_COLOR,
  1407                              <1> BankSize22:		db	0
  1408                              <1> NumberOfImagePages22:	db	3
  1409                              <1> Reserved_page22:	db	0
  1410                              <1> RedMaskSize22:		db	5
  1411                              <1> RedFieldPosition22:	db	11
  1412                              <1> GreenMaskSize22:	db	6
  1413                              <1> GreenFieldPosition22:	db	5
  1414                              <1> BlueMaskSize22:		db	5
  1415                              <1> BlueFieldPosition22:	db	0
  1416                              <1> RsvdMaskSize22:		db	0
  1417                              <1> RsvdFieldPosition22:	db	0
  1418                              <1> DirectColorModeInfo22:	db	0
  1419                              <1> PhysBasePtr22:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1420                              <1> OffScreenMemOffset22:	dd	0
  1421                              <1> OffScreenMemSize22:	dw	0
  1422                              <1> LinBytesPerScanLine22:	dw	3840
  1423                              <1> BnkNumberOfPages22: 	db	0
  1424                              <1> LinNumberOfPages22: 	db	0
  1425                              <1> LinRedMaskSize22:	db	5
  1426                              <1> LinRedFieldPosition22:	db	11
  1427                              <1> LinGreenMaskSize22:	db	6
  1428                              <1> LinGreenFieldPosition22:db	5
  1429                              <1> LinBlueMaskSize22:	db	5
  1430                              <1> LinBlueFieldPosition22:	db	0
  1431                              <1> LinRsvdMaskSize22:	db	0
  1432                              <1> LinRsvdFieldPosition22:	db	0
  1433                              <1> MaxPixelClock22:	dd	0
  1434                              <1> 			
  1435                              <1> 			dw	0191h ; 1920x1080x24
  1436                              <1> ModeAttributes23: 	dw	MODE_ATTRIBUTES
  1437                              <1> WinAAttributes23: 	db	WINA_ATTRIBUTES
  1438                              <1> WinBAttributes23: 	db	0
  1439                              <1> WinGranularity23: 	dw	VBE_DISPI_BANK_SIZE_KB
  1440                              <1> WinSize23: 		dw	VBE_DISPI_BANK_SIZE_KB
  1441                              <1> WinASegment23:		dw	VGAMEM_GRAPH
  1442                              <1> WinBSegment23:		dw	0000h
  1443                              <1> WinFuncPtr23:		dd	0
  1444                              <1> BytesPerScanLine23:	dw	5760
  1445                              <1> XResolution23:		dw	1920
  1446                              <1> YResolution23:		dw	1080
  1447                              <1> XCharSize23:		db	8
  1448                              <1> YCharSize23:		db	16
  1449                              <1> NumberOfPlanes23:	db	1
  1450                              <1> BitsPerPixel23:		db	24
  1451                              <1> NumberOfBanks23:	db	95
  1452                              <1> MemoryModel23:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1453                              <1> BankSize23:		db	0
  1454                              <1> NumberOfImagePages23:	db	1
  1455                              <1> Reserved_page23:	db	0
  1456                              <1> RedMaskSize23:		db	8
  1457                              <1> RedFieldPosition23:	db	16
  1458                              <1> GreenMaskSize23:	db	8
  1459                              <1> GreenFieldPosition23:	db	8
  1460                              <1> BlueMaskSize23:		db	8
  1461                              <1> BlueFieldPosition23:	db	0
  1462                              <1> RsvdMaskSize23:		db	0
  1463                              <1> RsvdFieldPosition23:	db	0
  1464                              <1> DirectColorModeInfo23:	db	0
  1465                              <1> PhysBasePtr23:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1466                              <1> OffScreenMemOffset23:	dd	0
  1467                              <1> OffScreenMemSize23:	dw	0
  1468                              <1> LinBytesPerScanLine23:	dw	5760
  1469                              <1> BnkNumberOfPages23: 	db	0
  1470                              <1> LinNumberOfPages23: 	db	0
  1471                              <1> LinRedMaskSize23:	db	8
  1472                              <1> LinRedFieldPosition23:	db	16
  1473                              <1> LinGreenMaskSize23:	db	8
  1474                              <1> LinGreenFieldPosition23:db	8
  1475                              <1> LinBlueMaskSize23:	db	8
  1476                              <1> LinBlueFieldPosition23:	db	0
  1477                              <1> LinRsvdMaskSize23:	db	0
  1478                              <1> LinRsvdFieldPosition23:	db	0
  1479                              <1> MaxPixelClock23:	dd	0
  1480                              <1> 
  1481                              <1> 			dw	0192h ; 1920x1080x32
  1482                              <1> ModeAttributes24: 	dw	MODE_ATTRIBUTES
  1483                              <1> WinAAttributes24: 	db	WINA_ATTRIBUTES
  1484                              <1> WinBAttributes24: 	db	0
  1485                              <1> WinGranularity24: 	dw	VBE_DISPI_BANK_SIZE_KB
  1486                              <1> WinSize24: 		dw	VBE_DISPI_BANK_SIZE_KB
  1487                              <1> WinASegment24:		dw	VGAMEM_GRAPH
  1488                              <1> WinBSegment24:		dw	0000h
  1489                              <1> WinFuncPtr24:		dd	0
  1490                              <1> BytesPerScanLine24:	dw	7680
  1491                              <1> XResolution24:		dw	1920
  1492                              <1> YResolution24:		dw	1080
  1493                              <1> XCharSize24:		db	8
  1494                              <1> YCharSize24:		db	16
  1495                              <1> NumberOfPlanes24:	db	1
  1496                              <1> BitsPerPixel24:		db	32
  1497                              <1> NumberOfBanks24:	db	127
  1498                              <1> MemoryModel24:		db	VBE_MEMORYMODEL_DIRECT_COLOR
  1499                              <1> BankSize24:		db	0
  1500                              <1> NumberOfImagePages24:	db	1
  1501                              <1> Reserved_page24:	db	0
  1502                              <1> RedMaskSize24:		db	8
  1503                              <1> RedFieldPosition24:	db	16
  1504                              <1> GreenMaskSize24:	db	8
  1505                              <1> GreenFieldPosition24:	db	8
  1506                              <1> BlueMaskSize24:		db	8
  1507                              <1> BlueFieldPosition24:	db	0
  1508                              <1> RsvdMaskSize24:		db	8
  1509                              <1> RsvdFieldPosition24:	db	24
  1510                              <1> DirectColorModeInfo24:	db	VBE_DIRECTCOLOR_RESERVED_BITS_AVAILABLE
  1511                              <1> PhysBasePtr24:		dd	VBE_DISPI_LFB_PHYSICAL_ADDRESS
  1512                              <1> OffScreenMemOffset24:	dd	0
  1513                              <1> OffScreenMemSize24:	dw	0
  1514                              <1> LinBytesPerScanLine24:	dw 	7680
  1515                              <1> BnkNumberOfPages24: 	db	0
  1516                              <1> LinNumberOfPages24: 	db	0
  1517                              <1> LinRedMaskSize24:	db	8
  1518                              <1> LinRedFieldPosition24:	db	16
  1519                              <1> LinGreenMaskSize24:	db	8
  1520                              <1> LinGreenFieldPosition24:db	8
  1521                              <1> LinBlueMaskSize24:	db	8
  1522                              <1> LinBlueFieldPosition24:	db	0
  1523                              <1> LinRsvdMaskSize24:	db	8
  1524                              <1> LinRsvdFieldPosition24:	db	24
  1525                              <1> MaxPixelClock24:	dd	0
  1526                              <1> 
  1527                              <1> VBE_VESA_MODE_END_OF_LIST: dw	0
  1528                              <1> 
  1529                              <1> %endif
  1530                              <1> 
  1531                              <1> ; 24/11/2020
  1532                              <1> 
  1533                              <1> direct_color_fields:
  1534                              <1> 	; 24/11/2020
  1535                              <1> 
  1536                              <1> ; (vbetables-gen.c)
  1537                              <1> ; // Direct Color fields 
  1538                              <1> ; (required for direct/6 and YUV/7 memory models)
  1539                              <1> ; switch(pm->depth) {
  1540                              <1>     
  1541                              <1> ;case 8:
  1542 00007416 00                  <1> r_size_8:  db 0
  1543 00007417 00                  <1> r_pos_8:   db 0
  1544 00007418 00                  <1> g_size_8:  db 0
  1545 00007419 00                  <1> g_pos_8:   db 0
  1546 0000741A 00                  <1> b_size_8:  db 0
  1547 0000741B 00                  <1> b_pos_8:   db 0
  1548 0000741C 00                  <1> a_size_8:  db 0
  1549 0000741D 00                  <1> a_pos_8:   db 0
  1550                              <1> 
  1551                              <1> ;case 16:
  1552 0000741E 05                  <1> r_size_16:  db 5
  1553 0000741F 0B                  <1> r_pos_16:   db 11
  1554 00007420 06                  <1> g_size_16:  db 6
  1555 00007421 05                  <1> g_pos_16:   db 5
  1556 00007422 05                  <1> b_size_16:  db 5
  1557 00007423 00                  <1> b_pos_16:   db 0
  1558 00007424 00                  <1> a_size_16:  db 0
  1559 00007425 00                  <1> a_pos_16:   db 0
  1560                              <1> 
  1561                              <1> ;case 24:
  1562 00007426 08                  <1> r_size_24:  db 8
  1563 00007427 10                  <1> r_pos_24:   db 16
  1564 00007428 08                  <1> g_size_24:  db 8
  1565 00007429 08                  <1> g_pos_24:   db 8
  1566 0000742A 08                  <1> b_size_24:  db 8
  1567 0000742B 00                  <1> b_pos_24:   db 0
  1568 0000742C 00                  <1> a_size_24:  db 0
  1569 0000742D 00                  <1> a_pos_24:   db 0
  1570                              <1> 
  1571                              <1> ;case 32:
  1572 0000742E 08                  <1> r_size_32:  db 8
  1573 0000742F 10                  <1> r_pos_32:   db 16
  1574 00007430 08                  <1> g_size_32:  db 8
  1575 00007431 08                  <1> g_pos_32:   db 8
  1576 00007432 08                  <1> b_size_32:  db 8
  1577 00007433 00                  <1> b_pos_32:   db 0
  1578 00007434 08                  <1> a_size_32:  db 8
  1579 00007435 18                  <1> a_pos_32:   db 24
  3072                                  ;%include 'diskdata.s'	; DISK (BIOS) DATA (initialized)
  3073                                  ;;;
  3074                                  
  3075                                  Align 2
  3076                                  
  3077                                  %include 'sysdefs.s' ; 24/01/2015
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - SYSTEM DEFINITIONS : sysdefs.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 31/12/2017
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; sysdefs.inc (14/11/2015)
    12                              <1> ; ****************************************************************************
    13                              <1> 
    14                              <1> ; Retro UNIX 386 v1 Kernel - SYSDEFS.INC
    15                              <1> ; Last Modification: 14/11/2015
    16                              <1> ;
    17                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
    18                              <1> ; (Modified from 
    19                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
    20                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
    21                              <1> ; 	UNIX.ASM (MASM 6.11) --> SYSDEFS.INC (NASM 2.11)
    22                              <1> ; ----------------------------------------------------------------------------
    23                              <1> ;
    24                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
    25                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
    26                              <1> ; <Bell Laboratories (17/3/1972)>
    27                              <1> ; <Preliminary Release of UNIX Implementation Document>
    28                              <1> ;
    29                              <1> ; ****************************************************************************
    30                              <1> 
    31                              <1> nproc 	equ	16  ; number of processes
    32                              <1> nfiles 	equ	50
    33                              <1> ntty	equ     8   ; 8+1 -> 8 (10/05/2013)
    34                              <1> nbuf	equ	4   ; 6 ;; 21/08/2015 - 'namei' buffer problem when nbuf > 4 	
    35                              <1> 		; NOTE: If fd0 super block buffer addres is beyond of the 1st
    36                              <1> 		; 32K, DMA r/w routine or someting else causes a jump to 
    37                              <1> 		; kernel panic routine (in 'alloc' routine, in u5.s)
    38                              <1> 		; because of invalid buffer content (r/w error). 
    39                              <1> 		; When all buffers are set before the end of the 1st 32k,
    40                              <1> 		; there is no problem!? (14/11/2015) 
    41                              <1> 
    42                              <1> ;csgmnt	equ	2000h	; 26/05/2013 (segment of process 1)
    43                              <1> ;core	equ 	0  	    ; 19/04/2013	
    44                              <1> ;ecore	equ	32768 - 64  ; 04/06/2013 (24/05/2013)
    45                              <1> 	; (if total size of argument list and arguments is 128 bytes)
    46                              <1> 	; maximum executable file size = 32768-(64+40+128-6) = 32530 bytes
    47                              <1> 	; maximum stack size = 40 bytes (+6 bytes for 'IRET' at 32570)	
    48                              <1> 	; initial value of user's stack pointer = 32768-64-128-2 = 32574
    49                              <1> 	; 	(sp=32768-args_space-2 at the beginning of execution)
    50                              <1> 	; argument list offset = 32768-64-128 = 32576 (if it is 128 bytes)
    51                              <1> 	; 'u' structure offset (for the '/core' dump file) = 32704
    52                              <1> 	; '/core' dump file size = 32768 bytes
    53                              <1>  
    54                              <1> ; 08/03/2014 
    55                              <1> ;sdsegmnt equ	6C0h  ; 256*16 bytes (swap data segment size for 16 processes)		 	 
    56                              <1> ; 19/04/2013 Retro UNIX 8086 v1 feaure only !
    57                              <1> ;;sdsegmnt equ 	740h  ; swap data segment (for user structures and registers)
    58                              <1> 
    59                              <1> ; 30/08/2013
    60                              <1> time_count equ 4 ; 10 --> 4 01/02/2014
    61                              <1> 
    62                              <1> ; 05/02/2014
    63                              <1> ; process status
    64                              <1> ;SFREE 	equ 0
    65                              <1> ;SRUN	equ 1
    66                              <1> ;SWAIT	equ 2
    67                              <1> ;SZOMB	equ 3
    68                              <1> ;SSLEEP	equ 4 ; Retro UNIX 8086 V1 extension (for sleep and wakeup)
    69                              <1> 
    70                              <1> ; 09/03/2015
    71                              <1> userdata equ 80000h ; user structure data address for current user ; temporary
    72                              <1> swap_queue equ 90000h - 2000h ; swap queue address ; temporary
    73                              <1> swap_alloc_table equ 0D0000h  ;  swap allocation table address ; temporary
    74                              <1> 
    75                              <1> ; 17/09/2015
    76                              <1> ESPACE equ 48 ; [u.usp] (at 'sysent') - [u.sp] value for error return
    77                              <1> 
    78                              <1> ; 31/12/2017
    79                              <1> ; 19/02/2017
    80                              <1> ; 15/10/2016
    81                              <1> ; 20/05/2016
    82                              <1> ; 19/05/2016
    83                              <1> ; 18/05/2016
    84                              <1> ; 29/04/2016 
    85                              <1> ; TRDOS 386 (TRDOS v2.0) system calls - temporary List 
    86                              <1> ; 14/07/2013 - 21/09/2015 (Retro UNIX 8086 & 386 system calls) 
    87                              <1> _ver 	equ 0 ; Get TRDOS version (v2.0)
    88                              <1> _exit 	equ 1
    89                              <1> _fork 	equ 2
    90                              <1> _read 	equ 3
    91                              <1> _write	equ 4
    92                              <1> _open	equ 5
    93                              <1> _close 	equ 6
    94                              <1> _wait 	equ 7
    95                              <1> _creat 	equ 8
    96                              <1> _rename	equ 9  ; TRDOS 386, Rename File (31/12/2017)	
    97                              <1> _delete	equ 10 ; TRDOS 386, Delete File (29/12/2017)
    98                              <1> _exec	equ 11
    99                              <1> _chdir	equ 12
   100                              <1> _time 	equ 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
   101                              <1> _mkdir 	equ 14
   102                              <1> _chmod	equ 15 ; TRDOS 386, Change Attributes (30/12/2017) 
   103                              <1> _rmdir	equ 16 ; TRDOS 386, Remove Directory (29/12/2017)
   104                              <1> _break	equ 17
   105                              <1> _drive	equ 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
   106                              <1> _seek	equ 19
   107                              <1> _tell 	equ 20
   108                              <1> _mem	equ 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
   109                              <1> _prompt	equ 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
   110                              <1> _path	equ 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
   111                              <1> _env	equ 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
   112                              <1> _stime	equ 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
   113                              <1> _quit	equ 26	
   114                              <1> _intr	equ 27
   115                              <1> _dir	equ 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
   116                              <1> _emt 	equ 29
   117                              <1> _ldrvt 	equ 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
   118                              <1> _video  equ 31 ; TRDOS 386 Video Functions (16/05/2016)
   119                              <1> _audio	equ 32 ; TRDOS 386 Video Functions (16/05/2016)
   120                              <1> _timer	equ 33 ; TRDOS 386 Timer Functions (18/05/2016)
   121                              <1> _sleep	equ 34 ; Retro UNIX 8086 v1 feature only !
   122                              <1> _msg	equ 35 ; Retro UNIX 386 v1 feature only !
   123                              <1> _geterr	equ 36 ; Retro UNIX 386 v1 feature only !
   124                              <1> _fpsave equ 37 ; TRDOS 386 FPU state option (28/02/2017)
   125                              <1> _pri 	equ 38 ; change priority - TRDOS 386 (20/05/2016)
   126                              <1> _rele	equ 39 ; TRDOS 386 (19/05/2016)
   127                              <1> _fff	equ 40 ; Find First File - TRDOS 386 (15/10/2016)
   128                              <1> _fnf	equ 41 ; Find Next File - TRDOS 386 (15/10/2016)
   129                              <1> _alloc	equ 42 ; Allocate memory - TRDOS 386 (19/02/2017)
   130                              <1> 	       ; TRDOS 386 (19/02/2017) DMA buff fuctions		
   131                              <1> _dalloc equ 43 ; Deallocate mem - TRDOS 386 (19/02/2017)
   132                              <1> _calbac equ 44 ; Set IRQ callback - TRDOS 386 (20/02/2017)  				
   133                              <1> _dma	equ 45 ; DMA service - TRDOS 386 (20/08/2017)  
   134                              <1> 
   135                              <1> %macro sys 1-4
   136                              <1>     ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
   137                              <1>     ; 03/09/2015	
   138                              <1>     ; 13/04/2015
   139                              <1>     ; Retro UNIX 386 v1 system call.		
   140                              <1>     %if %0 >= 2   
   141                              <1>         mov ebx, %2
   142                              <1>         %if %0 >= 3    
   143                              <1>             mov ecx, %3
   144                              <1>             %if %0 = 4
   145                              <1>                mov edx, %4   
   146                              <1>             %endif
   147                              <1>         %endif
   148                              <1>     %endif
   149                              <1>     mov eax, %1
   150                              <1>     ;int 30h
   151                              <1>     int 40h ; TRDOS 386 (TRDOS v2.0)		   
   152                              <1> %endmacro
   153                              <1> 
   154                              <1> ; TRDOS 386 system calls, interrupt number
   155                              <1> ; 25/12/2016
   156                              <1> SYSCALL_INT_NUM   equ '40' ; '40h'
   157                              <1> 
   158                              <1> ; 13/05/2015 - ERROR CODES
   159                              <1> ERR_FILE_NOT_OPEN  equ 10 ; 'file not open !' error
   160                              <1> ERR_FILE_ACCESS    equ 11 ; 'permission denied !' error
   161                              <1> ; 14/05/2015
   162                              <1> ERR_DIR_ACCESS     equ 11 ; 'permission denied !' error
   163                              <1> ERR_FILE_NOT_FOUND equ 12 ; 'file not found !' error
   164                              <1> ERR_TOO_MANY_FILES equ 13 ; 'too many open files !' error
   165                              <1> ERR_DIR_EXISTS     equ 14 ; 'directory already exists !' error 	
   166                              <1> ; 16/05/2015		
   167                              <1> ERR_DRV_NOT_RDY    equ 15 ; 'drive not ready !' error
   168                              <1> ; 18/05/2015
   169                              <1> ERR_DEV_NOT_RDY    equ 15 ; 'device not ready !' error
   170                              <1> ERR_DEV_ACCESS     equ 11 ; 'permission denied !' error 
   171                              <1> ERR_DEV_NOT_OPEN   equ 10 ; 'device not open !' error	
   172                              <1> ; 07/06/2015
   173                              <1> ERR_FILE_EOF	   equ 16 ; 'end of file !' error
   174                              <1> ERR_DEV_VOL_SIZE   equ 16 ; 'out of volume !' error
   175                              <1> ; 09/06/2015
   176                              <1> ERR_DRV_READ	   equ 17 ; 'disk read error !'
   177                              <1> ERR_DRV_WRITE	   equ 18 ; 'disk write error !'
   178                              <1> ; 16/06/2015
   179                              <1> ERR_NOT_DIR	   equ 19 ; 'not a (valid) directory !' error
   180                              <1> ERR_FILE_SIZE	   equ 20 ; 'file size error !'	
   181                              <1> ; 22/06/2015
   182                              <1> ERR_NOT_SUPERUSER  equ 11 ; 'permission denied !' error
   183                              <1> ERR_NOT_OWNER      equ 11 ; 'permission denied !' error
   184                              <1> ERR_NOT_FILE       equ 11 ; 'permission denied !' error	
   185                              <1> ; 23/06/2015
   186                              <1> ERR_FILE_EXISTS    equ 14 ; 'file already exists !' error
   187                              <1> ERR_DRV_NOT_SAME   equ 21 ; 'not same drive !' error
   188                              <1> ERR_DIR_NOT_FOUND  equ 12 ; 'directory not found !' error
   189                              <1> ERR_NOT_EXECUTABLE equ 22 ; 'not executable file !' error
   190                              <1> ; 27/06/2015
   191                              <1> ERR_INV_PARAMETER  equ 23 ; 'invalid parameter !' error
   192                              <1> ERR_INV_DEV_NAME   equ 24 ; 'invalid device name !' error
   193                              <1> ; 29/06/2015
   194                              <1> ERR_TIME_OUT	   equ 25 ; 'time out !' error			
   195                              <1> ERR_DEV_NOT_RESP   equ 25 ; 'device not responding !' error
   196                              <1> ; 10/10/2016
   197                              <1> ERR_INV_FILE_NAME  equ 26 ; 'invalid file name !' error
   198                              <1> ERR_INV_FLAGS	   equ 23 ; 'invalid flags !' error
   199                              <1> ; For code compatibility with previous version of TRDOS (2011)
   200                              <1> ; (Temporary error codes for current TRDOS 386 -2016- version) 
   201                              <1> ERR_NO_MORE_FILES  equ 12 ; 'no more files !' error
   202                              <1> ERR_PATH_NOT_FOUND equ  3 ; 'path not found !' error 
   203                              <1> 			  ; 'dir not found !' ; TRDOS 8086
   204                              <1> ERR_NOT_FOUND:	   equ  2 ; 'file not found !' ; TRDOS 8086
   205                              <1> ERR_DISK_SPACE	   equ 39 ; 'out of volume !' TRDOS 8086
   206                              <1> 			  ; 'insufficient disk space !' ; 27h
   207                              <1> ERR_DISK_WRITE	   equ 30 ; 'disk write protected !' ; 16/10/2016
   208                              <1> ERR_ACCESS_DENIED  equ  5 ; 'access denied !' ; TRDOS 8086 	
   209                              <1> ; 28/02/2017
   210                              <1> ERR_PERM_DENIED	   equ 11 ; 'permission denied !' error  	
   211                              <1> ; 18/05/2016
   212                              <1> ERR_MISC	   equ 27 ; miscellaneous/other errors
   213                              <1> ; 15/10/2016
   214                              <1> ; TRDOS 8086 -> TRDOS 386 (0Bh -> 28)
   215                              <1> ERR_INV_FORMAT	   equ 28 ; 'invalid format !' error
   216                              <1> ; TRDOS 8086 -> TRDOS 386 (0Dh -> 29)
   217                              <1> ERR_INV_DATA	   equ 29 ; 'invalid data !' error
   218                              <1> ; TRDOS 8086 -> TRDOS 386 (0Eh -> 20)
   219                              <1> ERR_ZERO_LENGTH	   equ 20  ; 'zero length !' error 	
   220                              <1> ; TRDOS 8086 -> TRDOS 386 (15h -> 17, 1Dh -> 18, 1Eh -> 17) 	
   221                              <1> ERR_DRV_NR_READ	   equ 17 ; 'drive not ready or read error !'
   222                              <1> ERR_DRV_NR_WRITE   equ 18 ; 'drive not ready or write error !'		
   223                              <1> ; 15/10/2016
   224                              <1> ERR_INV_PATH_NAME  equ 19 ; 'bad path name !' error
   225                              <1> ERR_BAD_CMD_ARG	   equ  1 ; 'bad command argument !' ; TRDOS 8086
   226                              <1> ERR_INV_FNUMBER	   equ  1 ; 'invalid function number !' ; TRDOS 8086
   227                              <1> ERR_BIG_FILE	   equ  8 ; 'big file & out of memory ! ; TRDOS 8086 	
   228                              <1> ERR_BIG_DATA	   equ  8 ; 'big data & out of memory ! ; TRDOS 8086
   229                              <1> ERR_CLUSTER	   equ 35 ; 'cluster not available !' ; TRDOS 8086
   230                              <1> ERR_OUT_OF_MEMORY  equ  4 ; 'out of memory !'
   231                              <1> 			  ; 'insufficient memory !'
   232                              <1> ERR_P_VIOLATION	   equ	6 ; 'protection violation !'
   233                              <1> ERR_PAGE_FAULT	   equ 224 ;'page fault !' ;0E0h						 
   234                              <1> ERR_SWP_DISK_READ  	   equ 40
   235                              <1> ERR_SWP_DISK_NOT_PRESENT   equ 41
   236                              <1> ERR_SWP_SECTOR_NOT_PRESENT equ 42
   237                              <1> ERR_SWP_NO_FREE_SPACE      equ 43
   238                              <1> ERR_SWP_DISK_WRITE         equ 44
   239                              <1> ERR_SWP_NO_PAGE_TO_SWAP    equ 45
   240                              <1> ; 10/04/2017
   241                              <1> ERR_BUFFER	   equ 46  ; 'buffer error !'
   242                              <1> ; 28/08/2017 (20/08/2017)
   243                              <1> ERR_DMA		   equ -1  ; DMA buffer (allocation/misc.) error!
   244                              <1> 
   245                              <1> ; 26/08/2015
   246                              <1> ; 24/07/2015
   247                              <1> ; 24/06/2015
   248                              <1> MAX_ARG_LEN	   equ 256 ; max. length of sys exec arguments
   249                              <1> ; 01/07/2015
   250                              <1> MAX_MSG_LEN	   equ 255 ; max. msg length for 'sysmsg'
   251                              <1> ;	
   252                              <1> ; 06/10/2016
   253                              <1> OPENFILES	   equ 10  ; max. number of open files (system)
   254                              <1> ; 07/10/2016
   255                              <1> ;NUMOFDEVICES	   equ 20  ; max. num of available devices (sys)
   256                              <1> 			 		
  3078                                  %include 'trdosk0.s' ; 04/01/2016 
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DEFINITIONS : trdosk0.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/02/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
    14                              <1> ;
    15                              <1> ; Masterboot / Partition Table at Beginning+1BEh
    16                              <1> ptBootable       equ 0
    17                              <1> ptBeginHead      equ 1
    18                              <1> ptBeginSector    equ 2
    19                              <1> ptBeginCylinder  equ 3
    20                              <1> ptFileSystemID   equ 4
    21                              <1> ptEndHead        equ 5
    22                              <1> ptEndSector      equ 6
    23                              <1> ptEndCylinder    equ 7
    24                              <1> ptStartSector    equ 8
    25                              <1> ptSectors        equ 12
    26                              <1> 
    27                              <1> ; Boot Sector Parameters at 7C00h
    28                              <1> DataArea1     equ -4
    29                              <1> DataArea2     equ -2
    30                              <1> BootStart     equ 0h
    31                              <1> OemName       equ 03h
    32                              <1> BytesPerSec   equ 0Bh
    33                              <1> SecPerClust   equ 0Dh
    34                              <1> ResSectors    equ 0Eh
    35                              <1> FATs          equ 10h
    36                              <1> RootDirEnts   equ 11h
    37                              <1> Sectors       equ 13h
    38                              <1> Media         equ 15h
    39                              <1> FATSecs       equ 16h
    40                              <1> SecPerTrack   equ 18h
    41                              <1> Heads         equ 1Ah 
    42                              <1> Hidden1       equ 1Ch
    43                              <1> Hidden2       equ 1Eh
    44                              <1> HugeSec1      equ 20h
    45                              <1> HugeSec2      equ 22h
    46                              <1> DriveNumber   equ 24h
    47                              <1> Reserved1     equ 25h
    48                              <1> bootsignature equ 26h                 
    49                              <1> VolumeID      equ 27h
    50                              <1> VolumeLabel   equ 2Bh
    51                              <1> FileSysType   equ 36h          
    52                              <1> Reserved2     equ 3Eh                           ; Starting cluster of P2000
    53                              <1> 
    54                              <1> ; FAT32 BPB Structure
    55                              <1> FAT32_FAT_Size equ 36
    56                              <1> FAT32_RootFClust equ 44
    57                              <1> FAT32_FSInfoSec equ 48
    58                              <1> FAT32_DrvNum equ 64
    59                              <1> FAT32_BootSig equ 66
    60                              <1> FAT32_VolID equ 67
    61                              <1> FAT32_VolLab equ 71
    62                              <1> FAT32_FilSysType equ 82
    63                              <1> 
    64                              <1> ; BIOS Disk Parameters
    65                              <1> DPDiskNumber  equ 0h
    66                              <1> DPDType       equ 1h
    67                              <1> DPReturn      equ 2h
    68                              <1> DPHeads       equ 3h
    69                              <1> DPCylinders   equ 4h
    70                              <1> DPSecPerTrack equ 6h
    71                              <1> DPDisks       equ 7h
    72                              <1> DPTableOff    equ 8h
    73                              <1> DPTableSeg    equ 0Ah
    74                              <1> DPNumOfSecs   equ 0Ch
    75                              <1> 
    76                              <1> ; BIOS INT 13h Extensions (LBA extensions)
    77                              <1> ; Just After DP Data (DPDiskNumber+)
    78                              <1> DAP_PacketSize equ 10h  ; If extensions present, this byte will be >=10h
    79                              <1> DAP_Reserved1 equ 11h   ; Reserved Byte 
    80                              <1> DAP_NumOfBlocks equ 12h ; Value of this byte must be 0 to 127
    81                              <1> DAP_Reserved2 equ 13h   ; Reserved Byte
    82                              <1> DAP_Destination equ 14h ; Address of Transfer Buffer as SEGMENT:OFFSET
    83                              <1> DAP_LBA_Address equ 18h ; LBA=(C1*H0+H1)*S0+S1-1
    84                              <1>                         ; C1= Selected Cylinder Number
    85                              <1>                         ; H0= Number Of Heads (Maximum Head Number + 1)
    86                              <1>                         ; H1= Selected Head Number
    87                              <1>                         ; S0= Maximum Sector Number
    88                              <1>                         ; S1= Selected Sector Number
    89                              <1>                         ; QUAD WORD
    90                              <1> ; DAP_Flat_Destination equ 20h ; 64 bit address, if value in 4h is FFFF:FFFFh
    91                              <1>                              ; QUAD WORD (Also, value in 0h must be 18h) 
    92                              <1>                              ; TR-DOS will not use 64 bit Flat Address
    93                              <1> 
    94                              <1> ; INT 13h Function 48h "Get Enhanced Disk Drive Parameters"
    95                              <1> ; Just After DP Data (DPDiskNumber+)
    96                              <1> GetDParams_48h equ 20h ; Word. Data Length, must be 26 (1Ah) for short data.
    97                              <1> GDP_48h_InfoFlag equ 22h ; Word
    98                              <1> ; Bit 1 = 1 -> The geometry returned in bytes 4-15 is valid.
    99                              <1> GDP_48h_NumOfPCyls equ 24h ; Double Word. Number physical cylinders.
   100                              <1> GDP_48h_NumOfPHeads equ 28h ; Double Word. Number of physical heads.
   101                              <1> GDP_48h_NumOfPSpT equ 2Ch ; Double word. Num of physical sectors per track.
   102                              <1> GDP_48h_LBA_Sectors equ 30h ; 8 bytes. Number of physical/LBA sectors.
   103                              <1> GDP_48h_BytesPerSec equ 38h ; Word. Number of bytes in a sector.
   104                              <1> 
   105                              <1> ; TR-DOS Standalone Program Extensions to the DiskParams Block
   106                              <1> ; Just After DP Data (DPDiskNumber+)
   107                              <1> TRDP_CurrentSector equ 3Ah  ; DX:AX (LBA)
   108                              <1> TRDP_SectorCount equ 3Eh    ; CX (or Counter)
   109                              <1> 
   110                              <1> 
   111                              <1> ; DOS Logical Disks
   112                              <1> LD_Name equ 0
   113                              <1> LD_DiskType equ 1
   114                              <1> LD_PhyDrvNo equ 2
   115                              <1> LD_FATType equ 3
   116                              <1> LD_FSType equ 4
   117                              <1> LD_LBAYes equ 5
   118                              <1> LD_BPB equ 6
   119                              <1> LD_FATBegin equ 96
   120                              <1> LD_ROOTBegin equ 100
   121                              <1> LD_DATABegin equ 104
   122                              <1> LD_StartSector equ 108
   123                              <1> LD_TotalSectors equ 112
   124                              <1> LD_FreeSectors equ 116
   125                              <1> LD_Clusters equ 120
   126                              <1> LD_PartitionEntry equ 124
   127                              <1> LD_DParamEntry equ 125
   128                              <1> LD_MediaChanged equ 126
   129                              <1> LD_CDirLevel equ 127
   130                              <1> LD_CurrentDirectory equ 128
   131                              <1> 
   132                              <1> ; Singlix FS Extensions to DOS Logical Disks
   133                              <1> ; 03/01/2010 (LD_BPB compatibility for CHS r/w)
   134                              <1> 
   135                              <1> LD_FS_Name equ 0
   136                              <1> LD_FS_DiskType equ 1
   137                              <1> LD_FS_PhyDrvNo equ 2
   138                              <1> LD_FS_FATType equ 3
   139                              <1> LD_FS_FSType equ 4
   140                              <1> LD_FS_LBAYes equ 5
   141                              <1> LD_FS_BPB equ 6
   142                              <1> LD_FS_MediaAttrib equ 6
   143                              <1> LD_FS_VersionMajor equ 7
   144                              <1> LD_FS_RootDirD equ 8
   145                              <1> LD_FS_MATLocation equ 12
   146                              <1> LD_FS_Reserved1 equ 16 ;1 reserved byte
   147                              <1> LD_FS_BytesPerSec equ 17 ; LD_BPB + 0Bh
   148                              <1> LD_FS_Reserved2 equ 19 ;2 reserved byte
   149                              <1> LD_FS_DATLocation equ 20
   150                              <1> LD_FS_DATSectors equ 24
   151                              <1> LD_FS_Reserved3 equ 28 ;3 reserved word
   152                              <1> LD_FS_SecPerTrack equ 30 ; LD_BPB + 18h
   153                              <1> LD_FS_NumHeads equ 32    ; LD_BPB + 1Ah
   154                              <1> LD_FS_UnDelDirD equ 34
   155                              <1> LD_FS_Reserved4 equ 38 ;4 reserved word
   156                              <1> LD_FS_VolumeSerial equ 40
   157                              <1> LD_FS_VolumeName equ 44
   158                              <1> LD_FS_BeginSector equ 108
   159                              <1> LD_FS_VolumeSize equ 112
   160                              <1> LD_FS_FreeSectors equ 116
   161                              <1> LD_FS_FirstFreeSector equ 120
   162                              <1> LD_FS_PartitionEntry equ 124
   163                              <1> LD_FS_DParamEntry equ 125
   164                              <1> LD_FS_MediaChanged equ 126
   165                              <1> LD_FS_CDirLevel equ 127
   166                              <1> LD_FS_CDIR_Converted equ 128
   167                              <1> 
   168                              <1> ; Valid FAT Types
   169                              <1> FS_FAT12 equ 1
   170                              <1> FS_FAT16_CHS equ 2
   171                              <1> FS_FAT32_CHS equ 3
   172                              <1> FS_FAT16_LBA equ 4
   173                              <1> FS_FAT32_LBA equ 5
   174                              <1> 
   175                              <1> ; Cursor Location
   176                              <1> CCCpointer equ  0450h   ; BIOS data, current cursor column
   177                              <1> ; FAT Clusters EOC sign
   178                              <1> FAT12EOC equ 0FFFh
   179                              <1> FAT16EOC equ 0FFFFh
   180                              <1> ;FAT32EOC equ 0FFFFFFFh ; It is not direct usable for 8086 code
   181                              <1> ; BAD Cluster
   182                              <1> FAT12BADC equ 0FF7h
   183                              <1> FAT16BADC equ 0FFF7h
   184                              <1> ;FAT32BADC equ 0FFFFFF7h ; It is not direct usable for 8086 code
   185                              <1> ; MS-DOS FAT16 FS (Maximum Possible) Last Cluster Number= 0FFF6h 
   186                              <1> 
   187                              <1> ; TRFS
   188                              <1> 
   189                              <1> bs_FS_JmpBoot equ 0 ; jmp short bsBootCode
   190                              <1>                 ; db 0EBh, db 3Fh, db 90h
   191                              <1> bs_FS_Identifier equ 3  ; db 'FS', db 0
   192                              <1> bs_FS_BytesPerSec equ 6 ; dw 512
   193                              <1> bs_FS_MediaAttrib equ 8 ; db 3
   194                              <1> bs_FS_PartitionID equ 9 ; db 0A1h
   195                              <1> bs_FS_VersionMaj equ 10 ; db 01h
   196                              <1> bs_FS_VersionMin equ 11 ; db 0
   197                              <1> bs_FS_BeginSector equ 12   ; dd 0 
   198                              <1> bs_FS_VolumeSize equ 16 ; dd 2880
   199                              <1> bs_FS_StartupFD equ 20 ; dd 0
   200                              <1> bs_FS_MATLocation equ 24 ; dd 1
   201                              <1> bs_FS_RootDirD equ 28 ; dd 8
   202                              <1> bs_FS_SystemConfFD equ 32 ; dd 0
   203                              <1> bs_FS_SwapFD equ 36 ; dd 0
   204                              <1> bs_FS_UnDelDirD equ 40 ; dd 0
   205                              <1> bs_FS_DriveNumber equ 44 ; db 0
   206                              <1> bs_FS_LBA_Ready equ 45 ; db 0
   207                              <1> bs_FS_MagicWord equ 46 
   208                              <1> bs_FS_SecPerTrack equ 46 ; db 0A1h
   209                              <1> bs_FS_Heads equ 47 ; db 01h 
   210                              <1> bs_FS_OperationSys equ 48 ; db "TR-SINGLIX v1.0b"
   211                              <1> bs_FS_Terminator equ 64 ; db 0
   212                              <1> bs_FS_BootCode equ 65 
   213                              <1> 
   214                              <1> FS_MAT_DATLocation equ 12
   215                              <1> FS_MAT_DATScount equ 16
   216                              <1> FS_MAT_FreeSectors equ 20
   217                              <1> FS_MAT_FirstFreeSector equ 24
   218                              <1> FS_RDT_VolumeSerialNo equ 28
   219                              <1> FS_RDT_VolumeName equ 64
   220                              <1> 
   221                              <1> ; FAT12 + FAT16 + FAT32
   222                              <1> BS_JmpBoot equ 0
   223                              <1> BS_OEMName equ 3
   224                              <1> BPB_BytsPerSec equ 11
   225                              <1> BPB_SecPerClust equ 13
   226                              <1> BPB_RsvdSecCnt equ 14
   227                              <1> BPB_NumFATs equ 16
   228                              <1> BPB_RootEntCnt equ 17
   229                              <1> BPB_TotalSec16 equ 19
   230                              <1> BPB_Media equ 21
   231                              <1> BPB_FATSz16 equ 22
   232                              <1> BPB_SecPerTrk equ 24
   233                              <1> BPB_NumHeads equ 26
   234                              <1> BPB_HiddSec equ 28
   235                              <1> BPB_TotalSec32 equ 32
   236                              <1> 
   237                              <1> ; FAT12 and FAT16 only
   238                              <1> BS_DrvNum equ 36
   239                              <1> BS_Reserved1 equ 37
   240                              <1> BS_BootSig equ 38
   241                              <1> BS_VolID equ 39
   242                              <1> BS_VolLab equ 43
   243                              <1> BS_FilSysType equ 54 ; 8 bytes
   244                              <1> BS_BootCode equ 62
   245                              <1> 
   246                              <1> ; FAT32 only
   247                              <1> BPB_FATSz32 equ 36 ; FAT32, 4 bytes
   248                              <1> BPB_ExtFlags equ 40 ; FAT32, 2 bytes
   249                              <1> BPB_FSVer equ 42 ; FAT32, 2 bytes
   250                              <1> BPB_RootClus equ 44 ; FAT32, 4 bytes
   251                              <1> BPB_FSInfo equ 48 ; FAT 32, 2 bytes 
   252                              <1> BPB_BkBootSec equ 50 ; FAT32, 2 bytes
   253                              <1> BPB_Reserved equ 52 ; FAT32, 12 bytes
   254                              <1> BS_FAT32_DrvNum equ 64 ; FAT32, 1 byte
   255                              <1> BS_FAT32_Reserved1 equ 65 ; FAT32, 1 byte
   256                              <1> BS_FAT32_BootSig equ 66 ; FAT32, 1 byte
   257                              <1> BS_FAT32_VolID equ 67 ; FAT32, 4 bytes
   258                              <1> BS_FAT32_VolLab equ 71 ; FAT32, 11 bytes
   259                              <1> BS_FAT32_FilSysType equ 82 ; FAT32, 8 bytes
   260                              <1> BS_FAT32_BootCode equ 90
   261                              <1> 
   262                              <1> ; 29/02/2016
   263                              <1> ;(FAT32 Free Cluster Count & First Free Cluster values)
   264                              <1> ;[BPB_Reserved] = Free Cluster Count (offset 52)
   265                              <1> ;[BPB_Reserved+4] = First Free Cluster (offset 56)
   266                              <1> 
   267                              <1> BS_Validation equ 510
   268                              <1> 
   269                              <1> ; 15/02/2016
   270                              <1> ; FILE.ASM - 09/10/2011
   271                              <1> ; Directory Entry Structure
   272                              <1> ; 29/10/2009 (According to Microsoft FAT32 File System Specification)
   273                              <1> DirEntry_Name equ 0
   274                              <1> DirEntry_Attr equ 11
   275                              <1> DirEntry_NTRes equ 12
   276                              <1> DirEntry_CrtTimeTenth equ 13
   277                              <1> DirEntry_CrtTime equ 14
   278                              <1> DirEntry_CrtDate equ 16
   279                              <1> DirEntry_LastAccDate equ 18
   280                              <1> DirEntry_FstClusHI equ 20
   281                              <1> DirEntry_WrtTime equ 22
   282                              <1> DirEntry_WrtDate equ 24
   283                              <1> DirEntry_FstClusLO equ 26
   284                              <1> DirEntry_FileSize equ 28
  3079                                  %include 'trdosk1.s' ; 04/01/2016 
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.3) - SYS INIT : trdosk1.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 06/12/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; TRDOS2.ASM (c) 2004-2011 Erdogan TAN [ 17/01/2004 ] Last Update: 09/11/2011
    14                              <1> ;
    15                              <1> 
    16                              <1> sys_init:
    17                              <1> 	; 20/01/2018  (v2.0.1)
    18                              <1> 	; 23/01/2017  (v2.0.0)
    19                              <1> 	; 07/05/2016
    20                              <1> 	; 02/05/2016
    21                              <1> 	; 24/04/2016
    22                              <1> 	; 14/04/2016
    23                              <1> 	; 13/04/2016
    24                              <1> 	; 30/03/2016
    25                              <1> 	; 24/01/2016
    26                              <1> 	; 06/01/2016
    27                              <1> 	; 04/01/2016
    28                              <1> 
    29                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
    30 00007436 B036                <1> 	mov	al, 00110110b ; 36h
    31 00007438 E643                <1>  	out	43h, al
    32 0000743A 31C0                <1> 	xor	eax, eax  ; sub	al, al ; 0
    33 0000743C E640                <1> 	out	40h, al ; LB
    34 0000743E E640                <1> 	out	40h, al ; HB
    35                              <1>  	; 
    36                              <1> 	; 30/03/2016
    37                              <1> 	; Clear Logical DOS Disk Description Tables Area
    38                              <1> 	;xor	eax, eax
    39 00007440 BF00010900          <1> 	mov	edi, Logical_DOSDisks
    40 00007445 B980060000          <1> 	mov	ecx, 6656/4 ; 26*256 = 6656 bytes
    41 0000744A F3AB                <1> 	rep	stosd ; 1664 times 4 bytes
    42                              <1> 
    43 0000744C B83F3A2F00          <1> 	mov	eax, '?:/'
    44 00007451 A3[978A0100]        <1> 	mov	[Current_Dir_Drv], eax
    45                              <1> 
    46                              <1> 	; Logical DRV INIT (only for hard disks)
    47 00007456 E825040000          <1> 	call 	ldrv_init  ; trdosk2.s
    48                              <1> 	
    49                              <1> 	; When floppy_drv_init call is disabled
    50                              <1> 	; media changed sign is needed
    51                              <1> 	; for proper drive initialization
    52                              <1>         
    53 0000745B BE00010900          <1> 	mov 	esi, Logical_DOSDisks
    54 00007460 B001                <1> 	mov 	al, 1 ; Initialization sign (invalid_fd_parameter)
    55 00007462 83C67E              <1> 	add 	esi, LD_MediaChanged ; Media Change Status = 1 (init needed)
    56 00007465 8806                <1> 	mov 	[esi], al ; A:
    57 00007467 81C600010000        <1> 	add 	esi, 100h 
    58 0000746D 8806                <1> 	mov 	[esi], al ; B: 
    59                              <1>            
    60                              <1> _current_drive_bootdisk:
    61 0000746F 8A15[FA6D0000]      <1> 	mov 	dl, [boot_drv] ; physical drive number
    62 00007475 80FAFF              <1> 	cmp 	dl, 0FFh
    63 00007478 740A                <1> 	je 	short _last_dos_diskno_check
    64                              <1> _boot_drive_check:
    65 0000747A 80FA80              <1> 	cmp 	dl, 80h
    66 0000747D 7218                <1> 	jb 	short _current_drive_a
    67 0000747F 80EA7E              <1> 	sub 	dl, 7Eh ; C = 2 , D = 3
    68 00007482 EB13                <1> 	jmp 	short _current_drive_a 
    69                              <1> 
    70                              <1> _last_dos_diskno_check:
    71 00007484 8A15[62400100]      <1> 	mov 	dl, [Last_DOS_DiskNo]
    72 0000748A 80FA02              <1> 	cmp 	dl, 2
    73 0000748D 7706                <1> 	ja 	short _current_drive_c
    74 0000748F 7406                <1> 	je 	short _current_drive_a
    75 00007491 30D2                <1> 	xor 	dl, dl ; A:
    76 00007493 EB02                <1> 	jmp 	short _current_drive_a
    77                              <1> 
    78                              <1> _current_drive_c:
    79 00007495 B202                <1> 	mov 	dl, 2 ; C:
    80                              <1> 
    81                              <1> _current_drive_a:
    82 00007497 8815[FB6D0000]      <1> 	mov	[drv], dl
    83 0000749D BE[64400100]        <1>         mov     esi, msg_CRLF_temp
    84 000074A2 E8AE000000          <1> 	call 	print_msg
    85                              <1> 
    86 000074A7 8A15[FB6D0000]      <1> 	mov	dl, [drv]
    87                              <1> _default_drive_c:
    88 000074AD E82C0C0000          <1> 	call 	change_current_drive
    89 000074B2 731C                <1> 	jnc 	short _start_mainprog
    90                              <1> 
    91                              <1> _drv_not_ready_error: 
    92 000074B4 BE[1F430100]        <1> 	mov 	esi, msgl_drv_not_ready
    93 000074B9 E897000000          <1> 	call 	print_msg
    94                              <1>         ;jmp	_end_of_mainprog
    95                              <1> 
    96                              <1> 	; 20/01/2018
    97 000074BE B202                <1> 	mov	dl, 2
    98 000074C0 3815[FB6D0000]      <1> 	cmp	[drv], dl
    99 000074C6 736B                <1> 	jnb	short _end_of_mainprog
   100 000074C8 8815[FB6D0000]      <1> 	mov	[drv], dl
   101 000074CE EBDD                <1> 	jmp	short _default_drive_c
   102                              <1> 
   103                              <1> _start_mainprog:
   104                              <1> 	; 07/01/2017
   105                              <1> 	; 07/05/2016
   106                              <1> 	; 02/05/2016
   107                              <1> 	; 24/04/2016
   108                              <1> 	; Retro UNIX 386 v1, 'sys_init' (u0.s)
   109                              <1> 	; 23/06/2015
   110                              <1> 
   111                              <1> 	; 02/05/2016
   112                              <1> 	; 24/04/2016
   113 000074D0 66B80100            <1> 	mov	ax, 1
   114 000074D4 A2[B3030300]        <1> 	mov	[u.uno], al
   115 000074D9 66A3[4E030300]      <1> 	mov	[mpid], ax
   116 000074DF 66A3[20000300]      <1> 	mov	[p.pid], ax
   117 000074E5 A2[B0000300]        <1> 	mov	[p.stat], al
   118 000074EA C605[A8030300]04    <1> 	mov	byte [u.quant], time_count  ; 07/01/2017
   119                              <1> 	;
   120 000074F1 A1[D0890100]        <1> 	mov	eax, [k_page_dir]
   121 000074F6 A3[B8030300]        <1> 	mov	[u.pgdir], eax ; reset
   122                              <1> 	;
   123 000074FB E8D3E6FFFF          <1> 	call	allocate_page
   124 00007500 0F82B5000000        <1> 	jc	panic
   125 00007506 A3[B4030300]        <1> 	mov	[u.upage], eax ; user structure page	
   126 0000750B A3[C0000300]        <1> 	mov	[p.upage], eax
   127 00007510 E838E7FFFF          <1> 	call	clear_page
   128                              <1> 	;
   129                              <1> 	; 24/08/2015
   130 00007515 FE0D[5B030300]      <1> 	dec 	byte [sysflg] ; FFh = ready for system call
   131                              <1> 			      ; 0 = executing a system call
   132                              <1> 	; 13/04/2016
   133                              <1> 	; Clear Environment Variables Page/Area
   134 0000751B BF00300900          <1> 	mov	edi, Env_Page ; 93000h
   135 00007520 B980000000          <1> 	mov	ecx, Env_Page_Size / 4 	; 512/4  (4096/4)				 	  		 	  
   136 00007525 31C0                <1> 	xor	eax, eax
   137 00007527 F3AB                <1> 	rep	stosd
   138                              <1> 
   139                              <1> 	; 14/04/2016
   140 00007529 E807350000          <1>  	call	mainprog_startup_configuration
   141                              <1> 
   142 0000752E E8EC0C0000          <1>         call    dos_prompt
   143                              <1>               
   144                              <1> _end_of_mainprog:
   145 00007533 BE[64400100]        <1>         mov     esi, msg_CRLF_temp
   146 00007538 E818000000          <1> 	call 	print_msg
   147 0000753D BE[6A400100]        <1> 	mov 	esi, mainprog_Version
   148 00007542 E80E000000          <1> 	call 	print_msg
   149                              <1> 	; 24/01/2016
   150 00007547 28E4                <1> 	sub	ah, ah
   151 00007549 E89799FFFF          <1> 	call	int16h ; call getch
   152 0000754E E9779EFFFF          <1> 	jmp	cpu_reset
   153                              <1> 
   154 00007553 EBFE                <1> infinitiveloop: jmp short infinitiveloop
   155                              <1> 
   156                              <1> print_msg:
   157                              <1> 	; 13/05/2016
   158                              <1> 	; 04/01/2016
   159                              <1> 	; 01/07/2015
   160                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   161                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
   162                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI, EDI)
   163                              <1> 	;
   164 00007555 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
   165                              <1> 	;mov	bl, 07h ; Black background, light gray forecolor
   166                              <1> 
   167 0000755B AC                  <1> 	lodsb
   168                              <1> pmsg1:
   169 0000755C 56                  <1> 	push 	esi
   170                              <1> 	;mov	bh, [ACTIVE_PAGE] ; 04/01/2016 (ptty)
   171 0000755D B307                <1> 	mov	bl, 07h ; Black background, light gray forecolor
   172 0000755F E899ADFFFF          <1> 	call 	_write_tty
   173 00007564 5E                  <1> 	pop	esi
   174 00007565 AC                  <1> 	lodsb
   175 00007566 20C0                <1> 	and 	al, al
   176 00007568 75F2                <1> 	jnz 	short pmsg1
   177 0000756A C3                  <1> 	retn
   178                              <1> 
   179                              <1> clear_screen:
   180                              <1> 	; 06/12/2020 
   181                              <1> 	; 03/12/2020 (TRDOS 386 v2.0.3)
   182                              <1> 	; 13/05/2016
   183                              <1> 	; 30/01/2016
   184                              <1> 	; 24/01/2016
   185                              <1> 	; 04/01/2016
   186 0000756B 0FB61D[FE890100]    <1> 	movzx	ebx, byte [ACTIVE_PAGE] ; video page number (0 to 7)
   187 00007572 8AA3[DB6F0000]      <1> 	mov 	ah, [ebx+vmode] ; default = 03h (80x25 text)
   188 00007578 80FC04              <1> 	cmp	ah, 4
   189 0000757B 7205                <1> 	jb	short cls1
   190 0000757D 80FC07              <1> 	cmp	ah, 7
   191 00007580 7530                <1> 	jne	short vga_clear
   192                              <1> cls1:
   193                              <1> 	;mov	bh, bl
   194                              <1> 	;mov	bl, 7
   195 00007582 3A25[CA6F0000]      <1> 	cmp	ah, [CRT_MODE] ; current video mode ? 
   196 00007588 740E                <1> 	je	short cls2 ; yes (current video mode = 3)
   197                              <1> 	;;call	set_mode_3 ; set video mode to 3 (& clear screen)
   198                              <1> 	;;retn
   199                              <1> 	; 06/12/2020
   200 0000758A 803D[1C120300]00    <1> 	cmp	byte [pmi32], 0
   201 00007591 771F                <1> 	ja	short vga_clear 	
   202 00007593 E96FADFFFF          <1> 	jmp	set_mode_3
   203                              <1> cls2:
   204 00007598 88DF                <1> 	mov	bh, bl ; video page (0 to 7)
   205 0000759A B307                <1> 	mov	bl, 07h ; attribute to be used on blanked line
   206 0000759C 28C0                <1> 	sub 	al, al ; 0 =  entire window
   207 0000759E 6631C9              <1> 	xor 	cx, cx
   208 000075A1 66BA4F18            <1> 	mov 	dx, 184Fh
   209 000075A5 E893AAFFFF          <1> 	call	_scroll_up ; 24/01/2016
   210                              <1> 	;
   211                              <1> 	;mov	bh, [ACTIVE_PAGE] ; video page number (0 to 7)
   212 000075AA 6631D2              <1> 	xor 	dx, dx
   213                              <1> 	;call	_set_cpos ; 24/01/2016 
   214                              <1> 	;;retn
   215                              <1> 	; 03/12/2020
   216 000075AD E9E5ADFFFF          <1> 	jmp	_set_cpos ; returns to the caller of this proc
   217                              <1> ;cls3:
   218                              <1> ;	retn
   219                              <1> 	; 06/12/2020
   220                              <1> vga_clear:
   221                              <1> 	; 03/12/2020
   222                              <1> 	; set mode by using _int10h
   223                              <1> 	; (also clears screen)
   224 000075B2 88E0                <1> 	mov	al, ah
   225 000075B4 28E4                <1> 	sub	ah, ah  ; set current video mode
   226                              <1> 	;call	_int10h ; simulates int 10h in TRDOS 386 kernel
   227                              <1> 	;jmp	short cls3
   228 000075B6 E9AEA1FFFF          <1> 	jmp	_int10h ; returns to the caller of this proc
   229                              <1> 
   230                              <1> panic:
   231                              <1> 	; 13/05/2016 (TRDOS 386 = TRDOS v2)
   232                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   233                              <1> 	; 07/03/2014 (Retro UNIX 8086 v1)
   234 000075BB BE[274D0100]        <1> 	mov 	esi, panic_msg
   235 000075C0 E890FFFFFF          <1> 	call 	print_msg
   236                              <1> key_to_reboot:
   237                              <1>         ; 24/01/2016
   238 000075C5 28E4                <1>         sub     ah, ah
   239 000075C7 E81999FFFF          <1>         call    int16h ; call   getch
   240                              <1>         ; wait for a character from the current tty
   241                              <1> 	;
   242 000075CC B00A                <1> 	mov	al, 0Ah
   243 000075CE 8A3D[FE890100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
   244 000075D4 B307                <1> 	mov	bl, 07h ; Black background, 
   245                              <1> 			; light gray forecolor
   246 000075D6 E822ADFFFF          <1> 	call 	_write_tty
   247 000075DB E9EA9DFFFF          <1> 	jmp	cpu_reset 
   248                              <1> 
   249                              <1> ctrlbrk:
   250                              <1> 	; 12/11/2015
   251                              <1> 	; 13/03/2015 (Retro UNIX 386 v1)
   252                              <1> 	; 06/12/2013 (Retro UNIX 8086 v1)
   253                              <1> 	;
   254                              <1> 	; INT 1Bh (control+break) handler		
   255                              <1> 	;
   256                              <1>       	; Retro Unix 8086 v1 feature only!
   257                              <1>       	;
   258 000075E0 66833D[AA030300]00  <1> 	cmp 	word [u.intr], 0
   259 000075E8 7645                <1> 	jna 	short cbrk4
   260                              <1> cbrk0:
   261                              <1> 	; 12/11/2015
   262                              <1> 	; 06/12/2013
   263 000075EA 66833D[AC030300]00  <1> 	cmp 	word [u.quit], 0
   264 000075F2 743B                <1> 	jz	short cbrk4
   265                              <1> 	;
   266                              <1> 	; 20/09/2013	
   267 000075F4 6650                <1> 	push 	ax
   268 000075F6 A0[FE890100]        <1> 	mov	al, [ptty]
   269                              <1> 	;
   270                              <1> 	; 12/11/2015
   271                              <1> 	;
   272                              <1> 	; ctrl+break (EOT, CTRL+D) from serial port
   273                              <1> 	; or ctrl+break from console (pseudo) tty
   274                              <1> 	; (!redirection!)
   275                              <1> 	;
   276 000075FB 3C08                <1> 	cmp	al, 8 ; serial port tty nums > 7
   277 000075FD 7211                <1>         jb      short cbrk1 ; console (pseudo) tty
   278                              <1> 	;	
   279                              <1> 	; Serial port interrupt handler sets [ptty]
   280                              <1> 	; to the port's tty number (as temporary).
   281                              <1> 	;
   282                              <1> 	; If active process is using a stdin or 
   283                              <1> 	; stdout redirection (by the shell),
   284                              <1>         ; console tty keyboard must be available
   285                              <1> 	; to terminate running process,
   286                              <1> 	; in order to prevent a deadlock. 
   287                              <1> 	;
   288 000075FF 52                  <1> 	push	edx
   289 00007600 0FB615[B3030300]    <1> 	movzx	edx, byte [u.uno]
   290 00007607 3A82[7F000300]      <1> 	cmp     al, [edx+p.ttyc-1] ; console tty (rw)
   291 0000760D 5A                  <1> 	pop	edx
   292 0000760E 7412                <1> 	je	short cbrk2
   293                              <1> cbrk1:
   294 00007610 FEC0                <1> 	inc 	al  ; [u.ttyp] : 1 based tty number
   295                              <1> 	; 06/12/2013
   296 00007612 3A05[94030300]      <1> 	cmp	al, [u.ttyp] ; recent open tty (r)
   297 00007618 7408                <1> 	je	short cbrk2	
   298 0000761A 3A05[95030300]      <1>         cmp     al, [u.ttyp+1] ; recent open tty (w)
   299 00007620 750B                <1> 	jne	short cbrk3	
   300                              <1> cbrk2:
   301                              <1> 	;; 06/12/2013
   302                              <1> 	;mov	ax, [u.quit]
   303                              <1> 	;and	ax, ax
   304                              <1> 	;jz	short cbrk3
   305                              <1> 	;
   306 00007622 6631C0              <1> 	xor	ax, ax ; 0
   307 00007625 6648                <1> 	dec	ax
   308                              <1> 	; 0FFFFh = 'ctrl+brk' keystroke
   309 00007627 66A3[AC030300]      <1> 	mov	[u.quit], ax
   310                              <1> cbrk3:
   311 0000762D 6658                <1> 	pop	ax
   312                              <1> cbrk4:
   313 0000762F C3                  <1> 	retn
   314                              <1> 
   315                              <1> 
   316                              <1> ; 31/12/2017
   317                              <1> ; TRDOS 386 - 30/12/2017
   318                              <1> %define get_rtc_date RTC_40
   319                              <1> %define get_rtc_time RTC_20
   320                              <1> %define	set_rtc_date RTC_50
   321                              <1> %define set_rtc_time RTC_30	
   322                              <1> get_rtc_date_time:
   323                              <1> ; Retro UNIX 8086 v1 - UNIX.ASM (01/09/2014)
   324                              <1> ;epoch:
   325                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
   326                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
   327                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1 - UNIX.ASM)
   328                              <1> 	; 'epoch' procedure prototype: 
   329                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
   330                              <1> 	; 14/11/2012
   331                              <1> 	; unixboot.asm (boot file configuration)
   332                              <1> 	; version of "epoch" procedure in "unixproc.asm"
   333                              <1> 	; 21/7/2012
   334                              <1> 	; 15/7/2012
   335                              <1> 	; 14/7/2012		
   336                              <1> 	; Erdogan Tan - RETRO UNIX v0.1
   337                              <1> 	; compute current date and time as UNIX Epoch/Time
   338                              <1> 	; UNIX Epoch: seconds since 1/1/1970 00:00:00
   339                              <1> 	;
   340                              <1>         ;  ((Modified registers: EAX, EDX, ECX, EBX))  
   341                              <1> 	;
   342                              <1> 
   343 00007630 E875F4FFFF          <1> 	call 	get_rtc_time		; Return Current Time
   344 00007635 86E9                <1>         xchg 	ch,cl
   345 00007637 66890D[9E860100]    <1>         mov 	[hour], cx
   346 0000763E 86F2                <1>         xchg 	dh,dl
   347 00007640 668915[A2860100]    <1>         mov 	[second], dx
   348                              <1> 	;
   349 00007647 E8CFF4FFFF          <1>         call 	get_rtc_date		; Return Current Date
   350 0000764C 86E9                <1>         xchg 	ch,cl
   351 0000764E 66890D[98860100]    <1>         mov 	[year], cx
   352 00007655 86F2                <1>         xchg 	dh,dl
   353 00007657 668915[9A860100]    <1>         mov 	[month], dx
   354                              <1> 	;
   355 0000765E 66B93030            <1> 	mov 	cx, 3030h
   356                              <1> 	;
   357 00007662 A0[9E860100]        <1> 	mov 	al, [hour] ; Hour
   358                              <1>         	; AL <= BCD number)
   359 00007667 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   360                              <1> 					; AH = AL / 10h
   361                              <1> 					; AL = AL MOD 10h
   362 00007669 D50A                <1>         aad 	; AX= AH*10+AL
   363 0000766B A2[9E860100]        <1> 	mov 	[hour], al
   364 00007670 A0[9F860100]        <1> 	mov 	al, [hour+1] ; Minute
   365                              <1>         	; AL <= BCD number)
   366 00007675 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   367                              <1> 					; AH = AL / 10h
   368                              <1> 					; AL = AL MOD 10h
   369 00007677 D50A                <1>         aad 	; AX= AH*10+AL
   370 00007679 A2[A0860100]        <1> 	mov 	[minute], al
   371 0000767E A0[A2860100]        <1> 	mov 	al, [second] ; Second
   372                              <1>         	; AL <= BCD number)
   373 00007683 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   374                              <1> 					; AH = AL / 10h
   375                              <1> 					; AL = AL MOD 10h
   376 00007685 D50A                <1>         aad 	; AX= AH*10+AL
   377 00007687 A2[A2860100]        <1> 	mov 	[second], al
   378 0000768C 66A1[98860100]      <1> 	mov 	ax, [year] ; Year (century)
   379 00007692 6650                <1>         push 	ax
   380                              <1> 	   	; AL <= BCD number)
   381 00007694 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   382                              <1> 					; AH = AL / 10h
   383                              <1> 					; AL = AL MOD 10h
   384 00007696 D50A                <1>         aad 	; AX= AH*10+AL
   385 00007698 B464                <1> 	mov 	ah, 100
   386 0000769A F6E4                <1> 	mul 	ah
   387 0000769C 66A3[98860100]      <1> 	mov 	[year], ax
   388 000076A2 6658                <1> 	pop	ax
   389 000076A4 88E0                <1> 	mov	al, ah
   390                              <1>         	; AL <= BCD number)
   391 000076A6 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   392                              <1> 					; AH = AL / 10h
   393                              <1> 					; AL = AL MOD 10h
   394 000076A8 D50A                <1>         aad 	; AX= AH*10+AL
   395 000076AA 660105[98860100]    <1> 	add 	[year], ax
   396 000076B1 A0[9A860100]        <1> 	mov 	al, [month] ; Month
   397                              <1>            	; AL <= BCD number)
   398 000076B6 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   399                              <1> 					; AH = AL / 10h
   400                              <1> 					; AL = AL MOD 10h
   401 000076B8 D50A                <1>         aad 	; AX= AH*10+AL
   402 000076BA A2[9A860100]        <1> 	mov 	[month], al	
   403 000076BF A0[9B860100]        <1>         mov     al, [month+1]      	; Day
   404                              <1>            	; AL <= BCD number)
   405 000076C4 D410                <1>         db 	0D4h,10h		; Undocumented inst. AAM
   406                              <1> 					; AH = AL / 10h
   407                              <1> 					; AL = AL MOD 10h
   408 000076C6 D50A                <1>         aad 	; AX= AH*10+AL
   409 000076C8 A2[9C860100]        <1>         mov     [day], al
   410                              <1> 	
   411 000076CD C3                  <1> 	retn	; 30/12/2017
   412                              <1> 
   413                              <1> epoch:
   414 000076CE E85DFFFFFF          <1> 	call	get_rtc_date_time ; TRDOS 386 - 30/12/2017
   415                              <1> 
   416                              <1> convert_to_epoch:
   417                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0)
   418                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit modification)
   419                              <1> 	; 09/04/2013 (Retro UNIX 8086 v1)
   420                              <1> 	;
   421                              <1> 	; ((Modified registers: EAX, EDX, EBX)) 
   422                              <1> 	;
   423                              <1> 	; Derived from DALLAS Semiconductor
   424                              <1> 	; Application Note 31 (DS1602/DS1603)
   425                              <1> 	; 6 May 1998
   426 000076D3 29C0                <1> 	sub 	eax, eax
   427 000076D5 66A1[98860100]      <1> 	mov 	ax, [year]
   428 000076DB 662DB207            <1> 	sub 	ax, 1970
   429 000076DF BA6D010000          <1> 	mov 	edx, 365
   430 000076E4 F7E2                <1> 	mul 	edx
   431 000076E6 31DB                <1> 	xor 	ebx, ebx
   432 000076E8 8A1D[9A860100]      <1> 	mov 	bl, [month]
   433 000076EE FECB                <1> 	dec 	bl
   434 000076F0 D0E3                <1> 	shl 	bl, 1
   435                              <1> 	;sub	edx, edx
   436 000076F2 668B93[A4860100]    <1> 	mov 	dx, [EBX+DMonth]
   437 000076F9 8A1D[9C860100]      <1>         mov     bl, [day]
   438 000076FF FECB                <1> 	dec 	bl
   439 00007701 01D0                <1> 	add 	eax, edx
   440 00007703 01D8                <1> 	add 	eax, ebx
   441                              <1> 			; EAX = days since 1/1/1970
   442 00007705 668B15[98860100]    <1> 	mov 	dx, [year]
   443 0000770C 6681EAB107          <1> 	sub 	dx, 1969
   444 00007711 66D1EA              <1> 	shr 	dx, 1
   445 00007714 66D1EA              <1> 	shr 	dx, 1		
   446                              <1> 		; (year-1969)/4
   447 00007717 01D0                <1> 	add 	eax, edx
   448                              <1> 			; + leap days since 1/1/1970
   449 00007719 803D[9A860100]02    <1> 	cmp 	byte [month], 2	; if past february
   450 00007720 7610                <1> 	jna 	short cte1
   451 00007722 668B15[98860100]    <1> 	mov 	dx, [year]
   452 00007729 6683E203            <1> 	and 	dx, 3 ; year mod 4
   453 0000772D 7503                <1> 	jnz 	short cte1		
   454                              <1> 			; and if leap year
   455 0000772F 83C001              <1> 	add 	eax, 1 	; add this year's leap day (february 29)
   456                              <1> cte1: 			; compute seconds since 1/1/1970
   457 00007732 BA18000000          <1> 	mov 	edx, 24
   458 00007737 F7E2                <1> 	mul	edx
   459 00007739 8A15[9E860100]      <1> 	mov 	dl, [hour]
   460 0000773F 01D0                <1> 	add 	eax, edx
   461                              <1> 		; EAX = hours since 1/1/1970 00:00:00
   462                              <1> 	;mov	ebx, 60
   463 00007741 B33C                <1> 	mov	bl, 60
   464 00007743 F7E3                <1> 	mul	ebx
   465 00007745 8A15[A0860100]      <1> 	mov 	dl, [minute]
   466 0000774B 01D0                <1> 	add 	eax, edx
   467                              <1> 		; EAX = minutes since 1/1/1970 00:00:00
   468                              <1> 	;mov 	ebx, 60
   469 0000774D F7E3                <1> 	mul	ebx
   470 0000774F 8A15[A2860100]      <1> 	mov 	dl, [second]
   471 00007755 01D0                <1> 	add 	eax, edx
   472                              <1>  		; EAX -> seconds since 1/1/1970 00:00:00
   473 00007757 C3                  <1> 	retn
   474                              <1> 
   475                              <1> ;set_date_time:
   476                              <1> convert_from_epoch:
   477                              <1> 	; 31/12/2017 (v2.0.0)
   478                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0)
   479                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
   480                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
   481                              <1> 	; 'convert_from_epoch' procedure prototype: 
   482                              <1> 	; 	            UNIXCOPY.ASM, 10/03/2013
   483                              <1> 	;
   484                              <1> 	; ((Modified registers: EAX, EDX, ECX, EBX))	
   485                              <1> 	;
   486                              <1> 	; Derived from DALLAS Semiconductor
   487                              <1> 	; Application Note 31 (DS1602/DS1603)
   488                              <1> 	; 6 May 1998
   489                              <1> 	;
   490                              <1> 	; INPUT:
   491                              <1> 	; EAX = Unix (Epoch) Time
   492                              <1> 	;
   493 00007758 31D2                <1> 	xor 	edx, edx
   494 0000775A B93C000000          <1> 	mov 	ecx, 60
   495 0000775F F7F1                <1> 	div	ecx
   496                              <1> 	;mov 	[imin], eax   ; whole minutes
   497                              <1> 			  ; since 1/1/1970
   498 00007761 668915[A2860100]    <1> 	mov 	[second], dx  ; leftover seconds
   499 00007768 29D2                <1> 	sub 	edx, edx
   500 0000776A F7F1                <1> 	div	ecx
   501                              <1> 	;mov 	[ihrs], eax   ; whole hours
   502                              <1> 	;		      ; since 1/1/1970
   503 0000776C 668915[A0860100]    <1> 	mov 	[minute], dx  ; leftover minutes
   504 00007773 31D2                <1> 	xor	edx, edx
   505                              <1> 	;mov 	cx, 24
   506 00007775 B118                <1> 	mov 	cl, 24
   507 00007777 F7F1                <1> 	div	ecx
   508                              <1> 	;mov 	[iday], ax   ; whole days
   509                              <1> 			     ; since 1/1/1970
   510 00007779 668915[9E860100]    <1> 	mov 	[hour], dx   ; leftover hours
   511 00007780 05DB020000          <1> 	add 	eax, 365+366 ; whole day since
   512                              <1> 			     ; 1/1/1968 	
   513                              <1> 	;mov 	[iday], ax
   514 00007785 50                  <1> 	push 	eax
   515 00007786 29D2                <1> 	sub	edx, edx
   516 00007788 B9B5050000          <1> 	mov 	ecx, (4*365)+1 ; 4 years = 1461 days
   517 0000778D F7F1                <1> 	div	ecx
   518 0000778F 59                  <1> 	pop 	ecx
   519                              <1> 	;mov 	[lday], ax   ; count of quadyrs (4 years)
   520 00007790 6652                <1> 	push 	dx
   521                              <1> 	;mov 	[qday], dx   ; days since quadyr began
   522 00007792 6683FA3C            <1> 	cmp 	dx, 31 + 29  ; if past feb 29 then
   523 00007796 F5                  <1> 	cmc		     ; add this quadyr's leap day
   524 00007797 83D000              <1> 	adc 	eax, 0	     ; to # of qadyrs (leap days)
   525                              <1> 	;mov 	[lday], ax   ; since 1968			  
   526                              <1> 	;mov 	cx, [iday]
   527 0000779A 91                  <1> 	xchg 	ecx, eax     ; ECX = lday, EAX = iday		  
   528 0000779B 29C8                <1> 	sub 	eax, ecx     ; iday - lday
   529 0000779D B96D010000          <1> 	mov 	ecx, 365
   530 000077A2 31D2                <1> 	xor	edx, edx
   531                              <1> 	; EAX = iday-lday, EDX = 0
   532 000077A4 F7F1                <1> 	div	ecx
   533                              <1> 	;mov 	[iyrs], ax   ; whole years since 1968
   534                              <1> 	;jday = iday - (iyrs*365) - lday
   535                              <1> 	;mov [jday], dx      ; days since 1/1 of current year
   536                              <1> 	;add	eax, 1968
   537 000077A6 6605B007            <1> 	add 	ax, 1968     ; compute year
   538 000077AA 66A3[98860100]      <1> 	mov 	[year], ax
   539 000077B0 6689D1              <1> 	mov 	cx, dx
   540                              <1> 	;mov 	dx, [qday]
   541 000077B3 665A                <1> 	pop 	dx
   542 000077B5 6681FA6D01          <1> 	cmp 	dx, 365	     ; if qday <= 365 and qday >= 60	
   543 000077BA 7709                <1> 	ja 	short cfe1   ; jday = jday +1
   544 000077BC 6683FA3C            <1> 	cmp 	dx, 60       ; if past 2/29 and leap year then
   545 000077C0 F5                  <1>         cmc		     ; add a leap day to the # of whole
   546 000077C1 6683D100            <1> 	adc 	cx, 0        ; days since 1/1 of current year
   547                              <1> cfe1:			
   548                              <1> 	;mov 	[jday], cx
   549 000077C5 66BB0C00            <1> 	mov 	bx, 12       ; estimate month
   550 000077C9 66BA6E01            <1> 	mov 	dx, 366      ; mday, max. days since 1/1 is 365
   551 000077CD 6683E003            <1> 	and 	ax, 11b      ; year mod 4 (and dx, 3) 
   552                              <1> cfe2:	; Month calculation  ; 0 to 11  (11 to 0)	
   553 000077D1 6639D1              <1> 	cmp 	cx, dx       ; mday = # of days passed from 1/1
   554 000077D4 731D                <1> 	jnb 	short cfe3
   555 000077D6 664B                <1> 	dec 	bx           ; month = month - 1
   556 000077D8 66D1E3              <1> 	shl 	bx, 1 
   557 000077DB 668B93[A4860100]    <1> 	mov 	dx, [EBX+DMonth] ; # elapsed days at 1st of month
   558 000077E2 66D1EB              <1> 	shr 	bx, 1        ; bx = month - 1 (0 to 11)
   559 000077E5 6683FB01            <1> 	cmp	bx, 1        ; if month > 2 and year mod 4  = 0	
   560 000077E9 76E6                <1> 	jna 	short cfe2   ; then mday = mday + 1
   561 000077EB 08C0                <1> 	or 	al, al       ; if past 2/29 and leap year then
   562 000077ED 75E2                <1> 	jnz 	short cfe2   ; add leap day (to mday)
   563 000077EF 6642                <1> 	inc 	dx           ; mday = mday + 1
   564 000077F1 EBDE                <1> 	jmp 	short cfe2
   565                              <1> cfe3:
   566 000077F3 6643                <1> 	inc 	bx	     ; -> bx = month, 1 to 12
   567 000077F5 66891D[9A860100]    <1> 	mov 	[month], bx
   568 000077FC 6629D1              <1> 	sub 	cx, dx	     ; day = jday - mday + 1	
   569 000077FF 6641                <1> 	inc 	cx 			  
   570 00007801 66890D[9C860100]    <1> 	mov 	[day], cx
   571                              <1> 	
   572                              <1> 	; eax, ebx, ecx, edx is changed at return
   573                              <1> 	; output ->
   574                              <1> 	; [year], [month], [day], [hour], [minute], [second]
   575                              <1> 
   576 00007808 C3                  <1> 	retn	; 31/12/2017 (TRDOS 386)
   577                              <1> 
   578                              <1> set_rtc_date_time:
   579                              <1> 	; 31/12/2017 (v2.0.0)
   580                              <1> 	; 30/12/2017 (TRDOS 386)
   581                              <1> 	; 15/03/2015 (Retro UNIX 386 v1 - 32 bit version)
   582                              <1> 	; 20/06/2013 (Retro UNIX 8086 v1)
   583 00007809 E80F000000          <1> 	call	set_date_bcd
   584                              <1> 	; Set real-time clock date
   585 0000780E E835F3FFFF          <1> 	call	set_rtc_date ; RTC_50
   586                              <1> 	; Set real-time clock time
   587 00007813 E832000000          <1> 	call	set_time_bcd
   588 00007818 E9BCF2FFFF          <1> 	jmp	set_rtc_time ; RTC_30	
   589                              <1> 
   590                              <1> ; 31/12/2017
   591                              <1> set_date_bcd:
   592 0000781D A0[99860100]        <1>         mov     al, [year+1]
   593 00007822 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   594 00007824 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   595                              <1> 			     ; AL = AH * 10h + AL
   596 00007826 88C5                <1> 	mov 	ch, al ; century (BCD)
   597 00007828 A0[98860100]        <1> 	mov 	al, [year]
   598 0000782D D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   599 0000782F D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   600                              <1> 			     ; AL = AH * 10h + AL
   601 00007831 88C1                <1> 	mov 	cl, al ; year (BCD)
   602 00007833 A0[9A860100]        <1>         mov 	al, [month]
   603 00007838 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   604 0000783A D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   605                              <1> 			     ; AL = AH * 10h + AL
   606 0000783C 88C6                <1> 	mov 	dh, al ; month (BCD)
   607 0000783E A0[9C860100]        <1> 	mov 	al, [day]
   608 00007843 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   609 00007845 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   610                              <1> 			     ; AL = AH * 10h + AL
   611 00007847 88C6                <1> 	mov 	dh, al ; day (BCD)
   612 00007849 C3                  <1> 	retn	; 30/12/2017
   613                              <1> 
   614                              <1> ; 31/12/2017
   615                              <1> set_time_bcd:
   616                              <1>         ; Read real-time clock time 
   617                              <1> 	; (get day light saving time bit status)
   618 0000784A FA                  <1>  	cli
   619 0000784B E84AF4FFFF          <1> 	CALL	UPD_IPR 		; CHECK FOR UPDATE IN PROCESS
   620                              <1> 	; cf = 1 -> al = 0
   621 00007850 7207                <1>         jc      short stime1
   622 00007852 B00B                <1> 	MOV	AL,CMOS_REG_B		; ADDRESS ALARM REGISTER
   623 00007854 E85CF4FFFF          <1> 	CALL	CMOS_READ		; READ CURRENT VALUE OF DSE BIT
   624                              <1> stime1:
   625 00007859 FB                  <1> 	sti
   626 0000785A 2401                <1> 	AND	AL,00000001B		; MASK FOR VALID DSE BIT
   627 0000785C 88C2                <1> 	MOV	DL,AL			; SET [DL] TO ZERO FOR NO DSE BIT
   628                              <1> 	; DL = 1 or 0 (day light saving time)
   629                              <1> 	;	
   630 0000785E A0[9E860100]        <1> 	mov 	al, [hour]
   631 00007863 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   632 00007865 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   633                              <1> 			     ; AL = AH * 10h + AL
   634 00007867 88C5                <1> 	mov 	ch, al ; hour (BCD)
   635 00007869 A0[A0860100]        <1>         mov     al, [minute]
   636 0000786E D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   637 00007870 D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   638                              <1> 			     ; AL = AH * 10h + AL
   639 00007872 88C1                <1> 	mov 	cl, al       ; minute (BCD)
   640 00007874 A0[A2860100]        <1>         mov     al, [second]
   641 00007879 D40A                <1> 	aam 	; ah = al / 10, al = al mod 10
   642 0000787B D510                <1> 	db 	0D5h,10h     ; Undocumented inst. AAD
   643                              <1> 			     ; AL = AH * 10h + AL
   644 0000787D 88C6                <1> 	mov 	dh, al	     ; second (BCD)
   645 0000787F C3                  <1> 	retn	; 30/12/2017
  3080                                  %include 'trdosk2.s' ; 04/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.2) - DRV INIT : trdosk2.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 30/08/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.14 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DRV_INIT.ASM (c) 2009-2011 Erdogan TAN  [26/09/2009] Last Update: 07/08/2011
    14                              <1> ;
    15                              <1> 
    16                              <1> ldrv_init: ; Logical Drive Initialization
    17                              <1> 	; 30/08/2020
    18                              <1> 	; 25/08/2020
    19                              <1> 	; 11/08/2020, 13/08/2020
    20                              <1> 	; 17/07/2020, 20/07/2020
    21                              <1> 	; 14/07/2020, 15/07/2020
    22                              <1> 	; 30/01/2018
    23                              <1> 	; 27/12/2017
    24                              <1> 	; 12/02/2016
    25                              <1> 	; 06/01/2016
    26                              <1> 	;  	('diskinit.inc', 'diskio.inc' integration)
    27                              <1> 	; 04/01/2016 (TRDOS 386 = TRDOS v2.0)
    28                              <1> 	; 07/08/2011
    29                              <1> 	; 20/09/2009
    30                              <1> 	; 2005
    31                              <1> 
    32                              <1> 	; 15/07/2020
    33                              <1> 	;movzx	ecx, byte [HF_NUM] ; number of fixed disks
    34                              <1> 	;cmp	cl, 1
    35                              <1> 	;jnb	short load_hd_partition_tables
    36                              <1> 
    37 00007880 A0[6C8A0100]        <1> 	mov	al, [HF_NUM] ; number of fixed disks
    38 00007885 20C0                <1> 	and 	al, al
    39 00007887 7501                <1> 	jnz	short load_hd_partition_tables
    40                              <1> 
    41                              <1> 	; no any hard disks
    42 00007889 C3                  <1> 	retn			
    43                              <1> 
    44                              <1> load_hd_partition_tables:
    45                              <1> 	;mov	esi, [HDPM_TBL_VEC] ; primary master disk FDPT
    46                              <1> 	; 15/07/2020
    47 0000788A BE[708A0100]        <1> 	mov	esi, HDPM_TBL_VEC
    48 0000788F BF[968E0100]        <1> 	mov 	edi, PTable_hd0
    49 00007894 B280                <1> 	mov 	dl, 80h
    50                              <1> 	; 15/07/2020
    51 00007896 A2[FD6D0000]        <1> 	mov	[hdc], al
    52                              <1> 	;xor	ecx, ecx ; 0
    53                              <1> load_next_hd_partition_table:
    54                              <1> 	; 20/07/2020
    55 0000789B 31C9                <1> 	xor	ecx, ecx ; 0
    56                              <1> 	;push	ecx
    57 0000789D 57                  <1> 	push	edi ; *
    58                              <1> 	;push	esi ; FDPT (+ DPTE) address
    59                              <1> 	; 15/07/2020
    60 0000789E AD                  <1> 	lodsd
    61 0000789F 56                  <1> 	push	esi ; ** ; next FDPT (+ DPTE) address ptr
    62                              <1> 	
    63                              <1> 	;mov	al, [esi+20] ; DPTE offset 4
    64                              <1> 	;and	al, 40h ;  LBA bit (bit 6)
    65                              <1> 	;;shr	al, 6
    66                              <1> 	;mov 	[HD_LBA_yes], al
    67                              <1> 	
    68                              <1> 	; 15/07/2020
    69 000078A0 8A4814              <1> 	mov	cl, [eax+20]
    70 000078A3 80E140              <1> 	and	cl, 40h
    71 000078A6 880D[9A8F0100]      <1> 	mov	[HD_LBA_yes], cl
    72                              <1> 	
    73 000078AC E844040000          <1> 	call	load_masterboot
    74                              <1> 	;jc	short pass_pt_this_hard_disk
    75                              <1> 	; 13/08/2020
    76 000078B1 0F828A000000        <1> 	jc	pass_pt_this_hard_disk
    77                              <1> 
    78 000078B7 BB[548E0100]        <1> 	mov	ebx, PartitionTable
    79 000078BC 89DE                <1> 	mov	esi, ebx
    80                              <1> 	;mov	ecx, 16
    81 000078BE B110                <1> 	mov	cl, 16
    82 000078C0 F3A5                <1> 	rep 	movsd
    83 000078C2 89DE                <1> 	mov 	esi, ebx 
    84                              <1> 	;mov 	byte [hdc], 4 ; 4 - partition index
    85                              <1> 	; 15/07/2020
    86 000078C4 C605[9B8F0100]04    <1> 	mov	byte [PP_Counter], 4
    87                              <1> loc_validate_hdp_partition:
    88                              <1> 	;cmp 	byte [esi+ptFileSystemID], 0
    89                              <1> 	;jna	short loc_validate_next_hdp_partition2
    90                              <1> 	; 13/08/2020
    91 000078CB 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
    92 000078CE 20C0                <1> 	and	al, al
    93 000078D0 7457                <1> 	jz	short loc_validate_next_hdp_partition2
    94                              <1> 
    95 000078D2 56                  <1> 	push	esi ; *** ; Masterboot partition table offset
    96 000078D3 52                  <1> 	push	edx ; **** ; dl = Physical drive number
    97                              <1> 
    98                              <1> 	; 13/08/2020
    99 000078D4 3C05                <1> 	cmp	al, 05h  ; Extended partition CHS
   100 000078D6 7404                <1>  	je	short loc_set_ep_counter
   101 000078D8 3C0F                <1> 	cmp	al, 0Fh  ; Extended partition LBA
   102 000078DA 7511                <1>  	jne	short loc_validate_next_hdp_partition0
   103                              <1> 	
   104                              <1> 	;;inc	byte [PP_Counter]
   105                              <1> 	; 15/07/2020
   106                              <1> 	;inc 	byte [EP_Counter] ; disk has valid partition(s)
   107                              <1> 
   108                              <1> loc_set_ep_counter:
   109                              <1> 	; 13/08/2020
   110 000078DC 803D[9C8F0100]80    <1> 	cmp	byte [EP_Counter], 80h
   111 000078E3 7342                <1> 	jnb	short loc_validate_next_hdp_partition1
   112                              <1> 
   113 000078E5 8815[9C8F0100]      <1> 	mov	byte [EP_Counter], dl ; disk drv has extd. part.
   114                              <1> 
   115 000078EB EB3A                <1> 	jmp	short loc_validate_next_hdp_partition1
   116                              <1> 
   117                              <1> loc_validate_next_hdp_partition0:
   118 000078ED 31FF                <1> 	xor	edi, edi ; 0  
   119                              <1> 	; Input -> ESI = PartitionTable offset
   120                              <1> 	; DL = Hard disk drive number 
   121                              <1> 	; EDI = 0 -> Primary Partition
   122                              <1> 	; EDI > 0 -> Extended Partition's Start Sector   
   123 000078EF E885010000          <1> 	call 	validate_hd_fat_partition
   124 000078F4 730E                <1> 	jnc 	short loc_set_valid_hdp_partition_entry
   125                              <1> 
   126                              <1> 	;pop	edx
   127                              <1> 	;push	edx
   128 000078F6 8B1424              <1> 	mov	edx, [esp]  ; ****
   129 000078F9 8B742404            <1> 	mov	esi, [esp+4] ; *** ; 30/01/2018
   130 000078FD E8D1020000          <1> 	call	validate_hd_fs_partition
   131 00007902 7223                <1> 	jc	short loc_validate_next_hdp_partition1
   132                              <1> loc_set_valid_hdp_partition_entry:
   133 00007904 8A0D[62400100]      <1> 	mov 	cl, [Last_DOS_DiskNo] 
   134 0000790A 80C141              <1> 	add 	cl, 'A'
   135                              <1> 	; ESI = Logical dos drive description table address
   136 0000790D 880E                <1> 	mov	[esi+LD_Name], cl
   137                              <1> 	; 15/07/2020
   138 0000790F 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo] ; Physical drive number
   139                              <1> 	;mov	al, [esp] ; ****
   140 00007912 2C7F                <1> 	sub	al, 7Fh
   141                              <1> 		; AL = 1 to 4	
   142 00007914 C0E002              <1> 	shl	al, 2 ; AL = 4 to 16
   143                              <1> 
   144 00007917 8A15[9B8F0100]      <1> 	mov	dl, [PP_Counter]
   145                              <1> 
   146                              <1> 	;sub	al, [PP_Counter]
   147 0000791D 28D0                <1> 	sub	al, dl ; [PP_Counter] ; 4 - partition index
   148                              <1> 
   149                              <1> 	; AL = Partition entry/index, 0 based
   150                              <1> 	;  0 -> hd 0, Partition Table offset = 0
   151                              <1> 	; 15 -> hd 3, Partition Table offset = 3
   152                              <1> 
   153                              <1> 	;mov	[esi+LD_PartitionEntry], al 
   154                              <1> 	
   155                              <1> 	; 15/07/2020
   156 0000791F B404                <1> 	mov	ah, 4
   157                              <1> 	;sub	ah, [PP_Counter]
   158 00007921 28D4                <1> 	sub	ah, dl
   159                              <1> 
   160                              <1> 	; AH = Primary partition index, 0 to 3 ; pt entry
   161                              <1> 	;		(4 to 7 for logical disk partitions)
   162                              <1> 
   163                              <1> 	;mov 	[esi+LD_DParamEntry], ah 
   164 00007923 6689467C            <1> 	mov 	[esi+LD_PartitionEntry], ax
   165                              <1> 
   166                              <1> loc_validate_next_hdp_partition1:
   167 00007927 5A                  <1> 	pop 	edx ; **** ; dl = Physical drive number 
   168 00007928 5E                  <1> 	pop	esi ; *** ; Masterboot partition table offset
   169                              <1> 
   170                              <1> loc_validate_next_hdp_partition2:
   171                              <1> 	; ESI = PartitionTable offset
   172                              <1> 	; DL = Hard/Fixed disk drive number
   173                              <1> 	
   174                              <1> 	;dec	byte [hdc] ; 4 - partition index
   175                              <1> 	;jz	short pass_pt_this_hard_disk
   176                              <1> 	; 15/07/2020
   177 00007929 FE0D[9B8F0100]      <1> 	dec	byte [PP_Counter] ; 4 - partition index
   178 0000792F 7410                <1> 	jz	short pass_pt_this_hard_disk
   179                              <1> 	
   180 00007931 83C610              <1> 	add	esi, 16 ; 10h
   181 00007934 EB95                <1> 	jmp	short loc_validate_hdp_partition
   182                              <1> 
   183                              <1> loc_not_any_extd_partitions:
   184                              <1> 	; 15/07/2020
   185 00007936 C3                  <1> 	retn	
   186                              <1> 
   187                              <1> loc_next_hd_partition_table:
   188 00007937 FEC2                <1> 	inc	dl
   189                              <1> 	; 15/07/2020
   190                              <1> 	;add	esi, 32 ; next FDPT address
   191 00007939 83C740              <1> 	add	edi, 64 ; next partition table destination
   192 0000793C E95AFFFFFF          <1>         jmp     load_next_hd_partition_table
   193                              <1> 
   194                              <1> pass_pt_this_hard_disk:
   195                              <1> 	;pop	esi ; FDPT (+ DPTE) address
   196                              <1> 	; 15/07/2020
   197 00007941 5E                  <1> 	pop	esi ; ** ; next FDPT (+ DPTE) address ptr
   198 00007942 5F                  <1> 	pop	edi ; * ; Ptable_hd?
   199                              <1> 	;pop	ecx
   200                              <1> 	;loop	loc_next_hd_partition_table
   201 00007943 FE0D[FD6D0000]      <1> 	dec	byte [hdc]
   202 00007949 75EC                <1> 	jnz	short loc_next_hd_partition_table
   203                              <1> 
   204                              <1> 	;cmp	byte [PP_Counter], 1
   205                              <1> 	;jnb	short load_extended_dos_partitions
   206                              <1> 	;; Empty partition table
   207                              <1> 	;retn
   208                              <1> 
   209                              <1> 	; 11/08/2020
   210                              <1> 	; 17/07/2020
   211                              <1> check_extended_partitions:
   212                              <1> 	; 15/07/2020
   213                              <1> 	;cmp	byte [EP_Counter], 0
   214                              <1> 	;jna	short loc_not_any_extd_partitions
   215                              <1> 	; 13/08/2020
   216 0000794B A0[9C8F0100]        <1> 	mov	al, [EP_Counter] ; 1st disk drv has extd partition
   217 00007950 08C0                <1> 	or	al, al ; 0 ?
   218 00007952 74E2                <1> 	jz	short loc_not_any_extd_partitions
   219                              <1> 
   220                              <1> load_extended_dos_partitions:
   221                              <1> 	;mov	byte [hdc], 80h
   222                              <1> 	; 13/08/2020
   223 00007954 A2[FD6D0000]        <1> 	mov	byte [hdc], al ; 1st disk drv has extd partition
   224                              <1> 	; 25/08/2020
   225 00007959 2C80                <1> 	sub	al, 80h
   226 0000795B 740E                <1> 	jz	short loc_set_ext_ptable_hd0
   227 0000795D C0E006              <1> 	shl	al, 6 ; * 64
   228 00007960 0FB6F0              <1> 	movzx	esi, al
   229 00007963 81C6[968E0100]      <1> 	add	esi, PTable_hd0
   230 00007969 EB05                <1> 	jmp 	short next_hd_extd_partition
   231                              <1> 
   232                              <1> 	; 25/08/2020
   233                              <1> loc_set_ext_ptable_hd0:
   234 0000796B BE[968E0100]        <1> 	mov	esi, PTable_hd0
   235                              <1> 
   236                              <1> next_hd_extd_partition:
   237                              <1> 	; 17/07/2020
   238                              <1> 	;mov 	byte [EP_Counter], 0 ; Reset for each physical disk
   239                              <1> 	; 13/08/2020
   240                              <1> 	;mov	byte [LD_Counter], 0 ; Reset logical drive index
   241 00007970 66C705[9C8F0100]00- <1> 	mov 	word [EP_Counter], 0 ; Reset EP index and LD index	
   241 00007978 00                  <1>
   242                              <1> 
   243 00007979 56                  <1> 	push	esi ; **** ; PTable_hd? offset
   244                              <1> 	
   245 0000797A C605[9B8F0100]04    <1> 	mov 	byte [PP_Counter], 4 
   246                              <1> 				; set for each extd partition table
   247                              <1> 	;;mov	ecx, 4
   248                              <1> 	;mov	cl, 4
   249 00007981 8A15[FD6D0000]      <1> 	mov	dl, [hdc]
   250                              <1> hd_check_fs_id_05h:
   251 00007987 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
   252 0000798A 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
   253 0000798C 7411                <1> 	je	short loc_set_ep_start_sector ; yes
   254                              <1> hd_check_fs_id_0Fh:
   255 0000798E 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
   256 00007990 740D                <1> 	je	short loc_set_ep_start_sector ; yes
   257                              <1> 
   258                              <1> continue_to_check_ep:
   259                              <1> 	;add	esi, 16
   260                              <1> 	;loop	hd_check_fs_id_05h
   261                              <1> 	; 15/07/2020
   262                              <1> 	;dec	cl
   263                              <1> 	;jz	short continue_check_ep_next_disk
   264 00007992 FE0D[9B8F0100]      <1> 	dec	byte [PP_Counter] ; 4 --> 0
   265 00007998 742D                <1> 	jz	short continue_check_ep_next_disk
   266 0000799A 83C610              <1> 	add	esi, 16
   267 0000799D EBE8                <1> 	jmp	short hd_check_fs_id_05h
   268                              <1> 
   269                              <1> loc_set_ep_start_sector:
   270                              <1> 	; dl = [hdc] ; Drive number
   271                              <1> 	; 15/07/2020
   272 0000799F 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
   273                              <1> 	; 30/08/2020
   274 000079A2 890D[9E8F0100]      <1> 	mov	[MBR_EP_StartSector], ecx 
   275                              <1> 	; 20/07/2020
   276                              <1> loc_validate_hde_partition_next:
   277 000079A8 890D[A28F0100]      <1> 	mov	[EP_StartSector], ecx ; Extended partition's start sector
   278 000079AE BB[968C0100]        <1>         mov	ebx, MasterBootBuff
   279 000079B3 803D[9A8F0100]01    <1> 	cmp	byte [HD_LBA_yes], 1 ; LBA ready = Yes
   280 000079BA 7227                <1> 	jb	short loc_hd_load_ep_05h ; cf = 1 ; 20/07/2020 
   281                              <1> 	; 11/08/2020
   282                              <1> 	; (BugFix for extended partition type 05h beyond CHS limit)
   283                              <1> 	; (Infact if extended partition starts at the beyond of CHS limit,
   284                              <1> 	;  it's partition ID must be 0Fh but they/somebodies had used 05h.)
   285                              <1> 	;cmp	al, 05h
   286                              <1> 	;je	short loc_hd_load_ep_05h
   287                              <1> loc_hd_load_ep_0Fh:
   288                              <1> 	; 04/01/2016
   289                              <1> 	;push	ecx
   290                              <1> 	; 15/07/2020
   291                              <1> 	;mov	ecx, [esi+ptStartSector] ; sector number
   292                              <1> 	;mov	ebx, MasterBootBuff ; buffer address
   293                              <1> 	; LBA read/write (with private LBA function) 
   294                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   295                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   296                              <1> 	;mov	ah, 1Bh ; LBA read
   297                              <1> 	;mov	al, 1 ; sector count
   298 000079BC 66B8011B            <1> 	mov	ax, 1B01h
   299 000079C0 E864D8FFFF          <1> 	call	int13h
   300                              <1> 	;pop	ecx
   301                              <1> 	;jnc	short loc_hd_move_ep_table
   302                              <1> 	; 15/07/2020
   303 000079C5 732E                <1> 	jnc	short loc_validate_hde_partition
   304                              <1> 
   305                              <1> continue_check_ep_next_disk:
   306                              <1> 	; 15/07/2020
   307                              <1> 	;pop	edi ; PTable_ep?
   308 000079C7 5E                  <1> 	pop	esi ; **** ; PTable_hd?
   309 000079C8 A0[6C8A0100]        <1> 	mov	al, [HF_NUM] ; number of hard disks
   310 000079CD 047F                <1> 	add	al, 7Fh
   311 000079CF 3805[FD6D0000]      <1> 	cmp	[hdc], al
   312 000079D5 730B                <1> 	jnb	short loc_validating_hd_partitions_ok
   313 000079D7 83C640              <1> 	add	esi, 64
   314                              <1> 	; 15/07/2020
   315                              <1> 	;add	edi, 64
   316 000079DA FE05[FD6D0000]      <1> 	inc	byte [hdc]
   317 000079E0 EB8E                <1> 	jmp	short next_hd_extd_partition
   318                              <1> 
   319                              <1> loc_validating_hd_partitions_ok:
   320                              <1> 	; 15/07/2020
   321                              <1> 	;mov	al, [Last_DOS_DiskNo]
   322                              <1> loc_drv_init_retn:
   323 000079E2 C3                  <1> 	retn
   324                              <1> 	
   325                              <1> loc_hd_load_ep_05h:
   326                              <1> 	; 20/07/2020 ('diskio.s', int13h, cf = 1 -> bugfix)
   327                              <1> 	;clc    ; (Bug: int13h would not clear carry flag bit, 
   328                              <1> 	;	; even if there would not be an error)
   329                              <1> 	;	; ((Fix: now, int13h procedure clears carry flag
   330                              <1> 	;	;  at the entrance of it.. 20/07/2020))
   331                              <1> 	; 15/07/2020
   332                              <1> 	;push	ecx 
   333 000079E3 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   334 000079E6 668B4E02            <1>         mov     cx, [esi+ptBeginSector]
   335 000079EA 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   336                              <1> 	;mov	ebx, MasterBootBuff
   337 000079EE E836D8FFFF          <1> 	call	int13h ; 20/07/2020
   338                              <1> 		       ; 'diskio.s' modification, 'clc'
   339                              <1> 	;pop	ecx  
   340 000079F3 72D2                <1> 	jc	short continue_check_ep_next_disk
   341                              <1> 	; 15/07/2020
   342                              <1> 	;jmp	short loc_validate_hde_partition
   343                              <1> 
   344                              <1> 	; 15/07/2020
   345                              <1> ;loc_hd_move_ep_table:
   346                              <1> 	;;pop	edi
   347                              <1> 	;;push	edi  ; PTable_ep?
   348                              <1> 	;mov	edi, [esp]        
   349                              <1>         ;mov	esi, PartitionTable ; Extended
   350                              <1> 	;mov	ebx, esi
   351                              <1> 	;;mov	ecx, 16
   352                              <1> 	;mov	cl, 16
   353                              <1>        	;rep	movsd
   354                              <1> 	;mov	esi, ebx 
   355                              <1> ;loc_set_hde_sub_partition_count:
   356                              <1> 	;mov	byte [PP_Counter], 4
   357                              <1> 	;mov	byte [EP_Counter], 0
   358                              <1> 
   359                              <1> loc_validate_hde_partition:
   360                              <1> 	; 13/08/2020
   361                              <1> 	; 15/07/2020
   362                              <1> 	;mov	byte [PP_Counter], 4
   363 000079F5 BE[548E0100]        <1> 	mov	esi, PartitionTable ; (in MasterBootBuff)
   364                              <1> 	; 13/08/2020
   365                              <1> 	;jmp	short get_minidisk_partition_entry
   366                              <1> 
   367                              <1> ;get_minidisk_partition_entry:
   368                              <1> ;	; 20/07/2020
   369                              <1> ;	cmp	byte [esi+ptFileSystemID], 0
   370                              <1> ;	ja	short loc_validate_minidisk_partition
   371                              <1> ;	; 13/08/2020
   372                              <1> ;	jmp	short continue_check_ep_next_disk
   373                              <1> 
   374                              <1> ;	; 11/08/2020
   375                              <1> ;get_minidisk_partition_entry_next:
   376                              <1> ;	; 13/08/2020
   377                              <1> ;	;dec 	byte [PP_Counter]
   378                              <1> ;	;jz	short continue_check_ep_next_disk
   379                              <1> ;	; 20/07/2020
   380                              <1> ;;get_minidisk_partition_entry_next:
   381                              <1> ;	; 13/08/2020
   382                              <1> ;	cmp	esi, PartitionTable+64 
   383                              <1> ;	jnb	short continue_check_ep_next_disk
   384                              <1> ;	
   385                              <1> ;	add 	esi, 16 ; 10h
   386                              <1> ;	;jmp	short get_minidisk_partition_entry
   387                              <1> 
   388                              <1> 	; 13/08/2020
   389                              <1> get_minidisk_partition_entry:
   390                              <1> 	; 20/07/2020
   391 000079FA 807E0400            <1> 	cmp	byte [esi+ptFileSystemID], 0
   392 000079FE 76C7                <1> 	jna	short continue_check_ep_next_disk ; 13/08/2020
   393                              <1> 
   394                              <1> loc_validate_minidisk_partition:
   395                              <1> 	; 13/08/2020
   396                              <1> 	; 20/07/2020
   397                              <1> 	;push	esi ; *** ; Extended partition table offset
   398                              <1> 
   399                              <1> 	; 13/08/2020
   400 00007A00 FE05[9C8F0100]      <1> 	inc	byte [EP_Counter] ; current (sub partition) index 
   401                              <1> 				  ; in current extended partition
   402                              <1> 
   403 00007A06 BF[A28F0100]        <1> 	mov	edi, EP_StartSector
   404                              <1> 
   405                              <1> 	; Input -> ESI = PartitionTable offset
   406                              <1> 	; DL = Hard disk drive number   
   407                              <1> 	; EDI = Extended partition start sector pointer
   408 00007A0B E869000000          <1> 	call	validate_hd_fat_partition
   409                              <1> 	;pop	ecx ; *
   410 00007A10 7308                <1> 	jnc	short loc_set_valid_hde_partition_entry
   411                              <1> 			 ; jump down to deep !!!
   412                              <1> 
   413                              <1> 	;pop	esi ; *** ; Extended partition table offset
   414                              <1> 	; 13/08/2020
   415                              <1> 	;mov	esi, PartitionTable
   416                              <1> 
   417                              <1> 	; 11/08/2020
   418                              <1> 	; ESI = Extended partition table offset
   419 00007A12 8A15[FD6D0000]      <1> 	mov	dl, [hdc]
   420                              <1> 
   421                              <1> 	;; DL = Hard disk drive number
   422                              <1> 	;dec	byte [PP_Counter]
   423                              <1> 	;jz	short continue_check_ep_next_disk
   424                              <1> 	;add 	esi, 16 ; 10h
   425                              <1> 	;mov	dl, [hdc]
   426                              <1> 	;jmp	short get_minidisk_partition_entry
   427                              <1> 
   428                              <1> 	; 11/08/2020
   429                              <1> 	;jmp	short get_minidisk_partition_entry_next
   430                              <1> 
   431                              <1> 	; 23/08/2020
   432 00007A18 EB3D                <1> 	jmp	short validate_next_minidisk_partition_ok
   433                              <1> 
   434                              <1> 	; 17/07/2020
   435                              <1> 	;; jumping down to deep levels !!!
   436                              <1> 	; ((That is a pitty microsoft preferred ep table chain
   437                              <1> 	; instead of a single table as mbr partition table!?))
   438                              <1> 
   439                              <1> loc_set_valid_hde_partition_entry:
   440                              <1> 	; 15/07/2020
   441 00007A1A A0[FD6D0000]        <1> 	mov	al, [hdc] ; Hard disk drive number (>=80h)
   442 00007A1F 88C2                <1> 	mov	dl, al ; mov dl, [hdc]
   443 00007A21 2C7F                <1> 	sub	al, 7Fh
   444                              <1> 		    ; 1 to 4	
   445 00007A23 C0E002              <1> 	shl	al, 2 ; 4 to 16
   446 00007A26 2A05[9B8F0100]      <1> 	sub	al, [PP_Counter] ; al - (4 - partition index)
   447                              <1> 			; (disk number * 4) + partition index
   448                              <1> 	
   449                              <1> 	; AL = Partition entry/index, 0 based
   450                              <1>         ;  0 -> hd 0, Partition Table offset = 0
   451                              <1>         ; 15 -> hd 3, Partition Table offset = 3
   452                              <1> 
   453                              <1> 	;mov	ah, 4 ; Logical dos partition (>= 4)
   454                              <1> 	;add	ah, [EP_Counter]
   455                              <1> 		; Logical disk partition index = 4 to 7
   456                              <1> 		; (Primary disk partition index = 0 to 3)
   457                              <1> 
   458                              <1> 	; 13/08/2020
   459 00007A2C 8A25[9D8F0100]      <1> 	mov	ah, [LD_Counter] ; Logical drive index number
   460                              <1> 				; (in current extended partition)
   461 00007A32 80C404              <1> 	add	ah, 4 ; 4 to 7
   462                              <1> 	
   463                              <1> 	; 15/07/2020
   464                              <1> 	; CX -> AX
   465                              <1> 	;; 06/01/2016 (TRDOS v2.0)
   466                              <1> 	;; BUGFIX *
   467                              <1> 	;;mov	[esi+LD_PartitionEntry], cl 
   468                              <1> 	;;mov	[esi+LD_DParamEntry], ch 
   469                              <1> 	;mov	[esi+LD_PartitionEntry], cx 
   470 00007A35 6689467C            <1> 	mov	[esi+LD_PartitionEntry], ax 	
   471                              <1> 
   472 00007A39 8A0D[62400100]      <1> 	mov	cl, [Last_DOS_DiskNo] 
   473 00007A3F 80C141              <1> 	add	cl, 'A'
   474 00007A42 880E                <1> 	mov	[esi+LD_Name], cl
   475                              <1> 
   476                              <1> 	; 17/07/2020
   477                              <1> 	;cmp	cl, 'Z'
   478                              <1> 	;jb	short logical_drive_count_ok_for_next
   479                              <1> 	;pop	esi ; ***
   480                              <1> 	;pop	esi ; ****
   481                              <1> 	;retn
   482                              <1> 
   483                              <1> ;logical_drive_count_ok_for_next:
   484                              <1> 
   485                              <1> 	;; 15/07/2020
   486                              <1> 	;inc	byte [EP_Counter]
   487                              <1> 	; 13/08/2020
   488 00007A44 FE05[9D8F0100]      <1> 	inc	byte [LD_Counter]	
   489                              <1> 
   490                              <1> 	;mov	dl, [hdc]
   491                              <1> 
   492                              <1> 	; 17/07/2020
   493                              <1> 	;; Now, 
   494                              <1> 	;; we are swimming in deep of an extended partition !!!
   495                              <1> 	; (! sub or chained extended partition tables !)
   496                              <1> 	; ((Logical dos partitions in extended partition were called
   497                              <1> 	;  as 'mini disk partition' in msdos 6.0 source code.))
   498                              <1> 
   499                              <1> validate_next_minidisk_partition:
   500                              <1> 	; 13/08/2020
   501                              <1> 	;pop	esi ; *** ; Extended partition table offset
   502                              <1> 
   503                              <1> 	; 17/07/2020
   504                              <1> 	;cmp	byte [EP_Counter], 4
   505                              <1> 	; 13/08/2020
   506 00007A4A 803D[9D8F0100]04    <1> 	cmp	byte [LD_Counter], 4 ; maximum 4 logical disks
   507                              <1> 				     ; per extended partition
   508 00007A51 0F8370FFFFFF        <1> 	jnb	continue_check_ep_next_disk
   509                              <1> 
   510                              <1> validate_next_minidisk_partition_ok:
   511                              <1> 	; 13/08/2020
   512                              <1> 	;dec	byte [PP_Counter] ; 4 --> 0
   513                              <1> 	;jz	continue_check_ep_next_disk
   514                              <1> 	
   515                              <1> 	;cmp	esi, PartitionTable+64 
   516                              <1> 	;jnb	continue_check_ep_next_disk
   517                              <1> 
   518                              <1> 	;add	esi, 16
   519                              <1> 	; 13/08/2020
   520 00007A57 BE[648E0100]        <1> 	mov	esi, PartitionTable+16
   521                              <1> 
   522                              <1> 	; 20/07/2020
   523 00007A5C 8A4604              <1> 	mov	al, [esi+ptFileSystemID]
   524                              <1> 
   525                              <1> 	; 20/07/2020
   526 00007A5F 3C05                <1> 	cmp	al, 05h ; Is it an extended dos partition ?
   527 00007A61 7408                <1> 	je	short loc_minidisk_next_ep_lba_chs ; 17/07/2020
   528 00007A63 3C0F                <1> 	cmp	al, 0Fh ; Is it an extended win4 (LBA mode) partition ?
   529 00007A65 0F855CFFFFFF        <1> 	jne	continue_check_ep_next_disk ; AL must be 0 here
   530                              <1> 					; (when it is not 05h or 0Fh)
   531                              <1> 					; If AL is not ZERO -> EP Bug!
   532                              <1> 					; (!Microsoft DOS convention!)
   533                              <1> loc_minidisk_next_ep_lba_chs:
   534                              <1> 	; 17/07/2020
   535 00007A6B 8B4E08              <1> 	mov	ecx, [esi+ptStartSector] ; relative start sector number
   536                              <1> 	;add	ecx, [EP_StartSector]
   537                              <1> 	; 30/08/2020	
   538 00007A6E 030D[9E8F0100]      <1> 	add	ecx, [MBR_EP_StartSector] 
   539                              <1> 	; 20/07/2020
   540 00007A74 E92FFFFFFF          <1> 	jmp	loc_validate_hde_partition_next
   541                              <1> 
   542                              <1> validate_hd_fat_partition:
   543                              <1> 	; 17/07/2020
   544                              <1> 	; 15/07/2020
   545                              <1> 	;	(optimization)
   546                              <1> 	; 14/07/2020
   547                              <1> 	;	(fat16 -big- partition search bugfix)
   548                              <1> 	; 27/12/2017
   549                              <1> 	; 12/02/2016
   550                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
   551                              <1> 	; 07/08/2011
   552                              <1> 	; 23/07/2011
   553                              <1> 	; Input
   554                              <1> 	;   DL = Hard/Fixed Disk Drive Number
   555                              <1> 	;   ESI = PartitionTable offset
   556                              <1> 	;   EDI = Extend. Part. Start Sector Pointer
   557                              <1> 	;   EDI = 0 -> Primary Partition 
   558                              <1> 	;   byte [Last_DOS_DiskNo]
   559                              <1>  	; Output
   560                              <1> 	;  cf=0 -> Validated
   561                              <1> 	;   ESI = Logical dos drv desc. table
   562                              <1> 	;   EBX = FAT boot sector buffer
   563                              <1> 	;   byte [Last_DOS_DiskNo]
   564                              <1> 	;  cf=1 -> Not a valid FAT partition
   565                              <1> 	; EAX, EDX, ECX, EDI -> changed 
   566                              <1> 	
   567                              <1> 	;mov 	esi, PartitionTable
   568 00007A79 8A6604              <1> 	mov 	ah, [esi+ptFileSystemID]
   569 00007A7C B002                <1> 	mov	al, 2 ; 27/12/2017
   570 00007A7E 80FC06              <1> 	cmp 	ah, 06h ; FAT16 CHS partition (>=32MB)
   571                              <1> 	; 12/02/2016
   572                              <1> 	;;jb	short loc_not_a_valid_fat_partition2
   573                              <1>  	;jnb	short vhdp_FAT16_32
   574                              <1> 	; 14/07/2020 (BugFix)
   575 00007A81 7711                <1> 	ja	short vhdp_FAT16_32
   576 00007A83 7425                <1> 	je	short loc_set_valid_hd_partition_params
   577                              <1> 
   578                              <1> vhdp_FAT12_16:
   579                              <1> 	; 27/12/2017
   580 00007A85 FEC8                <1> 	dec	al ; mov al, 1
   581 00007A87 38C4                <1> 	cmp	ah, al ; 1 ; FAT12 partition
   582 00007A89 741F                <1> 	je	short loc_set_valid_hd_partition_params
   583                              <1> 	;
   584 00007A8B FEC0                <1> 	inc	al ; mov al, 2
   585 00007A8D 80FC04              <1> 	cmp	ah, 04h ; FAT16 CHS partition (< 32MB)
   586 00007A90 7418                <1> 	je	short loc_set_valid_hd_partition_params
   587                              <1> 	
   588                              <1> 	; 15/07/2020
   589                              <1> 	; (ah = 05h, 02h or 03h)
   590                              <1> loc_not_a_valid_fat_partition1:
   591 00007A92 F9                  <1> 	stc
   592                              <1> 	; cf=1
   593 00007A93 C3                  <1> 	retn
   594                              <1> 
   595                              <1> vhdp_FAT16_32:
   596                              <1> 	; 15/07/2020
   597                              <1> 	;mov	al, 3
   598 00007A94 FEC0                <1> 	inc	al
   599 00007A96 80FC0C              <1> 	cmp	ah, 0Ch ; FAT32 LBA partition
   600 00007A99 740F                <1> 	je	short loc_set_valid_hd_partition_params
   601 00007A9B 7706                <1> 	ja	short vhdp_check_FAT16_lba
   602                              <1> 
   603                              <1> vhdp_check_FAT32_chs:
   604 00007A9D 80FC0B              <1> 	cmp	ah, 0Bh ; FAT32 CHS partition 
   605 00007AA0 7408                <1> 	je	short loc_set_valid_hd_partition_params
   606                              <1> 	;jne	short loc_not_a_valid_fat_partition1
   607                              <1> 
   608                              <1> 	;stc
   609                              <1> loc_not_a_valid_fat_partition2:
   610 00007AA2 C3                  <1> 	retn
   611                              <1> 
   612                              <1> vhdp_check_FAT16_lba:
   613 00007AA3 80FC0E              <1> 	cmp	ah, 0Eh ; FAT16 LBA partition
   614 00007AA6 75EA                <1> 	jne	short loc_not_a_valid_fat_partition1
   615                              <1> 
   616                              <1> 	;mov	al, 2
   617 00007AA8 FEC8                <1> 	dec	al
   618                              <1> 
   619                              <1> loc_set_valid_hd_partition_params:
   620                              <1> 	; 15/07/2020
   621                              <1> 	;inc 	byte [Last_DOS_DiskNo] ; > 1
   622                              <1> 	;
   623 00007AAA 31DB                <1> 	xor	ebx, ebx
   624 00007AAC 8A3D[62400100]      <1> 	mov	bh, [Last_DOS_DiskNo] ; * 256	
   625 00007AB2 FEC7                <1> 	inc	bh ; 15/07/2020
   626 00007AB4 81C300010900        <1> 	add	ebx, Logical_DOSDisks
   627                              <1> 	;
   628 00007ABA C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
   629 00007ABE 885302              <1> 	mov	byte [ebx+LD_PhyDrvNo], dl
   630                              <1> 	;mov	byte [ebx+LD_FATType], al ; 2 or 3
   631                              <1> 	;mov	byte [ebx+LD_FSType], ah ; 06h, 0Eh, 0Bh, 0Ch
   632 00007AC1 66894303            <1> 	mov	word [ebx+LD_FATType], ax
   633                              <1> 	;
   634 00007AC5 8B4E08              <1> 	mov	ecx, [esi+ptStartSector]
   635 00007AC8 09FF                <1> 	or	edi, edi 
   636 00007ACA 7402                <1> 	jz	short pass_hd_FAT_ep_start_sector_adding
   637                              <1> loc_add_hd_FAT_ep_start_sector:
   638                              <1> 	; 17/07/2020
   639 00007ACC 030F                <1> 	add	ecx, [edi]
   640                              <1> pass_hd_FAT_ep_start_sector_adding:
   641 00007ACE 894B6C              <1> 	mov	[ebx+LD_StartSector], ecx
   642                              <1> loc_hd_FAT_logical_drv_init:
   643 00007AD1 89DD                <1> 	mov	ebp, ebx
   644                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
   645 00007AD3 A0[9A8F0100]        <1> 	mov	al, [HD_LBA_yes] ; 07/01/2016
   646 00007AD8 884305              <1> 	mov	[ebx+LD_LBAYes], al
   647 00007ADB BB[A68F0100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
   648 00007AE0 08C0                <1> 	or	al, al
   649 00007AE2 740C                <1> 	jz	short loc_hd_FAT_drv_init_load_bs_chs
   650                              <1> loc_hd_FAT_drv_init_load_bs_lba:
   651                              <1> 	; DL = Physical drive number
   652                              <1>    	;mov	ecx, [esi+ptStartSector] ; sector number
   653                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
   654                              <1> 	; LBA read/write (with private LBA function) 
   655                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   656                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   657 00007AE4 B41B                <1> 	mov	ah, 1Bh ; LBA read
   658 00007AE6 B001                <1> 	mov	al, 1 ; sector count
   659 00007AE8 E83CD7FFFF          <1> 	call	int13h
   660 00007AED 7313                <1> 	jnc	short loc_hd_drv_FAT_boot_validation
   661                              <1> loc_not_a_valid_fat_partition3:
   662 00007AEF C3                  <1> 	retn
   663                              <1> loc_hd_FAT_drv_init_load_bs_chs:
   664 00007AF0 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   665 00007AF3 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
   666 00007AF7 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   667                              <1> 	;mov	ebx, DOSBootSectorBuff
   668 00007AFB E829D7FFFF          <1> 	call	int13h
   669 00007B00 72ED                <1> 	jc	short loc_not_a_valid_fat_partition3
   670                              <1> loc_hd_drv_FAT_boot_validation:
   671                              <1> 	;mov	esi, DOSBootSectorBuff
   672 00007B02 89DE                <1> 	mov	esi, ebx
   673 00007B04 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   674 00007B0D 7512                <1> 	jne	short loc_not_a_valid_fat_partition4
   675 00007B0F 807E15F8            <1> 	cmp	byte [esi+BPB_Media], 0F8h
   676 00007B13 750C                <1> 	jne	short loc_not_a_valid_fat_partition4
   677                              <1> 
   678                              <1> 	; 27/12/2017
   679 00007B15 807D0303            <1> 	cmp	byte [ebp+LD_FATType], 3
   680 00007B19 7508                <1> 	jne	short loc_hd_FAT16_BPB
   681                              <1> 
   682                              <1> loc_hd_drv_FAT32_boot_validation:
   683 00007B1B 807E4229            <1> 	cmp	byte [esi+BS_FAT32_BootSig], 29h
   684 00007B1F 7416                <1> 	je	short loc_hd_FAT32_BPB
   685                              <1> 
   686                              <1> loc_not_a_valid_fat_partition4:
   687 00007B21 F9                  <1> 	stc
   688 00007B22 C3                  <1> 	retn
   689                              <1> 
   690                              <1> loc_hd_FAT16_BPB:
   691 00007B23 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
   692 00007B27 75F8                <1> 	jne	short loc_not_a_valid_fat_partition4
   693                              <1> 
   694 00007B29 66837E1600          <1> 	cmp	word [esi+BPB_FATSz16], 0
   695 00007B2E 7607                <1> 	jna	short loc_hd_big_FAT16_BPB
   696 00007B30 B920000000          <1> 	mov	ecx, 32
   697 00007B35 EB05                <1> 	jmp	short loc_hd_move_FAT_BPB
   698                              <1> 
   699                              <1> loc_hd_FAT32_BPB:
   700                              <1> 	;cmp	word [esi+BPB_FATSz16], 0
   701                              <1> 	;ja	short loc_not_a_valid_fat_partition4
   702                              <1> loc_hd_big_FAT16_BPB:
   703 00007B37 B92D000000          <1> 	mov	ecx, 45
   704                              <1> 	
   705                              <1> loc_hd_move_FAT_BPB:
   706 00007B3C 89EF                <1> 	mov 	edi, ebp
   707                              <1> 	;mov	esi, ebx ; Boot sector
   708 00007B3E 57                  <1> 	push	edi
   709 00007B3F 83C706              <1> 	add	edi, LD_BPB
   710 00007B42 F366A5              <1> 	rep	movsw 
   711 00007B45 5E                  <1> 	pop	esi
   712 00007B46 0FB74614            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RsvdSecCnt]
   713 00007B4A 03466C              <1> 	add	eax, [esi+LD_StartSector]
   714 00007B4D 894660              <1> 	mov	[esi+LD_FATBegin], eax
   715 00007B50 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
   716 00007B54 7224                <1> 	jb	short loc_set_FAT16_RootDirLoc
   717                              <1> loc_set_FAT32_RootDirLoc:
   718 00007B56 8B462A              <1> 	mov	eax, [esi+LD_BPB+BPB_FATSz32]
   719 00007B59 0FB65E16            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_NumFATs]
   720 00007B5D F7E3                <1> 	mul	ebx
   721 00007B5F 034660              <1> 	add	eax, [esi+LD_FATBegin]
   722                              <1> loc_set_FAT32_data_begin:
   723 00007B62 894668              <1> 	mov	[esi+LD_DATABegin], eax
   724 00007B65 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   725                              <1> 	; If Root Directory Cluster <> 2 then
   726                              <1> 	; change the beginning sector value 
   727                              <1> 	; of the root dir by adding sector offset.
   728 00007B68 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
   729 00007B6B 83E802              <1> 	sub	eax, 2
   730 00007B6E 7435                <1> 	jz	short short loc_set_32bit_FAT_total_sectors  
   731                              <1> 	;movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
   732 00007B70 8A5E13              <1> 	mov	bl, [esi+LD_BPB+BPB_SecPerClust] 
   733 00007B73 F7E3                <1> 	mul	ebx
   734 00007B75 014664              <1> 	add	[esi+LD_ROOTBegin], eax
   735 00007B78 EB2B                <1> 	jmp	short loc_set_32bit_FAT_total_sectors
   736                              <1> 	;
   737                              <1> loc_set_FAT16_RootDirLoc:
   738 00007B7A 0FB64616            <1> 	movzx	eax, byte [esi+LD_BPB+BPB_NumFATs]
   739 00007B7E 0FB7561C            <1> 	movzx	edx, word [esi+LD_BPB+BPB_FATSz16]
   740 00007B82 F7E2                <1> 	mul	edx
   741 00007B84 034660              <1> 	add	eax, [esi+LD_FATBegin]  
   742 00007B87 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
   743                              <1> loc_set_FAT16_data_begin:
   744 00007B8A 894668              <1> 	mov	[esi+LD_DATABegin], eax 
   745                              <1> 	;mov	eax, 20h  ; Size of a directory entry
   746                              <1> 	;;movzx	edx, word [esi+LD_BPB+BPB_RootEntCnt]
   747                              <1>         ;mov     dx, [esi+LD_BPB+BPB_RootEntCnt]
   748                              <1>         ;mul	edx
   749                              <1> 	;;mov	ecx, 511
   750                              <1> 	;mov	cx, 511
   751                              <1> 	;add	eax, ecx
   752                              <1> 	;inc	ecx ; 512
   753                              <1> 	;div	ecx
   754                              <1> 	; 14/07/2020
   755 00007B8D 0FB74617            <1> 	movzx	eax, word [esi+LD_BPB+BPB_RootEntCnt]
   756 00007B91 6683C00F            <1> 	add	ax, 15
   757 00007B95 66C1E804            <1> 	shr	ax, 4 ; / 16 ; (16 entries per sector)
   758 00007B99 014668              <1> 	add	[esi+LD_DATABegin], eax
   759                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
   760 00007B9C 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
   761 00007BA0 6685C0              <1> 	test	ax, ax
   762                              <1> 	;jz	short loc_set_32bit_FAT_total_sectors
   763                              <1> ;loc_set_16bit_FAT_total_sectors:
   764                              <1> 	;mov	[esi+LD_TotalSectors], eax
   765                              <1> 	;jmp	short loc_set_hd_FAT_cluster_count
   766                              <1> 	; 14/07/2020
   767 00007BA3 7503                <1> 	jnz	short loc_set_hd_FAT_cluster_count
   768                              <1> loc_set_32bit_FAT_total_sectors:
   769 00007BA5 8B4626              <1> 	mov	eax, [esi+LD_BPB+BPB_TotalSec32]
   770                              <1> 	;mov	[esi+LD_TotalSectors], eax
   771                              <1> loc_set_hd_FAT_cluster_count:
   772 00007BA8 894670              <1> 	mov	[esi+LD_TotalSectors], eax ; 14/07/2020
   773 00007BAB 8B5668              <1> 	mov	edx, [esi+LD_DATABegin]
   774 00007BAE 2B566C              <1> 	sub	edx, [esi+LD_StartSector]
   775 00007BB1 29D0                <1> 	sub	eax, edx
   776 00007BB3 31D2                <1> 	xor	edx, edx ; 0
   777 00007BB5 0FB64E13            <1>         movzx   ecx, byte [esi+LD_BPB+BPB_SecPerClust]
   778 00007BB9 F7F1                <1>         div	ecx 
   779 00007BBB 894678              <1> 	mov	[esi+LD_Clusters], eax
   780                              <1> 	; Maximum Valid Cluster Number= EAX +1
   781                              <1> 	; with 2 reserved clusters= EAX +2
   782                              <1> loc_set_hd_FAT_fs_free_sectors:
   783                              <1> 	;mov	dword [esi+LD_FreeSectors], 0
   784 00007BBE E855010000          <1> 	call	get_free_FAT_sectors
   785 00007BC3 720D                <1> 	jc	short loc_validate_hd_FAT_partition_retn
   786 00007BC5 894674              <1> 	mov	[esi+LD_FreeSectors], eax
   787 00007BC8 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6  ; Volume Name Reset
   788                              <1> 
   789                              <1> 	; 15/07/2020
   790 00007BCC FE05[62400100]      <1> 	inc 	byte [Last_DOS_DiskNo] ; > 1
   791                              <1> 
   792                              <1> 	;mov	cl, [Last_DOS_DiskNo] 
   793                              <1> 	;add	cl, 'A'
   794                              <1> 	;mov	[esi+LD_FS_Name], cl
   795                              <1> 
   796                              <1> loc_validate_hd_FAT_partition_retn:         
   797 00007BD2 C3                  <1> 	retn
   798                              <1> 
   799                              <1> validate_hd_fs_partition:
   800                              <1> 	; 03/02/2018
   801                              <1> 	; 09/12/2017
   802                              <1> 	; 13/02/2016
   803                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   804                              <1> 	; 29/01/2011
   805                              <1> 	; 23/07/2011
   806                              <1> 	; Input
   807                              <1> 	;   DL = Hard/Fixed Disk Drive Number
   808                              <1> 	;   ESI = PartitionTable offset
   809                              <1> 	;   byte [Last_DOS_DiskNo]
   810                              <1> 	; Output
   811                              <1> 	;  cf=0 -> Validated
   812                              <1> 	;   ESI = Logical dos drv desc. table
   813                              <1> 	;   EBX = Singlix FS boot sector buffer
   814                              <1> 	;   byte [Last_DOS_DiskNo]
   815                              <1> 	;  cf=1 -> Not a valid 'Singlix FS' partition
   816                              <1> 	; EAX, EDX, ECX, EDI -> changed 
   817                              <1> 
   818                              <1> 	;mov	esi, PartitionTable
   819 00007BD3 8A6604              <1> 	mov	ah, [esi+ptFileSystemID]
   820 00007BD6 80FCA1              <1> 	cmp	ah, 0A1h ; SINGLIX FS1 (trfs1) partition
   821 00007BD9 7549                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   822                              <1> loc_set_valid_hd_fs_partition_params:
   823 00007BDB FE05[62400100]      <1> 	inc	byte [Last_DOS_DiskNo] ; > 1
   824 00007BE1 30C0                <1> 	xor	al, al ; mov al, 0
   825                              <1> 	;mov	[drv], dl
   826 00007BE3 29DB                <1> 	sub	ebx, ebx ; 0
   827 00007BE5 8A3D[62400100]      <1> 	mov	bh, [Last_DOS_DiskNo] 
   828 00007BEB 81C300010900        <1> 	add	ebx, Logical_DOSDisks
   829 00007BF1 C6430102            <1> 	mov	byte [ebx+LD_DiskType], 2
   830 00007BF5 885302              <1> 	mov	[ebx+LD_PhyDrvNo], dl
   831                              <1> 	;mov	[ebx+LD_FATType], al ; 0
   832                              <1> 	;mov	[ebx+LD_FSType], ah
   833 00007BF8 66894303            <1> 	mov	[ebx+LD_FATType], ax
   834                              <1> 	;mov	eax, [esi+ptStartSector]
   835                              <1> 	;mov	[ebx+LD_StartSector], eax
   836                              <1> loc_hd_fs_logical_drv_init:
   837 00007BFC 89DD                <1> 	mov	ebp, ebx ; 10/01/2016
   838                              <1> 	;mov	dl, [ebx+LD_PhyDrvNo]
   839 00007BFE A0[9A8F0100]        <1> 	mov	al, [HD_LBA_yes] ; 10/01/2016
   840 00007C03 884305              <1> 	mov	[ebx+LD_LBAYes], al
   841 00007C06 89DE                <1> 	mov	esi, ebx
   842 00007C08 BB[A68F0100]        <1> 	mov	ebx, DOSBootSectorBuff ; buffer address
   843 00007C0D 08C0                <1> 	or	al, al
   844 00007C0F 7515                <1> 	jnz	short loc_hd_fs_drv_init_load_bs_lba
   845                              <1> loc_hd_fs_drv_init_load_bs_chs:
   846 00007C11 8A7601              <1> 	mov	dh, [esi+ptBeginHead]
   847 00007C14 668B4E02            <1> 	mov	cx, [esi+ptBeginSector]
   848 00007C18 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
   849                              <1> 	;mov	ebx, DOSBootSectorBuff
   850 00007C1C E808D6FFFF          <1> 	call	int13h
   851 00007C21 7311                <1> 	jnc	short loc_hd_drv_fs_boot_validation
   852                              <1> loc_validate_hd_fs_partition_err_retn:
   853 00007C23 C3                  <1> 	retn
   854                              <1> loc_validate_hd_fs_partition_stc_retn:
   855 00007C24 F9                  <1> 	stc
   856 00007C25 C3                  <1> 	retn
   857                              <1> loc_hd_fs_drv_init_load_bs_lba:
   858                              <1> 	; DL = Physical drive number
   859                              <1> 	;mov	esi, ebx
   860 00007C26 8B4E08              <1>    	mov	ecx, [esi+ptStartSector] ; sector number
   861                              <1> 	;mov	ebx, DOSBootSectorBuff ; buffer address
   862                              <1> 	; LBA read/write (with private LBA function) 
   863                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   864                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   865 00007C29 B41B                <1> 	mov	ah, 1Bh ; LBA read
   866 00007C2B B001                <1> 	mov	al, 1 ; sector count
   867 00007C2D E8F7D5FFFF          <1> 	call	int13h
   868 00007C32 72EF                <1> 	jc	short loc_validate_hd_fs_partition_err_retn
   869                              <1> loc_hd_drv_fs_boot_validation:
   870                              <1> 	;mov	esi, DOSBootSectorBuff
   871 00007C34 89DE                <1> 	mov	esi, ebx ; Boot sector buffer
   872 00007C36 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
   873 00007C3F 75E3                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   874                              <1>         ;
   875                              <1> 	;Singlix FS Extensions to TR-DOS (7/6/2009) 
   876 00007C41 66817E034653        <1> 	cmp	word [esi+bs_FS_Identifier], 'FS' ; 03/02/2018
   877 00007C47 75DB                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   878                              <1>         ;'A1h' check is not necessary
   879                              <1> 	;  if 'FS' check is passed as OK/Yes.
   880 00007C49 807E09A1            <1> 	cmp	byte [esi+bs_FS_PartitionID], 0A1h
   881 00007C4D 75D5                <1> 	jne	short loc_validate_hd_fs_partition_stc_retn
   882                              <1> 	;
   883 00007C4F 89EF                <1> 	mov	edi, ebp ; 10/01/2016
   884                              <1> 	;
   885 00007C51 8A462D              <1> 	mov	al, byte [esi+bs_FS_LBA_Ready]
   886 00007C54 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
   887                              <1> 	;
   888                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
   889 00007C57 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
   890 00007C5A 884706              <1> 	mov	byte [edi+LD_FS_MediaAttrib], al
   891                              <1> 	;
   892 00007C5D 8A460A              <1> 	mov	al, [esi+bs_FS_VersionMaj]
   893 00007C60 884707              <1> 	mov	[edi+LD_FS_VersionMajor], al
   894                              <1> 	;
   895 00007C63 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
   896 00007C67 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
   897 00007C6B 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
   898 00007C6E 30E4                <1> 	xor	ah, ah ; 09/12/2017
   899 00007C70 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
   900 00007C74 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
   901 00007C77 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
   902                              <1> 	;
   903 00007C7B 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
   904 00007C7E 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
   905 00007C81 8B5618              <1> 	mov	edx, [esi+bs_FS_MATLocation]
   906 00007C84 89570C              <1> 	mov	[edi+LD_FS_MATLocation], edx
   907 00007C87 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
   908 00007C8A 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
   909 00007C8D 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
   910 00007C90 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
   911 00007C93 8B4710              <1> 	mov	eax, [edi+bs_FS_VolumeSize]
   912 00007C96 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
   913                              <1> 	;
   914 00007C99 89D0                <1> 	mov	eax, edx ; [edi+LD_FS_MATLocation]
   915 00007C9B 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
   916 00007C9E 89FE                <1> 	mov	esi, edi
   917                              <1> mread_hd_fs_MAT_sector:
   918                              <1>        ;mov	ebx, DOSBootSectorBuff
   919 00007CA0 B901000000          <1> 	mov	ecx, 1
   920 00007CA5 E8B3AE0000          <1> 	call	disk_read
   921 00007CAA 7248                <1> 	jc	short loc_validate_hd_fs_partition_retn
   922                              <1> 	; EDI will not be changed
   923 00007CAC 89DE                <1> 	mov	esi, ebx
   924                              <1> use_hdfs_mat_sector_params:
   925 00007CAE 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
   926 00007CB1 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
   927 00007CB4 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
   928 00007CB7 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
   929 00007CBA 8B4614              <1> 	mov	eax, [esi+FS_MAT_FreeSectors]
   930 00007CBD 894774              <1>         mov     [edi+LD_FS_FreeSectors], eax
   931 00007CC0 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
   932 00007CC3 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
   933 00007CC6 8B4708              <1> 	mov	eax, [edi+LD_FS_RootDirD]
   934 00007CC9 03476C              <1> 	add	eax, [edi+LD_FS_BeginSector]
   935 00007CCC 89FE                <1> 	mov	esi, edi   
   936                              <1> read_hd_fs_RDT_sector:
   937 00007CCE BB[A68F0100]        <1> 	mov	ebx, DOSBootSectorBuff
   938                              <1> 	;mov	ecx, 1
   939 00007CD3 B101                <1> 	mov	cl, 1
   940 00007CD5 E883AE0000          <1> 	call	disk_read
   941 00007CDA 7218                <1> 	jc	short loc_validate_hd_fs_partition_retn
   942                              <1> 	; EDI will not be changed
   943 00007CDC 89DE                <1> 	mov	esi, ebx
   944                              <1> use_hdfs_RDT_sector_params:
   945 00007CDE 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
   946 00007CE1 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
   947 00007CE4 57                  <1> 	push	edi
   948                              <1> 	;mov	ecx, 16
   949 00007CE5 B110                <1> 	mov	cl, 16
   950 00007CE7 83C640              <1> 	add	esi, FS_RDT_VolumeName
   951 00007CEA 83C72C              <1> 	add	edi, LD_FS_VolumeName
   952 00007CED F3A5                <1> 	rep	movsd ; 64 bytes
   953 00007CEF 5E                  <1> 	pop	esi
   954                              <1> 		; Volume Name Reset
   955 00007CF0 C6467E06            <1>         mov     byte [esi+LD_FS_MediaChanged], 6
   956                              <1> 	;
   957                              <1>         ;mov	cl, [Last_DOS_DiskNo] 
   958                              <1> 	;add	cl, 'A'
   959                              <1> 	;mov	[esi+LD_FS_Name], cl
   960                              <1> 
   961                              <1> loc_validate_hd_fs_partition_retn:
   962 00007CF4 C3                  <1> 	retn
   963                              <1> 
   964                              <1> load_masterboot:
   965                              <1> 	; 14/07/2020 (Reset function has been removed)
   966                              <1> 	;
   967                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
   968                              <1> 	; 2005 - 2011
   969                              <1> 	; input -> DL = drive number
   970                              <1> ;	mov	ah, 0Dh ; Alternate disk reset
   971                              <1> ;	call	int13h
   972                              <1> ;	jnc	short pass_reset_error
   973                              <1> ;harddisk_error:
   974                              <1> ;  	retn
   975                              <1> ;pass_reset_error:
   976 00007CF5 BB[968C0100]        <1> 	mov	ebx, MasterBootBuff
   977 00007CFA 66B80102            <1> 	mov	ax, 0201h
   978 00007CFE 66B90100            <1> 	mov	cx, 1
   979 00007D02 30F6                <1> 	xor	dh, dh
   980 00007D04 E820D5FFFF          <1>  	call	int13h
   981 00007D09 720C                <1> 	jc	short harddisk_error
   982                              <1> 	;
   983 00007D0B 66813D[948E0100]55- <1> 	cmp	word [MBIDCode], 0AA55h
   983 00007D13 AA                  <1>
   984 00007D14 7401                <1> 	je	short load_masterboot_ok
   985 00007D16 F9                  <1> 	stc
   986                              <1> harddisk_error:
   987                              <1> load_masterboot_ok:
   988 00007D17 C3                  <1> 	retn
   989                              <1> 
   990                              <1> get_free_FAT_sectors:
   991                              <1> 	; 21/12/2017
   992                              <1> 	; 29/02/2016
   993                              <1> 	; 13/02/2016
   994                              <1> 	; 04/02/2016
   995                              <1> 	; 07/01/2016 (TRDOS 386 = TRDOS v2.0)
   996                              <1> 	; 11/07/2010
   997                              <1> 	; 21/06/2009
   998                              <1> 	; INPUT: ESI = Logical DOS Drive Description Table address
   999                              <1> 	; OUTPUT: STC => Error
  1000                              <1>         ;	cf = 0 and EAX = Free FAT sectors
  1001                              <1> 	; Also, related parameters and FAT buffer will be reset and updated
  1002                              <1> 
  1003 00007D18 31C0                <1> 	xor	eax, eax
  1004                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Reset
  1005                              <1> 	
  1006 00007D1A 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
  1007 00007D1E 7654                <1> 	jna	short loc_gfc_get_fat_free_clusters
  1008                              <1> 
  1009                              <1> 	; 29/02/2016
  1010 00007D20 48                  <1> 	dec	eax ; 0FFFFFFFFh
  1011 00007D21 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count (reset)
  1012 00007D24 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster (reset)
  1013 00007D27 40                  <1> 	inc	eax ; 0
  1014                              <1> 	;
  1015 00007D28 668B4636            <1> 	mov	ax, [esi+LD_BPB+BPB_FSInfo]
  1016 00007D2C 03466C              <1> 	add	eax, [esi+LD_StartSector]
  1017                              <1> 
  1018 00007D2F BB[A68F0100]        <1> 	mov	ebx, DOSBootSectorBuff
  1019 00007D34 B901000000          <1> 	mov	ecx, 1
  1020 00007D39 E81FAE0000          <1>  	call	disk_read
  1021 00007D3E 7301                <1> 	jnc	short loc_gfc_check_fsinfo_signs
  1022                              <1> retn_gfc_get_fsinfo_sec:
  1023 00007D40 C3                  <1> 	retn
  1024                              <1> 
  1025                              <1> loc_gfc_check_fsinfo_signs:
  1026 00007D41 BB[A68F0100]        <1> 	mov 	ebx, DOSBootSectorBuff ; 13/02/2016
  1027 00007D46 813B52526141        <1>         cmp     dword [ebx], 41615252h
  1028 00007D4C 7524                <1> 	jne	short retn_gfc_get_fsinfo_stc
  1029                              <1> 	;add	ebx, 484
  1030                              <1> 	;cmp	dword [ebx], 61417272h
  1031 00007D4E 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  1031 00007D57 61                  <1>
  1032 00007D58 7518                <1> 	jne	short retn_gfc_get_fsinfo_stc
  1033                              <1> 	;add	ebx, 4
  1034                              <1> 	;mov	eax, [ebx]
  1035 00007D5A 8B83E8010000        <1> 	mov	eax, [ebx+488]
  1036                              <1> 	; 29/02/2016
  1037 00007D60 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  1038 00007D63 8B93EC010000        <1> 	mov	edx,  [ebx+492] 
  1039 00007D69 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First Free Cluster
  1040                              <1> 	; 21/12/2017
  1041 00007D6C 89C3                <1> 	mov	ebx, eax ; (initial value = 0FFFFFFFFh)
  1042 00007D6E 43                  <1> 	inc	ebx ; 0FFFFFFFFh -> 0  
  1043 00007D6F 7513                <1> 	jnz	short short retn_from_get_free_fat32_clusters
  1044 00007D71 C3                  <1> 	retn
  1045                              <1> 
  1046                              <1> retn_gfc_get_fsinfo_stc:
  1047 00007D72 F9                  <1> 	stc
  1048 00007D73 C3                  <1> 	retn
  1049                              <1> 
  1050                              <1> loc_gfc_get_fat_free_clusters:
  1051                              <1> 	;mov	eax, 2
  1052 00007D74 B002                <1> 	mov	al, 2
  1053                              <1> 	;mov	[FAT_CurrentCluster], eax
  1054                              <1> loc_gfc_loop_get_next_cluster:
  1055 00007D76 E8EB4F0000          <1> 	call	get_next_cluster
  1056 00007D7B 730E                <1> 	jnc	short loc_gfc_free_fat_clusters_cont
  1057 00007D7D 21C0                <1> 	and	eax, eax
  1058 00007D7F 7411                <1> 	jz	short loc_gfc_pass_inc_free_cluster_count
  1059                              <1>  
  1060                              <1> retn_from_get_free_fat_clusters:
  1061 00007D81 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors] ; Free clusters !
  1062                              <1> retn_from_get_free_fat32_clusters:
  1063 00007D84 0FB65E13            <1>         movzx	ebx, byte [esi+LD_BPB+BPB_SecPerClust]
  1064 00007D88 F7E3                <1>       	mul	ebx
  1065                              <1> 	;mov	[esi+LD_FreeSectors], eax ; Free sectors
  1066                              <1> retn_get_free_sectors_calc:
  1067 00007D8A C3                  <1> 	retn
  1068                              <1> 
  1069                              <1> loc_gfc_free_fat_clusters_cont:
  1070 00007D8B 09C0                <1> 	or	eax, eax
  1071 00007D8D 7503                <1> 	jnz	short loc_gfc_pass_inc_free_cluster_count
  1072 00007D8F FF4674              <1> 	inc	dword [esi+LD_FreeSectors] ; Free clusters !
  1073                              <1>    
  1074                              <1> loc_gfc_pass_inc_free_cluster_count:
  1075                              <1> 	;mov	eax, [FAT_CurrentCluster]
  1076 00007D92 89C8                <1> 	mov	eax, ecx ; [FAT_CurrentCluster]
  1077 00007D94 3B4678              <1> 	cmp	eax, [esi+LD_Clusters]
  1078 00007D97 77E8                <1> 	ja	short retn_from_get_free_fat_clusters
  1079 00007D99 40                  <1> 	inc	eax
  1080                              <1> 	;mov	[FAT_CurrentCluster], eax
  1081 00007D9A EBDA                <1> 	jmp	short loc_gfc_loop_get_next_cluster
  1082                              <1> 
  1083                              <1> floppy_drv_init:
  1084                              <1> 	; 09/12/2017
  1085                              <1> 	; 06/07/2016
  1086                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1087                              <1> 	; 24/07/2011
  1088                              <1> 	; 04/07/2009
  1089                              <1> 	; INPUT ->
  1090                              <1> 	;	DL = Drive number (0,1)
  1091                              <1> 	; OUTPUT ->
  1092                              <1> 	;	BL = drive name
  1093                              <1> 	;	BH = drive number
  1094                              <1> 	;	ESI = Logical DOS drv description table
  1095                              <1> 	;	EAX = Volume serial number
  1096                              <1>  
  1097 00007D9C BE[FE6D0000]        <1> 	mov	esi, fd0_type ; 10/01/2016
  1098 00007DA1 BF00010900          <1> 	mov	edi, Logical_DOSDisks
  1099 00007DA6 08D2                <1> 	or	dl, dl
  1100 00007DA8 7407                <1> 	jz	short loc_drv_init_fd0_fd1
  1101 00007DAA 81C700010000        <1> 	add	edi, 100h
  1102 00007DB0 46                  <1> 	inc	esi ; fd1_type ; 10/01/2016
  1103                              <1> loc_drv_init_fd0_fd1:
  1104 00007DB1 C6477E00            <1> 	mov	byte [edi+LD_MediaChanged], 0
  1105 00007DB5 803E01              <1> 	cmp	byte [esi], 1 ; type (>0 if it is existing) 
  1106                              <1> 		; 4 = 1.44 MB, 80 track, 3 1/2"
  1107 00007DB8 7221                <1> 	jb	short read_fd_boot_sector_retn
  1108 00007DBA 885702              <1> 	mov	[edi+LD_PhyDrvNo], dl
  1109                              <1> read_fd_boot_sector:
  1110 00007DBD 30F6                <1> 	xor	dh, dh
  1111 00007DBF B904000000          <1> 	mov	ecx, 4 ; Retry Count
  1112                              <1> read_fd_boot_sector_again:
  1113 00007DC4 51                  <1> 	push 	ecx
  1114                              <1> 	;mov	cx, 1
  1115 00007DC5 B101                <1> 	mov	cl, 1
  1116 00007DC7 66B80102            <1> 	mov	ax, 0201h ; Read 1 sector
  1117 00007DCB BB[A68F0100]        <1> 	mov	ebx, DOSBootSectorBuff
  1118 00007DD0 E854D4FFFF          <1> 	call	int13h
  1119 00007DD5 59                  <1> 	pop	ecx
  1120 00007DD6 7304                <1> 	jnc	short use_fd_boot_sector_params
  1121 00007DD8 E2EA                <1> 	loop	read_fd_boot_sector_again
  1122                              <1> 
  1123                              <1> read_fd_boot_sector_stc_retn:
  1124 00007DDA F9                  <1> 	stc
  1125                              <1> read_fd_boot_sector_retn:
  1126 00007DDB C3                  <1> 	retn
  1127                              <1> 
  1128                              <1> use_fd_boot_sector_params:
  1129                              <1> 	;mov	esi, DOSBootSectorBuff
  1130 00007DDC 89DE                <1> 	mov	esi, ebx
  1131 00007DDE 6681BEFE01000055AA  <1> 	cmp	word [esi+BS_Validation], 0AA55h
  1132 00007DE7 75F1                <1> 	jne	short read_fd_boot_sector_stc_retn
  1133 00007DE9 66817E035346        <1>         cmp     word [esi+bs_FS_Identifier], 'SF'
  1134 00007DEF 0F85A2000000        <1>         jne     use_fd_fatfs_boot_sector_params
  1135                              <1> 	;
  1136 00007DF5 8A462D              <1> 	mov	al, [esi+bs_FS_LBA_Ready]
  1137 00007DF8 884705              <1> 	mov	[edi+LD_FS_LBAYes], al
  1138                              <1> 	;
  1139                              <1> 	; 03/01/2010 CHS -> DOS FAT/BPB compatibility fix
  1140 00007DFB 8A4608              <1> 	mov	al, [esi+bs_FS_MediaAttrib]
  1141 00007DFE 884706              <1> 	mov	[edi+LD_FS_MediaAttrib], al
  1142                              <1> 	;
  1143 00007E01 8A460A              <1>         mov	al, [esi+bs_FS_VersionMaj]
  1144 00007E04 884707              <1> 	mov	byte [edi+LD_FS_VersionMajor], al
  1145 00007E07 668B4606            <1> 	mov	ax, [esi+bs_FS_BytesPerSec]
  1146 00007E0B 66894711            <1> 	mov	[edi+LD_FS_BytesPerSec], ax
  1147 00007E0F 8A462E              <1> 	mov	al, [esi+bs_FS_SecPerTrack]
  1148 00007E12 28E4                <1> 	sub	ah, ah ; 09/12/2017
  1149 00007E14 6689471E            <1> 	mov	[edi+LD_FS_SecPerTrack], ax
  1150 00007E18 8A462F              <1> 	mov	al, [esi+bs_FS_Heads]
  1151 00007E1B 66894720            <1> 	mov	[edi+LD_FS_NumHeads], ax
  1152                              <1> 	;
  1153 00007E1F 8B4628              <1> 	mov	eax, [esi+bs_FS_UnDelDirD]
  1154 00007E22 894722              <1> 	mov	[edi+LD_FS_UnDelDirD], eax
  1155 00007E25 8B4618              <1> 	mov	eax, [esi+bs_FS_MATLocation]
  1156 00007E28 89470C              <1> 	mov	[edi+LD_FS_MATLocation], eax
  1157 00007E2B 8B461C              <1> 	mov	eax, [esi+bs_FS_RootDirD]
  1158 00007E2E 894708              <1> 	mov	[edi+LD_FS_RootDirD], eax
  1159 00007E31 8B460C              <1> 	mov	eax, [esi+bs_FS_BeginSector]
  1160 00007E34 89476C              <1> 	mov	[edi+LD_FS_BeginSector], eax
  1161 00007E37 8B4610              <1> 	mov	eax, [esi+bs_FS_VolumeSize]
  1162 00007E3A 894770              <1> 	mov	[edi+LD_FS_VolumeSize], eax
  1163                              <1> 	;		
  1164 00007E3D 89FE                <1> 	mov	esi, edi
  1165 00007E3F 8B460C              <1>  	mov	eax, [esi+LD_FS_MATLocation]
  1166                              <1> 	;add	eax, [edi+LD_FS_BeginSector]
  1167                              <1> read_fd_MAT_sector_again:
  1168                              <1> 	;mov	ebx, DOSBootSectorBuff
  1169                              <1> 	;mov	ecx, 1
  1170 00007E42 B101                <1> 	mov	cl, 1
  1171 00007E44 E81AAD0000          <1> 	call	chs_read
  1172 00007E49 89DE                <1> 	mov	esi, ebx
  1173 00007E4B 7301                <1> 	jnc	short use_fdfs_mat_sector_params
  1174                              <1> 	;jmp	short read_fd_boot_sector_retn
  1175 00007E4D C3                  <1> 	retn
  1176                              <1> use_fdfs_mat_sector_params:
  1177 00007E4E 8B460C              <1> 	mov	eax, [esi+FS_MAT_DATLocation]
  1178 00007E51 894714              <1> 	mov	[edi+LD_FS_DATLocation], eax
  1179 00007E54 8B4610              <1> 	mov	eax, [esi+FS_MAT_DATScount]
  1180 00007E57 894718              <1> 	mov	[edi+LD_FS_DATSectors], eax
  1181 00007E5A 8B4714              <1> 	mov	eax, [edi+FS_MAT_FreeSectors]
  1182 00007E5D 894774              <1> 	mov	[edi+LD_FS_FreeSectors], eax
  1183 00007E60 8B4618              <1> 	mov	eax, [esi+FS_MAT_FirstFreeSector]
  1184 00007E63 894778              <1> 	mov	[edi+LD_FS_FirstFreeSector], eax
  1185                              <1> 	;
  1186 00007E66 89FE                <1> 	mov	esi, edi
  1187 00007E68 8B4608              <1>  	mov	eax, [esi+LD_FS_RootDirD]
  1188                              <1> read_fd_RDT_sector_again:
  1189                              <1> 	;mov	ebx, DOSBootSectorBuff
  1190                              <1> 	;mov	cx, 1
  1191 00007E6B B101                <1> 	mov	cl, 1
  1192 00007E6D E8F1AC0000          <1> 	call	chs_read
  1193 00007E72 89DE                <1> 	mov	esi, ebx
  1194 00007E74 7220                <1> 	jc	short read_fd_RDT_sector_retn
  1195                              <1> use_fdfs_RDT_sector_params:
  1196 00007E76 8B461C              <1> 	mov	eax, [esi+FS_RDT_VolumeSerialNo]
  1197 00007E79 894728              <1> 	mov	[edi+LD_FS_VolumeSerial], eax
  1198 00007E7C 57                  <1> 	push	edi
  1199                              <1> 	;mov	ecx, 16
  1200 00007E7D B110                <1> 	mov	cl, 16	
  1201 00007E7F 83C640              <1> 	add	esi, FS_RDT_VolumeName
  1202 00007E82 83C72C              <1> 	add	edi, LD_FS_VolumeName
  1203 00007E85 F3A5                <1> 	rep	movsd ; 64 bytes
  1204 00007E87 5E                  <1> 	pop	esi
  1205 00007E88 C6460300            <1> 	mov	byte [esi+LD_FATType], 0
  1206 00007E8C C64604A1            <1> 	mov	byte [esi+LD_FSType], 0A1h  
  1207 00007E90 E9A5000000          <1>         jmp     loc_cont_use_fd_boot_sector_params
  1208                              <1> 
  1209                              <1> read_fd_RDT_sector_stc_retn:
  1210 00007E95 F9                  <1> 	stc
  1211                              <1> read_fd_RDT_sector_retn:
  1212 00007E96 C3                  <1> 	retn
  1213                              <1> 
  1214                              <1> use_fd_fatfs_boot_sector_params:
  1215 00007E97 807E2629            <1> 	cmp	byte [esi+BS_BootSig], 29h
  1216 00007E9B 75F8                <1> 	jne	short read_fd_RDT_sector_stc_retn
  1217 00007E9D 807E15F0            <1> 	cmp	byte [esi+BPB_Media], 0F0h
  1218 00007EA1 72F3                <1> 	jb	short read_fd_RDT_sector_retn
  1219 00007EA3 57                  <1> 	push	edi
  1220 00007EA4 83C706              <1> 	add	edi, LD_BPB
  1221                              <1> 	;mov	ecx, 16
  1222 00007EA7 B110                <1> 	mov	cl, 16
  1223 00007EA9 F3A5                <1> 	rep	movsd ; 64 bytes 
  1224 00007EAB 5E                  <1> 	pop	esi
  1225 00007EAC 31C0                <1> 	xor	eax, eax
  1226 00007EAE 89466C              <1> 	mov	[esi+LD_StartSector], eax ; 0
  1227 00007EB1 668B461C            <1> 	mov	ax, [esi+LD_BPB+BPB_FATSz16]
  1228 00007EB5 8A4E16              <1> 	mov	cl, [esi+LD_BPB+BPB_NumFATs] 
  1229 00007EB8 F7E1                <1>   	mul	ecx
  1230                              <1> 	; edx = 0 !
  1231 00007EBA 668B5614            <1> 	mov	dx, [esi+LD_BPB+BPB_RsvdSecCnt]
  1232 00007EBE 66895660            <1> 	mov	[esi+LD_FATBegin], dx
  1233                              <1> 	;add	eax, edx
  1234 00007EC2 6601D0              <1> 	add	ax, dx
  1235 00007EC5 894664              <1> 	mov	[esi+LD_ROOTBegin], eax
  1236 00007EC8 894668              <1> 	mov	[esi+LD_DATABegin], eax 
  1237 00007ECB 668B5617            <1> 	mov	dx, [esi+LD_BPB+BPB_RootEntCnt]
  1238                              <1> 	;;shl	edx, 5 ; * 32 (Size of a directory entry)
  1239                              <1> 	;shl	dx, 5
  1240                              <1> 	;;add	edx, 511
  1241                              <1> 	;add	dx, 511
  1242                              <1> 	;;shr	edx, 9 ; edx = ((edx*32)+511) / 512
  1243                              <1> 	;shr	dx, 9
  1244 00007ECF 6683C20F            <1> 	add	dx, 15 ; 06/07/2016 (+(512/32)-1)
  1245 00007ED3 66C1EA04            <1> 	shr	dx, 4 ; / 16 (==16 entries per sector)
  1246 00007ED7 015668              <1> 	add 	[esi+LD_DATABegin], edx ; + rd sectors
  1247                              <1> 	;movzx	eax, word [esi+LD_BPB+BPB_TotalSec16]
  1248 00007EDA 668B4619            <1> 	mov	ax, [esi+LD_BPB+BPB_TotalSec16]
  1249 00007EDE 894670              <1> 	mov	[esi+LD_TotalSectors], eax
  1250 00007EE1 2B4668              <1> 	sub	eax, [esi+LD_DATABegin]
  1251                              <1>   	;movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust]
  1252 00007EE4 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]  
  1253 00007EE7 80F901              <1> 	cmp	cl, 1
  1254 00007EEA 7605                <1> 	jna	short save_fd_fatfs_cluster_count
  1255                              <1> 	;sub	edx, edx
  1256 00007EEC 6629D2              <1> 	sub	dx, dx ; 0
  1257                              <1> 	;sub	dl, dl ; 06/07/2016
  1258 00007EEF F7F1                <1> 	div	ecx
  1259                              <1> save_fd_fatfs_cluster_count:
  1260 00007EF1 894678              <1> 	mov	[esi+LD_Clusters], eax
  1261                              <1> 
  1262                              <1>       ; Maximum Valid Cluster Number = EAX +1
  1263                              <1>       ; with 2 reserved clusters= EAX +2
  1264                              <1>  
  1265                              <1> reset_FAT_buffer_decriptors:
  1266 00007EF4 29C0                <1> 	sub	eax, eax ; 0  
  1267 00007EF6 A2[AA910100]        <1> 	mov	[FAT_BuffValidData], al ; 0
  1268 00007EFB A2[AB910100]        <1> 	mov	[FAT_BuffDrvName], al ; 0
  1269 00007F00 A3[AE910100]        <1> 	mov	[FAT_BuffSector], eax ; 0
  1270                              <1> 
  1271                              <1> read_fd_FAT_sectors:
  1272 00007F05 BB001C0900          <1>   	mov	ebx, FAT_Buffer
  1273 00007F0A 668B4614            <1> 	mov	ax, [esi+LD_BPB+BPB_RsvdSecCnt]
  1274                              <1> 	;mov	ecx, 3
  1275 00007F0E B103                <1> 	mov	cl, 3 ; 3 sectors
  1276 00007F10 E84EAC0000          <1> 	call	chs_read
  1277 00007F15 7240                <1> 	jc	short read_fd_FAT_sectors_retn
  1278                              <1> use_fd_FAT_sectors:
  1279 00007F17 8A4602              <1> 	mov	al, [esi+LD_PhyDrvNo]
  1280 00007F1A 0441                <1> 	add	al, 'A' 
  1281 00007F1C A2[AB910100]        <1> 	mov	[FAT_BuffDrvName], al 
  1282 00007F21 C605[AA910100]01    <1>  	mov	byte [FAT_BuffValidData], 1
  1283 00007F28 E82B000000          <1> 	call	fd_init_calculate_free_clusters
  1284 00007F2D 7228                <1> 	jc	short read_fd_FAT_sectors_retn
  1285                              <1>   
  1286                              <1> loc_use_fd_boot_sector_params_FAT:
  1287 00007F2F C6460301            <1> 	mov	byte [esi+LD_FATType], 1 ; FAT 12
  1288 00007F33 C6460401            <1> 	mov	byte [esi+LD_FSType], 1
  1289 00007F37 8B462D              <1>         mov     eax, [esi+LD_BPB+VolumeID]
  1290                              <1> loc_cont_use_fd_boot_sector_params:
  1291 00007F3A 8A7E02              <1> 	mov	bh, [esi+LD_PhyDrvNo]
  1292 00007F3D 887E7D              <1> 	mov	[esi+LD_DParamEntry], bh
  1293 00007F40 88FB                <1> 	mov	bl, bh
  1294 00007F42 80C341              <1> 	add	bl, 'A'
  1295 00007F45 881E                <1> 	mov	byte [esi+LD_Name], bl
  1296 00007F47 C6460101            <1> 	mov	byte [esi+LD_DiskType], 1
  1297 00007F4B C6460500            <1> 	mov	byte [esi+LD_LBAYes], 0
  1298 00007F4F C6467C00            <1> 	mov	byte [esi+LD_PartitionEntry], 0
  1299 00007F53 C6467E06            <1> 	mov	byte [esi+LD_MediaChanged], 6 ; Volume Name Reset
  1300                              <1> 
  1301                              <1> read_fd_FAT_sectors_retn:
  1302 00007F57 C3                  <1> 	retn   
  1303                              <1> 
  1304                              <1> fd_init_calculate_free_clusters:
  1305                              <1> 	; 09/12/2017
  1306                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1307                              <1> 	; 04/07/2009
  1308                              <1> 	; INPUT ->
  1309                              <1> 	;     ESI = Logical DOS drive description table address
  1310                              <1> 	; OUTPUT ->
  1311                              <1> 	;    [ESI+LD_FreeSectors] will be set
  1312                              <1> 	
  1313 00007F58 29C0                <1> 	sub	eax, eax
  1314 00007F5A 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; 0
  1315 00007F5D B002                <1> 	mov	al, 2 ; eax = 2
  1316                              <1> 
  1317                              <1> fd_init_loop_get_next_cluster:
  1318 00007F5F E830000000          <1> 	call	fd_init_get_next_cluster
  1319 00007F64 722D                <1> 	jc	short fd_init_calculate_free_clusters_retn
  1320                              <1> 
  1321                              <1> fd_init_free_fat_clusters:
  1322                              <1> 	;cmp 	eax, 0
  1323                              <1> 	;ja	short fd_init_pass_inc_free_cluster_count
  1324                              <1> 	;and	eax, eax
  1325                              <1> 	;jnz	short fd_init_pass_inc_free_cluster_count
  1326 00007F66 6621C0              <1> 	and	ax, ax
  1327 00007F69 7504                <1> 	jnz	short fd_init_pass_inc_free_cluster_count
  1328                              <1> 	;inc	dword [esi+LD_FreeSectors]
  1329 00007F6B 66FF4674            <1>         inc	word [esi+LD_FreeSectors]
  1330                              <1>     
  1331                              <1> fd_init_pass_inc_free_cluster_count:
  1332                              <1>   	;mov	eax, [FAT_CurrentCluster]
  1333 00007F6F 66A1[A6910100]      <1> 	mov	ax, [FAT_CurrentCluster]
  1334                              <1> 	;cmp	eax, [esi+LD_Clusters]
  1335 00007F75 663B4678            <1> 	cmp	ax, [esi+LD_Clusters]
  1336 00007F79 7704                <1> 	ja	short short retn_from_fd_init_calculate_free_clusters
  1337                              <1> 	;inc	eax
  1338 00007F7B 6640                <1> 	inc	ax
  1339 00007F7D EBE0                <1> 	jmp	short fd_init_loop_get_next_cluster
  1340                              <1> 
  1341                              <1> retn_from_fd_init_calculate_free_clusters:
  1342 00007F7F 8A4613              <1>   	mov	al, [esi+LD_BPB+BPB_SecPerClust]
  1343 00007F82 3C01                <1>   	cmp	al, 1
  1344 00007F84 760D                <1> 	jna	short fd_init_calculate_free_clusters_retn
  1345                              <1> 	;movzx	eax, al
  1346 00007F86 30E4                <1> 	xor	ah, ah ; 09/12/2017
  1347                              <1> 	;mov	ecx, [esi+LD_FreeSectors]
  1348 00007F88 668B4E74            <1> 	mov	cx, [esi+LD_FreeSectors] ; Count of free clusters
  1349                              <1>   	;mul	ecx
  1350 00007F8C 66F7E1              <1> 	mul	cx
  1351                              <1> 	;mov	[esi+LD_FreeSectors], eax
  1352 00007F8F 66894674            <1> 	mov	[esi+LD_FreeSectors], ax
  1353                              <1> fd_init_calculate_free_clusters_retn:
  1354 00007F93 C3                  <1> 	retn
  1355                              <1> 
  1356                              <1> fd_init_get_next_cluster:
  1357                              <1> 	; 04/02/2016
  1358                              <1> 	; 02/02/2016
  1359                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1360                              <1> 	; 04/07/2009
  1361                              <1> 	; INPUT ->
  1362                              <1> 	;    EAX = Current cluster
  1363                              <1> 	;    ESI = Logical DOS drive description table address
  1364                              <1> 	;    EDX = 0
  1365                              <1> 	; OUTPUT ->
  1366                              <1> 	;    EAX = Next cluster
  1367                              <1> 
  1368 00007F94 A3[A6910100]        <1> 	mov	[FAT_CurrentCluster], eax
  1369                              <1> fd_init_get_next_cluster_readnext:
  1370 00007F99 29D2                <1> 	sub	edx, edx ; 0
  1371 00007F9B BB00040000          <1>   	mov	ebx, 1024 ; 400h
  1372 00007FA0 F7F3                <1>   	div	ebx
  1373                              <1>   	; EAX = Count of 3 FAT sectors
  1374                              <1>   	; EDX = Buffer entry index
  1375 00007FA2 89C1                <1> 	mov	ecx, eax
  1376                              <1> 	;mov	eax, 3
  1377 00007FA4 B003                <1> 	mov	al, 3
  1378 00007FA6 F7E2                <1> 	mul	edx ; Multiply by 3
  1379 00007FA8 66D1E8              <1> 	shr	ax, 1 ; Divide by 2
  1380 00007FAB 89C3                <1> 	mov	ebx, eax ; Buffer byte offset
  1381 00007FAD 81C3001C0900        <1> 	add	ebx, FAT_Buffer
  1382 00007FB3 89C8                <1> 	mov	eax, ecx
  1383                              <1> 	;mov	edx, 3
  1384 00007FB5 66BA0300            <1> 	mov	dx, 3
  1385 00007FB9 F7E2                <1> 	mul	edx 
  1386                              <1>   	; EAX = FAT Beginning Sector
  1387                              <1> 	; EDX = 0
  1388 00007FBB 8A0E                <1> 	mov	cl, [esi+LD_Name]
  1389                              <1> 	;cmp	byte [FAT_BuffValidData], 0
  1390                              <1> 	;jna	short fd_init_load_FAT_sectors0
  1391 00007FBD 3A0D[AB910100]      <1> 	cmp	cl, [FAT_BuffDrvName]
  1392 00007FC3 751E                <1> 	jne	short fd_init_load_FAT_sectors0
  1393 00007FC5 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
  1394 00007FCB 751C                <1> 	jne	short fd_init_load_FAT_sectors1
  1395                              <1> 	;mov	eax, [FAT_CurrentCluster]
  1396 00007FCD A0[A6910100]        <1> 	mov	al, [FAT_CurrentCluster]
  1397                              <1> 	;shr	eax, 1
  1398 00007FD2 D0E8                <1> 	shr	al, 1
  1399 00007FD4 668B03              <1> 	mov	ax, [ebx]
  1400 00007FD7 7306                <1>   	jnc	short fd_init_gnc_even
  1401 00007FD9 66C1E804            <1> 	shr	ax, 4
  1402                              <1> fd_init_gnc_clc_retn:
  1403 00007FDD F8                  <1> 	clc
  1404 00007FDE C3                  <1> 	retn
  1405                              <1> 
  1406                              <1> fd_init_gnc_even:
  1407 00007FDF 80E40F              <1> 	and	ah, 0Fh
  1408 00007FE2 C3                  <1> 	retn
  1409                              <1> 
  1410                              <1> fd_init_load_FAT_sectors0:
  1411 00007FE3 880D[AB910100]      <1> 	mov 	[FAT_BuffDrvName], cl
  1412                              <1> fd_init_load_FAT_sectors1:
  1413 00007FE9 C605[AA910100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  1414 00007FF0 A3[AE910100]        <1> 	mov	[FAT_BuffSector], eax
  1415 00007FF5 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1416 00007FF8 BB001C0900          <1>  	mov	ebx, FAT_Buffer
  1417                              <1> 	;movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
  1418 00007FFD 668B4E1C            <1> 	mov	cx, [esi+LD_BPB+BPB_FATSz16]
  1419 00008001 662B0D[AE910100]    <1> 	sub	cx, [FAT_BuffSector]
  1420                              <1>         ;cmp	ecx, 3
  1421 00008008 6683F903            <1> 	cmp	cx, 3
  1422 0000800C 7605                <1> 	jna	short fdinit_pass_fix_sector_count_3
  1423                              <1> 	;mov	ecx, 3
  1424 0000800E B903000000          <1> 	mov	ecx, 3
  1425                              <1> fdinit_pass_fix_sector_count_3:  
  1426 00008013 E84BAB0000          <1> 	call	chs_read
  1427 00008018 730D                <1> 	jnc	short fd_init_FAT_sectors_no_load_error
  1428 0000801A C605[AA910100]00    <1> 	mov	byte [FAT_BuffValidData], 0
  1429                              <1> 		; Drv not ready or read Error !
  1430 00008021 B80F000000          <1> 	mov	eax, ERR_DRV_NOT_RDY ; 15
  1431                              <1> 	;xor	edx, edx
  1432 00008026 C3                  <1> 	retn
  1433                              <1> 
  1434                              <1> fd_init_FAT_sectors_no_load_error:
  1435 00008027 C605[AA910100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  1436 0000802E A1[A6910100]        <1> 	mov	eax, [FAT_CurrentCluster]
  1437 00008033 E961FFFFFF          <1>         jmp     fd_init_get_next_cluster_readnext
  1438                              <1> 
  1439                              <1> get_FAT_volume_name:
  1440                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1441                              <1> 	; 12/09/2009
  1442                              <1> 	; INPUT ->
  1443                              <1> 	;	BH = Logical DOS drive number (0,1,2,3,4 ...)
  1444                              <1> 	;       BL = 0
  1445                              <1> 	; OUTPUT ->
  1446                              <1> 	;	CF = 0 -> ESI = Volume name address
  1447                              <1> 	; 	CF = 1 -> Root volume name not found
  1448                              <1> 
  1449                              <1> 	;mov 	ah, 0FFh
  1450                              <1> 	;mov 	al, [Last_Dos_DiskNo]
  1451                              <1> 	;cmp 	al, bh
  1452                              <1> 	;jb     short loc_gfvn_dir_load_err
  1453                              <1> 
  1454 00008038 89DE                <1> 	mov	esi, ebx
  1455 0000803A 81E600FF0000        <1> 	and	esi, 0FF00h ; esi = bh
  1456 00008040 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1457 00008046 8A06                <1> 	mov     al, [esi+LD_Name]
  1458 00008048 8A6603              <1> 	mov     ah, [esi+LD_FATType]
  1459 0000804B 80FC01              <1> 	cmp     ah, 1
  1460 0000804E 7210                <1> 	jb    	short loc_gfvn_dir_load_err
  1461 00008050 3C41                <1> 	cmp 	al, 'A'
  1462 00008052 720C                <1> 	jb      short loc_gfvn_dir_load_err
  1463 00008054 80FC02              <1> 	cmp 	ah, 2 
  1464 00008057 7708                <1> 	ja      short get_FAT32_root_cluster
  1465                              <1> 	
  1466 00008059 E8634E0000          <1> 	call    load_FAT_root_directory
  1467 0000805E 730B                <1> 	jnc     short loc_get_volume_name
  1468                              <1> 
  1469                              <1> loc_gfvn_dir_load_err:
  1470 00008060 C3                  <1> 	retn
  1471                              <1> 
  1472                              <1> get_FAT32_root_cluster:
  1473 00008061 8B4632              <1> 	mov	eax, [esi+LD_BPB+BPB_RootClus]
  1474 00008064 E8E34E0000          <1> 	call    load_FAT_sub_directory
  1475 00008069 7224                <1> 	jc	short loc_get_volume_name_retn
  1476                              <1> 
  1477                              <1> loc_get_volume_name:
  1478 0000806B BE00000800          <1>         mov     esi, Directory_Buffer
  1479 00008070 6631C9              <1> 	xor	cx, cx ; 0
  1480                              <1> check_root_volume_name:
  1481 00008073 8A06                <1> 	mov	al, [esi]
  1482 00008075 08C0                <1> 	or      al, al
  1483 00008077 7416                <1> 	jz      short loc_get_volume_name_retn
  1484 00008079 807E0B08            <1> 	cmp     byte [esi+0Bh], 08h
  1485 0000807D 7410                <1> 	je      short loc_get_volume_name_retn
  1486 0000807F 663B0D[BF910100]    <1> 	cmp     cx, [DirBuff_LastEntry]
  1487 00008086 7308                <1> 	jnb     short pass_check_root_volume_name
  1488 00008088 6641                <1> 	inc     cx
  1489 0000808A 83C620              <1> 	add     esi, 32
  1490 0000808D EBE4                <1> 	jmp     short check_root_volume_name
  1491                              <1> 
  1492                              <1> loc_get_volume_name_retn:
  1493 0000808F C3                  <1> 	retn
  1494                              <1>     
  1495                              <1> pass_check_root_volume_name:
  1496 00008090 803D[BB910100]03    <1> 	cmp	byte [DirBuff_FATType], 3
  1497 00008097 7230                <1> 	jb	short loc_get_volume_name_retn_xor
  1498                              <1> 
  1499 00008099 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1500 0000809E BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1501 000080A3 31C0                <1> 	xor	eax, eax
  1502 000080A5 8A25[BA910100]      <1> 	mov	ah, [DirBuff_DRV]
  1503 000080AB 80EC41              <1> 	sub	ah, 'A' 
  1504 000080AE 01C6                <1> 	add	esi, eax
  1505 000080B0 A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
  1506 000080B5 E8AC4C0000          <1> 	call	get_next_cluster
  1507 000080BA 7305                <1> 	jnc 	short loc_gfvn_load_FAT32_dir_cluster
  1508                              <1>   	
  1509 000080BC 83F801              <1> 	cmp     eax, 1
  1510 000080BF F5                  <1> 	cmc
  1511 000080C0 C3                  <1> 	retn
  1512                              <1>   
  1513                              <1> loc_gfvn_load_FAT32_dir_cluster:
  1514 000080C1 E8864E0000          <1> 	call	load_FAT_sub_directory
  1515 000080C6 73A3                <1> 	jnc	short loc_get_volume_name
  1516 000080C8 C3                  <1> 	retn
  1517                              <1> 
  1518                              <1> loc_get_volume_name_retn_xor:
  1519 000080C9 31C0                <1> 	xor 	eax, eax
  1520 000080CB C3                  <1> 	retn
  1521                              <1> 
  1522                              <1> get_media_change_status:
  1523                              <1> 	; 10/01/2016 (TRDOS 386 = TRDOS v2.0)
  1524                              <1> 	; 09/09/2009
  1525                              <1> 	; INPUT:
  1526                              <1> 	;     DL = Drive number (physical)
  1527                              <1> 	; OUTPUT: clc & AH = 6 media changed
  1528                              <1> 	;     clc & AH = 0 media not changed         
  1529                              <1> 	;     stc -> Drive not ready or an error 
  1530                              <1>   
  1531 000080CC B416                <1> 	mov	ah, 16h
  1532 000080CE E856D1FFFF          <1>   	call	int13h
  1533 000080D3 80FC06              <1> 	cmp	ah, 06h
  1534 000080D6 7405                <1> 	je	short loc_gmc_status_retn
  1535 000080D8 08E4                <1> 	or	ah, ah
  1536 000080DA 7401                <1> 	jz	short loc_gmc_status_retn
  1537                              <1> loc_gmc_status_stc_retn:    
  1538 000080DC F9                  <1> 	stc
  1539                              <1> loc_gmc_status_retn:
  1540 000080DD C3                  <1> 	retn
  3081                                  %include 'trdosk3.s' ; 06/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - MAIN PROGRAM : trdosk3.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 31/12/2017
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 06/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; MAINPROG.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; MAINPROG.ASM [ TRDOS KERNEL - COMMAND EXECUTER SECTION - MAIN PROGRAM ]
    14                              <1> ; (c) 2004-2011  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/11/2011
    15                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ] Last Update: 09/11/2011
    16                              <1> ; DIR.ASM [ DIRECTORY FUNCTIONS ] Last Update: 09/10/2011
    17                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
    18                              <1> 
    19                              <1> change_current_drive:
    20                              <1> 	; 16/10/2016
    21                              <1> 	; 02/02/2016
    22                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
    23                              <1> 	; 18/08/2011
    24                              <1> 	; 09/09/2009
    25                              <1> 	; INPUT:
    26                              <1> 	;   DL = Logical DOS Drive Number
    27                              <1> 	; OUTPUT:
    28                              <1> 	;  cf=1 -> Not successful
    29                              <1> 	;   EAX = Error code
    30                              <1> 	;  cf=0 ->
    31                              <1> 	;   EAX = 0 (successful)
    32                              <1> 
    33 000080DE 31DB                <1> 	xor	ebx, ebx
    34 000080E0 88D7                <1> 	mov	bh, dl
    35                              <1> 
    36                              <1> 	;cmp	dl, 1
    37                              <1> 	;jna	short loc_ccdrv_initial_media_change_check
    38                              <1> 	;cmp	bh, [Last_Dos_DiskNo]
    39                              <1> 	;ja	short loc_ccdrv_drive_not_ready_err
    40                              <1> 
    41                              <1> loc_ccdrv_initial_media_change_check:
    42 000080E2 BE00010900          <1> 	mov	esi, Logical_DOSDisks
    43 000080E7 01DE                <1> 	add	esi, ebx
    44                              <1> loc_ccdrv_dos_drive_name_check:
    45 000080E9 80FA02              <1> 	cmp	dl, 2
    46 000080EC 720F                <1> 	jb	short loc_ccdrv_dos_drive_name_check_ok
    47                              <1> 
    48 000080EE 8A06                <1> 	mov	al, [esi+LD_Name]
    49 000080F0 2C41                <1> 	sub	al, 'A'
    50 000080F2 38D0                <1> 	cmp	al, dl
    51 000080F4 7407                <1> 	je	short loc_ccdrv_dos_drive_name_check_ok
    52                              <1> 
    53                              <1> loc_ccdrv_drive_not_ready_err:
    54                              <1> 	; 16/10/2016 (15h -> 15)
    55 000080F6 B80F000000          <1> 	mov	eax, 15 ; Drive not ready
    56                              <1> loc_change_current_drive_stc_retn:
    57 000080FB F9                  <1> 	stc
    58 000080FC C3                  <1> 	retn  
    59                              <1> 
    60                              <1> loc_ccdrv_dos_drive_name_check_ok:
    61 000080FD 8A667E              <1> 	mov	ah, [esi+LD_MediaChanged]
    62 00008100 80FC06              <1> 	cmp	ah, 6  ; VOLUME NAME CHECK/MOVE SIGN
    63 00008103 7455                <1> 	je	short loc_ccdrv_get_FAT_volume_name_0
    64                              <1> 
    65 00008105 80FA01              <1> 	cmp	dl, 1
    66 00008108 777D                <1> 	ja	short loc_gmcs_init_drv_hd
    67                              <1> 
    68                              <1> loc_gmcs_init_drv_fd:
    69 0000810A 08E4                <1> 	or	ah, ah 
    70                              <1> 	; AH = 1 is initialization sign (invalid_fd_parameter)
    71 0000810C 7517                <1> 	jnz	short loc_ccdrv_call_fd_init
    72                              <1> 
    73 0000810E E8B9FFFFFF          <1> 	call	get_media_change_status
    74 00008113 72E1                <1> 	jc	short loc_ccdrv_drive_not_ready_err
    75                              <1> 
    76 00008115 20E4                <1> 	and	ah, ah
    77 00008117 7476                <1> 	jz	short loc_change_current_drv3
    78                              <1> 
    79 00008119 80F406              <1> 	xor	ah, 6
    80 0000811C 75D8                <1> 	jnz	short loc_ccdrv_drive_not_ready_err
    81                              <1> 
    82                              <1> loc_ccdrv_call_fd_init_check_vol_id:
    83 0000811E E8440A0000          <1> 	call	get_volume_serial_number
    84 00008123 730D                <1> 	jnc	short loc_ccdrv_check_vol_serial
    85                              <1> 
    86                              <1> loc_ccdrv_call_fd_init:
    87 00008125 E872FCFFFF          <1> 	call	floppy_drv_init
    88 0000812A 731A                <1> 	jnc	short loc_reset_drv_fd_current_dir
    89                              <1> 
    90                              <1> loc_ccdrv_fdinit_fail_retn:
    91                              <1> 	; 16/10/2016
    92 0000812C B80F000000          <1> 	mov	eax, 15 ; Drive not ready
    93 00008131 C3                  <1> 	retn
    94                              <1> 
    95                              <1> loc_ccdrv_check_vol_serial:
    96 00008132 A3[8C8A0100]        <1> 	mov	[Current_VolSerial], eax
    97                              <1> 	;mov	dl, bh
    98 00008137 E860FCFFFF          <1> 	call	floppy_drv_init
    99 0000813C 72EE                <1> 	jc	short loc_ccdrv_fdinit_fail_retn
   100                              <1> 
   101 0000813E 3B05[8C8A0100]      <1> 	cmp	eax, [Current_VolSerial]
   102 00008144 7445                <1> 	je	short loc_change_current_drv2
   103                              <1> 
   104                              <1> loc_reset_drv_fd_current_dir:
   105 00008146 31C0                <1> 	xor	eax, eax              
   106 00008148 88467F              <1>         mov	[esi+LD_CDirLevel], al
   107 0000814B 89F7                <1> 	mov	edi, esi
   108 0000814D 81C780000000        <1> 	add	edi, LD_CurrentDirectory
   109 00008153 B920000000          <1> 	mov	ecx, 32
   110 00008158 F3AB                <1> 	rep	stosd   
   111                              <1>  
   112                              <1> loc_ccdrv_get_FAT_volume_name_0:
   113 0000815A 8A4603              <1> 	mov	al, [esi+LD_FATType]
   114 0000815D 08C0                <1> 	or	al, al
   115 0000815F 742A                <1> 	jz	short loc_change_current_drv2
   116                              <1> 
   117 00008161 56                  <1> 	push	esi 
   118 00008162 3C02                <1> 	cmp	al, 2
   119 00008164 7705                <1> 	ja	short loc_ccdrv_get_FAT32_vol_name
   120                              <1>              
   121                              <1> loc_ccdrv_get_FAT2_16_vol_name:
   122 00008166 83C631              <1> 	add	esi, LD_BPB + VolumeLabel
   123 00008169 EB03                <1> 	jmp	short loc_ccdrv_get_FAT_volume_name_1
   124                              <1> 
   125                              <1> loc_ccdrv_get_FAT32_vol_name:
   126 0000816B 83C64D              <1> 	add	esi, LD_BPB + FAT32_VolLab
   127                              <1> loc_ccdrv_get_FAT_volume_name_1:
   128 0000816E 53                  <1> 	push	ebx
   129 0000816F 56                  <1> 	push	esi
   130 00008170 E8C3FEFFFF          <1> 	call	get_FAT_volume_name
   131 00008175 5F                  <1> 	pop	edi
   132 00008176 5B                  <1> 	pop	ebx
   133                              <1> 	; BL = 0
   134 00008177 720B                <1> 	jc	short loc_change_current_drv1
   135 00008179 20C0                <1> 	and	al, al
   136 0000817B 7407                <1> 	jz	short loc_change_current_drv1
   137                              <1> 
   138                              <1> loc_ccdrv_move_FAT_volume_name:
   139 0000817D B90B000000          <1> 	mov	ecx, 11
   140 00008182 F3A4                <1> 	rep	movsb
   141                              <1> 
   142                              <1> loc_change_current_drv1:
   143 00008184 5E                  <1> 	pop	esi
   144 00008185 EB04                <1> 	jmp	short loc_change_current_drv2
   145                              <1> 
   146                              <1> loc_gmcs_init_drv_hd:
   147 00008187 08E4                <1> 	or	ah, ah
   148 00008189 7404                <1> 	jz	short loc_change_current_drv3
   149                              <1> 	; BL = 0, BH = Logical DOS drive number
   150                              <1> loc_change_current_drv2:
   151 0000818B C6467E00            <1> 	mov	byte [esi+LD_MediaChanged], 0
   152                              <1> loc_change_current_drv3:
   153 0000818F 883D[968A0100]      <1> 	mov	[Current_Drv], bh
   154                              <1> 
   155                              <1> 	;call	restore_current_directory
   156                              <1> 	;retn
   157                              <1> 
   158                              <1> restore_current_directory:
   159                              <1> 	; 11/02/2016
   160                              <1> 	; 15/01/2016 (TRDOS 386 = TRDOS v2.0)
   161                              <1> 	; 25/01/2010
   162                              <1> 	; 12/10/2009
   163                              <1> 	;
   164                              <1> 	; INPUT:
   165                              <1> 	;   ESI = Logical DOS Drive Description Table
   166                              <1> 	;
   167                              <1> 	; OUTPUT:
   168                              <1> 	;   ESI = Logical DOS Drive Description Table
   169                              <1> 	;   EDI = offset Current_Dir_Drv 
   170                              <1> 
   171 00008195 8A4603              <1> 	mov	al, [esi+LD_FATType]
   172 00008198 A2[958A0100]        <1> 	mov	[Current_FATType], al
   173                              <1> 
   174 0000819D 8A26                <1> 	mov	ah, [esi+LD_Name] 
   175 0000819F 8825[978A0100]      <1> 	mov	[Current_Dir_Drv], ah
   176                              <1> 
   177 000081A5 20C0                <1> 	and	al, al
   178 000081A7 741D                <1> 	jz	short loc_restore_FS_current_directory
   179                              <1> 
   180                              <1> loc_restore_FAT_current_directory:
   181 000081A9 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
   182 000081AC 8825[948A0100]      <1> 	mov	[Current_Dir_Level], ah
   183 000081B2 08E4                <1> 	or	ah, ah
   184 000081B4 7416                <1>         jz	short loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster
   185                              <1> 
   186 000081B6 0FB6D4              <1> 	movzx	edx, ah
   187 000081B9 C0E204              <1> 	shl	dl, 4 ; * 16
   188 000081BC 01F2                <1>         add	edx, esi
   189 000081BE 8B828C000000        <1> 	mov	eax, [edx+LD_CurrentDirectory+12]
   190 000081C4 EB2C                <1> 	jmp	short loc_ccdrv_reset_cdir_FAT_fcluster
   191                              <1> 
   192                              <1> loc_restore_FS_current_directory:
   193 000081C6 E8BC4D0000          <1> 	call	load_current_FS_directory 
   194 000081CB C3                  <1> 	retn 
   195                              <1> 
   196                              <1> loc_ccdrv_reset_cdir_FAT_12_16_32_fcluster:
   197 000081CC 3C03                <1> 	cmp	al, 3
   198 000081CE 7205                <1> 	jb	short loc_ccdrv_reset_cdir_FAT_12_16_fcluster
   199                              <1> loc_ccdrv_reset_cdir_FAT32_fcluster:
   200 000081D0 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
   201 000081D3 EB04                <1> 	jmp	short loc_ccdrv_check_rootdir_sign
   202                              <1> loc_ccdrv_reset_cdir_FAT_12_16_fcluster:   
   203 000081D5 30C0                <1> 	xor	al, al  ; xor eax, eax
   204 000081D7 31D2                <1> 	xor	edx, edx
   205                              <1> loc_ccdrv_check_rootdir_sign:
   206 000081D9 80BE8000000000      <1> 	cmp	byte [esi+LD_CurrentDirectory], 0
   207 000081E0 7510                <1> 	jne	short loc_ccdrv_reset_cdir_FAT_fcluster
   208                              <1> loc_ccdrv_set_rootdir_FAT_fcluster:
   209 000081E2 89868C000000        <1>         mov     [esi+LD_CurrentDirectory+12], eax
   210 000081E8 C78680000000524F4F- <1> 	mov	dword [esi+LD_CurrentDirectory], 'ROOT'
   210 000081F1 54                  <1>
   211                              <1> 
   212                              <1> loc_ccdrv_reset_cdir_FAT_fcluster:
   213 000081F2 A3[908A0100]        <1> 	mov	[Current_Dir_FCluster], eax
   214                              <1> 
   215 000081F7 BF[F3910100]        <1> 	mov	edi, PATH_Array
   216 000081FC 89F2                <1> 	mov	edx, esi
   217 000081FE 81C680000000        <1> 	add	esi, LD_CurrentDirectory
   218 00008204 B920000000          <1> 	mov	ecx, 32
   219 00008209 F3A5                <1> 	rep	movsd
   220                              <1> 
   221 0000820B E84C2D0000          <1> 	call	change_prompt_dir_string
   222                              <1> 	
   223 00008210 89D6                <1> 	mov	esi, edx
   224                              <1> 	
   225 00008212 29C0                <1>         sub	eax, eax
   226                              <1>        ;sub	edx, edx
   227 00008214 BF[978A0100]        <1> 	mov	edi, Current_Dir_Drv
   228                              <1> 
   229 00008219 A2[63400100]        <1> 	mov	[Restore_CDIR], al ; 0
   230 0000821E C3                  <1> 	retn
   231                              <1> 
   232                              <1> dos_prompt:
   233                              <1> 	; 06/05/2016
   234                              <1> 	; 30/01/2016
   235                              <1> 	; 29/01/2016
   236                              <1> 	; 16/01/2016 (TRDOS 386 = TRDOS v2.0)
   237                              <1> 	; 15/09/2011
   238                              <1> 	; 13/09/2009
   239                              <1> 	; 2004-2005
   240                              <1> 
   241                              <1> 	; 06/05/2016
   242 0000821F C705[50960100]-     <1> 	mov	dword [mainprog_return_addr], return_from_cmd_interpreter
   242 00008225 [D3820000]          <1>
   243                              <1> 
   244                              <1> loc_TRDOS_prompt:
   245 00008229 BF[968B0100]        <1> 	mov	edi, TextBuffer
   246 0000822E C6075B              <1> 	mov	byte [edi], "["
   247 00008231 47                  <1> 	inc	edi
   248 00008232 BE[B6400100]        <1> 	mov	esi, TRDOSPromptLabel
   249                              <1> get_next_prompt_label_char:
   250 00008237 803E20              <1> 	cmp	byte [esi], 20h
   251 0000823A 7203                <1> 	jb	short pass_prompt_label
   252 0000823C A4                  <1> 	movsb
   253 0000823D EBF8                <1> 	jmp	short get_next_prompt_label_char
   254                              <1> pass_prompt_label:
   255 0000823F C6075D              <1> 	mov	byte [edi], "]"
   256 00008242 47                  <1> 	inc	edi
   257 00008243 C60720              <1> 	mov	byte [edi], 20h
   258 00008246 47                  <1> 	inc	edi
   259 00008247 BE[978A0100]        <1> 	mov	esi, Current_Dir_Drv
   260 0000824C 66A5                <1> 	movsw
   261 0000824E A4                  <1> 	movsb 
   262                              <1> loc_prompt_current_directory:
   263 0000824F 803E20              <1> 	cmp	byte [esi], 20h
   264 00008252 7203                <1> 	jb	short pass_prompt_current_directory
   265 00008254 A4                  <1> 	movsb
   266 00008255 EBF8                <1> 	jmp	short loc_prompt_current_directory  
   267                              <1> pass_prompt_current_directory:
   268 00008257 C6073E              <1> 	mov	byte [edi], '>'
   269 0000825A 47                  <1> 	inc	edi
   270 0000825B C60700              <1> 	mov	byte [edi], 0  
   271 0000825E BE[968B0100]        <1> 	mov	esi, TextBuffer
   272 00008263 E8EDF2FFFF          <1> 	call	print_msg
   273                              <1>         
   274                              <1> 	;sub	bh, bh ; video page = 0
   275                              <1> 	;call	get_cpos ; get cursor position
   276 00008268 668B15[EE890100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
   277 0000826F 8815[F68A0100]      <1> 	mov	[CursorColumn], dl
   278                              <1> 
   279                              <1> 	; 30/01/2016 (to show cursor on the row, again)
   280                              <1> 	; (Initial color attributes of video page 0 is 0)
   281                              <1> 	; (see: 'StartPMP' in trdos386.s)
   282                              <1> 	; 
   283                              <1> 	;mov	edi, 0B8000h ; start of video page 0
   284                              <1> 	;movzx	ecx, dl ; column	 
   285                              <1> 	;mov	al, 80
   286                              <1> 	;mul	dh
   287                              <1> 	;add	ax, cx
   288                              <1> 	;shl	ax, 1 ; character + attribute
   289                              <1> 	;add	di, ax ; (2*80*row) + (2*column)
   290                              <1> 	;neg	cl
   291                              <1> 	;add	cl, 80
   292                              <1> 	;mov	ax, 700h ;  ah = 7 (color attribute)
   293                              <1> 	;rep	stosw	
   294                              <1> 
   295                              <1> loc_rw_char:
   296 00008275 E899000000          <1> 	call	rw_char
   297                              <1> loc_move_command:
   298 0000827A BE[468B0100]        <1> 	mov	esi, CommandBuffer
   299 0000827F 89F7                <1> 	mov	edi, esi
   300 00008281 31C9                <1> 	xor	ecx, ecx
   301                              <1> first_command_char:
   302 00008283 AC                  <1> 	lodsb
   303 00008284 3C20                <1> 	cmp	al, 20h
   304 00008286 772E                <1> 	ja	short pass_space_control
   305 00008288 7241                <1> 	jb	short loc_move_cmd_arguments_ok
   306 0000828A 81FE[958B0100]      <1> 	cmp	esi, CommandBuffer + 79
   307 00008290 72F1                <1> 	jb	short first_command_char
   308 00008292 EB37                <1> 	jmp	short loc_move_cmd_arguments_ok
   309                              <1> 
   310                              <1> next_command_char:
   311 00008294 AC                  <1> 	lodsb
   312 00008295 3C20                <1> 	cmp	al, 20h
   313 00008297 771D                <1> 	ja	short pass_space_control
   314 00008299 7230                <1> 	jb	short loc_move_cmd_arguments_ok
   315                              <1> 
   316                              <1> loc_1st_cmd_arg: ; 30/01/2016
   317 0000829B AC                  <1> 	lodsb
   318 0000829C 3C20                <1> 	cmp	al, 20h
   319 0000829E 74FB                <1> 	je	short loc_1st_cmd_arg
   320 000082A0 7229                <1> 	jb	short loc_move_cmd_arguments_ok
   321                              <1> 	
   322 000082A2 C60700              <1>         mov     byte [edi], 0
   323 000082A5 47                  <1> 	inc	edi
   324                              <1> 
   325                              <1> loc_move_cmd_arguments:
   326 000082A6 AA                  <1> 	stosb
   327 000082A7 81FE[958B0100]      <1> 	cmp	esi, CommandBuffer + 79
   328 000082AD 731C                <1> 	jnb	short loc_move_cmd_arguments_ok
   329 000082AF AC                  <1>         lodsb
   330 000082B0 3C20                <1> 	cmp	al, 20h
   331 000082B2 73F2                <1> 	jnb	short loc_move_cmd_arguments
   332 000082B4 EB15                <1> 	jmp	short loc_move_cmd_arguments_ok
   333                              <1> 
   334                              <1> pass_space_control:
   335 000082B6 3C61                <1> 	cmp	al, 61h
   336 000082B8 7206                <1> 	jb	short pass_capitalize
   337 000082BA 3C7A                <1> 	cmp	al, 7Ah
   338 000082BC 7702                <1> 	ja	short pass_capitalize
   339 000082BE 24DF                <1> 	and	al, 0DFh
   340                              <1> pass_capitalize:
   341 000082C0 AA                  <1> 	stosb   
   342 000082C1 FEC1                <1> 	inc     cl
   343 000082C3 81FE[958B0100]      <1>         cmp     esi, CommandBuffer + 79
   344 000082C9 72C9                <1> 	jb      short next_command_char 
   345                              <1> 
   346                              <1> loc_move_cmd_arguments_ok:
   347 000082CB C60700              <1>         mov     byte [edi], 0
   348                              <1> 
   349                              <1> call_command_interpreter:
   350 000082CE E8CF080000          <1> 	call    command_interpreter
   351                              <1> 
   352                              <1> return_from_cmd_interpreter:
   353 000082D3 B950000000          <1>         mov	ecx, 80
   354                              <1> 	;mov	cx, 80
   355 000082D8 BF[468B0100]        <1> 	mov	edi, CommandBuffer
   356 000082DD 30C0                <1> 	xor	al, al
   357 000082DF F3AA                <1> 	rep	stosb
   358                              <1> 	;cmp	byte [Program_Exit], 0
   359                              <1> 	;ja	short loc_terminate_trdos
   360                              <1>         
   361                              <1> 	; 16/01/2016
   362 000082E1 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80*25 color
   363 000082E8 741D                <1> 	je	short pass_set_txt_mode
   364                              <1> 
   365 000082EA E87798FFFF          <1> 	call	set_txt_mode ; set vide mode to 03h
   366                              <1> 	; 07/01/2017
   367 000082EF 30C0                <1> 	xor	al, al
   368                              <1> 
   369                              <1> loc_check_active_page:
   370                              <1> 	;xor	al, al
   371 000082F1 3805[FE890100]      <1> 	cmp	[ACTIVE_PAGE], al ; 0
   372 000082F7 0F842CFFFFFF        <1>         je      loc_TRDOS_prompt 
   373                              <1> 	; AL = 0 = video page 0
   374 000082FD E8AD9CFFFF          <1> 	call	set_active_page
   375 00008302 E922FFFFFF          <1>         jmp     loc_TRDOS_prompt ; infinitive loop
   376                              <1> 
   377                              <1> pass_set_txt_mode: 
   378 00008307 BE[FF4C0100]        <1> 	mov	esi, nextline
   379 0000830C E844F2FFFF          <1> 	call	print_msg
   380 00008311 EBDE                <1> 	jmp     short loc_check_active_page
   381                              <1> 
   382                              <1> rw_char:
   383                              <1> 	; 13/05/2016
   384                              <1> 	; 30/01/2016
   385                              <1> 	; 29/01/2016
   386                              <1> 	; 17/01/2016 (TRDOS 386 = TRDOS v2.0)
   387                              <1> 	; 2004-2005
   388                              <1> 	
   389                              <1> 	; DH = cursor row, DL = cursor column
   390                              <1> 	; BH = 0 = video page number (active page)
   391                              <1> 
   392                              <1> 	;xor	bh, bh ; 0 = video page 0
   393                              <1> 
   394                              <1> readnextchar:
   395 00008313 30E4                <1> 	xor     ah, ah
   396 00008315 E8CB8BFFFF          <1> 	call	int16h
   397 0000831A 20C0                <1> 	and	al, al
   398 0000831C 7432                <1> 	jz	short loc_arrow    
   399 0000831E 3CE0                <1> 	cmp	al, 0E0h          
   400 00008320 742E                <1> 	je	short loc_arrow
   401 00008322 3C08                <1> 	cmp	al, 08h             
   402 00008324 7542                <1> 	jne	short char_return
   403                              <1> loc_back:
   404 00008326 3A15[F68A0100]      <1> 	cmp	dl, [CursorColumn]
   405 0000832C 76E5                <1> 	jna     short readnextchar
   406                              <1> prev_column:
   407 0000832E FECA                <1> 	dec	dl
   408                              <1> set_cursor_pos:
   409                              <1> 	;push	dx
   410 00008330 52                  <1> 	push	edx ; 29/12/2017
   411                              <1> 	;xor	bh, bh ; 0 = video page 0
   412                              <1> 	; DH = Row, DL = Column
   413 00008331 E861A0FFFF          <1> 	call	_set_cpos ; 17/01/2016
   414 00008336 5A                  <1>         pop	edx ; 29/12/2017
   415                              <1> 	;pop	dx
   416                              <1> 	;movzx	ebx, dl
   417 00008337 88D3                <1> 	mov	bl, dl
   418 00008339 2A1D[F68A0100]      <1> 	sub	bl, [CursorColumn] 
   419 0000833F B020                <1> 	mov	al, 20h
   420 00008341 8883[468B0100]      <1> 	mov	[CommandBuffer+ebx], al
   421                              <1> 	;sub	bh, bh ; video page 0
   422                              <1> 	;mov	cx, 1
   423 00008347 B307                <1> 	mov	bl, 7 ; color attribute
   424 00008349 E8289FFFFF          <1> 	call	_write_c_current ; 17/01/2016
   425                              <1> 	;mov	dx, [CURSOR_POSN]
   426 0000834E EBC3                <1> 	jmp	short readnextchar
   427                              <1> loc_arrow:    
   428 00008350 80FC4B              <1> 	cmp	ah, 4Bh
   429 00008353 74D1                <1> 	je	short loc_back
   430 00008355 80FC53              <1> 	cmp	ah, 53h
   431 00008358 74CC                <1> 	je      short loc_back
   432 0000835A 80FC4D              <1> 	cmp	ah, 4Dh
   433 0000835D 75B4                <1> 	jne	short readnextchar
   434 0000835F 80FA4F              <1> 	cmp	dl, 79
   435 00008362 73AF                <1> 	jnb	short readnextchar
   436 00008364 FEC2                <1> 	inc	dl
   437 00008366 EBC8                <1> 	jmp	short set_cursor_pos
   438                              <1> char_return:
   439 00008368 0FB6DA              <1> 	movzx	ebx, dl
   440 0000836B 2A1D[F68A0100]      <1> 	sub	bl, [CursorColumn] 
   441 00008371 3C20                <1> 	cmp	al, 20h
   442 00008373 721D                <1> 	jb	short loc_escape
   443 00008375 8883[468B0100]      <1> 	mov	[CommandBuffer+ebx], al
   444 0000837B 80FA4F              <1> 	cmp	dl, 79
   445 0000837E 7393                <1> 	jnb	short readnextchar
   446 00008380 66BB0700            <1> 	mov	bx, 7 ; color attribute
   447 00008384 E8749FFFFF          <1> 	call	_write_tty
   448 00008389 668B15[EE890100]    <1> 	mov	dx, [CURSOR_POSN] ; video page 0
   449 00008390 EB81                <1>         jmp     readnextchar
   450                              <1> loc_escape:
   451 00008392 3C1B                <1> 	cmp	al, 1Bh
   452 00008394 7418                <1> 	je	short rw_char_retn
   453                              <1> 	;
   454 00008396 3C0D                <1> 	cmp	al, 0Dh ; CR
   455 00008398 0F8575FFFFFF        <1>         jne     readnextchar
   456                              <1> 	; 13/05/2016
   457 0000839E 66BB0700            <1> 	mov	bx, 7 ; attribute/color (bl)
   458                              <1> 		      ; video page 0 (bh=0)	
   459 000083A2 E8569FFFFF          <1> 	call	_write_tty
   460                              <1> 	;mov	bx, 7  ; attribute/color
   461                              <1> 		      ; video page 0 (bh=0)
   462 000083A7 B00A                <1> 	mov	al, 0Ah ; LF
   463 000083A9 E84F9FFFFF          <1> 	call	_write_tty
   464                              <1> rw_char_retn:
   465 000083AE C3                  <1> 	retn
   466                              <1> 
   467                              <1> show_date:
   468                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   469                              <1>         ; 2004-2005
   470                              <1> 
   471                              <1> 	;mov	ah, 04h
   472                              <1> 	;call	int1Ah
   473 000083AF E867E7FFFF          <1> 	call	RTC_40	; GET RTC DATE
   474                              <1> 
   475 000083B4 88D0                <1> 	mov	al, dl
   476 000083B6 E81D8BFFFF          <1>   	call	bcd_to_ascii
   477 000083BB 66A3[A2410100]      <1> 	mov	[Day], ax
   478                              <1> 
   479 000083C1 88F0                <1> 	mov	al, dh
   480 000083C3 E8108BFFFF          <1>   	call	bcd_to_ascii
   481 000083C8 66A3[A5410100]      <1> 	mov	[Month], ax
   482                              <1> 
   483 000083CE 88E8                <1> 	mov	al, ch
   484 000083D0 E8038BFFFF          <1>   	call	bcd_to_ascii
   485 000083D5 66A3[A8410100]      <1> 	mov	[Century], ax
   486                              <1> 
   487 000083DB 88C8                <1> 	mov	al, cl
   488 000083DD E8F68AFFFF          <1>   	call	bcd_to_ascii
   489 000083E2 66A3[AA410100]      <1> 	mov	word [Year], ax
   490                              <1> 
   491 000083E8 BE[92410100]        <1> 	mov	esi, Msg_Show_Date
   492 000083ED E863F1FFFF          <1> 	call	print_msg
   493                              <1> 
   494 000083F2 C3                  <1> 	retn
   495                              <1> 
   496                              <1> set_date:
   497                              <1> 	; 13/05/2016
   498                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   499                              <1>         ; 2004-2005
   500                              <1> 
   501 000083F3 BE[76410100]        <1> 	mov	esi, Msg_Enter_Date
   502 000083F8 E858F1FFFF          <1> 	call	print_msg
   503                              <1> 
   504                              <1> loc_enter_day_1:
   505 000083FD 30E4                <1> 	xor     ah, ah
   506 000083FF E8E18AFFFF          <1> 	call	int16h
   507                              <1> 	; AL = ASCII Code of the Character
   508 00008404 3C0D                <1> 	cmp	al, 13
   509 00008406 0F84B7010000        <1> 	je	loc_set_date_retn
   510 0000840C 3C1B                <1> 	cmp	al, 27
   511 0000840E 0F84AF010000        <1> 	je	loc_set_date_retn
   512 00008414 A2[A2410100]        <1> 	mov	[Day], al
   513 00008419 3C30                <1> 	cmp	al, '0'
   514 0000841B 0F82AD010000        <1> 	jb	loc_set_date_stc_0
   515 00008421 3C33                <1> 	cmp	al, '3'
   516 00008423 0F87A5010000        <1> 	ja	loc_set_date_stc_0
   517                              <1> 	; 13/05/2016
   518                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   519                              <1> 		      ; video page 0 (bh)	
   520 00008429 B307                <1> 	mov	bl, 7
   521 0000842B E8CD9EFFFF          <1> 	call	_write_tty
   522                              <1> loc_enter_day_2:
   523 00008430 30E4                <1> 	xor     ah, ah
   524 00008432 E8AE8AFFFF          <1> 	call	int16h
   525                              <1> 	; AL = ASCII Code of the Character
   526 00008437 3C1B                <1> 	cmp	al, 27
   527 00008439 0F8484010000        <1>         je      loc_set_date_retn
   528 0000843F A2[A3410100]        <1> 	mov	[Day+1], al
   529 00008444 3C30                <1> 	cmp	al, '0'
   530 00008446 0F828C010000        <1>         jb      loc_set_date_stc_1
   531 0000844C 3C39                <1> 	cmp	al, '9'
   532 0000844E 0F8784010000        <1>         ja      loc_set_date_stc_1
   533 00008454 803D[A2410100]33    <1> 	cmp	byte [Day], '3'
   534 0000845B 7208                <1> 	jb	short pass_set_day_31
   535 0000845D 3C31                <1> 	cmp	al, '1'
   536 0000845F 0F8773010000        <1>         ja      loc_set_date_stc_1
   537                              <1> pass_set_day_31:
   538                              <1> 	; 13/05/2016
   539                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   540                              <1> 		      ; video page 0 (bh)	
   541 00008465 B307                <1> 	mov	bl, 7
   542 00008467 E8919EFFFF          <1> 	call	_write_tty
   543                              <1> loc_enter_separator_1:
   544 0000846C 28E4                <1> 	sub     ah, ah ; 0
   545 0000846E E8728AFFFF          <1> 	call	int16h
   546                              <1> 	; AL = ASCII Code of the Character
   547 00008473 3C1B                <1> 	cmp	al, 27
   548 00008475 0F8448010000        <1>         je      loc_set_date_retn
   549 0000847B 3C2D                <1> 	cmp	al, '-'
   550 0000847D 7408                <1> 	je	short pass_set_date_separator_1
   551 0000847F 3C2F                <1> 	cmp	al, '/'
   552 00008481 0F856C010000        <1>         jne     loc_set_date_stc_2
   553                              <1> pass_set_date_separator_1:
   554                              <1> 	; 13/05/2016
   555                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   556                              <1> 		      ; video page 0 (bh)
   557 00008487 B307                <1> 	mov	bl, 7	
   558 00008489 E86F9EFFFF          <1> 	call	_write_tty
   559                              <1> loc_enter_month_1:
   560 0000848E 30E4                <1> 	xor     ah, ah ; 0
   561 00008490 E8508AFFFF          <1> 	call	int16h
   562                              <1> 	; AL = ASCII Code of the Character
   563 00008495 3C1B                <1> 	cmp	al, 27
   564 00008497 0F8426010000        <1>         je      loc_set_date_retn
   565 0000849D A2[A5410100]        <1> 	mov	[Month], al
   566 000084A2 3C30                <1> 	cmp	al, '0'
   567 000084A4 0F8264010000        <1>         jb      loc_set_date_stc_3
   568 000084AA 3C31                <1> 	cmp	al, '1'
   569 000084AC 0F875C010000        <1>         ja      loc_set_date_stc_3
   570                              <1> 	; 13/05/2016
   571                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   572                              <1> 		      ; video page 0 (bh)	
   573 000084B2 B307                <1> 	mov	bl, 7
   574 000084B4 E8449EFFFF          <1> 	call	_write_tty
   575                              <1> loc_enter_month_2:
   576 000084B9 30E4                <1> 	xor     ah, ah
   577 000084BB E8258AFFFF          <1> 	call	int16h
   578                              <1> 	; AL = ASCII Code of the Character
   579 000084C0 3C1B                <1> 	cmp	al, 27
   580 000084C2 0F84FB000000        <1>         je      loc_set_date_retn
   581 000084C8 A2[A6410100]        <1> 	mov	[Month+1], al
   582 000084CD 3C30                <1> 	cmp	al, '0'
   583 000084CF 0F8254010000        <1>         jb      loc_set_date_stc_4
   584 000084D5 3C39                <1> 	cmp	al, '9'
   585 000084D7 0F874C010000        <1>         ja      loc_set_date_stc_4
   586 000084DD 803D[A5410100]31    <1> 	cmp	byte [Month], '1'
   587 000084E4 7208                <1> 	jb	short pass_set_month_12
   588 000084E6 3C32                <1> 	cmp	al, '2'
   589 000084E8 0F873B010000        <1>         ja      loc_set_date_stc_4
   590                              <1> pass_set_month_12:
   591                              <1> 	; 13/05/2016
   592                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   593                              <1> 		      ; video page 0 (bh)
   594 000084EE B307                <1> 	mov	bl, 7	
   595 000084F0 E8089EFFFF          <1> 	call	_write_tty
   596                              <1> loc_enter_separator_2:
   597 000084F5 28E4                <1> 	sub     ah, ah
   598 000084F7 E8E989FFFF          <1> 	call	int16h
   599                              <1> 	; AL = ASCII Code of the Character
   600 000084FC 3C1B                <1> 	cmp	al, 27
   601 000084FE 0F84BF000000        <1>         je      loc_set_date_retn
   602 00008504 3C2D                <1> 	cmp	al, '-'
   603 00008506 7408                <1> 	je	short pass_set_date_separator_2
   604 00008508 3C2F                <1> 	cmp	al, '/'
   605 0000850A 0F8534010000        <1>         jne     loc_set_date_stc_5
   606                              <1> pass_set_date_separator_2:
   607                              <1> 	; 13/05/2016
   608                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   609                              <1> 		      ; video page 0 (bh)	
   610 00008510 B307                <1> 	mov	bl, 7
   611 00008512 E8E69DFFFF          <1> 	call	_write_tty
   612                              <1> loc_enter_year_1:
   613 00008517 30E4                <1> 	xor    ah, ah
   614 00008519 E8C789FFFF          <1> 	call	int16h
   615                              <1> 	; AL = ASCII Code of the Character
   616 0000851E 3C1B                <1> 	cmp	al, 27
   617 00008520 0F849D000000        <1>         je      loc_set_date_retn
   618 00008526 A2[AA410100]        <1> 	mov	[Year], al
   619 0000852B 3C30                <1> 	cmp	al, '0'
   620 0000852D 0F822C010000        <1>         jb      loc_set_date_stc_6
   621 00008533 3C39                <1> 	cmp	al, '9'
   622 00008535 0F8724010000        <1>         ja      loc_set_date_stc_6
   623                              <1> 	; 13/05/2016
   624                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   625                              <1> 		      ; video page 0 (bh)
   626 0000853B B307                <1> 	mov	bl, 7	
   627 0000853D E8BB9DFFFF          <1> 	call	_write_tty
   628                              <1> loc_enter_year_2:
   629 00008542 30E4                <1> 	xor	ah, ah
   630 00008544 E89C89FFFF          <1> 	call	int16h
   631                              <1> 	; AL = ASCII Code of the Character
   632 00008549 3C1B                <1> 	cmp	al, 27
   633 0000854B 7476                <1> 	je	short loc_set_date_retn
   634 0000854D A2[AB410100]        <1> 	mov	byte [Year+1], al
   635 00008552 3C30                <1> 	cmp	al, '0'
   636 00008554 0F8220010000        <1>         jb      loc_set_date_stc_7
   637 0000855A 3C39                <1> 	cmp	al, '9'
   638 0000855C 0F8718010000        <1>         ja      loc_set_date_stc_7
   639                              <1> 	; 13/05/2016
   640                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   641                              <1> 		      ; video page 0 (bh)
   642 00008562 B307                <1> 	mov	bl, 7	
   643 00008564 E8949DFFFF          <1> 	call	_write_tty
   644                              <1> loc_set_date_get_lchar_again:
   645 00008569 28E4                <1> 	sub	ah, ah ; 0
   646 0000856B E87589FFFF          <1> 	call	int16h
   647                              <1> 	; AL = ASCII Code of the Character
   648 00008570 3C0D                <1> 	cmp	al, 13 ; ENTER key
   649 00008572 7412                <1> 	je	short loc_set_date_progress
   650 00008574 3C1B                <1> 	cmp	al, 27 ; ESC key
   651 00008576 744B                <1> 	je	short loc_set_date_retn
   652                              <1> 	;
   653 00008578 E82A010000          <1> 	call	check_for_backspace
   654 0000857D 75EA                <1> 	jne	short loc_set_date_get_lchar_again
   655                              <1> 
   656                              <1> loc_set_date_bs_8:
   657 0000857F E811010000          <1> 	call	write_backspace
   658 00008584 EBBC                <1> 	jmp	short loc_enter_year_2
   659                              <1> 
   660                              <1> loc_set_date_progress:
   661                              <1> 	; Get Current Date
   662                              <1> 	;mov	ah, 04h
   663                              <1> 	;call	int1Ah
   664 00008586 E890E5FFFF          <1> 	call	RTC_40	; GET RTC DATE
   665                              <1> 	; CH = century (in BCD)
   666                              <1> 
   667 0000858B 66A1[AA410100]      <1> 	mov	ax, [Year]
   668 00008591 662D3030            <1> 	sub	ax, '00'
   669 00008595 C0E004              <1> 	shl	al, 4 ; * 16
   670 00008598 88C1                <1> 	mov	cl, al
   671 0000859A 00E1                <1> 	add	cl, ah
   672 0000859C 66A1[A5410100]      <1> 	mov	ax, [Month]
   673 000085A2 662D3030            <1> 	sub	ax, '00'
   674 000085A6 C0E004              <1> 	shl	al, 4 ; * 16
   675 000085A9 88C6                <1> 	mov	dh, al
   676 000085AB 00E6                <1> 	add	dh, ah
   677 000085AD 66A1[A2410100]      <1> 	mov	ax, [Day]
   678 000085B3 662D3030            <1> 	sub	ax, '00'
   679 000085B7 C0E004              <1> 	shl	al, 4 ; * 16
   680 000085BA 88C2                <1> 	mov	dl, al
   681 000085BC 00E2                <1> 	add	dl, ah
   682                              <1> 
   683                              <1> 	;mov	ah, 05h
   684                              <1> 	;call	int1Ah
   685 000085BE E885E5FFFF          <1> 	call	RTC_50	; SET RTC DATE
   686                              <1> 
   687                              <1> loc_set_date_retn:
   688 000085C3 BE[FF4C0100]        <1> 	mov	esi, nextline
   689 000085C8 E888EFFFFF          <1> 	call	print_msg
   690 000085CD C3                  <1> 	retn
   691                              <1> 
   692                              <1> loc_set_date_stc_0:
   693                              <1> 	;xor	bh, bh ; video page 0
   694 000085CE E8169EFFFF          <1> 	call	beeper ; BEEP !
   695 000085D3 E925FEFFFF          <1>         jmp     loc_enter_day_1
   696                              <1> loc_set_date_stc_1:
   697 000085D8 E8CA000000          <1> 	call	check_for_backspace
   698 000085DD 740A                <1> 	je	short loc_set_date_bs_1
   699                              <1> 	;xor	bh, bh ; video page 0
   700 000085DF E8059EFFFF          <1> 	call	beeper ; BEEP !
   701 000085E4 E947FEFFFF          <1>         jmp     loc_enter_day_2
   702                              <1> loc_set_date_bs_1:
   703 000085E9 E8A7000000          <1> 	call	write_backspace
   704 000085EE E90AFEFFFF          <1>         jmp     loc_enter_day_1
   705                              <1> loc_set_date_stc_2:
   706 000085F3 E8AF000000          <1> 	call	check_for_backspace
   707 000085F8 740A                <1> 	je	short loc_set_date_bs_2
   708                              <1> 	;xor	bh, bh ; video page 0
   709 000085FA E8EA9DFFFF          <1> 	call	beeper ; BEEP !
   710 000085FF E968FEFFFF          <1>         jmp     loc_enter_separator_1
   711                              <1> loc_set_date_bs_2:
   712 00008604 E88C000000          <1> 	call	write_backspace
   713 00008609 E922FEFFFF          <1>         jmp     loc_enter_day_2
   714                              <1> loc_set_date_stc_3:
   715 0000860E E894000000          <1> 	call	check_for_backspace	
   716 00008613 740A                <1> 	je short loc_set_date_bs_3
   717                              <1> 	;xor	bh, bh ; video page 0
   718 00008615 E8CF9DFFFF          <1> 	call	beeper ; BEEP !
   719 0000861A E96FFEFFFF          <1>         jmp     loc_enter_month_1
   720                              <1> loc_set_date_bs_3:
   721 0000861F E871000000          <1> 	call	write_backspace
   722 00008624 E943FEFFFF          <1>         jmp     loc_enter_separator_1
   723                              <1> loc_set_date_stc_4:
   724 00008629 E879000000          <1> 	call	check_for_backspace	
   725 0000862E 740A                <1> 	je	short loc_set_date_bs_4
   726                              <1> 	;xor	bh, bh ; video page 0
   727 00008630 E8B49DFFFF          <1> 	call	beeper ; BEEP !
   728 00008635 E97FFEFFFF          <1>         jmp     loc_enter_month_2
   729                              <1> loc_set_date_bs_4:
   730 0000863A E856000000          <1> 	call	write_backspace
   731 0000863F E94AFEFFFF          <1>         jmp     loc_enter_month_1
   732                              <1> loc_set_date_stc_5:
   733 00008644 E85E000000          <1> 	call	check_for_backspace
   734 00008649 740A                <1> 	je	short loc_set_date_bs_5
   735                              <1> 	;xor	bh, bh ; video page 0
   736 0000864B E8999DFFFF          <1> 	call	beeper ; BEEP !
   737 00008650 E9A0FEFFFF          <1>         jmp     loc_enter_separator_2
   738                              <1> loc_set_date_bs_5:
   739 00008655 E83B000000          <1> 	call	write_backspace
   740 0000865A E95AFEFFFF          <1>         jmp     loc_enter_month_2
   741                              <1> loc_set_date_stc_6:
   742 0000865F E843000000          <1> 	call	check_for_backspace
   743 00008664 740A                <1>         je      short  loc_set_date_bs_6
   744                              <1> 	;xor	bh, bh ; video page 0
   745 00008666 E87E9DFFFF          <1> 	call	beeper ; BEEP !
   746 0000866B E9A7FEFFFF          <1>         jmp     loc_enter_year_1
   747                              <1> loc_set_date_bs_6:
   748 00008670 E820000000          <1> 	call	write_backspace
   749 00008675 E97BFEFFFF          <1>         jmp     loc_enter_separator_2
   750                              <1> loc_set_date_stc_7:
   751 0000867A E828000000          <1> 	call	check_for_backspace
   752 0000867F 740A                <1> 	je	short loc_set_date_bs_7
   753                              <1> 	;xor	bh, bh ; video page 0
   754 00008681 E8639DFFFF          <1> 	call	beeper ; BEEP !
   755 00008686 E9B7FEFFFF          <1>         jmp     loc_enter_year_2
   756                              <1> loc_set_date_bs_7:
   757 0000868B E805000000          <1> 	call	write_backspace
   758 00008690 E982FEFFFF          <1>         jmp     loc_enter_year_1
   759                              <1> 
   760                              <1> write_backspace:
   761                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   762 00008695 B008                <1> 	mov	al, 08h ; BACKSPACE
   763                              <1> 	; 13/05/2016
   764 00008697 66BB0700            <1> 	mov	bx, 7 ; bl = attribute/color
   765                              <1> 		      ; bh = video page = 0	
   766 0000869B E85D9CFFFF          <1> 	call	_write_tty
   767 000086A0 B020                <1> 	mov	al, 20h ; BLANK/SPACE char 
   768                              <1> 	;mov	bx, 7 ; attribute/color
   769                              <1> 	;call	_write_c_current
   770                              <1> 	;retn
   771 000086A2 E9CF9BFFFF          <1> 	jmp	_write_c_current
   772                              <1> 
   773                              <1> check_for_backspace:
   774                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   775 000086A7 663D080E            <1> 	cmp	ax, 0E08h
   776 000086AB 7410                <1> 	je	short cfbs_retn
   777 000086AD 663DE04B            <1> 	cmp	ax, 4BE0h
   778 000086B1 740A                <1> 	je	short cfbs_retn
   779 000086B3 663D004B            <1> 	cmp	ax, 4B00h
   780 000086B7 7404                <1> 	je	short cfbs_retn
   781 000086B9 663DE053            <1> 	cmp	ax, 53E0h
   782                              <1> cfbs_retn:
   783 000086BD C3                  <1> 	retn
   784                              <1> 
   785                              <1> show_time:
   786                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   787                              <1>         ; 2004-2005
   788                              <1> 
   789                              <1> 	;mov	ah, 02h
   790                              <1> 	;call	int1Ah
   791 000086BE E8E7E3FFFF          <1> 	call	RTC_20	; GET RTC TIME
   792                              <1> 	
   793 000086C3 88E8                <1> 	mov	al, ch
   794 000086C5 E80E88FFFF          <1> 	call	bcd_to_ascii
   795 000086CA 66A3[D0410100]      <1> 	mov	[Hour], ax
   796                              <1> 
   797 000086D0 88C8                <1> 	mov	al, cl
   798 000086D2 E80188FFFF          <1> 	call	bcd_to_ascii
   799 000086D7 66A3[D3410100]      <1> 	mov	[Minute], ax
   800                              <1> 
   801 000086DD 88F0                <1> 	mov	al, dh
   802 000086DF E8F487FFFF          <1> 	call	bcd_to_ascii
   803 000086E4 66A3[D6410100]      <1> 	mov	[Second], ax
   804                              <1> 
   805 000086EA BE[C0410100]        <1> 	mov	esi, Msg_Show_Time
   806 000086EF E861EEFFFF          <1> 	call	print_msg
   807 000086F4 C3                  <1> 	retn
   808                              <1> 
   809                              <1> set_time:
   810                              <1> 	; 13/05/2016
   811                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
   812                              <1>         ; 2004-2005
   813                              <1> 
   814 000086F5 BE[AF410100]        <1> 	mov 	esi, Msg_Enter_Time
   815 000086FA E856EEFFFF          <1> 	call	print_msg
   816                              <1> 
   817                              <1> loc_enter_hour_1:
   818 000086FF 30E4                <1> 	xor     ah, ah
   819 00008701 E8DF87FFFF          <1> 	call	int16h
   820                              <1> 	; AL = ASCII Code of the Character
   821 00008706 3C0D                <1> 	cmp	al, 13 ; ENTER key
   822 00008708 0F84AE010000        <1>         je      loc_set_time_retn
   823 0000870E 3C1B                <1> 	cmp	al, 27 ; ESC key
   824 00008710 0F84A6010000        <1>         je      loc_set_time_retn
   825 00008716 A2[D0410100]        <1> 	mov	[Hour], al
   826 0000871B 3C30                <1> 	cmp	al, '0'
   827 0000871D 0F82A4010000        <1>         jb      loc_set_time_stc_0
   828 00008723 3C32                <1> 	cmp	al, '2'
   829 00008725 0F879C010000        <1>         ja      loc_set_time_stc_0
   830                              <1> 	; 13/05/2016
   831                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   832                              <1> 		      ; video page 0 (bh)
   833 0000872B B307                <1> 	mov	bl, 7	
   834 0000872D E8CB9BFFFF          <1> 	call	_write_tty
   835                              <1> loc_enter_hour_2:
   836 00008732 30E4                <1> 	xor     ah, ah
   837 00008734 E8AC87FFFF          <1> 	call	int16h
   838                              <1> 	; AL = ASCII Code of the Character
   839 00008739 3C1B                <1> 	cmp	al, 27
   840 0000873B 0F847B010000        <1>         je      loc_set_time_retn
   841 00008741 A2[D1410100]        <1> 	mov	[Hour+1], al
   842 00008746 3C30                <1> 	cmp	al, '0'
   843 00008748 0F8283010000        <1>         jb      loc_set_time_stc_1
   844 0000874E 3C39                <1> 	cmp	al, '9'
   845 00008750 0F877B010000        <1> 	ja	loc_set_time_stc_1
   846 00008756 803D[D0410100]32    <1>         cmp     byte [Hour], '2'
   847 0000875D 7208                <1> 	jb	short pass_set_time_24
   848 0000875F 3C34                <1> 	cmp	al, '4'
   849 00008761 0F876A010000        <1>         ja      loc_set_time_stc_1
   850                              <1> pass_set_time_24:
   851                              <1> 	; 13/05/2016
   852                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   853                              <1> 		      ; video page 0 (bh)
   854 00008767 B307                <1> 	mov	bl, 7	
   855 00008769 E88F9BFFFF          <1> 	call	_write_tty
   856                              <1> loc_enter_time_separator_1:
   857 0000876E 28E4                <1> 	sub    ah, ah ; 0
   858 00008770 E87087FFFF          <1> 	call	int16h
   859                              <1> 	; AL = ASCII Code of the Character
   860 00008775 3C1B                <1> 	cmp	al, 27
   861 00008777 0F843F010000        <1>         je      loc_set_time_retn
   862 0000877D 3C3A                <1> 	cmp	al, ':'
   863 0000877F 0F8567010000        <1>         jne     loc_set_time_stc_2
   864                              <1> 	; 13/05/2016
   865                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   866                              <1> 		      ; video page 0 (bh)
   867 00008785 B307                <1> 	mov	bl, 7	
   868 00008787 E8719BFFFF          <1> 	call	_write_tty
   869                              <1> loc_enter_minute_1:
   870 0000878C 30E4                <1> 	xor     ah, ah
   871 0000878E E85287FFFF          <1> 	call	int16h
   872                              <1> 	; AL = ASCII Code of the Character
   873 00008793 3C1B                <1> 	cmp	al, 27
   874 00008795 0F8421010000        <1>         je      loc_set_time_retn
   875 0000879B A2[D3410100]        <1> 	mov	[Minute], al
   876 000087A0 3C30                <1> 	cmp	al, '0'
   877 000087A2 0F825F010000        <1>         jb      loc_set_time_stc_3
   878 000087A8 3C35                <1> 	cmp	al, '5'
   879 000087AA 0F8757010000        <1>         ja      loc_set_time_stc_3
   880                              <1> 	; 13/05/2016
   881                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   882                              <1> 		      ; video page 0 (bh)
   883 000087B0 B307                <1> 	mov	bl, 7	
   884 000087B2 E8469BFFFF          <1> 	call	_write_tty
   885                              <1> loc_enter_minute_2:
   886 000087B7 30E4                <1> 	xor     ah, ah
   887 000087B9 E82787FFFF          <1> 	call	int16h
   888                              <1> 	; AL = ASCII Code of the Character
   889 000087BE 3C1B                <1> 	cmp	al, 27
   890 000087C0 0F84F6000000        <1>         je      loc_set_time_retn
   891 000087C6 A2[D4410100]        <1> 	mov	[Minute+1], al
   892 000087CB 3C30                <1> 	cmp	al, '0'
   893 000087CD 0F824F010000        <1>         jb      loc_set_time_stc_4
   894 000087D3 3C39                <1> 	cmp	al, '9'
   895 000087D5 0F8747010000        <1>         ja      loc_set_time_stc_4
   896                              <1> 	; 13/05/2016
   897                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   898                              <1> 		      ; video page 0 (bh)
   899 000087DB B307                <1> 	mov	bl, 7	
   900 000087DD E81B9BFFFF          <1> 	call	_write_tty
   901                              <1> loc_enter_time_separator_2:
   902 000087E2 66C705[D6410100]30- <1> 	mov	word [Second], 3030h
   902 000087EA 30                  <1>
   903 000087EB 28E4                <1> 	sub     ah, ah
   904 000087ED E8F386FFFF          <1> 	call	int16h
   905                              <1> 	; AL = ASCII Code of the Character
   906 000087F2 3C0D                <1> 	cmp	al, 13
   907 000087F4 0F8485000000        <1>         je      loc_set_time_progress
   908 000087FA 3C1B                <1> 	cmp	al, 27
   909 000087FC 0F84BA000000        <1>         je      loc_set_time_retn
   910 00008802 3C3A                <1> 	cmp	al, ':'
   911 00008804 0F8533010000        <1>         jne     loc_set_time_stc_5
   912                              <1> 	; 13/05/2016
   913                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   914                              <1> 		      ; video page 0 (bh)
   915 0000880A B307                <1> 	mov	bl, 7	
   916 0000880C E8EC9AFFFF          <1> 	call	_write_tty
   917                              <1> loc_enter_second_1:
   918 00008811 30E4                <1> 	xor     ah, ah
   919 00008813 E8CD86FFFF          <1> 	call	int16h
   920                              <1> 	; AL = ASCII Code of the Character
   921 00008818 3C0D                <1> 	cmp	al, 13
   922 0000881A 7463                <1> 	je	short loc_set_time_progress
   923 0000881C 3C1B                <1> 	cmp	al, 27
   924 0000881E 0F8498000000        <1>         je      loc_set_time_retn
   925 00008824 A2[D6410100]        <1> 	mov	[Second], al
   926 00008829 3C30                <1> 	cmp	al, '0'
   927 0000882B 0F8227010000        <1>         jb      loc_set_time_stc_6
   928 00008831 3C35                <1> 	cmp	al, '5'
   929 00008833 0F871F010000        <1>         ja      loc_set_time_stc_6
   930                              <1> 	; 13/05/2016
   931                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   932                              <1> 		      ; video page 0 (bh)
   933 00008839 B307                <1> 	mov	bl, 7	
   934 0000883B E8BD9AFFFF          <1> 	call	_write_tty
   935                              <1> loc_enter_second_2:
   936 00008840 30E4                <1> 	xor     ah, ah
   937 00008842 E89E86FFFF          <1> 	call	int16h
   938                              <1> 	; AL = ASCII Code of the Character
   939 00008847 3C1B                <1> 	cmp	al, 27
   940 00008849 7471                <1> 	je	short loc_set_time_retn
   941 0000884B 3C30                <1> 	cmp	al, '0'
   942 0000884D 0F8229010000        <1>         jb      loc_set_time_stc_7
   943 00008853 3C39                <1> 	cmp	al, '9'
   944 00008855 0F8721010000        <1>         ja      loc_set_time_stc_7
   945                              <1> 	; 13/05/2016
   946                              <1> 	;mov	bx, 7 ; attribute/color (bl)
   947                              <1> 		      ; video page 0 (bh)
   948 0000885B B307                <1> 	mov	bl, 7	
   949 0000885D E89B9AFFFF          <1> 	call	_write_tty
   950                              <1> loc_set_time_get_lchar_again:
   951 00008862 28E4                <1> 	sub	ah, ah ; 0
   952 00008864 E87C86FFFF          <1> 	call	int16h
   953                              <1> 	; AL = ASCII Code of the Character
   954 00008869 3C0D                <1> 	cmp	al, 13
   955 0000886B 7412                <1> 	je	short loc_set_time_progress
   956 0000886D 3C1B                <1> 	cmp	al, 27
   957 0000886F 744B                <1> 	je	short loc_set_time_retn
   958                              <1> 	;
   959 00008871 E831FEFFFF          <1> 	call	check_for_backspace
   960 00008876 75EA                <1> 	jne	short loc_set_time_get_lchar_again
   961                              <1> 
   962                              <1> loc_set_time_bs_8:
   963 00008878 E818FEFFFF          <1> 	call	write_backspace
   964 0000887D EBC1                <1> 	jmp	short loc_enter_second_2
   965                              <1> 
   966                              <1> loc_set_time_progress:
   967                              <1> 	; Get Current Time
   968                              <1> 	;mov 	ah, 02h
   969                              <1> 	;call	int1Ah
   970 0000887F E826E2FFFF          <1> 	call	RTC_20	; GET RTC TIME
   971                              <1> 	;DL = Daylight Savings Enable option (0-1)	
   972                              <1> 
   973 00008884 66A1[D0410100]      <1> 	mov	ax, [Hour]
   974 0000888A 662D3030            <1> 	sub	ax, '00'
   975 0000888E C0E004              <1> 	shl	al, 4 ; * 16
   976 00008891 88C5                <1> 	mov	ch, al
   977 00008893 00E5                <1> 	add	ch, ah
   978 00008895 66A1[D3410100]      <1> 	mov	ax, [Minute]
   979 0000889B 662D3030            <1> 	sub	ax, '00'
   980 0000889F C0E004              <1> 	shl	al, 4 ; * 16
   981 000088A2 88C1                <1> 	mov	cl, al
   982 000088A4 00E1                <1> 	add	cl, ah
   983 000088A6 66A1[D6410100]      <1> 	mov	ax, [Second]
   984 000088AC 662D3030            <1> 	sub	ax, '00'
   985 000088B0 C0E004              <1> 	shl	al, 4 ; * 16
   986 000088B3 88C6                <1> 	mov	dh, al
   987 000088B5 00E6                <1> 	add	dh, ah
   988                              <1> 	
   989                              <1> 	;mov	ah, 03h
   990                              <1> 	;call	int1Ah
   991 000088B7 E81DE2FFFF          <1> 	call	RTC_30	; SET RTC TIME
   992                              <1> 
   993                              <1> loc_set_time_retn:
   994 000088BC BE[FF4C0100]        <1> 	mov 	esi, nextline
   995 000088C1 E88FECFFFF          <1> 	call	print_msg
   996 000088C6 C3                  <1> 	retn
   997                              <1> 
   998                              <1> loc_set_time_stc_0:
   999                              <1> 	;xor	bh, bh ; video page 0
  1000 000088C7 E81D9BFFFF          <1> 	call	beeper ; BEEP !
  1001 000088CC E92EFEFFFF          <1>         jmp     loc_enter_hour_1
  1002                              <1> loc_set_time_stc_1:
  1003 000088D1 E8D1FDFFFF          <1> 	call	check_for_backspace
  1004 000088D6 740A                <1> 	je	short loc_set_time_bs_1
  1005                              <1> 	;xor	bh, bh ; video page 0
  1006 000088D8 E80C9BFFFF          <1> 	call	beeper ; BEEP !
  1007 000088DD E950FEFFFF          <1>         jmp     loc_enter_hour_2
  1008                              <1> loc_set_time_bs_1:
  1009 000088E2 E8AEFDFFFF          <1> 	call	write_backspace
  1010 000088E7 E913FEFFFF          <1>         jmp     loc_enter_hour_1
  1011                              <1> loc_set_time_stc_2:
  1012 000088EC E8B6FDFFFF          <1> 	call	check_for_backspace
  1013 000088F1 740A                <1> 	je	short loc_set_time_bs_2
  1014                              <1> 	;xor	bh, bh ; video page 0
  1015 000088F3 E8F19AFFFF          <1> 	call	beeper ; BEEP !
  1016 000088F8 E971FEFFFF          <1>         jmp     loc_enter_time_separator_1
  1017                              <1> loc_set_time_bs_2:
  1018 000088FD E893FDFFFF          <1> 	call	write_backspace
  1019 00008902 E92BFEFFFF          <1>         jmp     loc_enter_hour_2
  1020                              <1> loc_set_time_stc_3:
  1021 00008907 E89BFDFFFF          <1> 	call	check_for_backspace
  1022 0000890C 740A                <1> 	je	short loc_set_time_bs_3
  1023                              <1> 	;xor	bh, bh ; video page 0
  1024 0000890E E8D69AFFFF          <1> 	call	beeper ; BEEP !6
  1025 00008913 E974FEFFFF          <1>         jmp     loc_enter_minute_1
  1026                              <1> loc_set_time_bs_3:
  1027 00008918 E878FDFFFF          <1> 	call	write_backspace
  1028 0000891D E94CFEFFFF          <1>         jmp     loc_enter_time_separator_1
  1029                              <1> loc_set_time_stc_4:
  1030 00008922 E880FDFFFF          <1> 	call	check_for_backspace
  1031 00008927 740A                <1> 	je	short loc_set_time_bs_4
  1032                              <1> 	;xor	bh, bh ; video page 0
  1033 00008929 E8BB9AFFFF          <1> 	call	beeper ; BEEP !
  1034 0000892E E984FEFFFF          <1>         jmp     loc_enter_minute_2
  1035                              <1> loc_set_time_bs_4:
  1036 00008933 E85DFDFFFF          <1> 	call	write_backspace
  1037 00008938 E94FFEFFFF          <1>         jmp     loc_enter_minute_1
  1038                              <1> loc_set_time_stc_5:
  1039 0000893D E865FDFFFF          <1> 	call	check_for_backspace
  1040 00008942 740A                <1> 	je	short loc_set_time_bs_5
  1041                              <1> 	;xor	bh, bh ; video page 0
  1042 00008944 E8A09AFFFF          <1> 	call	beeper ; BEEP !
  1043 00008949 E994FEFFFF          <1>         jmp     loc_enter_time_separator_2
  1044                              <1> loc_set_time_bs_5:
  1045 0000894E E842FDFFFF          <1> 	call	write_backspace
  1046 00008953 E95FFEFFFF          <1>         jmp     loc_enter_minute_2
  1047                              <1> loc_set_time_stc_6:
  1048 00008958 E84AFDFFFF          <1> 	call	check_for_backspace
  1049 0000895D 7413                <1> 	je	short loc_set_time_bs_6
  1050                              <1> 	;xor	bh, bh ; video page 0
  1051 0000895F E8859AFFFF          <1> 	call	beeper ; BEEP !
  1052 00008964 66C705[D6410100]30- <1> 	mov	word [Second], 3030h
  1052 0000896C 30                  <1>
  1053 0000896D E99FFEFFFF          <1>         jmp     loc_enter_second_1
  1054                              <1> loc_set_time_bs_6:
  1055 00008972 E81EFDFFFF          <1> 	call	write_backspace
  1056 00008977 E966FEFFFF          <1>         jmp     loc_enter_time_separator_2
  1057                              <1> loc_set_time_stc_7:
  1058 0000897C E826FDFFFF          <1> 	call	check_for_backspace
  1059 00008981 740A                <1> 	je	short loc_set_time_bs_7
  1060                              <1> 	;xor	bh, bh ; video page 0
  1061 00008983 E8619AFFFF          <1> 	call	beeper ; BEEP !
  1062 00008988 E9B3FEFFFF          <1>         jmp     loc_enter_second_2
  1063                              <1> loc_set_time_bs_7:
  1064 0000898D E803FDFFFF          <1> 	call	write_backspace
  1065 00008992 E97AFEFFFF          <1>         jmp     loc_enter_second_1
  1066                              <1> 
  1067                              <1> print_volume_info:
  1068                              <1> 	; 01/03/2016
  1069                              <1> 	; 08/02/2016
  1070                              <1> 	; 06/02/2016
  1071                              <1> 	; 04/02/2016
  1072                              <1> 	; 18/01/2016 (TRDOS 386 = TRDOS v2.0)
  1073                              <1> 	; 25/10/2009
  1074                              <1> 	;
  1075                              <1> 	; "Volume Serial No: "
  1076                              <1>  	;
  1077                              <1> 	; INPUT  : AL = DOS Drive Number
  1078                              <1> 	; OUTPUT : AH = FS Type
  1079                              <1> 	;          AL = DOS Drive Name
  1080                              <1> 	; CF = 0 -> OK
  1081                              <1> 	; CF = 1 -> Drive not ready 
  1082                              <1> 
  1083 00008997 88C4                <1> 	mov	ah, al
  1084 00008999 28C0                <1> 	sub	al, al
  1085 0000899B 0FB7F0              <1> 	movzx	esi, ax	
  1086 0000899E 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1087 000089A4 8A06                <1> 	mov	al, [esi]
  1088 000089A6 3C41                <1> 	cmp	al, 'A'  
  1089 000089A8 7304                <1> 	jnb	short loc_pvi_set_vol_name
  1090 000089AA 8A6604              <1> 	mov	ah, [esi+LD_FSType]
  1091 000089AD C3                  <1> 	retn
  1092                              <1> 
  1093                              <1> loc_pvi_set_vol_name:
  1094 000089AE A2[0A420100]        <1> 	mov	[Vol_Drv_Name], al
  1095 000089B3 56                  <1> 	push	esi
  1096 000089B4 E858010000          <1> 	call	move_volume_name_and_serial_no ;;;
  1097 000089B9 7302                <1> 	jnc	short loc_pvi_mvn_ok
  1098 000089BB 5E                  <1> 	pop	esi
  1099 000089BC C3                  <1> 	retn
  1100                              <1> 
  1101                              <1> loc_pvi_mvn_ok:
  1102 000089BD 8B3424              <1> 	mov	esi, [esp]
  1103 000089C0 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  1104 000089C4 7509                <1> 	jne	short loc_pvi_fat_vol_size
  1105 000089C6 8B4670              <1> 	mov	eax, [esi+LD_FS_VolumeSize]
  1106 000089C9 0FB75E11            <1> 	movzx	ebx, word [esi+LD_FS_BytesPerSec]
  1107 000089CD EB07                <1> 	jmp	short loc_vol_size_mul32
  1108                              <1> loc_pvi_fat_vol_size:
  1109 000089CF 8B4670              <1> 	mov	eax, [esi+LD_TotalSectors]
  1110 000089D2 0FB75E11            <1> 	movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  1111                              <1> loc_vol_size_mul32:
  1112 000089D6 F7E3                <1> 	mul	ebx
  1113 000089D8 09D2                <1> 	or	edx, edx
  1114 000089DA 7507                <1> 	jnz	short loc_vol_size_in_kbytes
  1115                              <1> loc_vol_size_in_bytes:
  1116 000089DC B9[E8410100]        <1> 	mov	ecx, VolSize_Bytes
  1117 000089E1 EB0D                <1> 	jmp	short loc_write_vol_size_str
  1118                              <1> loc_vol_size_in_kbytes:
  1119 000089E3 66BB0004            <1> 	mov	bx, 1024
  1120 000089E7 F7F3                <1> 	div	ebx
  1121 000089E9 B9[DB410100]        <1> 	mov 	ecx, VolSize_KiloBytes
  1122 000089EE 31D2                <1> 	xor	edx, edx ; 0
  1123                              <1> loc_write_vol_size_str:
  1124 000089F0 890D[CB910100]      <1> 	mov	[VolSize_Unit1], ecx
  1125                              <1> 	; 
  1126 000089F6 BF[E1910100]        <1> 	mov	edi, Vol_Tot_Sec_Str_End
  1127                              <1>         ;mov	byte [edi], 0
  1128 000089FB B90A000000          <1> 	mov	ecx, 10
  1129                              <1> loc_write_vol_size_chr:
  1130 00008A00 F7F1                <1> 	div	ecx
  1131 00008A02 80C230              <1> 	add	dl, '0'
  1132 00008A05 4F                  <1> 	dec	edi	
  1133 00008A06 8817                <1> 	mov	[edi], dl
  1134 00008A08 85C0                <1> 	test	eax, eax
  1135 00008A0A 7404                <1> 	jz	short loc_write_vol_size_str_ok
  1136 00008A0C 28D2                <1> 	sub	dl, dl ; 0
  1137 00008A0E EBF0                <1> 	jmp	short loc_write_vol_size_chr
  1138                              <1> 
  1139                              <1> loc_write_vol_size_str_ok:
  1140 00008A10 893D[D3910100]      <1> 	mov	[Vol_Tot_Sec_Str_Start], edi
  1141                              <1> 	;
  1142 00008A16 BF[F3410100]        <1> 	mov	edi, Vol_FS_Name
  1143 00008A1B 8A4E03              <1> 	mov	cl, [esi+LD_FATType]
  1144 00008A1E 20C9                <1> 	and	cl, cl ; 0 ?
  1145 00008A20 7515                <1> 	jnz	short loc_write_vol_FAT_str_1
  1146 00008A22 66C7075452          <1> 	mov	word [edi], 'TR'
  1147 00008A27 C7470420465331      <1> 	mov	dword [edi+4], ' FS1'
  1148                              <1> 	;movzx	ebx, word [esi+LD_FS_BytesPerSec]
  1149 00008A2E 668B5E11            <1> 	mov	bx, [esi+LD_FS_BytesPerSec]
  1150 00008A32 8B4674              <1> 	mov	eax, [esi+LD_FS_FreeSectors]
  1151 00008A35 EB36                <1> 	jmp	short loc_vol_freespace_mul32
  1152                              <1> 
  1153                              <1> loc_write_vol_FAT_str_1:
  1154 00008A37 66B83332            <1> 	mov	ax, '32' ; FAT32
  1155 00008A3B 80F902              <1> 	cmp	cl, 2 ; [esi+LD_FATType]
  1156 00008A3E 7708                <1> 	ja	short loc_write_vol_FAT_str_2
  1157 00008A40 66B83132            <1> 	mov	ax, '12' ; FAT12
  1158 00008A44 7202                <1> 	jb	short loc_write_vol_FAT_str_2
  1159 00008A46 B436                <1> 	mov	ah, '6'  ; FAT16
  1160                              <1> loc_write_vol_FAT_str_2:
  1161 00008A48 C70746415420        <1> 	mov	dword [edi], 'FAT '
  1162 00008A4E 66894704            <1> 	mov	word [edi+4], ax
  1163                              <1> 	;
  1164                              <1> 	;movzx	ebx, word [esi+LD_BPB+BPB_BytsPerSec]
  1165 00008A52 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec]
  1166 00008A56 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  1167                              <1> 
  1168                              <1> loc_vol_freespace_recalc0:
  1169                              <1> 	; 01/03/2016
  1170 00008A59 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  1171 00008A5C 720F                <1> 	jb	short loc_vol_freespace_mul32
  1172                              <1> 	;inc	eax ; 0
  1173 00008A5E 20C9                <1> 	and	cl, cl ; byte [esi+LD_FATType]
  1174 00008A60 740B                <1> 	jz	short loc_vol_freespace_mul32 	
  1175 00008A62 53                  <1> 	push	ebx
  1176 00008A63 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free sectors
  1177 00008A67 E876490000          <1> 	call	calculate_fat_freespace
  1178 00008A6C 5B                  <1> 	pop	ebx
  1179                              <1> 
  1180                              <1> loc_vol_freespace_mul32:
  1181 00008A6D F7E3                <1> 	mul	ebx
  1182 00008A6F 09D2                <1> 	or	edx, edx
  1183 00008A71 7507                <1> 	jnz	short loc_vol_fspace_in_kbytes
  1184                              <1> loc_vol_fspace_in_bytes:
  1185 00008A73 B9[E8410100]        <1> 	mov	ecx, VolSize_Bytes
  1186 00008A78 EB0D                <1> 	jmp	short loc_write_vol_fspace_str
  1187                              <1> loc_vol_fspace_in_kbytes:
  1188 00008A7A 66BB0004            <1> 	mov	bx, 1024
  1189 00008A7E F7F3                <1> 	div	ebx
  1190 00008A80 B9[DB410100]        <1> 	mov 	ecx, VolSize_KiloBytes
  1191 00008A85 31D2                <1> 	xor	edx, edx ; 0
  1192                              <1> loc_write_vol_fspace_str:
  1193 00008A87 890D[CF910100]      <1> 	mov	[VolSize_Unit2], ecx
  1194                              <1> 	;	
  1195 00008A8D BF[F1910100]        <1> 	mov	edi, Vol_Free_Sectors_Str_End
  1196                              <1>         ;mov	byte [edi], 0
  1197 00008A92 B90A000000          <1> 	mov	ecx, 10
  1198                              <1> loc_write_vol_fspace_chr:
  1199 00008A97 F7F1                <1> 	div	ecx
  1200 00008A99 80C230              <1> 	add	dl, '0'
  1201 00008A9C 4F                  <1> 	dec	edi	
  1202 00008A9D 8817                <1> 	mov	[edi], dl
  1203 00008A9F 85C0                <1> 	test	eax, eax
  1204 00008AA1 7404                <1> 	jz	short loc_write_vol_fspace_str_ok
  1205 00008AA3 28D2                <1> 	sub	dl, dl ; 0
  1206 00008AA5 EBF0                <1> 	jmp	short loc_write_vol_fspace_chr
  1207                              <1> 
  1208                              <1> loc_write_vol_fspace_str_ok:
  1209 00008AA7 893D[E3910100]      <1> 	mov	[Vol_Free_Sectors_Str_Start], edi
  1210                              <1> 	;
  1211 00008AAD BE[F1410100]        <1> 	mov	esi, Volume_in_drive
  1212 00008AB2 E89EEAFFFF          <1> 	call	print_msg
  1213 00008AB7 BE[31420100]        <1> 	mov	esi, Vol_Name
  1214 00008ABC E894EAFFFF          <1> 	call	print_msg
  1215 00008AC1 BE[FF4C0100]        <1> 	mov	esi, nextline
  1216 00008AC6 E88AEAFFFF          <1> 	call	print_msg
  1217                              <1> 	;
  1218 00008ACB BE[92420100]        <1> 	mov	esi, Vol_Total_Sector_Header
  1219 00008AD0 E880EAFFFF          <1> 	call	print_msg
  1220 00008AD5 8B35[D3910100]      <1> 	mov	esi, [Vol_Tot_Sec_Str_Start]
  1221 00008ADB E875EAFFFF          <1> 	call	print_msg
  1222 00008AE0 8B35[CB910100]      <1> 	mov	esi, [VolSize_Unit1]
  1223 00008AE6 E86AEAFFFF          <1> 	call	print_msg
  1224                              <1> 	;
  1225 00008AEB BE[A3420100]        <1> 	mov	esi, Vol_Free_Sectors_Header
  1226 00008AF0 E860EAFFFF          <1> 	call	print_msg
  1227 00008AF5 8B35[E3910100]      <1> 	mov	esi, [Vol_Free_Sectors_Str_Start]
  1228 00008AFB E855EAFFFF          <1> 	call	print_msg
  1229 00008B00 8B35[CF910100]      <1> 	mov	esi, [VolSize_Unit2]
  1230 00008B06 E84AEAFFFF          <1> 	call	print_msg
  1231                              <1> 	;
  1232 00008B0B 5E                  <1> 	pop	esi
  1233                              <1> 	
  1234                              <1> 	;mov	ah, [esi+LD_FSType]
  1235                              <1> 	;mov	al, [esi+LD_FATType]
  1236 00008B0C 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  1237                              <1> 
  1238 00008B10 C3                  <1> 	retn
  1239                              <1> 
  1240                              <1> move_volume_name_and_serial_no:
  1241                              <1> 	; 08/02/2016  (TRDOS 386 = TRDOS v2.0)
  1242                              <1> 	; this routine will be called by
  1243                              <1> 	; "print_volume_info" and "print_directory"
  1244                              <1> 	; INPUT ->
  1245                              <1> 	;	ESI = Logical DOS drv descripton table address
  1246                              <1> 	; OUTPUT ->
  1247                              <1> 	;	*Volume name will be moved to text area
  1248                              <1> 	;	*Volume serial number will be converted to
  1249                              <1> 	;	 text and will be moved to text area
  1250                              <1> 	;   cf = 1 -> invalid/unknown dos drive
  1251                              <1> 	;   cf = 0 -> ecx = 0
  1252                              <1> 	;
  1253                              <1> 	; (eax, edx, ecx, esi, edi will be changed)
  1254                              <1> 
  1255 00008B11 BF[31420100]        <1> 	mov 	edi, Vol_Name
  1256                              <1> 
  1257                              <1> 	;mov	ah, [esi+LD_FSType]
  1258                              <1> 	;mov	al, [esi+LD_FATType]
  1259 00008B16 668B4603            <1> 	mov	ax, [esi+LD_FATType]
  1260 00008B1A 80FCA1              <1> 	cmp	ah, 0A1h
  1261 00008B1D 7418                <1> 	je	short mvn_2
  1262 00008B1F 08E4                <1> 	or	ah, ah
  1263 00008B21 7404                <1> 	jz	short mvn_0
  1264 00008B23 08C0                <1> 	or	al, al
  1265 00008B25 7504                <1> 	jnz	short mvn_1
  1266                              <1> mvn_0:
  1267 00008B27 8A06                <1> 	mov	al, [esi]
  1268 00008B29 F9                  <1> 	stc
  1269 00008B2A C3                  <1> 	retn
  1270                              <1> mvn_1:
  1271 00008B2B 3C02                <1> 	cmp	al, 2
  1272 00008B2D 7717                <1> 	ja	short mvn_3 
  1273                              <1> 	;or	al, al
  1274                              <1> 	;jz	short mvn_2
  1275 00008B2F 8B462D              <1> 	mov	eax, [esi+LD_BPB+VolumeID]
  1276 00008B32 83C631              <1> 	add	esi, LD_BPB+VolumeLabel
  1277 00008B35 EB15                <1> 	jmp	short mvn_4
  1278                              <1> mvn_2:
  1279 00008B37 8B4628              <1> 	mov	eax, [esi+LD_FS_VolumeSerial]
  1280 00008B3A 83C62C              <1> 	add	esi, LD_FS_VolumeName
  1281 00008B3D B910000000          <1> 	mov	ecx, 16
  1282 00008B42 F3A5                <1> 	rep	movsd
  1283 00008B44 EB10                <1> 	jmp	short mvn_5
  1284                              <1> mvn_3:
  1285 00008B46 8B4649              <1> 	mov	eax, [esi+LD_BPB+FAT32_VolID]
  1286 00008B49 83C64D              <1> 	add	esi, LD_BPB+FAT32_VolLab
  1287                              <1> mvn_4:
  1288 00008B4C B90B000000          <1> 	mov	ecx, 11
  1289 00008B51 F3A4                <1> 	rep	movsb
  1290 00008B53 C60700              <1> 	mov	byte [edi], 0
  1291                              <1> mvn_5:
  1292                              <1> 	;mov	[Current_VolSerial], eax  
  1293 00008B56 E8B2B7FFFF          <1> 	call	dwordtohex
  1294 00008B5B 8915[86420100]      <1> 	mov	[Vol_Serial1], edx
  1295 00008B61 A3[8B420100]        <1> 	mov	[Vol_Serial2], eax
  1296                              <1> 	; ecx = 0
  1297 00008B66 C3                  <1> 	retn
  1298                              <1> 
  1299                              <1> get_volume_serial_number:
  1300                              <1> 	; 19/01/2016 (TRDOS 386 = TRDOS v2.0)
  1301                              <1> 	; 08/08/2010
  1302                              <1> 	;
  1303                              <1> 	; INPUT -> DL = Logical DOS Drive number
  1304                              <1> 	; OUTPUT -> EAX = Volume serial number
  1305                              <1> 	;          BL= FAT Type	    
  1306                              <1> 	;          BH = Logical DOS drv Number (DL input)
  1307                              <1> 	; cf = 1 -> Drive not ready
  1308                              <1> 
  1309 00008B67 31DB                <1> 	xor	ebx, ebx
  1310 00008B69 88D7                <1> 	mov	bh, dl
  1311 00008B6B 3815[62400100]      <1> 	cmp	[Last_DOS_DiskNo], dl
  1312 00008B71 7304                <1> 	jnb	short loc_gvsn_start
  1313                              <1> loc_gvsn_stc_retn:
  1314 00008B73 31C0                <1> 	xor	eax, eax
  1315 00008B75 F9                  <1> 	stc 
  1316 00008B76 C3                  <1>         retn 
  1317                              <1> loc_gvsn_start:
  1318 00008B77 56                  <1> 	push	esi
  1319 00008B78 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1320 00008B7D 01DE                <1> 	add	esi, ebx
  1321 00008B7F 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
  1322 00008B82 20DB                <1> 	and	bl, bl
  1323 00008B84 740F                <1> 	jz	short loc_gvsn_fs
  1324 00008B86 80FB02              <1> 	cmp	bl, 2
  1325 00008B89 7705                <1> 	ja	short loc_gvsn_fat32
  1326                              <1> loc_gvsn_fat:
  1327 00008B8B 83C62D              <1> 	add	esi, LD_BPB + VolumeID
  1328 00008B8E EB0E                <1> 	jmp	short loc_gvsn_return
  1329                              <1> loc_gvsn_fat32: 
  1330 00008B90 83C649              <1> 	add	esi, LD_BPB + FAT32_VolID
  1331 00008B93 EB09                <1> 	jmp	short loc_gvsn_return 
  1332                              <1> loc_gvsn_fs:
  1333 00008B95 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  1334 00008B99 75D8                <1> 	jne	short loc_gvsn_stc_retn 
  1335 00008B9B 83C628              <1> 	add	esi, LD_FS_VolumeSerial
  1336                              <1> loc_gvsn_return:
  1337 00008B9E 8B06                <1> 	mov	eax, [esi]
  1338 00008BA0 5E                  <1> 	pop	esi
  1339 00008BA1 C3                  <1> 	retn
  1340                              <1> 
  1341                              <1> ; CMD_INTR.ASM [ TRDOS Command Interpreter Procedure ]
  1342                              <1> ; 09/11/2011
  1343                              <1> ; 29/01/2005
  1344                              <1> 
  1345                              <1> command_interpreter:
  1346                              <1> 	; 16/10/2016
  1347                              <1> 	; 12/10/2016
  1348                              <1> 	; 13/05/2016
  1349                              <1> 	; 07/05/2016
  1350                              <1> 	; 04/03/2016
  1351                              <1> 	; 04/02/2016
  1352                              <1> 	; 03/02/2016
  1353                              <1> 	; 30/01/2016
  1354                              <1> 	; 29/01/2016 (TRDOS 386 = TRDOS 2.0)
  1355                              <1> 	; 15/09/2011         
  1356                              <1> 	; 29/01/2005
  1357                              <1>         
  1358                              <1> 	; Input: ecx = command word length (CL)
  1359                              <1> 	;	 CommandBuffer = Command string offset
  1360                              <1>  
  1361 00008BA2 C605[84920100]00    <1> 	mov	byte [Program_Exit],0
  1362 00008BA9 80F904              <1> 	cmp	cl, 4
  1363 00008BAC 0F87B5020000        <1>         ja      c_6
  1364 00008BB2 0F8237010000        <1>         jb      c_2
  1365                              <1> c_4:
  1366                              <1> 
  1367                              <1> cmp_cmd_exit:
  1368 00008BB8 BF[D0400100]        <1> 	mov	edi, Cmd_Exit
  1369 00008BBD E8C2030000          <1> 	call	cmp_cmd	
  1370 00008BC2 7208                <1> 	jc	short cmp_cmd_date
  1371                              <1> 
  1372 00008BC4 C605[84920100]01    <1>         mov     byte [Program_Exit], 1
  1373 00008BCB C3                  <1>         retn
  1374                              <1> 
  1375                              <1> cmp_cmd_date:
  1376 00008BCC B104                <1> 	mov	cl, 4
  1377 00008BCE BF[EC400100]        <1> 	mov	edi, Cmd_Date
  1378 00008BD3 E8AC030000          <1> 	call	cmp_cmd	
  1379 00008BD8 720B                <1>         jc	short cmp_cmd_time
  1380                              <1> 	
  1381 00008BDA E8D0F7FFFF          <1> 	call	show_date
  1382 00008BDF E80FF8FFFF          <1> 	call	set_date
  1383 00008BE4 C3                  <1> 	retn
  1384                              <1> 
  1385                              <1> cmp_cmd_time:
  1386 00008BE5 B104                <1> 	mov	cl, 4
  1387 00008BE7 BF[F1400100]        <1> 	mov	edi, Cmd_Time
  1388 00008BEC E893030000          <1>    	call	cmp_cmd	
  1389 00008BF1 720B                <1> 	jc	short cmp_cmd_show
  1390                              <1> 
  1391 00008BF3 E8C6FAFFFF          <1> 	call	show_time
  1392 00008BF8 E8F8FAFFFF          <1> 	call	set_time
  1393 00008BFD C3                  <1> 	retn
  1394                              <1> 
  1395                              <1> cmp_cmd_show:
  1396 00008BFE B104                <1> 	mov	cl, 4
  1397 00008C00 BF[02410100]        <1> 	mov	edi, Cmd_Show
  1398 00008C05 E87A030000          <1>    	call	cmp_cmd	
  1399 00008C0A 0F83050A0000        <1>         jnc     show_file
  1400                              <1> 
  1401                              <1> cmp_cmd_echo:
  1402 00008C10 B104                <1> 	mov	cl, 4
  1403 00008C12 BF[3E410100]        <1> 	mov	edi, Cmd_Echo
  1404 00008C17 E868030000          <1>    	call	cmp_cmd	
  1405 00008C1C 7224                <1> 	jc	short cmp_cmd_copy
  1406                              <1> 	
  1407                              <1> 	; 22/11/2017
  1408                              <1> 	; AL = 0
  1409 00008C1E 803E20              <1> 	cmp	byte [esi], 20h
  1410 00008C21 7215                <1> 	jb	short cmd_echo_nextline
  1411                              <1> 	; 14/04/2016
  1412 00008C23 56                  <1> 	push	esi
  1413                              <1> cmd_echo_asciiz:
  1414                              <1> 	;inc	esi
  1415                              <1> 	;mov	al, [esi]
  1416                              <1> 	; 22/11/2017
  1417 00008C24 AC                  <1> 	lodsb
  1418 00008C25 3C20                <1> 	cmp	al, 20h
  1419 00008C27 73FB                <1> 	jnb	short cmd_echo_asciiz
  1420 00008C29 4E                  <1> 	dec	esi
  1421 00008C2A C60600              <1> 	mov	byte [esi], 0
  1422 00008C2D 5E                  <1> 	pop	esi
  1423 00008C2E 89F7                <1> 	mov	edi, esi
  1424 00008C30 E820E9FFFF          <1> 	call	print_msg
  1425 00008C35 C60700              <1> 	mov	byte [edi], 0	
  1426                              <1> cmd_echo_nextline:
  1427 00008C38 BE[6D4D0100]        <1> 	mov	esi, NextLine
  1428                              <1> 	;call	print_msg   
  1429                              <1> 	;retn
  1430 00008C3D E913E9FFFF          <1> 	jmp	print_msg
  1431                              <1> 
  1432                              <1> cmp_cmd_copy:
  1433 00008C42 B104                <1> 	mov	cl, 4
  1434 00008C44 BF[25410100]        <1> 	mov	edi, Cmd_Copy
  1435 00008C49 E836030000          <1>    	call	cmp_cmd	
  1436 00008C4E 0F83CC170000        <1> 	jnc	copy_file
  1437                              <1> 
  1438                              <1> cmp_cmd_move:
  1439 00008C54 B104                <1> 	mov	cl, 4
  1440 00008C56 BF[2A410100]        <1> 	mov	edi, Cmd_Move
  1441 00008C5B E824030000          <1>    	call	cmp_cmd	
  1442 00008C60 0F836E160000        <1> 	jnc	move_file
  1443                              <1> 
  1444                              <1> cmp_cmd_path:
  1445 00008C66 B104                <1> 	mov	cl, 4
  1446 00008C68 BF[2F410100]        <1> 	mov	edi, Cmd_Path
  1447 00008C6D E812030000          <1>    	call	cmp_cmd	
  1448 00008C72 0F83F0190000        <1> 	jnc	set_get_path
  1449                              <1> 
  1450                              <1> cmp_cmd_beep:
  1451 00008C78 B104                <1> 	mov	cl, 4
  1452 00008C7A BF[5C410100]        <1> 	mov	edi, Cmd_Beep
  1453 00008C7F E800030000          <1>    	call	cmp_cmd	
  1454 00008C84 720B                <1> 	jc	short cmp_cmd_find
  1455                              <1> 	; 13/05/2016
  1456 00008C86 8A3D[FE890100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  1457 00008C8C E95897FFFF          <1> 	jmp	beeper
  1458                              <1> 
  1459                              <1> cmp_cmd_find:
  1460 00008C91 B104                <1> 	mov	cl, 4
  1461 00008C93 BF[39410100]        <1> 	mov	edi, Cmd_Find
  1462 00008C98 E8E7020000          <1>    	call	cmp_cmd	
  1463 00008C9D 0F82C4020000        <1>         jc      cmp_cmd_external
  1464                              <1> 
  1465                              <1> 	;call	find_and_list_files
  1466 00008CA3 E9AF220000          <1> 	jmp	find_and_list_files
  1467                              <1> 	;retn
  1468                              <1> 
  1469                              <1> c_1:
  1470 00008CA8 AD                  <1> 	lodsd
  1471                              <1> cmp_cmd_help:
  1472 00008CA9 3C3F                <1> 	cmp	al, '?'
  1473 00008CAB 751D                <1>         jne     short cmp_cmd_remark
  1474                              <1> 
  1475 00008CAD BE[C2400100]        <1> 	mov	esi, Command_List
  1476                              <1> cmd_help_next_w:
  1477 00008CB2 E89EE8FFFF          <1> 	call	print_msg
  1478                              <1> 
  1479 00008CB7 803E20              <1> 	cmp	byte [esi], 20h ; 0
  1480 00008CBA 7232                <1> 	jb	short cmd_help_retn
  1481                              <1> 	
  1482 00008CBC 56                  <1> 	push	esi
  1483 00008CBD BE[FF4C0100]        <1> 	mov	esi, nextline
  1484 00008CC2 E88EE8FFFF          <1> 	call	print_msg
  1485 00008CC7 5E                  <1> 	pop	esi
  1486 00008CC8 EBE8                <1> 	jmp	short cmd_help_next_w	
  1487                              <1> 
  1488                              <1> cmp_cmd_remark:
  1489 00008CCA 3C2A                <1> 	cmp	al, '*'
  1490 00008CCC 0F8595020000        <1>         jne     cmp_cmd_external
  1491 00008CD2 46                  <1> 	inc	esi
  1492 00008CD3 BF[F88A0100]        <1> 	mov	edi, Remark
  1493 00008CD8 8A06                <1> 	mov	al, [esi]
  1494 00008CDA 3C20                <1> 	cmp	al, 20h
  1495 00008CDC 7707                <1> 	ja	short cmd_remark_write
  1496 00008CDE 89FE                <1> 	mov	esi, edi ; Remark
  1497 00008CE0 E970E8FFFF          <1> 	jmp	print_msg
  1498                              <1> 
  1499                              <1> cmd_remark_write:
  1500 00008CE5 AA                  <1> 	stosb
  1501 00008CE6 AC                  <1> 	lodsb
  1502 00008CE7 3C20                <1> 	cmp	al, 20h
  1503 00008CE9 73FA                <1> 	jnb	short cmd_remark_write
  1504 00008CEB C60700              <1> 	mov	byte [edi], 0
  1505                              <1> 
  1506                              <1> cmd_help_retn:
  1507                              <1> cmd_remark_retn:
  1508                              <1> cd_retn:
  1509 00008CEE C3                  <1> 	retn
  1510                              <1> 
  1511                              <1> c_2:
  1512 00008CEF 80F902              <1> 	cmp	cl, 2
  1513 00008CF2 0F87AF000000        <1>         ja      c_3
  1514 00008CF8 BE[468B0100]        <1> 	mov	esi, CommandBuffer
  1515 00008CFD 72A9                <1> 	jb	short c_1
  1516                              <1> 
  1517                              <1> cmp_cmd_cd:
  1518 00008CFF 66AD                <1> 	lodsw
  1519 00008D01 663D4344            <1> 	cmp	ax, 'CD'
  1520 00008D05 7551                <1> 	jne	short cmp_cmd_drive
  1521 00008D07 46                  <1>         inc	esi
  1522                              <1> cd_0:
  1523 00008D08 668B06              <1> 	mov	ax, [esi]	
  1524 00008D0B 3C20                <1> 	cmp	al, 20h
  1525 00008D0D 76DF                <1> 	jna	short cd_retn
  1526                              <1> 	; 10/02/2016
  1527 00008D0F 80FC3A              <1> 	cmp	ah, ':'
  1528 00008D12 7504                <1> 	jne	short cd_1
  1529 00008D14 46                  <1> 	inc	esi
  1530 00008D15 46                  <1> 	inc	esi
  1531 00008D16 EB49                <1> 	jmp	short cd_2
  1532                              <1> 
  1533                              <1> cd_1:	; change current directory
  1534                              <1> 	; 29/11/2009
  1535                              <1> 	; AH = CDh	; to separate 'CD' command from others
  1536                              <1> 			; for restoring current directory
  1537                              <1> 			; 0CDh sign is for saving cdir into 
  1538                              <1> 			; DOS drv description table cdir area
  1539                              <1> 	
  1540 00008D18 B4CD                <1> 	mov	ah, 0CDh ; mov byte [CD_COMMAND], 0CDh 
  1541                              <1> 
  1542 00008D1A E81D230000          <1> 	call	change_current_directory
  1543 00008D1F 0F8337220000        <1>         jnc     change_prompt_dir_string
  1544                              <1> 
  1545                              <1> cd_error_messages:
  1546 00008D25 3C03                <1> 	cmp	al, 3
  1547 00008D27 740C                <1> 	je	short cd_path_not_found
  1548                              <1> 	; 16/10/2016 (15h -> 15)
  1549 00008D29 3C0F                <1> 	cmp	al, 15 ; drive not ready error 
  1550 00008D2B 7459                <1> 	je	short cd_drive_not_ready
  1551 00008D2D 3C11                <1> 	cmp	al, 17 ; read error
  1552 00008D2F 7455                <1> 	je	short cd_drive_not_ready	
  1553 00008D31 3C13                <1> 	cmp	al, 19 ; ; Bad directory/path name 
  1554 00008D33 7466                <1> 	je	short cd_command_failed
  1555                              <1> 
  1556                              <1> cd_path_not_found:
  1557 00008D35 50                  <1> 	push	eax ; 29/12/2017
  1558                              <1> 	;push	ax	
  1559 00008D36 BE[65430100]        <1> 	mov	esi, Msg_Dir_Not_Found
  1560 00008D3B E815E8FFFF          <1> 	call	print_msg
  1561                              <1> 	;pop	ax
  1562 00008D40 58                  <1> 	pop	eax ; 29/12/2017
  1563 00008D41 3A25[948A0100]      <1> 	cmp	ah, [Current_Dir_Level]
  1564 00008D47 0F830F220000        <1>         jnb     change_prompt_dir_string
  1565 00008D4D 8825[948A0100]      <1> 	mov	[Current_Dir_Level], ah
  1566 00008D53 E904220000          <1>         jmp     change_prompt_dir_string   
  1567                              <1> 
  1568                              <1> cmp_cmd_drive: ; change current drive
  1569                              <1> 	; C:, D:, E: etc.
  1570 00008D58 80FC3A              <1> 	cmp	ah, ':'
  1571 00008D5B 0F8506020000        <1>         jne     cmp_cmd_external
  1572                              <1> 
  1573                              <1> cd_2:	; 'CD C:', 'CD D:' ...
  1574 00008D61 803E20              <1> 	cmp	byte [esi], 20h
  1575 00008D64 0F8707020000        <1>         ja      loc_cmd_failed
  1576                              <1> 
  1577 00008D6A 24DF                <1> 	and	al, 0DFh
  1578 00008D6C 2C41                <1> 	sub	al, 'A'
  1579 00008D6E 0F82FD010000        <1>         jc      loc_cmd_failed
  1580                              <1> 
  1581 00008D74 3A05[62400100]      <1>         cmp     al, [Last_DOS_DiskNo]
  1582 00008D7A 770A                <1>         ja	short cd_drive_not_ready
  1583                              <1> 	
  1584 00008D7C 88C2                <1> 	mov	dl, al
  1585 00008D7E E85BF3FFFF          <1> 	call 	change_current_drive
  1586 00008D83 7201                <1> 	jc	short cd_drive_not_ready	
  1587 00008D85 C3                  <1> 	retn
  1588                              <1> 
  1589                              <1> cd_drive_not_ready:
  1590 00008D86 BE[22430100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  1591 00008D8B E8C5E7FFFF          <1> 	call	print_msg
  1592                              <1> 
  1593                              <1> cd_fail_drive_restart:
  1594 00008D90 8A15[968A0100]      <1> 	mov	dl, [Current_Drv]
  1595                              <1> 	;call 	change_current_drive
  1596 00008D96 E943F3FFFF          <1>         jmp     change_current_drive
  1597                              <1> 	;retn
  1598                              <1> 
  1599                              <1> cd_command_failed:
  1600 00008D9B BE[03430100]        <1> 	mov	esi, Msg_Bad_Command
  1601 00008DA0 E8B0E7FFFF          <1> 	call	print_msg
  1602 00008DA5 EBE9                <1> 	jmp	short cd_fail_drive_restart
  1603                              <1> 
  1604                              <1> c_3:
  1605                              <1> cmp_cmd_dir:
  1606 00008DA7 BF[C2400100]        <1> 	mov	edi, Cmd_Dir
  1607 00008DAC E8D3010000          <1> 	call	cmp_cmd	
  1608 00008DB1 0F8380020000        <1> 	jnc	print_directory_list
  1609                              <1> 
  1610                              <1> cmp_cmd_cls:
  1611 00008DB7 B103                <1> 	mov	cl, 3
  1612 00008DB9 BF[FE400100]        <1> 	mov	edi, Cmd_Cls
  1613 00008DBE E8C1010000          <1> 	call	cmp_cmd	
  1614 00008DC3 0F83A2E7FFFF        <1>         jnc	clear_screen
  1615                              <1> 
  1616                              <1> cmp_cmd_ver:
  1617 00008DC9 B103                <1> 	mov	cl, 3
  1618 00008DCB BF[CC400100]        <1> 	mov	edi, Cmd_Ver
  1619 00008DD0 E8AF010000          <1> 	call	cmp_cmd	
  1620 00008DD5 720A                <1> 	jc	short cmp_cmd_mem
  1621                              <1> 
  1622 00008DD7 BE[6A400100]        <1> 	mov	esi, mainprog_Version
  1623                              <1> 	;call	print_msg
  1624 00008DDC E974E7FFFF          <1> 	jmp	print_msg
  1625                              <1> 	;retn
  1626                              <1> 
  1627                              <1> cmp_cmd_mem:
  1628 00008DE1 B103                <1> 	mov	cl, 3
  1629 00008DE3 BF[34410100]        <1> 	mov	edi, Cmd_Mem
  1630 00008DE8 E897010000          <1> 	call	cmp_cmd	
  1631 00008DED 0F834CB4FFFF        <1> 	jnc	memory_info
  1632                              <1> 
  1633                              <1> cmp_cmd_del:
  1634 00008DF3 B103                <1> 	mov	cl, 3
  1635 00008DF5 BF[07410100]        <1> 	mov	edi, Cmd_Del
  1636 00008DFA E885010000          <1> 	call	cmp_cmd	
  1637 00008DFF 0F83280F0000        <1>         jnc     delete_file
  1638                              <1> 
  1639                              <1> cmp_cmd_set:
  1640 00008E05 B103                <1> 	mov	cl, 3
  1641 00008E07 BF[FA400100]        <1> 	mov	edi, Cmd_Set
  1642 00008E0C E873010000          <1> 	call	cmp_cmd	
  1643 00008E11 0F83C9170000        <1>         jnc     set_get_env
  1644                              <1> 
  1645                              <1> cmp_cmd_run:
  1646 00008E17 B103                <1> 	mov	cl, 3
  1647 00008E19 BF[F6400100]        <1> 	mov	edi, Cmd_Run
  1648 00008E1E E861010000          <1> 	call	cmp_cmd	
  1649                              <1> 	; 07/05/2016
  1650 00008E23 0F823E010000        <1>         jc      cmp_cmd_external
  1651 00008E29 E90F1E0000          <1> 	jmp	load_and_execute_file
  1652                              <1> c_5:
  1653                              <1> cmp_cmd_mkdir:
  1654 00008E2E BF[1F410100]        <1> 	mov	edi, Cmd_Mkdir
  1655 00008E33 E84C010000          <1> 	call	cmp_cmd	
  1656 00008E38 0F83990A0000        <1>         jnc     make_directory
  1657                              <1> 
  1658                              <1> cmp_cmd_rmdir:
  1659 00008E3E B105                <1> 	mov	cl, 5
  1660 00008E40 BF[19410100]        <1> 	mov	edi, Cmd_Rmdir
  1661 00008E45 E83A010000          <1> 	call	cmp_cmd	
  1662 00008E4A 0F83AA0B0000        <1>         jnc     delete_directory
  1663                              <1> 
  1664                              <1> cmp_cmd_chdir:
  1665 00008E50 B105                <1> 	mov	cl, 5
  1666 00008E52 BF[56410100]        <1> 	mov	edi, Cmd_Chdir
  1667 00008E57 E828010000          <1> 	call	cmp_cmd	
  1668 00008E5C 0F8205010000        <1>         jc      cmp_cmd_external
  1669                              <1> 
  1670 00008E62 E9A1FEFFFF          <1> 	jmp	cd_0
  1671                              <1> 
  1672                              <1> c_6:
  1673 00008E67 80F906              <1> 	cmp	cl, 6
  1674 00008E6A 0F87E0000000        <1>         ja      c_8
  1675 00008E70 72BC                <1> 	jb	short c_5
  1676                              <1> cmp_cmd_prompt:
  1677 00008E72 BF[D5400100]        <1> 	mov	edi, Cmd_Prompt
  1678 00008E77 E808010000          <1> 	call	cmp_cmd	
  1679 00008E7C 722F                <1>         jc	short cmp_cmd_volume
  1680                              <1> get_prompt_name_fchar:
  1681 00008E7E AC                  <1> 	lodsb
  1682 00008E7F 3C20                <1> 	cmp	al, 20h
  1683 00008E81 74FB                <1> 	je	short get_prompt_name_fchar
  1684 00008E83 7713                <1> 	ja	short loc_change_prompt_label
  1685                              <1> default_command_prompt: ; 31/12/2017 ('sysprompt')
  1686 00008E85 BE[B6400100]        <1> 	mov	esi, TRDOSPromptLabel
  1687 00008E8A C7065452444F        <1> 	mov	dword [esi], "TRDO"
  1688 00008E90 66C746045300        <1>        	mov	word [esi+4], "S" 
  1689                              <1> loc_cmd_prompt_return:
  1690 00008E96 C3                  <1> 	retn
  1691                              <1> 
  1692                              <1> set_command_prompt: ; 31/12/2017 ('sysprompt')
  1693 00008E97 AC                  <1> 	lodsb
  1694                              <1> loc_change_prompt_label:
  1695 00008E98 66B90B00            <1> 	mov	cx, 11
  1696 00008E9C BF[B6400100]        <1> 	mov	edi, TRDOSPromptLabel
  1697                              <1> put_char_new_prompt_label:
  1698 00008EA1 AA                  <1> 	stosb
  1699 00008EA2 AC                  <1> 	lodsb
  1700 00008EA3 3C20                <1> 	cmp	al, 20h
  1701 00008EA5 7202                <1> 	jb	short pass_put_new_prompt_label
  1702 00008EA7 E2F8                <1> 	loop	put_char_new_prompt_label
  1703                              <1> pass_put_new_prompt_label:
  1704 00008EA9 C60700              <1> 	mov	byte [edi], 0
  1705 00008EAC C3                  <1> 	retn
  1706                              <1> 
  1707                              <1> cmp_cmd_volume:
  1708 00008EAD B106                <1> 	mov	cl, 6
  1709 00008EAF BF[DC400100]        <1> 	mov	edi, Cmd_Volume
  1710 00008EB4 E8CB000000          <1> 	call	cmp_cmd	
  1711 00008EB9 7255                <1>         jc	short cmp_cmd_attrib
  1712                              <1> 
  1713                              <1> cmd_vol1:
  1714 00008EBB AC                  <1> 	lodsb
  1715 00008EBC 3C20                <1> 	cmp	al, 20h
  1716 00008EBE 7707                <1> 	ja	short cmd_vol2
  1717 00008EC0 A0[968A0100]        <1> 	mov	al, [Current_Drv]
  1718 00008EC5 EB3D                <1> 	jmp	short cmd_vol4
  1719                              <1> cmd_vol2:
  1720 00008EC7 3C41                <1> 	cmp	al, 'A'
  1721 00008EC9 0F82A2000000        <1>         jb      loc_cmd_failed
  1722 00008ECF 3C7A                <1> 	cmp	al, 'z'
  1723 00008ED1 0F879A000000        <1>         ja      loc_cmd_failed
  1724 00008ED7 3C5A                <1> 	cmp	al, 'Z'
  1725 00008ED9 760A                <1> 	jna	short cmd_vol3
  1726 00008EDB 3C61                <1> 	cmp	al, 'a'
  1727 00008EDD 0F828E000000        <1>         jb      loc_cmd_failed
  1728 00008EE3 24DF                <1> 	and	al, 0DFh
  1729                              <1> cmd_vol3:
  1730 00008EE5 8A26                <1> 	mov	ah, [esi]
  1731 00008EE7 80FC3A              <1> 	cmp	ah, ':'
  1732 00008EEA 0F8581000000        <1>         jne     loc_cmd_failed
  1733 00008EF0 2C41                <1> 	sub	al, 'A'
  1734 00008EF2 3A05[62400100]      <1>         cmp     al, [Last_DOS_DiskNo]
  1735 00008EF8 760A                <1> 	jna	short cmd_vol4
  1736                              <1> 
  1737 00008EFA BE[22430100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  1738 00008EFF E951E6FFFF          <1> 	jmp	print_msg
  1739                              <1> 	
  1740                              <1> cmd_vol4:
  1741 00008F04 E88EFAFFFF          <1> 	call	print_volume_info
  1742 00008F09 0F8277FEFFFF        <1>         jc      cd_drive_not_ready
  1743 00008F0F C3                  <1> 	retn
  1744                              <1> 
  1745                              <1> cmp_cmd_attrib:
  1746 00008F10 B106                <1> 	mov	cl, 6
  1747 00008F12 BF[0B410100]        <1> 	mov	edi, Cmd_Attrib
  1748 00008F17 E868000000          <1> 	call	cmp_cmd	
  1749 00008F1C 0F831D0F0000        <1>         jnc     set_file_attributes
  1750                              <1> 
  1751                              <1> cmp_cmd_rename:
  1752 00008F22 B106                <1> 	mov	cl, 6
  1753 00008F24 BF[12410100]        <1> 	mov	edi, Cmd_Rename
  1754 00008F29 E856000000          <1> 	call	cmp_cmd	
  1755 00008F2E 0F8353110000        <1>         jnc     rename_file
  1756                              <1> 
  1757                              <1> cmp_cmd_device:
  1758 00008F34 B106                <1> 	mov	cl, 6
  1759 00008F36 BF[47410100]        <1> 	mov	edi, Cmd_Device
  1760 00008F3B E844000000          <1> 	call	cmp_cmd	
  1761 00008F40 7225                <1>         jc	short cmp_cmd_external
  1762                              <1> 
  1763 00008F42 C3                  <1> 	retn
  1764                              <1> 
  1765                              <1> c_7:
  1766                              <1> cmp_cmd_devlist:
  1767 00008F43 BF[4E410100]        <1> 	mov	edi, Cmd_DevList
  1768 00008F48 E837000000          <1> 	call	cmp_cmd	
  1769 00008F4D 7218                <1>         jc	short cmp_cmd_external
  1770                              <1> 
  1771                              <1> loc_cmd_return:
  1772 00008F4F C3                  <1> 	retn
  1773                              <1> 
  1774                              <1> c_8:
  1775 00008F50 80F908              <1>         cmp	cl, 8
  1776 00008F53 7712                <1> 	ja	short cmp_cmd_external
  1777 00008F55 72EC                <1> 	jb	short c_7
  1778                              <1> 
  1779                              <1> cmp_cmd_longname:
  1780 00008F57 BF[E3400100]        <1> 	mov	edi, Cmd_LongName
  1781 00008F5C E823000000          <1> 	call	cmp_cmd	
  1782 00008F61 0F8350060000        <1>         jnc     get_and_print_longname
  1783                              <1> 
  1784                              <1> cmp_cmd_external:
  1785                              <1> 	; 07/05/2016
  1786                              <1> 	; 22/04/2016
  1787 00008F67 BE[468B0100]        <1> 	mov	esi, CommandBuffer
  1788 00008F6C E9CC1C0000          <1> 	jmp	loc_run_check_filename 
  1789                              <1> 
  1790                              <1> loc_cmd_failed:
  1791 00008F71 803D[468B0100]20    <1> 	cmp	byte [CommandBuffer], 20h
  1792 00008F78 76D5                <1> 	jna	short loc_cmd_return
  1793 00008F7A BE[03430100]        <1> 	mov	esi, Msg_Bad_Command
  1794                              <1> ;	call	print_msg
  1795                              <1> ;loc_cmd_return:
  1796                              <1> ;	retn
  1797 00008F7F E9D1E5FFFF          <1> 	jmp	print_msg
  1798                              <1> 
  1799                              <1> cmp_cmd:
  1800                              <1> 	 ; 29/01/2016 (TRDOS 386 = TRDOS v2.0)
  1801 00008F84 BE[468B0100]        <1>          mov	esi, CommandBuffer
  1802                              <1>          ; edi = internal command word (ASCIIZ)
  1803                              <1> 	 ; ecx = command length (<=8)
  1804                              <1> cmp_cmd_1:
  1805 00008F89 AC                  <1> 	lodsb
  1806 00008F8A AE                  <1> 	scasb
  1807 00008F8B 750D                <1> 	jne	short cmp_cmd_3
  1808 00008F8D E2FA                <1> 	loop	cmp_cmd_1
  1809 00008F8F AC                  <1>  	lodsb
  1810 00008F90 3C20                <1> 	cmp	al, 20h
  1811 00008F92 7703                <1> 	ja	short cmp_cmd_2
  1812 00008F94 30C0                <1> 	xor	al, al
  1813                              <1> 	; ZF = 1 -> internal command word matches
  1814 00008F96 C3                  <1> 	retn
  1815                              <1> cmp_cmd_2:
  1816                              <1> 	; ZF = 0 (CF = 0) -> external command word 	
  1817 00008F97 58                  <1> 	pop	eax ; no return to the caller from here 
  1818 00008F98 EBCD                <1> 	jmp	cmp_cmd_external	
  1819                              <1> cmp_cmd_3:
  1820 00008F9A F9                  <1> 	stc
  1821                              <1> 	; CF = 1 -> internal command word does not match
  1822 00008F9B C3                  <1> 	retn
  1823                              <1> 
  1824                              <1> loc_run_cmd_failed:
  1825                              <1> 	; 15/03/2016
  1826                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  1827                              <1> 	; 07/12/2009 (CMD_INTR.ASM)	
  1828                              <1> 	; 29/11/2009
  1829                              <1> 
  1830 00008F9C E863000000          <1> 	call	restore_cdir_after_cmd_fail
  1831                              <1> 
  1832                              <1> loc_run_cmd_failed_cmp_al:
  1833                              <1> 	; End of Restore_CDIR code (29/11/2009)
  1834                              <1> 
  1835 00008FA1 3C01                <1> 	cmp	al, 1 ; Bad command or file name
  1836 00008FA3 74CC                <1> 	je	loc_cmd_failed
  1837                              <1> loc_run_dir_not_found:
  1838 00008FA5 3C03                <1> 	cmp	al, 3
  1839 00008FA7 750A                <1> 	jne	short loc_run_file_notfound_msg
  1840                              <1> 	; Path not found (MS-DOS Error Code = 3)
  1841 00008FA9 BE[65430100]        <1> 	mov	esi, Msg_Dir_Not_Found
  1842 00008FAE E9A2E5FFFF          <1> 	jmp	print_msg
  1843                              <1> 
  1844                              <1> loc_run_file_notfound_msg:
  1845 00008FB3 3C02                <1> 	cmp	al, 2 ; File not found
  1846 00008FB5 750A                <1> 	jne	short loc_run_file_drv_read_err
  1847                              <1> 
  1848                              <1> loc_print_file_notfound_msg: 
  1849 00008FB7 BE[7C430100]        <1>         mov     esi, Msg_File_Not_Found
  1850                              <1> 	;call	proc_printmsg
  1851                              <1> 	;retn
  1852 00008FBC E994E5FFFF          <1> 	jmp	print_msg
  1853                              <1> 
  1854                              <1> loc_run_file_drv_read_err:
  1855                              <1> 	; Err: 17 (Read fault)
  1856 00008FC1 3C11                <1> 	cmp	al, 17 ; Drive not ready or read error
  1857 00008FC3 7404                <1> 	je	short loc_run_file_print_drv_read_err
  1858                              <1> 	;
  1859 00008FC5 3C0F                <1> 	cmp	al, 15 ; Drive not ready (or read error)
  1860 00008FC7 750A                <1> 	jne	short loc_run_file_toobig
  1861                              <1> 
  1862                              <1> loc_run_file_print_drv_read_err:
  1863 00008FC9 BE[22430100]        <1> 	mov	esi, Msg_Not_Ready_Read_Err
  1864 00008FCE E982E5FFFF          <1> 	jmp	print_msg
  1865                              <1> 
  1866                              <1> loc_run_file_toobig:
  1867 00008FD3 3C08                <1> 	cmp	al, 8 ; Not enough free memory to load&run file
  1868 00008FD5 750A                <1> 	jne	short loc_run_file_perm_denied
  1869 00008FD7 BE[C7430100]        <1> 	mov	esi, Msg_Insufficient_Memory
  1870 00008FDC E974E5FFFF          <1> 	jmp	print_msg
  1871                              <1> 
  1872                              <1> loc_run_file_perm_denied:
  1873                              <1> 	; 29/12/2017
  1874 00008FE1 3C0B                <1> 	cmp	al, ERR_PERM_DENIED ; 11 ; Permission denied
  1875 00008FE3 750A                <1> 	jne	short loc_run_misc_error
  1876 00008FE5 BE[5C450100]        <1> 	mov	esi, Msg_Permission_Denied
  1877 00008FEA E966E5FFFF          <1> 	jmp	print_msg	
  1878                              <1> 
  1879                              <1> 	; 15/03/2016
  1880                              <1> print_misc_error_msg:
  1881                              <1> loc_run_misc_error:
  1882                              <1> 	; AL = Error code
  1883 00008FEF E8D9B2FFFF          <1> 	call	bytetohex
  1884 00008FF4 66A3[FB430100]      <1>         mov     [error_code_hex], ax
  1885                              <1> 	
  1886 00008FFA BE[DE430100]        <1> 	mov	esi, Msg_Error_Code 
  1887                              <1> 	;call	print_msg 
  1888                              <1> 	;retn
  1889                              <1> 
  1890 00008FFF E951E5FFFF          <1> 	jmp	print_msg
  1891                              <1> 
  1892                              <1> restore_cdir_after_cmd_fail:
  1893                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  1894 00009004 50                  <1> 	push	eax
  1895 00009005 8A3D[F2910100]      <1> 	mov	bh, [RUN_CDRV] ; it is set at the beginning
  1896                              <1> 				; of the 'run' command.
  1897 0000900B 3A3D[968A0100]      <1> 	cmp	bh, [Current_Drv]
  1898 00009011 7409                <1> 	je	short loc_run_restore_cdir
  1899 00009013 88FA                <1> 	mov	dl, bh
  1900 00009015 E8C4F0FFFF          <1> 	call	change_current_drive 
  1901 0000901A EB19                <1> 	jmp	short loc_run_err_pass_restore_cdir
  1902                              <1> 
  1903                              <1> loc_run_restore_cdir:
  1904 0000901C 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  1905 00009023 7610                <1> 	jna	short loc_run_err_pass_restore_cdir
  1906 00009025 30DB                <1> 	xor	bl, bl
  1907 00009027 0FB7F3              <1> 	movzx	esi, bx
  1908 0000902A 81C600010900        <1> 	add	esi, Logical_DOSDisks
  1909 00009030 E860F1FFFF          <1> 	call	restore_current_directory
  1910                              <1> 
  1911                              <1> loc_run_err_pass_restore_cdir:
  1912 00009035 58                  <1> 	pop	eax
  1913 00009036 C3                  <1> 	retn
  1914                              <1> 
  1915                              <1> print_directory_list:
  1916                              <1> 	; 10/02/2016
  1917                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  1918                              <1> 	; 06/12/2009 ('cmp_cmd_dir')	
  1919                              <1> 	;
  1920 00009037 66C705[34930100]00- <1> 	mov	word [AttributesMask], 0800h ; ..except volume names..
  1920 0000903F 08                  <1>
  1921 00009040 A0[968A0100]        <1> 	mov	al, [Current_Drv]
  1922 00009045 A2[F2910100]        <1> 	mov	[RUN_CDRV], al
  1923                              <1> get_dfname_fchar:
  1924 0000904A AC                  <1> 	lodsb
  1925 0000904B 3C20                <1> 	cmp	al, 20h
  1926 0000904D 74FB                <1> 	je	short get_dfname_fchar
  1927 0000904F 0F82A4000000        <1>         jb      loc_print_dir_call_all
  1928 00009055 3C2D                <1> 	cmp	al, '-'
  1929 00009057 7542                <1> 	jne	short loc_print_dir_call_flt
  1930                              <1> get_next_attr_char:
  1931 00009059 AC                  <1> 	lodsb
  1932 0000905A 3C20                <1> 	cmp	al, 20h
  1933 0000905C 74FB                <1> 	je	short get_next_attr_char
  1934 0000905E 0F820DFFFFFF        <1>         jb      loc_cmd_failed
  1935 00009064 24DF                <1> 	and	al, 0DFh
  1936 00009066 3C44                <1> 	cmp	al, 'D' ; directories only ?
  1937 00009068 7512                <1> 	jne	short pass_only_directories
  1938 0000906A AC                  <1> 	lodsb
  1939 0000906B 3C20                <1> 	cmp	al, 20h
  1940 0000906D 0F87FEFEFFFF        <1>         ja      loc_cmd_failed
  1941 00009073 800D[34930100]10    <1> 	or	byte [AttributesMask], 10h ; ..directory..
  1942 0000907A EB18                <1> 	jmp	short get_dfname_fchar_attr
  1943                              <1> pass_only_directories:
  1944 0000907C 3C46                <1> 	cmp	al, 'F'	; files only ?
  1945 0000907E 0F85B0000000        <1>         jne     check_attr_s
  1946 00009084 AC                  <1> 	lodsb
  1947 00009085 3C20                <1> 	cmp	al, 20h
  1948 00009087 0F87E4FEFFFF        <1>         ja      loc_cmd_failed
  1949 0000908D 800D[35930100]10    <1> 	or	byte [AttributesMask+1], 10h ; ..except directories..
  1950                              <1> get_dfname_fchar_attr:
  1951 00009094 AC                  <1> 	lodsb
  1952 00009095 3C20                <1> 	cmp	al, 20h
  1953 00009097 74FB                <1> 	je	short get_dfname_fchar_attr
  1954 00009099 725E                <1> 	jb	short loc_print_dir_call_all
  1955                              <1> 
  1956                              <1> loc_print_dir_call_flt:
  1957 0000909B 4E                  <1> 	dec	esi
  1958 0000909C BF[36930100]        <1> 	mov	edi, FindFile_Drv
  1959 000090A1 E8AC250000          <1> 	call	parse_path_name
  1960 000090A6 7308                <1>  	jnc	short loc_print_dir_change_drv_1
  1961 000090A8 3C01                <1> 	cmp	al, 1
  1962 000090AA 0F87ECFEFFFF        <1>         ja      loc_run_cmd_failed
  1963                              <1> 
  1964                              <1> loc_print_dir_change_drv_1:
  1965 000090B0 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  1966                              <1> loc_print_dir_change_drv_2:
  1967 000090B6 3A15[F2910100]      <1> 	cmp	dl, [RUN_CDRV]
  1968 000090BC 740B                <1> 	je	short loc_print_dir_change_directory 
  1969 000090BE E81BF0FFFF          <1> 	call	change_current_drive
  1970 000090C3 0F82D3FEFFFF        <1>         jc      loc_run_cmd_failed
  1971                              <1> loc_print_dir_change_directory:
  1972 000090C9 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h ; 0 or 20h ?
  1973 000090D0 761D                <1> 	jna	short pass_print_dir_change_directory
  1974                              <1> 
  1975 000090D2 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  1976 000090D8 BE[37930100]        <1> 	mov	esi, FindFile_Directory
  1977 000090DD 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  1978 000090DF E8581F0000          <1> 	call	change_current_directory
  1979 000090E4 0F82B2FEFFFF        <1>         jc      loc_run_cmd_failed
  1980                              <1> 
  1981                              <1> loc_print_dir_change_prompt_dir_string:
  1982 000090EA E86D1E0000          <1> 	call	change_prompt_dir_string
  1983                              <1> 
  1984                              <1> pass_print_dir_change_directory:
  1985 000090EF BE[78930100]        <1> 	mov	esi, FindFile_Name
  1986 000090F4 803E20              <1> 	cmp	byte [esi], 20h ; ; 0 or 20h ?
  1987 000090F7 7706                <1> 	ja	short loc_print_dir_call
  1988                              <1> 
  1989                              <1> loc_print_dir_call_all:
  1990 000090F9 C7062A2E2A00        <1> 	mov	dword [esi], '*.*'
  1991                              <1> loc_print_dir_call:
  1992 000090FF E87E000000          <1> 	call	print_directory
  1993                              <1> 
  1994 00009104 8A15[F2910100]      <1> 	mov	dl, [RUN_CDRV]  ; it is set at the beginning
  1995 0000910A 3A15[968A0100]      <1> 	cmp	dl, [Current_Drv]
  1996 00009110 7406                <1> 	je	short loc_print_dir_call_restore_cdir_retn
  1997 00009112 E8C7EFFFFF          <1> 	call	change_current_drive 
  1998 00009117 C3                  <1> 	retn
  1999                              <1> 
  2000                              <1> loc_print_dir_call_restore_cdir_retn:
  2001 00009118 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  2002 0000911F 7610                <1> 	jna	short pass_print_dir_call_restore_cdir_retn
  2003                              <1> 
  2004 00009121 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2005 00009126 31C0                <1> 	xor	eax, eax
  2006 00009128 88D4                <1> 	mov	ah, dl
  2007 0000912A 01C6                <1> 	add	esi, eax
  2008                              <1> 
  2009 0000912C E864F0FFFF          <1> 	call	restore_current_directory
  2010                              <1> 
  2011                              <1> pass_print_dir_call_restore_cdir_retn:
  2012 00009131 C3                  <1> 	retn
  2013                              <1> 
  2014                              <1> check_attr_s_cap:
  2015 00009132 24DF                <1> 	and	al, 0DFh
  2016                              <1> check_attr_s:
  2017 00009134 3C53                <1> 	cmp	al, 'S'
  2018 00009136 7514                <1> 	jne	short pass_attr_s
  2019 00009138 800D[34930100]04    <1> 	or	byte [AttributesMask], 4 ; system
  2020 0000913F AC                  <1> 	lodsb
  2021 00009140 3C20                <1> 	cmp	al, 20h
  2022 00009142 0F844CFFFFFF        <1>         je      get_dfname_fchar_attr
  2023 00009148 72AF                <1> 	jb	short loc_print_dir_call_all
  2024 0000914A 24DF                <1> 	and	al, 0DFh
  2025                              <1> pass_attr_s:
  2026 0000914C 3C48                <1> 	cmp	al, 'H'
  2027 0000914E 7514                <1> 	jne	short pass_attr_h
  2028 00009150 800D[34930100]02    <1> 	or	byte [AttributesMask], 2 ; hidden
  2029                              <1> pass_attr_shr:
  2030 00009157 AC                  <1> 	lodsb
  2031 00009158 3C20                <1> 	cmp	al, 20h
  2032 0000915A 0F8434FFFFFF        <1>         je      get_dfname_fchar_attr
  2033 00009160 7297                <1> 	jb	short loc_print_dir_call_all
  2034 00009162 EBCE                <1> 	jmp	short check_attr_s_cap
  2035                              <1> 
  2036                              <1> pass_attr_h:
  2037 00009164 3C52                <1> 	cmp	al, 'R'
  2038 00009166 7509                <1> 	jne	short pass_attr_r
  2039 00009168 800D[34930100]01    <1> 	or	byte [AttributesMask], 1 ; read only
  2040 0000916F EBE6                <1> 	jmp	short pass_attr_shr
  2041                              <1> 
  2042                              <1> pass_attr_r:
  2043 00009171 3C41                <1> 	cmp	al, 'A'
  2044 00009173 0F85F8FDFFFF        <1>         jne     loc_cmd_failed
  2045 00009179 800D[34930100]20    <1> 	or	byte [AttributesMask], 20h ; archive
  2046 00009180 EBD5                <1> 	jmp	short pass_attr_shr
  2047                              <1> 
  2048                              <1> print_directory:
  2049                              <1> 	; 13/05/2016
  2050                              <1> 	; 11/02/2016
  2051                              <1> 	; 10/02/2016
  2052                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2053                              <1> 	; 30/10/2010 ('proc_print_directory')	
  2054                              <1> 	; 19/09/2009
  2055                              <1> 	; 2005 
  2056                              <1> 	; INPUT ->
  2057                              <1> 	;	ESI = Asciiz File/Dir Name Address
  2058                              <1> 
  2059 00009182 56                  <1> 	push	esi
  2060                              <1> 
  2061 00009183 29C0                <1> 	sub	eax, eax
  2062                              <1> 
  2063 00009185 66A3[C0930100]      <1> 	mov	word [Dir_Count], ax ; 0
  2064 0000918B 66A3[BE930100]      <1> 	mov 	word [File_Count], ax ; 0
  2065 00009191 A3[C2930100]        <1> 	mov 	dword [Total_FSize], eax ; 0
  2066                              <1> 
  2067 00009196 E8D0E3FFFF          <1> 	call    clear_screen
  2068                              <1> 	
  2069 0000919B 31C9                <1> 	xor	ecx, ecx	
  2070 0000919D 8A2D[968A0100]      <1> 	mov     ch, [Current_Drv] ; DirBuff_Drv - 'A'
  2071 000091A3 A0[978A0100]        <1> 	mov     al, [Current_Dir_Drv] 
  2072 000091A8 A2[20420100]        <1> 	mov     [Dir_Drive_Name], al
  2073 000091AD BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2074 000091B2 01CE                <1> 	add	esi, ecx
  2075                              <1> 
  2076 000091B4 E858F9FFFF          <1> 	call	move_volume_name_and_serial_no
  2077 000091B9 730C                <1> 	jnc	short print_dir_strlen_check
  2078                              <1> 
  2079 000091BB 5E                  <1> 	pop	esi
  2080 000091BC 8A3D[FE890100]      <1> 	mov	bh, [ptty] ; [ACTIVE_PAGE]
  2081                              <1> 	;call	beeper
  2082                              <1> 	;retn
  2083 000091C2 E92292FFFF          <1> 	jmp	beeper  ; beep ! and return
  2084                              <1> 
  2085                              <1> print_dir_strlen_check:
  2086 000091C7 BE[998A0100]        <1> 	mov	esi, Current_Dir_Root
  2087 000091CC BF[BD420100]        <1> 	mov	edi, Dir_Str_Root
  2088                              <1> 	
  2089                              <1> 	;xor	ecx, ecx
  2090 000091D1 8A0D[F58A0100]      <1>         mov     cl, [Current_Dir_StrLen]
  2091 000091D7 FEC1                <1> 	inc	cl
  2092 000091D9 80F940              <1> 	cmp	cl, 64
  2093 000091DC 760D                <1> 	jna	short pass_print_dir_strlen_shorting
  2094 000091DE 46                  <1> 	inc	esi
  2095 000091DF 01CE                <1> 	add	esi, ecx
  2096 000091E1 83EE40              <1> 	sub	esi, 64 
  2097 000091E4 47                  <1> 	inc	edi
  2098 000091E5 B82E2E2E20          <1> 	mov	eax, '... ' 
  2099 000091EA AB                  <1> 	stosd
  2100                              <1>  
  2101                              <1> pass_print_dir_strlen_shorting:
  2102 000091EB F3A4                <1> 	rep	movsb
  2103                              <1> 
  2104 000091ED BE[13420100]        <1> 	mov	esi, Dir_Drive_Str
  2105 000091F2 E85EE3FFFF          <1> 	call	print_msg
  2106                              <1> 
  2107 000091F7 BE[72420100]        <1> 	mov	esi, Vol_Serial_Header
  2108 000091FC E854E3FFFF          <1> 	call	print_msg
  2109                              <1> 
  2110 00009201 BE[B2420100]        <1> 	mov	esi, Dir_Str_Header
  2111 00009206 E84AE3FFFF          <1> 	call	print_msg
  2112                              <1> 	
  2113 0000920B BE[FD4C0100]        <1> 	mov	esi, next2line
  2114 00009210 E840E3FFFF          <1> 	call	print_msg
  2115                              <1> 
  2116                              <1> loc_print_dir_first_file:
  2117 00009215 C605[D5930100]10    <1> 	mov	byte [PrintDir_RowCounter], 16
  2118 0000921C 66A1[34930100]      <1> 	mov	ax, [AttributesMask]
  2119 00009222 5E                  <1> 	pop	esi
  2120                              <1> 
  2121 00009223 E859020000          <1> 	call	find_first_file
  2122 00009228 0F826F010000        <1>         jc      loc_dir_ok
  2123                              <1> 	 
  2124                              <1> loc_dfname_use_this:
  2125                              <1> 	; bl =	File Attributes (bh = Long Name Entry Length)
  2126 0000922E F6C310              <1> 	test	bl, 10h  ; Is it a directory?
  2127 00009231 741B                <1> 	jz	short loc_not_dir
  2128                              <1> 
  2129 00009233 66FF05[C0930100]    <1> 	inc	word [Dir_Count]
  2130 0000923A 89F2                <1> 	mov	edx, esi 	; FindFile_DirEntry address
  2131 0000923C BE[02440100]        <1>  	mov	esi, Type_Dir	; '<DIR>     '
  2132 00009241 BF[19440100]        <1> 	mov	edi, Dir_Or_FileSize
  2133                              <1> 	; move 10 bytes
  2134 00009246 A5                  <1> 	movsd
  2135 00009247 A5                  <1> 	movsd
  2136 00009248 66A5                <1> 	movsw	    	
  2137 0000924A 89D6                <1> 	mov	esi, edx
  2138 0000924C EB36                <1> 	jmp     short loc_dir_attribute
  2139                              <1> 
  2140                              <1> loc_not_dir:
  2141 0000924E 66FF05[BE930100]    <1> 	inc	word [File_Count]
  2142 00009255 0105[C2930100]      <1> 	add	[Total_FSize], eax
  2143                              <1> 
  2144 0000925B B90A000000          <1> 	mov	ecx, 10  ; 32 bit divisor
  2145 00009260 89CF                <1> 	mov	edi, ecx
  2146 00009262 81C7[19440100]      <1> 	add	edi, Dir_Or_FileSize
  2147                              <1> loc_dir_rdivide:
  2148 00009268 29D2                <1> 	sub	edx, edx
  2149 0000926A F7F1                <1> 	div	ecx 	 ; remainder in dl (< 10)
  2150 0000926C 80C230              <1> 	add     dl, '0'	 ; to make visible (ascii)
  2151 0000926F 4F                  <1> 	dec	edi
  2152 00009270 8817                <1> 	mov     [edi], dl
  2153 00009272 21C0                <1> 	and	eax, eax
  2154 00009274 75F2                <1> 	jnz	short loc_dir_rdivide
  2155                              <1> 
  2156                              <1> loc_dir_fill_space:
  2157 00009276 81FF[19440100]      <1> 	cmp     edi, Dir_Or_FileSize
  2158 0000927C 7606                <1> 	jna     short loc_dir_attribute
  2159 0000927E 4F                  <1> 	dec     edi
  2160 0000927F C60720              <1> 	mov     byte [edi], 20h
  2161 00009282 EBF2                <1> 	jmp     short loc_dir_fill_space
  2162                              <1> 
  2163                              <1> loc_dir_attribute:
  2164 00009284 C705[24440100]2020- <1> 	mov	dword [File_Attribute], 20202020h
  2164 0000928C 2020                <1>
  2165                              <1> 
  2166 0000928E 80FB20              <1> 	cmp	bl, 20h  ; Is it an archive file?
  2167 00009291 7207                <1> 	jb	short loc_dir_pass_arch
  2168 00009293 C605[27440100]41    <1> 	mov	byte [File_Attribute+3], 'A'
  2169                              <1> 
  2170                              <1> loc_dir_pass_arch:
  2171 0000929A 80E307              <1> 	and	bl, 7
  2172 0000929D 7428                <1> 	jz	short loc_dir_file_name
  2173 0000929F 88DF                <1> 	mov	bh, bl
  2174 000092A1 80E303              <1> 	and	bl, 3
  2175 000092A4 38DF                <1> 	cmp	bh, bl
  2176 000092A6 7607                <1> 	jna	short loc_dir_pass_s
  2177 000092A8 C605[24440100]53    <1> 	mov	byte [File_Attribute], 'S'
  2178                              <1> 
  2179                              <1> loc_dir_pass_s:
  2180 000092AF 80E302              <1> 	and     bl,2
  2181 000092B2 7407                <1> 	jz      short loc_dir_pass_h
  2182 000092B4 C605[25440100]48    <1> 	mov     byte [File_Attribute+1], 'H'
  2183                              <1> loc_dir_pass_h:
  2184 000092BB 80E701              <1> 	and     bh,1
  2185 000092BE 7407                <1> 	jz      short loc_dir_file_name
  2186 000092C0 C605[26440100]52    <1> 	mov     byte [File_Attribute+2], 'R'
  2187                              <1> loc_dir_file_name:
  2188                              <1> 	;mov     bx, [esi+18h] ; Date
  2189                              <1> 	;mov     dx, [esi+16h] ; Time
  2190 000092C7 8B5E16              <1> 	mov	ebx, [esi+16h]
  2191 000092CA 89F1                <1> 	mov	ecx, esi ; FindFile_DirEntry address
  2192 000092CC BF[0C440100]        <1> 	mov     edi, File_Name
  2193                              <1> 	; move 8 bytes
  2194 000092D1 A5                  <1> 	movsd
  2195 000092D2 A5                  <1> 	movsd
  2196 000092D3 C60720              <1> 	mov	byte [edi], 20h
  2197 000092D6 47                  <1> 	inc	edi
  2198                              <1> 	; move 3 bytes
  2199 000092D7 66A5                <1> 	movsw
  2200 000092D9 A4                  <1> 	movsb
  2201 000092DA 89CE                <1> 	mov	esi, ecx
  2202                              <1> 
  2203                              <1> Dir_Time_start:
  2204                              <1> 	;mov	ax, dx		; Time
  2205 000092DC 6689D8              <1> 	mov	ax, bx
  2206 000092DF 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  2207 000092E3 6683E03F            <1> 	and	ax, 0000111111b	; Minute Mask
  2208 000092E7 D40A                <1> 	aam			; Q([AL]/10)->AH
  2209                              <1> 				; R([AL]/10)->AL
  2210                              <1> 				; [AL]+[AH]= Minute as BCD
  2211 000092E9 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  2212 000092ED 86E0                <1> 	xchg	ah, al
  2213 000092EF 66A3[37440100]      <1> 	mov	[File_Minute], ax
  2214                              <1> 
  2215                              <1> 	;mov	al, dh
  2216 000092F5 88F8                <1> 	mov	al, bh
  2217 000092F7 C0E803              <1> 	shr	al, 3		; shift right 3 times
  2218 000092FA D40A                <1> 	aam			; [AL]+[AH]= Hours as BCD
  2219 000092FC 660D3030            <1> 	or	ax, '00'
  2220 00009300 86E0                <1> 	xchg	ah, al
  2221 00009302 66A3[34440100]      <1> 	mov     [File_Hour], ax
  2222                              <1> 
  2223 00009308 C1EB10              <1> 	shr	ebx, 16		; BX = Date
  2224                              <1> 	
  2225                              <1> Dir_Date_start:
  2226 0000930B 6689D8              <1> 	mov	ax, bx		; Date
  2227 0000930E 6683E01F            <1> 	and	ax, 00011111b	; Day Mask
  2228 00009312 D40A                <1> 	aam			; Q([AL]/10)->AH
  2229                              <1> 				; R([AL]/10)->AL
  2230                              <1> 				; [AL]+[AH]= Day as BCD
  2231 00009314 660D3030            <1> 	or	ax, '00'	; Convert to ASCII
  2232 00009318 86C4                <1> 	xchg	al, ah
  2233                              <1> 
  2234 0000931A 66A3[29440100]      <1> 	mov	[File_Day], ax
  2235                              <1> 
  2236 00009320 6689D8              <1> 	mov	ax, bx
  2237 00009323 66C1E805            <1> 	shr	ax, 5		; shift right 5 times
  2238 00009327 6683E00F            <1> 	and	ax, 00001111b	; Month Mask
  2239 0000932B D40A                <1> 	aam
  2240 0000932D 660D3030            <1> 	or	ax, '00'
  2241 00009331 86E0                <1> 	xchg	ah, al
  2242 00009333 66A3[2C440100]      <1> 	mov	[File_Month], ax
  2243                              <1> 
  2244 00009339 6689D8              <1> 	mov	ax, bx
  2245 0000933C 66C1E809            <1> 	shr     ax, 9
  2246 00009340 6683E07F            <1> 	and	ax, 01111111b	; Result = Year - 1980
  2247 00009344 6605BC07            <1> 	add	ax, 1980
  2248                              <1> 
  2249 00009348 B10A                <1> 	mov	cl, 10
  2250 0000934A F6F1                <1> 	div	cl		; Q -> AL, R -> AH 
  2251 0000934C 80CC30              <1> 	or	ah, '0'
  2252 0000934F 8825[32440100]      <1> 	mov	[File_Year+3], ah
  2253 00009355 D40A                <1> 	aam
  2254 00009357 86E0                <1> 	xchg	ah, al
  2255 00009359 80CC30              <1> 	or	ah, '0'	  ; Convert to ASCII
  2256 0000935C 8825[31440100]      <1> 	mov	[File_Year+2], ah
  2257 00009362 D40A                <1> 	aam
  2258 00009364 86C4                <1> 	xchg	al, ah
  2259 00009366 660D3030            <1> 	or	ax, '00'
  2260 0000936A 66A3[2F440100]      <1> 	mov	[File_Year], ax
  2261                              <1> 
  2262                              <1> loc_show_line:
  2263 00009370 56                  <1> 	push	esi
  2264 00009371 BE[0C440100]        <1> 	mov     esi, File_Name
  2265 00009376 E8DAE1FFFF          <1> 	call	print_msg
  2266 0000937B BE[FF4C0100]        <1> 	mov	esi, nextline
  2267 00009380 E8D0E1FFFF          <1> 	call	print_msg
  2268 00009385 5E                  <1> 	pop	esi
  2269                              <1> 
  2270 00009386 FE0D[D5930100]      <1> 	dec	byte [PrintDir_RowCounter]
  2271 0000938C 0F84D4000000        <1>         jz      pause_dir_scroll
  2272                              <1> 
  2273                              <1> loc_next_entry:
  2274 00009392 E899010000          <1> 	call	find_next_file
  2275 00009397 0F8391FEFFFF        <1>         jnc     loc_dfname_use_this
  2276                              <1> 
  2277                              <1> loc_dir_ok:
  2278 0000939D B90A000000          <1> 	mov     ecx, 10
  2279 000093A2 66A1[C0930100]      <1> 	mov	ax, [Dir_Count]
  2280 000093A8 BF[4D440100]        <1> 	mov	edi, Decimal_Dir_Count
  2281 000093AD 6639C8              <1> 	cmp	ax, cx ; 10
  2282 000093B0 7216                <1> 	jb	short pass_ddc
  2283 000093B2 47                  <1> 	inc	edi
  2284 000093B3 6683F864            <1> 	cmp	ax, 100
  2285 000093B7 720F                <1> 	jb	short pass_ddc
  2286 000093B9 47                  <1> 	inc	edi
  2287 000093BA 663DE803            <1> 	cmp	ax, 1000
  2288 000093BE 7208                <1> 	jb	short pass_ddc
  2289 000093C0 47                  <1> 	inc	edi
  2290 000093C1 663D1027            <1> 	cmp	ax, 10000
  2291 000093C5 7201                <1> 	jb	short pass_ddc
  2292 000093C7 47                  <1> 	inc	edi
  2293                              <1> pass_ddc:
  2294 000093C8 886F01              <1> 	mov     [edi+1], ch ; 0
  2295                              <1> loc_ddc_rediv:
  2296 000093CB 31D2                <1> 	xor     edx, edx
  2297 000093CD 66F7F1              <1> 	div     cx	; 10
  2298 000093D0 80C230              <1> 	add     dl, '0'
  2299 000093D3 8817                <1> 	mov     [edi], dl
  2300 000093D5 4F                  <1> 	dec     edi
  2301 000093D6 6609C0              <1> 	or	ax, ax
  2302 000093D9 75F0                <1> 	jnz	short loc_ddc_rediv
  2303                              <1> 
  2304 000093DB 66A1[BE930100]      <1> 	mov     ax, [File_Count]
  2305 000093E1 BF[3C440100]        <1> 	mov     edi, Decimal_File_Count
  2306 000093E6 6639C8              <1> 	cmp     ax, cx ; 10
  2307 000093E9 7216                <1> 	jb      short pass_dfc
  2308 000093EB 47                  <1> 	inc     edi
  2309 000093EC 6683F864            <1> 	cmp     ax, 100
  2310 000093F0 720F                <1> 	jb      short pass_dfc
  2311 000093F2 47                  <1> 	inc     edi
  2312 000093F3 663DE803            <1> 	cmp     ax, 1000
  2313 000093F7 7208                <1> 	jb      short pass_dfc
  2314 000093F9 47                  <1> 	inc     edi
  2315 000093FA 663D1027            <1> 	cmp     ax, 10000
  2316 000093FE 7201                <1> 	jb      short pass_dfc
  2317 00009400 47                  <1> 	inc     edi
  2318                              <1> pass_dfc:
  2319                              <1> 	;mov    cx, 10
  2320 00009401 886F01              <1> 	mov     [edi+1], ch ; 00
  2321                              <1> loc_dfc_rediv:
  2322                              <1> 	;xor	dx, dx
  2323 00009404 30D2                <1> 	xor	dl, dl
  2324 00009406 66F7F1              <1> 	div	cx
  2325 00009409 80C230              <1> 	add	dl, '0'
  2326 0000940C 8817                <1> 	mov	[edi], dl
  2327 0000940E 4F                  <1> 	dec	edi
  2328 0000940F 6609C0              <1> 	or	ax, ax
  2329 00009412 75F0                <1> 	jnz	short loc_dfc_rediv
  2330                              <1> 
  2331 00009414 BF[D4930100]        <1> 	mov     edi, TFS_Dec_End
  2332                              <1>         ;mov    byte [edi], 0
  2333 00009419 A1[C2930100]        <1> 	mov     eax, [Total_FSize]
  2334                              <1> 	;mov    ecx, 10
  2335                              <1> rediv_tfs_hex:
  2336                              <1> 	;sub	edx, edx
  2337 0000941E 28D2                <1> 	sub	dl, dl
  2338 00009420 F7F1                <1> 	div	ecx
  2339 00009422 80C230              <1> 	add	dl, '0'
  2340 00009425 4F                  <1> 	dec     edi
  2341 00009426 8817                <1> 	mov     [edi], dl
  2342 00009428 21C0                <1> 	and	eax, eax
  2343 0000942A 75F2                <1> 	jnz	short rediv_tfs_hex
  2344                              <1> 	
  2345 0000942C 893D[C6930100]      <1> 	mov	[TFS_Dec_Begin], edi
  2346 00009432 BE[3A440100]        <1> 	mov	esi, Decimal_File_Count_Header
  2347 00009437 E819E1FFFF          <1> 	call	print_msg
  2348 0000943C BE[42440100]        <1> 	mov	esi, str_files
  2349 00009441 E80FE1FFFF          <1> 	call	print_msg
  2350 00009446 BE[53440100]        <1> 	mov	esi, str_dirs
  2351 0000944B E805E1FFFF          <1> 	call	print_msg
  2352 00009450 8B35[C6930100]      <1> 	mov	esi, [TFS_Dec_Begin]
  2353 00009456 E8FAE0FFFF          <1> 	call	print_msg
  2354 0000945B BE[64440100]        <1> 	mov	esi, str_bytes
  2355 00009460 E8F0E0FFFF          <1> 	call	print_msg
  2356                              <1> 
  2357 00009465 C3                  <1> 	retn
  2358                              <1> 
  2359                              <1> pause_dir_scroll:
  2360 00009466 28E4                <1> 	sub	ah, ah           
  2361 00009468 E8787AFFFF          <1> 	call	int16h
  2362 0000946D 3C1B                <1> 	cmp	al, 1Bh
  2363 0000946F 0F8428FFFFFF        <1>         je      loc_dir_ok
  2364 00009475 C605[D5930100]10    <1> 	mov	byte [PrintDir_RowCounter], 16 ; Reset counter
  2365 0000947C E911FFFFFF          <1>         jmp     loc_next_entry
  2366                              <1> 
  2367                              <1> find_first_file:
  2368                              <1> 	; 11/02/2016
  2369                              <1> 	; 10/02/2016
  2370                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2371                              <1> 	; 09/10/2011
  2372                              <1> 	; 17/09/2009
  2373                              <1> 	; 2005
  2374                              <1> 	; INPUT ->
  2375                              <1> 	;	ESI = ASCIIZ File/Dir Name Address (in Current Directory)
  2376                              <1> 	;	AL = Attributes AND mask (The AND result must be equal to AL)
  2377                              <1> 	;	      bit 0 = Read Only
  2378                              <1> 	;	      bir 1 = Hidden
  2379                              <1> 	;	      bit 2 = System
  2380                              <1> 	;	      bit 3 = Volume Label
  2381                              <1> 	;	      bit 4 = Directory
  2382                              <1> 	;	      bit 5 = Archive
  2383                              <1> 	;	      bit 6 = Reserved, must be 0
  2384                              <1> 	;	      bit 7 = Reserved, must be 0
  2385                              <1> 	;       AH = Attributes Negative AND mask (The AND result must be ZERO)
  2386                              <1> 	;
  2387                              <1> 	; OUTPUT ->
  2388                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  2389                              <1> 	;	CF = 0 ->
  2390                              <1> 	;	     ESI = Directory Entry (FindFile_DirEntry) Location
  2391                              <1> 	;	     EDI = Directory Buffer Directory Entry Location
  2392                              <1> 	;	     EAX = File Size
  2393                              <1> 	;	      BL = Attributes of The File/Directory
  2394                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  2395                              <1> 	;             DX > 0 : Ambiguous filename chars are used
  2396                              <1> 	;
  2397                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2398                              <1> 
  2399 00009481 66A3[86930100]      <1> 	mov	[FindFile_AttributesMask], ax
  2400 00009487 BF[88930100]        <1> 	mov	edi, FindFile_DirEntry ; TR-DOS Fullfilename formatted buffer
  2401 0000948C 31C0                <1> 	xor	eax, eax
  2402 0000948E B90B000000          <1> 	mov	ecx, 11
  2403 00009493 F3AB                <1> 	rep	stosd	; 44 bytes
  2404                              <1> 	;stosw		; +2 bytes 
  2405                              <1> 	    
  2406 00009495 BF[78930100]        <1> 	mov	edi, FindFile_Name ; FFF structure, offset 66
  2407 0000949A 39FE                <1> 	cmp	esi, edi
  2408 0000949C 7408                <1> 	je	short loc_fff_mfn_ok
  2409 0000949E 89FA                <1> 	mov	edx, edi 
  2410                              <1> 	 ; move 13 bytes
  2411 000094A0 A5                  <1> 	movsd
  2412 000094A1 A5                  <1> 	movsd
  2413 000094A2 A5                  <1> 	movsd
  2414 000094A3 AA                  <1> 	stosb
  2415 000094A4 89D6                <1> 	mov	esi, edx
  2416                              <1> loc_fff_mfn_ok:
  2417 000094A6 BF[27930100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  2418 000094AB E8D7200000          <1> 	call	convert_file_name
  2419 000094B0 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  2420                              <1> 
  2421 000094B2 66A1[86930100]      <1> 	mov	ax, [FindFile_AttributesMask]
  2422                              <1> 	;xor	ecx, ecx
  2423 000094B8 30C9                <1> 	xor	cl, cl  
  2424 000094BA E8D11D0000          <1> 	call	locate_current_dir_file
  2425 000094BF 726E                <1> 	jc	short loc_fff_retn
  2426                              <1> 	; EDI = Directory Entry
  2427                              <1> 	; EBX = Directory Buffer Entry Index/Number
  2428                              <1> 
  2429                              <1> loc_fff_fnf_ln_check:
  2430 000094C1 30ED                <1> 	xor	ch, ch 
  2431 000094C3 80F60F              <1> 	xor	dh, 0Fh
  2432 000094C6 7408                <1> 	jz	short loc_fff_longname_yes
  2433 000094C8 882D[85930100]      <1> 	mov	[FindFile_LongNameYes], ch ; 0
  2434 000094CE EB0C                <1> 	jmp	short loc_fff_longname_no
  2435                              <1> 
  2436                              <1> loc_fff_longname_yes:
  2437                              <1> 	;inc	byte [FindFile_LongNameYes]
  2438 000094D0 8A0D[92920100]      <1> 	mov	cl, [LFN_EntryLength]  
  2439 000094D6 880D[85930100]      <1> 	mov	[FindFile_LongNameEntryLength], cl ; FindFile_LongNameYes
  2440                              <1> 
  2441                              <1> loc_fff_longname_no:
  2442                              <1> 	;mov	bx, [DirBuff_CurrentEntry]
  2443 000094DC 66891D[B0930100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  2444 000094E3 6689C2              <1> 	mov	dx, ax ; Ambiguous Filename chars used sign > 0
  2445                              <1> 
  2446 000094E6 A0[968A0100]        <1> 	mov	al, [Current_Drv]
  2447 000094EB A2[36930100]        <1> 	mov	[FindFile_Drv], al 
  2448                              <1> 
  2449 000094F0 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  2450 000094F5 A3[A8930100]        <1> 	mov	[FindFile_DirFirstCluster], eax
  2451                              <1> 
  2452 000094FA A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
  2453 000094FF A3[AC930100]        <1> 	mov	[FindFile_DirCluster], eax
  2454                              <1> 
  2455 00009504 66FF05[B2930100]    <1> 	inc	word [FindFile_MatchCounter]
  2456                              <1> 
  2457 0000950B 89FB                <1> 	mov	ebx, edi
  2458 0000950D 89FE                <1> 	mov	esi, edi
  2459 0000950F BF[88930100]        <1> 	mov	edi, FindFile_DirEntry
  2460 00009514 89F8                <1> 	mov	eax, edi
  2461 00009516 B108                <1> 	mov	cl, 8
  2462 00009518 F3A5                <1> 	rep	movsd
  2463 0000951A 89C6                <1> 	mov	esi, eax
  2464 0000951C 89DF                <1> 	mov	edi, ebx
  2465                              <1> 
  2466 0000951E A1[A4930100]        <1> 	mov	eax, [FindFile_DirEntry+28] ; File Size
  2467                              <1> 
  2468 00009523 8A1D[93930100]      <1> 	mov	bl, [FindFile_DirEntry+11] ; File Attributes 
  2469 00009529 8A3D[85930100]      <1> 	mov	bh, [FindFile_LongNameYes]
  2470                              <1> 
  2471                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  2472                              <1> 	;mov	[FindFile_DirEntryNumber], cx
  2473                              <1> 	;mov	cx, [FindFile_DirEntryNumber]
  2474                              <1> 	; ecx = 0
  2475                              <1> 
  2476                              <1> loc_fff_retn:
  2477 0000952F C3                  <1> 	retn
  2478                              <1> 
  2479                              <1> find_next_file:
  2480                              <1> 	; 15/10/2016
  2481                              <1> 	; 10/02/2016
  2482                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  2483                              <1> 	; 06/02/2011
  2484                              <1> 	; 17/09/2009
  2485                              <1> 	; 2005
  2486                              <1> 	; INPUT ->
  2487                              <1> 	;	NONE, Find First File Parameters
  2488                              <1> 	; OUTPUT ->
  2489                              <1> 	;	CF = 1 -> Error, Error Code in EAX (AL)
  2490                              <1> 	;	CF = 0 -> 
  2491                              <1> 	;	    ESI = Directory Entry (FindFile_DirEntry) Location
  2492                              <1> 	;	    EDI = Directory Buffer Directory Entry Location
  2493                              <1> 	;	    EAX = File Size
  2494                              <1> 	;	      BL = Attributes of The File/Directory
  2495                              <1> 	;	      BH = Long Name Yes/No Status (>0 is YES)
  2496                              <1> 	;             DX > 0 : Ambiguous filename chars are used 
  2497                              <1> 	;
  2498                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2499                              <1> 
  2500 00009530 66833D[B2930100]00  <1> 	cmp	word [FindFile_MatchCounter], 0
  2501 00009538 7707                <1> 	ja	short loc_start_search_next_file
  2502                              <1> 
  2503                              <1> loc_fnf_stc_retn:
  2504 0000953A F9                  <1> 	stc
  2505                              <1> loc_fnf_ax12h_retn:
  2506 0000953B B80C000000          <1> 	mov	eax, 12 ; No More files
  2507                              <1> ;loc_fnf_retn:
  2508 00009540 C3                  <1> 	retn
  2509                              <1> 
  2510                              <1> loc_start_search_next_file:
  2511 00009541 668B1D[B0930100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  2512 00009548 6643                <1> 	inc	bx
  2513 0000954A 663B1D[BF910100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  2514 00009551 7719                <1> 	ja	short loc_cont_search_next_file
  2515                              <1> 
  2516                              <1> loc_fnf_search:
  2517 00009553 BE[27930100]        <1> 	mov	esi, Dir_Entry_Name
  2518 00009558 66A1[86930100]      <1> 	mov	ax, [FindFile_AttributesMask]
  2519 0000955E 6631C9              <1> 	xor	cx, cx
  2520 00009561 E82E1E0000          <1> 	call	find_directory_entry
  2521 00009566 0F8355FFFFFF        <1>         jnc     loc_fff_fnf_ln_check
  2522                              <1> 
  2523                              <1> loc_cont_search_next_file:
  2524 0000956C 31DB                <1> 	xor	ebx, ebx
  2525 0000956E 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  2526 00009574 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2527 00009579 01DE                <1> 	add	esi, ebx
  2528                              <1> 
  2529 0000957B 803D[948A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  2530 00009582 7608                <1> 	jna	short loc_fnf_check_FAT_type
  2531 00009584 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  2532 00009588 72B1                <1> 	jb	short loc_fnf_ax12h_retn
  2533 0000958A EB06                <1> 	jmp	short loc_fnf_check_next_cluster
  2534                              <1>  
  2535                              <1> loc_fnf_check_FAT_type:
  2536 0000958C 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3
  2537 00009590 72A9                <1> 	jb	short loc_fnf_ax12h_retn
  2538                              <1> 
  2539                              <1> loc_fnf_check_next_cluster:
  2540 00009592 A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
  2541 00009597 E8CA370000          <1> 	call	get_next_cluster
  2542 0000959C 7306                <1> 	jnc	short loc_fnf_load_next_dir_cluster
  2543 0000959E 09C0                <1> 	or	eax, eax
  2544 000095A0 7498                <1> 	jz	short loc_fnf_stc_retn
  2545                              <1> 	;mov	eax, 17 ;Drive not ready or read error
  2546 000095A2 F5                  <1>  	cmc	;stc
  2547                              <1> loc_fnf_retn:
  2548 000095A3 C3                  <1> 	retn
  2549                              <1> 
  2550                              <1> loc_fnf_load_next_dir_cluster:
  2551 000095A4 E8A3390000          <1> 	call	load_FAT_sub_directory
  2552 000095A9 72F8                <1> 	jc	short loc_fnf_retn
  2553 000095AB 6631DB              <1> 	xor	bx, bx
  2554 000095AE 66891D[B0930100]    <1> 	mov	[FindFile_DirEntryNumber], bx
  2555 000095B5 EB9C                <1> 	jmp	short loc_fnf_search
  2556                              <1> 
  2557                              <1> get_and_print_longname:
  2558                              <1> 	; 16/10/2016
  2559                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  2560                              <1> 	; 24/01/2010
  2561                              <1> 	; 17/10/2009 (CMD_INTR.ASM, 'cmp_cmd_longname')
  2562                              <1> get_longname_fchar:
  2563 000095B7 803E20              <1> 	cmp	byte [esi], 20h
  2564 000095BA 7701                <1> 	ja	short loc_find_longname
  2565                              <1> 	;jb	short loc_longname_retn
  2566                              <1> 	;inc	esi
  2567                              <1> 	;je	short get_longname_fchar
  2568                              <1> ;loc_longname_retn:
  2569 000095BC C3                  <1> 	retn
  2570                              <1> loc_find_longname:
  2571 000095BD E839210000          <1> 	call	find_longname
  2572 000095C2 7328                <1> 	jnc	short loc_print_longname
  2573                              <1> 	
  2574 000095C4 08C0                <1> 	or	al, al
  2575 000095C6 741A                <1> 	jz	short loc_longname_not_found
  2576                              <1> 	  
  2577                              <1> 	; 16/10/2016 (15h -> 15, 17)
  2578 000095C8 3C0F                <1> 	cmp	al, 15
  2579 000095CA 0F84B6F7FFFF        <1> 	je	cd_drive_not_ready ; drive not ready
  2580                              <1> 				   ; or
  2581 000095D0 3C11                <1> 	cmp	al, 17		   ; read error	
  2582 000095D2 0F84AEF7FFFF        <1> 	je	cd_drive_not_ready 
  2583                              <1> 
  2584                              <1> loc_ln_file_dir_not_found:
  2585 000095D8 BE[8E430100]        <1> 	mov	esi, Msg_File_Directory_Not_Found
  2586                              <1> 	;call	print_msg	
  2587                              <1>         ;retn
  2588 000095DD E973DFFFFF          <1> 	jmp	print_msg
  2589                              <1> 
  2590                              <1> loc_longname_not_found:
  2591 000095E2 BE[AD430100]        <1>         mov     esi, Msg_LongName_Not_Found
  2592                              <1> 	;call	print_msg	
  2593                              <1>         ;retn
  2594 000095E7 E969DFFFFF          <1> 	jmp	print_msg
  2595                              <1> 
  2596                              <1> loc_print_longname:
  2597                              <1> 	;mov	esi, LongFileName
  2598 000095EC BF[968B0100]        <1> 	mov	edi, TextBuffer
  2599 000095F1 57                  <1> 	push	edi 
  2600 000095F2 3C00                <1> 	cmp	al, 0
  2601 000095F4 7708                <1> 	ja	short loc_print_longname_1
  2602                              <1> loc_print_FS_longname: ; Singlix FS (64 byte ASCIIZ file name)
  2603 000095F6 AC                  <1> 	lodsb
  2604 000095F7 AA                  <1> 	stosb  
  2605 000095F8 08C0                <1> 	or	al, al
  2606 000095FA 75FA                <1> 	jnz	short loc_print_FS_longname
  2607 000095FC EB07                <1> 	jmp	short loc_print_longname_2
  2608                              <1> 	;
  2609                              <1> loc_print_longname_1: ; MS Windows long name (UNICODE chars)
  2610 000095FE 66AD                <1> 	lodsw
  2611 00009600 AA                  <1> 	stosb  
  2612 00009601 08C0                <1> 	or	al, al
  2613 00009603 75F9                <1> 	jnz	short loc_print_longname_1
  2614                              <1> 	;
  2615                              <1> loc_print_longname_2:	
  2616 00009605 5E                  <1> 	pop	esi
  2617 00009606 E84ADFFFFF          <1> 	call	print_msg
  2618 0000960B BE[FF4C0100]        <1>   	mov	esi, nextline
  2619                              <1> 	;call	print_msg
  2620                              <1> 	;retn
  2621 00009610 E940DFFFFF          <1> 	jmp	print_msg	
  2622                              <1> 
  2623                              <1> show_file:
  2624                              <1> 	; 18/02/2016
  2625                              <1> 	; 17/02/2016
  2626                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  2627                              <1> 	; 13/09/2011 (CMD_INTR.ASM, 'cmp_cmd_show')
  2628                              <1> 	; 08/11/2009
  2629                              <1> 
  2630                              <1> loc_show_parse_path_name:
  2631 00009615 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  2632 0000961A E833200000          <1> 	call	parse_path_name
  2633 0000961F 0F824CF9FFFF        <1> 	jc	loc_cmd_failed
  2634                              <1> 
  2635                              <1> loc_show_check_filename_exists:
  2636 00009625 BE[78930100]        <1> 	mov	esi, FindFile_Name
  2637 0000962A 803E20              <1> 	cmp	byte [esi], 20h
  2638 0000962D 0F863EF9FFFF        <1> 	jna	loc_cmd_failed
  2639                              <1> 
  2640                              <1> 	; 15/02/2016 (invalid file name check)
  2641 00009633 E807020000          <1> 	call	check_filename 	
  2642 00009638 730A                <1> 	jnc	short loc_show_change_drv
  2643                              <1> 
  2644 0000963A BE[7A440100]        <1> 	mov	esi, Msg_invalid_name_chars
  2645 0000963F E911DFFFFF          <1> 	jmp	print_msg
  2646                              <1>    
  2647                              <1> loc_show_change_drv:
  2648 00009644 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  2649 0000964A 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  2650 00009650 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  2651 00009656 38F2                <1> 	cmp	dl, dh
  2652 00009658 740B                <1> 	je	short loc_show_change_directory
  2653 0000965A E87FEAFFFF          <1> 	call	change_current_drive
  2654                              <1> 	;jc	loc_file_rw_cmd_failed
  2655 0000965F 0F8237F9FFFF        <1> 	jc	loc_run_cmd_failed
  2656                              <1> 
  2657                              <1> loc_show_change_directory:
  2658 00009665 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  2659 0000966C 7618                <1> 	jna	short loc_findload_showfile
  2660                              <1> 
  2661 0000966E FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  2662 00009674 BE[37930100]        <1> 	mov	esi, FindFile_Directory
  2663 00009679 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2664 0000967B E8BC190000          <1> 	call	change_current_directory
  2665                              <1> 	;jc	loc_file_rw_cmd_failed
  2666 00009680 0F8216F9FFFF        <1> 	jc	loc_run_cmd_failed
  2667                              <1> 
  2668                              <1> ;loc_show_change_prompt_dir_string:
  2669                              <1> 	;call	change_prompt_dir_string
  2670                              <1> 
  2671                              <1> loc_findload_showfile:
  2672                              <1> 	; 15/02/2016
  2673 00009686 BE[78930100]        <1> 	mov	esi, FindFile_Name
  2674 0000968B BF[27930100]        <1> 	mov	edi, Dir_Entry_Name ; Dir Entry Format File Name
  2675 00009690 E8F21E0000          <1> 	call	convert_file_name
  2676 00009695 89FE                <1> 	mov	esi, edi ; offset Dir_Entry_Name
  2677                              <1> 
  2678 00009697 28C0                <1> 	sub	al, al	; Attrib AND mask = 0
  2679                              <1> 	; Directory attribute : 10h
  2680                              <1> 	; Volume name attribute: 8h
  2681 00009699 B418                <1> 	mov	ah, 00011000b ; 18h (Attrib NAND, AND --> zero mask)
  2682                              <1> 	;
  2683 0000969B 6631C9              <1> 	xor	cx, cx  
  2684 0000969E E8ED1B0000          <1> 	call	locate_current_dir_file
  2685                              <1> 	;jc	loc_file_rw_cmd_failed
  2686 000096A3 0F82F3F8FFFF        <1> 	jc	loc_run_cmd_failed
  2687                              <1> 
  2688                              <1> loc_show_load_file:
  2689                              <1> 	; EDI = Directory Entry
  2690 000096A9 668B4714            <1> 	mov	ax, [edi+DirEntry_FstClusHI] ; First Cluster High Word
  2691 000096AD C1E010              <1> 	shl	eax, 16
  2692 000096B0 668B471A            <1> 	mov	ax, [edi+DirEntry_FstClusLO] ; First Cluster Low Word
  2693 000096B4 A3[E0930100]        <1> 	mov	[Show_Cluster], eax
  2694 000096B9 8B471C              <1> 	mov	eax, [edi+DirEntry_FileSize] ; File Size
  2695 000096BC 21C0                <1> 	and	eax, eax ; Empty file !
  2696 000096BE 0F8491000000        <1>         jz      end_of_show_file 
  2697 000096C4 A3[E4930100]        <1> 	mov	[Show_FileSize], eax
  2698 000096C9 31C0                <1> 	xor	eax, eax
  2699 000096CB A3[E8930100]        <1> 	mov	[Show_FilePointer], eax ; 0
  2700 000096D0 66A3[EC930100]      <1> 	mov	[Show_ClusterPointer], ax ; 0
  2701 000096D6 29DB                <1> 	sub	ebx, ebx
  2702 000096D8 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  2703 000096DE BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2704 000096E3 01DE                <1> 	add	esi, ebx
  2705 000096E5 8935[DC930100]      <1> 	mov	[Show_LDDDT], esi ; Logical DOS Drv Description Table addr
  2706                              <1> 
  2707 000096EB 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0	
  2708 000096EF 7713                <1> 	ja	short loc_show_calculate_cluster_size
  2709                              <1> 	; Singlix FS
  2710                              <1> 	; First Cluster Number is FDT number (in compatibility buffer)
  2711 000096F1 8B15[E0930100]      <1> 	mov	edx, [Show_Cluster] ; Compatibility dir. buffer value (FDT)	
  2712 000096F7 8915[D8930100]      <1> 	mov	[Show_FDT], edx
  2713 000096FD 31C0                <1> 	xor	eax, eax
  2714 000096FF A3[E0930100]        <1> 	mov	[Show_Cluster], eax ; Sector index  = 0
  2715                              <1> 				    ; (next time it will be 1)			
  2716                              <1> loc_show_calculate_cluster_size:
  2717 00009704 668B5E11            <1> 	mov	bx, [esi+LD_BPB+BPB_BytsPerSec] ; FAT 12-16-32 (512)
  2718                              <1> 	; BX = 512 = [esi+LD_FS_BytesPerSec] ; Singlix FS	
  2719 00009708 8A4613              <1> 	mov	al, [esi+LD_BPB+BPB_SecPerClust] ; FAT 12-16-32 (<= 128)
  2720                              <1> 	; AL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  2721 0000970B F7E3                <1> 	mul	ebx	
  2722                              <1> 
  2723                              <1> 	;cmp	eax, 65536 ; non-compatible (very big) cluster size
  2724                              <1> 	;ja	short end_of_show_file	
  2725 0000970D 66A3[EE930100]      <1> 	mov	[Show_ClusterSize], ax
  2726                              <1> 
  2727                              <1> loc_start_show_file:
  2728 00009713 BE[FF4C0100]        <1> 	mov	esi, nextline
  2729 00009718 E838DEFFFF          <1> 	call	print_msg
  2730                              <1> 
  2731 0000971D A1[E0930100]        <1> 	mov	eax, [Show_Cluster]
  2732 00009722 C605[F0930100]17    <1> 	mov	byte [Show_RowCount], 23
  2733                              <1> 
  2734                              <1> 	; 17/02/2016
  2735 00009729 8B35[DC930100]      <1> 	mov	esi, [Show_LDDDT]
  2736                              <1> 
  2737                              <1> loc_show_next_cluster:
  2738                              <1> 	; 15/02/2016
  2739 0000972F BB00000700          <1> 	mov	ebx, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  2740                              <1> 	; ESI = Logical DOS drv description table address
  2741 00009734 E851380000          <1> 	call	read_cluster
  2742                              <1> 	;jc	loc_file_rw_cmd_failed
  2743 00009739 0F825DF8FFFF        <1> 	jc	loc_run_cmd_failed
  2744                              <1> 
  2745 0000973F 31DB                <1> 	xor 	ebx, ebx
  2746                              <1> loc_show_next_byte:
  2747 00009741 803D[F0930100]00    <1> 	cmp	byte [Show_RowCount], 0
  2748 00009748 7521                <1> 	jne	short pass_show_wait_for_key
  2749 0000974A 30E4                <1> 	xor	ah, ah
  2750 0000974C E89477FFFF          <1> 	call	int16h
  2751 00009751 3C1B                <1> 	cmp	al, 1Bh
  2752 00009753 750F                <1> 	jne	short pass_exit_show
  2753                              <1> end_of_show_file:
  2754                              <1> pass_show_file:
  2755 00009755 BE[FF4C0100]        <1> 	mov	esi, nextline
  2756 0000975A E8F6DDFFFF          <1> 	call	print_msg
  2757 0000975F E94B010000          <1> 	jmp	loc_file_rw_restore_retn
  2758                              <1> 
  2759                              <1> pass_exit_show:
  2760 00009764 C605[F0930100]14    <1> 	mov	byte [Show_RowCount], 20
  2761                              <1> pass_show_wait_for_key:
  2762 0000976B 81C300000700        <1> 	add	ebx, Cluster_Buffer
  2763 00009771 8A03                <1> 	mov	al, [ebx]
  2764 00009773 3C0D                <1> 	cmp	al, 0Dh
  2765 00009775 0F8590000000        <1>         jne     loc_show_check_tab_space
  2766 0000977B FE0D[F0930100]      <1> 	dec	byte [Show_RowCount]
  2767                              <1> pass_show_dec_rowcount:
  2768 00009781 B307                <1> 	mov	bl, 7 ; (light gray character color, black background)
  2769 00009783 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  2770 00009789 E86F8BFFFF          <1> 	call	_write_tty
  2771                              <1> loc_show_check_eof:
  2772 0000978E FF05[E8930100]      <1> 	inc	dword [Show_FilePointer]
  2773 00009794 A1[E8930100]        <1> 	mov	eax, [Show_FilePointer]
  2774 00009799 3B05[E4930100]      <1> 	cmp	eax, [Show_FileSize]
  2775 0000979F 73B4                <1> 	jnb	short end_of_show_file
  2776 000097A1 66FF05[EC930100]    <1> 	inc	word [Show_ClusterPointer]
  2777 000097A8 0FB71D[EC930100]    <1> 	movzx	ebx, word [Show_ClusterPointer]
  2778                              <1> 
  2779                              <1> 	; 17/02/2016
  2780                              <1> 	; (sector boundary -9 bits- check, 512 = 0)
  2781 000097AF 66F7C3FF01          <1>         test    bx, 1FFh ;  1 to 511
  2782 000097B4 758B                <1> 	jnz	short loc_show_next_byte
  2783                              <1> 
  2784                              <1> 	; 16/02/2016
  2785 000097B6 8B35[DC930100]      <1> 	mov	esi, [Show_LDDDT]
  2786                              <1> 	;
  2787 000097BC 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  2788 000097C0 7719                <1> 	ja	short loc_show_check_fat_cluster_size
  2789                              <1> 
  2790                              <1> 	; Singlix FS
  2791                              <1> 	; 1 sector, more... (cluster size = 1 sector)
  2792 000097C2 A1[E0930100]        <1> 	mov	eax, [Show_Cluster]
  2793 000097C7 40                  <1> 	inc	eax
  2794 000097C8 A3[E0930100]        <1> 	mov	[Show_Cluster], eax
  2795                              <1> 
  2796 000097CD 6621DB              <1> 	and	bx, bx ; 65536 -> 0
  2797 000097D0 0F856BFFFFFF        <1>         jnz	loc_show_next_byte
  2798 000097D6 E954FFFFFF          <1> 	jmp     loc_show_next_cluster
  2799                              <1> 	 
  2800                              <1> loc_show_check_fat_cluster_size:
  2801                              <1> 	; 17/02/2016
  2802 000097DB 663B1D[EE930100]    <1> 	cmp	bx, [Show_ClusterSize] ; cluster size in bytes
  2803 000097E2 0F8259FFFFFF        <1>         jb	loc_show_next_byte
  2804 000097E8 66C705[EC930100]00- <1> 	mov	word [Show_ClusterPointer], 0
  2804 000097F0 00                  <1>
  2805                              <1> 
  2806 000097F1 A1[E0930100]        <1> 	mov	eax, [Show_Cluster]
  2807                              <1> 	;mov	esi, [Show_LDDDT]
  2808                              <1> loc_show_get_next_cluster:
  2809 000097F6 E86B350000          <1> 	call	get_next_cluster
  2810                              <1> 	;jc	loc_file_rw_cmd_failed
  2811 000097FB 0F829BF7FFFF        <1> 	jc	loc_run_cmd_failed
  2812                              <1> loc_show_update_ccluster:
  2813 00009801 A3[E0930100]        <1> 	mov	[Show_Cluster], eax			
  2814 00009806 E924FFFFFF          <1>         jmp     loc_show_next_cluster
  2815                              <1> 
  2816                              <1> loc_show_check_tab_space:
  2817 0000980B 3C09                <1> 	cmp	al, 09h
  2818 0000980D 0F856EFFFFFF        <1>         jne     pass_show_dec_rowcount
  2819                              <1> loc_show_put_tab_space:
  2820 00009813 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE] ; [ptty]
  2821 00009819 E85B87FFFF          <1> 	call	get_cpos
  2822                              <1> 	; dl = cursor column
  2823 0000981E 80E207              <1> 	and	dl, 7 ; 18/02/2016
  2824                              <1> 	;shr	bh, 1 ; [ACTIVE_PAGE]
  2825 00009821 8A3D[FE890100]      <1> 	mov	bh, [ACTIVE_PAGE]
  2826 00009827 B307                <1> 	mov	bl, 7 ; color attribute
  2827                              <1> loc_show_put_space_chars:
  2828 00009829 B020                <1> 	mov	al, 20h ; space
  2829                              <1> 	;mov	bh, [ACTIVE_PAGE] ; [ptty]
  2830                              <1> 	;mov	bl, 7 ; color attribute
  2831                              <1> 	;push	dx
  2832 0000982B 52                  <1> 	push	edx ; 29/12/2017
  2833 0000982C E8CC8AFFFF          <1> 	call	_write_tty
  2834 00009831 5A                  <1> 	pop	edx ; 29/12/2017
  2835                              <1> 	;pop	dx
  2836                              <1> 	; 18/02/2016
  2837 00009832 80FA07              <1> 	cmp	dl, 7
  2838 00009835 0F8353FFFFFF        <1> 	jnb	loc_show_check_eof
  2839 0000983B FEC2                <1> 	inc	dl
  2840 0000983D EBEA                <1> 	jmp	short loc_show_put_space_chars
  2841                              <1> 
  2842                              <1> check_filename:
  2843                              <1> 	; 10/10/2016
  2844                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  2845                              <1> 	; 07/08/2010 (FILE.ASM, 'proc_check_filename')
  2846                              <1> 	; 10/07/2010
  2847                              <1> 	; Derived from 'proc_check_filename'
  2848                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  2849                              <1> 	;
  2850                              <1> 	; INPUT -> 
  2851                              <1> 	;	ESI = Dot File Name Location
  2852                              <1> 	; OUTPUT ->
  2853                              <1> 	;	cf = 1 -> error code in AL
  2854                              <1> 	;	     AL = ERR_INV_FILE_NAME (=26)
  2855                              <1> 	;		  Invalid file name chars   
  2856                              <1> 	;	cf = 0 -> valid file name
  2857                              <1> 	; 
  2858                              <1> 	;(EAX, ECX, EDI will be changed)
  2859                              <1> 
  2860                              <1> check_invalid_filename_chars:
  2861                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  2862                              <1> 	; 10/07/2010 (FILE.ASM, 'proc_check_invalid_filename_chars')
  2863                              <1> 	; 10/02/2010
  2864                              <1> 	; Derived from 'proc_check_invalid_filename_chars'
  2865                              <1> 	; in the old TRDOS.ASM (09/02/2005).
  2866                              <1> 	;
  2867                              <1> 	; INPUT -> 
  2868                              <1> 	;	ESI = ASCIIZ FileName
  2869                              <1> 	; OUTPUT ->
  2870                              <1> 	;	cf = 1 -> invalid
  2871                              <1> 	;	cf = 0 -> valid
  2872                              <1> 	; 
  2873                              <1> 	;(EAX, ECX, EDI will be changed)
  2874                              <1>   
  2875 0000983F 56                  <1> 	push	esi
  2876                              <1> 
  2877 00009840 BF[62410100]        <1>         mov     edi, invalid_fname_chars
  2878 00009845 AC                  <1> 	lodsb
  2879                              <1> check_filename_next_char:
  2880 00009846 B914000000          <1> 	mov	ecx, sizeInvFnChars
  2881 0000984B BF[62410100]        <1> 	mov	edi, invalid_fname_chars
  2882                              <1> loc_scan_invalid_filename_char:
  2883 00009850 AE                  <1> 	scasb 
  2884 00009851 741F                <1> 	je	short loc_invalid_filename_stc 
  2885 00009853 E2FB                <1> 	loop	loc_scan_invalid_filename_char
  2886 00009855 AC                  <1> 	lodsb
  2887 00009856 3C1F                <1> 	cmp	al, 1Fh  ; 20h and above 
  2888 00009858 77EC                <1> 	ja	short check_filename_next_char
  2889                              <1> 
  2890                              <1> check_filename_dot:
  2891 0000985A 8B3424              <1> 	mov	esi, [esp]
  2892                              <1> 
  2893 0000985D B421                <1> 	mov	ah, 21h
  2894 0000985F B908000000          <1> 	mov	ecx, 8
  2895                              <1> loc_check_filename_next_char:
  2896 00009864 AC                  <1> 	lodsb
  2897 00009865 3C2E                <1> 	cmp	al, 2Eh
  2898 00009867 7511                <1> 	jne	short pass_check_fn_dot_check
  2899                              <1> loc_check_filename_ext_0:
  2900 00009869 AC                  <1> 	lodsb
  2901 0000986A 38E0                <1> 	cmp	al, ah ; 21h
  2902 0000986C 7205                <1> 	jb	short loc_invalid_filename
  2903 0000986E 3C2E                <1> 	cmp	al, 2Eh
  2904 00009870 7519                <1> 	jne	short loc_check_filename_ext_1
  2905                              <1> 
  2906                              <1> loc_invalid_filename_stc:
  2907                              <1> loc_check_fn_stc_rtn:
  2908 00009872 F9                  <1> 	stc
  2909                              <1> loc_invalid_filename:
  2910                              <1> 	; 10/10/2016 (0Bh -> 26)
  2911 00009873 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; (=26)
  2912                              <1> 	; Invalid file name chars
  2913                              <1> loc_check_fn_rtn:
  2914 00009878 5E                  <1> 	pop	esi
  2915 00009879 C3                  <1> 	retn
  2916                              <1> 
  2917                              <1> pass_check_fn_dot_check:
  2918 0000987A 38E0                <1> 	cmp	al, ah ; 21h
  2919 0000987C 7224                <1> 	jb	short loc_check_fn_clc_rtn
  2920 0000987E E2E4                <1> 	loop	loc_check_filename_next_char
  2921 00009880 AC                  <1> 	lodsb
  2922 00009881 38E0                <1> 	cmp	al, ah ; 21h
  2923 00009883 721D                <1> 	jb	short loc_check_fn_clc_rtn
  2924 00009885 3C2E                <1> 	cmp	al, 2Eh
  2925 00009887 75E9                <1> 	jne	short loc_check_fn_stc_rtn
  2926 00009889 EBDE                <1> 	jmp	short loc_check_filename_ext_0
  2927                              <1> 
  2928                              <1> loc_check_filename_ext_1:
  2929 0000988B AC                  <1> 	lodsb
  2930 0000988C 38E0                <1> 	cmp	al, ah ; 21h
  2931 0000988E 7212                <1> 	jb	short loc_check_fn_clc_rtn
  2932 00009890 3C2E                <1> 	cmp	al, 2Eh
  2933 00009892 74DE                <1> 	je	short loc_check_fn_stc_rtn
  2934 00009894 AC                  <1> 	lodsb
  2935 00009895 38E0                <1> 	cmp	al, ah ; 21h
  2936 00009897 7209                <1> 	jb	short loc_check_fn_clc_rtn
  2937 00009899 3C2E                <1> 	cmp	al, 2Eh
  2938 0000989B 74D5                <1> 	je	short loc_check_fn_stc_rtn
  2939 0000989D AC                  <1> 	lodsb
  2940 0000989E 38E0                <1> 	cmp	al, ah ; 21h
  2941 000098A0 73D0                <1> 	jnb	short loc_check_fn_stc_rtn
  2942                              <1> 
  2943                              <1> loc_check_fn_clc_rtn:
  2944 000098A2 5E                  <1> 	pop	esi
  2945 000098A3 F8                  <1> 	clc
  2946 000098A4 C3                  <1> 	retn
  2947                              <1> 
  2948                              <1> loc_print_deleted_message:
  2949 000098A5 BE[4F450100]        <1> 	mov	esi, Msg_Deleted
  2950 000098AA E8A6DCFFFF          <1> 	call	print_msg
  2951                              <1> 
  2952                              <1> 	;clc
  2953                              <1> 
  2954                              <1> loc_file_rw_restore_retn:
  2955                              <1> 	; 15/02/2016 (TRDOS 386 = TRDOS v2.0)
  2956                              <1> 	; 28/02/2010 (CMD_INTR.ASM)
  2957                              <1> loc_file_rw_cmd_failed:
  2958 000098AF 9C                  <1> 	pushf 
  2959 000098B0 E84FF7FFFF          <1> 	call	restore_cdir_after_cmd_fail	
  2960 000098B5 9D                  <1> 	popf
  2961 000098B6 720D                <1> 	jc	short loc_file_rw_check_write_fault
  2962 000098B8 C3                  <1> 	retn
  2963                              <1> 
  2964                              <1> loc_permission_denied:
  2965                              <1> 	; 27/02/2016
  2966 000098B9 BE[5C450100]        <1> 	mov	esi, Msg_Permission_Denied
  2967 000098BE E892DCFFFF          <1> 	call	print_msg
  2968 000098C3 EBEA                <1> 	jmp	short loc_file_rw_restore_retn
  2969                              <1> 
  2970                              <1> loc_file_rw_check_write_fault:
  2971                              <1> 	;cmp	al, 1Dh ; Write Fault
  2972 000098C5 3C12                <1>         cmp	al, 18 ; 05/11/2016
  2973 000098C7 0F85D4F6FFFF        <1> 	jne     loc_run_cmd_failed_cmp_al
  2974 000098CD BE[43430100]        <1> 	mov	esi, Msg_Not_Ready_Write_Err
  2975                              <1> 	;call	print_msg
  2976                              <1> 	;retn
  2977 000098D2 E97EDCFFFF          <1> 	jmp	print_msg
  2978                              <1> 
  2979                              <1> make_directory:
  2980                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  2981                              <1> 	; 12/03/2011 (CMD_INTR.ASM, 'cmp_cmd_mkdir')
  2982                              <1> 	; 14/08/2010
  2983                              <1> 	; 10/07/2010
  2984                              <1> 	; 29/11/2009
  2985                              <1> 	;
  2986                              <1> get_mkdir_fchar:
  2987                              <1> 	; esi = directory name
  2988 000098D7 803E20              <1> 	cmp	byte [esi], 20h
  2989 000098DA 7701                <1>         ja	short loc_mkdir_parse_path_name
  2990                              <1> 
  2991                              <1> loc_mkdir_nodirname_retn:
  2992 000098DC C3                  <1> 	retn
  2993                              <1> 
  2994                              <1> loc_mkdir_parse_path_name:
  2995 000098DD BF[36930100]        <1> 	mov	edi, FindFile_Drv
  2996 000098E2 E86B1D0000          <1>         call    parse_path_name
  2997 000098E7 0F8284F6FFFF        <1> 	jc	loc_cmd_failed
  2998                              <1> 
  2999                              <1> loc_mkdir_check_dirname_exists:
  3000 000098ED BE[78930100]        <1> 	mov	esi, FindFile_Name
  3001 000098F2 803E20              <1> 	cmp	byte [esi], 20h
  3002 000098F5 0F8676F6FFFF        <1> 	jna	loc_cmd_failed
  3003 000098FB 8935[F4930100]      <1> 	mov	[DelFile_FNPointer], esi
  3004 00009901 E839FFFFFF          <1> 	call	check_filename
  3005 00009906 7259                <1> 	jc	short loc_mkdir_invalid_dir_name_chars
  3006                              <1> 
  3007                              <1> loc_mkdir_drv:
  3008 00009908 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  3009 0000990E 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  3010                              <1> 	
  3011 00009914 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  3012 0000991A 38F2                <1> 	cmp	dl, dh
  3013 0000991C 7407                <1> 	je	short loc_mkdir_change_directory
  3014                              <1> 
  3015 0000991E E8BBE7FFFF          <1> 	call	change_current_drive
  3016 00009923 728A                <1> 	jc	loc_file_rw_cmd_failed
  3017                              <1> 
  3018                              <1> loc_mkdir_change_directory:
  3019 00009925 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3020 0000992C 7614                <1> 	jna	short loc_mkdir_find_directory
  3021                              <1> 
  3022 0000992E FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  3023 00009934 BE[37930100]        <1> 	mov	esi, FindFile_Directory
  3024 00009939 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3025 0000993B E8FC160000          <1> 	call	change_current_directory
  3026 00009940 722E                <1> 	jc	short loc_mkdir_check_error_code
  3027                              <1> 
  3028                              <1> ;loc_mkdir_change_prompt_dir_string:
  3029                              <1> 	;call	change_prompt_dir_string
  3030                              <1> 
  3031                              <1> loc_mkdir_find_directory:
  3032                              <1> 	;mov	esi, FindFile_Name
  3033 00009942 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3034                              <1> 	;xor	eax, eax
  3035 00009948 6631C0              <1> 	xor	ax, ax ; any name (dir, file, volume)
  3036 0000994B E831FBFFFF          <1> 	call	find_first_file
  3037 00009950 721E                <1> 	jc	short loc_mkdir_check_error_code
  3038                              <1> 
  3039                              <1> loc_mkdir_directory_found:
  3040 00009952 BE[A7440100]        <1> 	mov	esi, Msg_Name_Exists
  3041 00009957 E8F9DBFFFF          <1> 	call	print_msg
  3042                              <1> 
  3043 0000995C E94EFFFFFF          <1>         jmp     loc_file_rw_restore_retn
  3044                              <1> 
  3045                              <1> loc_mkdir_invalid_dir_name_chars:
  3046 00009961 BE[7A440100]        <1> 	mov	esi, Msg_invalid_name_chars
  3047 00009966 E8EADBFFFF          <1> 	call	print_msg
  3048                              <1> 
  3049 0000996B E93FFFFFFF          <1>         jmp     loc_file_rw_restore_retn
  3050                              <1> 
  3051                              <1> loc_mkdir_check_error_code:
  3052 00009970 3C02                <1> 	cmp	al, 2
  3053                              <1> 	;je	short loc_mkdir_directory_not_found
  3054 00009972 7406                <1> 	je	short loc_mkdir_ask_for_yes_no
  3055 00009974 F9                  <1> 	stc
  3056 00009975 E935FFFFFF          <1>         jmp     loc_file_rw_cmd_failed
  3057                              <1> 
  3058                              <1> loc_mkdir_directory_not_found:
  3059                              <1> loc_mkdir_ask_for_yes_no:
  3060 0000997A BE[C8440100]        <1> 	mov	esi, Msg_DoYouWantMkdir
  3061 0000997F E8D1DBFFFF          <1> 	call	print_msg
  3062 00009984 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3063 0000998A E8C6DBFFFF          <1> 	call	print_msg
  3064 0000998F BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  3065 00009994 E8BCDBFFFF          <1> 	call	print_msg
  3066                              <1> 
  3067 00009999 C605[F1440100]20    <1> 	mov	byte [Y_N_nextline], 20h
  3068                              <1> 
  3069                              <1> loc_mkdir_ask_again:
  3070 000099A0 30E4                <1> 	xor	ah, ah
  3071 000099A2 E83E75FFFF          <1> 	call	int16h
  3072 000099A7 3C1B                <1> 	cmp	al, 1Bh
  3073                              <1> 	;je	short loc_do_not_make_directory
  3074 000099A9 7439                <1> 	je	short loc_mkdir_y_n_escape
  3075 000099AB 24DF                <1> 	and	al, 0DFh ; y -> Y, n -> N
  3076 000099AD 3C59                <1> 	cmp	al, 'Y' ; 'yes'
  3077 000099AF 7404                <1> 	je	short loc_mkdir_yes_make_directory
  3078 000099B1 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3079 000099B3 75EB                <1> 	jne	short loc_mkdir_ask_again
  3080                              <1> 
  3081                              <1> loc_do_not_make_directory:
  3082                              <1> loc_mkdir_yes_make_directory:
  3083 000099B5 E82E000000          <1> 	call	y_n_answer ; 29/12/2017
  3084                              <1> 	;cmp	al, 'Y' ; 'yes'
  3085                              <1> 	;cmc
  3086                              <1>         ;jnc	loc_file_rw_restore_retn
  3087 000099BA 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3088 000099BC 0F84EDFEFFFF        <1>         je	loc_file_rw_restore_retn  
  3089                              <1> 
  3090                              <1> loc_mkdir_call_make_sub_directory:
  3091 000099C2 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3092 000099C8 B110                <1> 	mov	cl, 10h ; Directory attributes 
  3093 000099CA E8821D0000          <1> 	call	make_sub_directory
  3094                              <1> loc_rename_file_ok: ; 06/03/2016
  3095 000099CF 0F82DAFEFFFF        <1>         jc	loc_file_rw_cmd_failed
  3096                              <1> move_source_file_to_destination_OK:
  3097 000099D5 BE[F5440100]        <1> 	mov	esi, Msg_OK
  3098 000099DA E876DBFFFF          <1> 	call	print_msg
  3099 000099DF E9CBFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3100                              <1> 
  3101                              <1> loc_mkdir_y_n_escape:
  3102 000099E4 B04E                <1> 	mov	al, 'N' ; 'no'
  3103 000099E6 EBCD                <1> 	jmp	short loc_do_not_make_directory
  3104                              <1> 
  3105                              <1> y_n_answer:
  3106                              <1> 	; 29/12/2017
  3107 000099E8 A2[F1440100]        <1> 	mov	[Y_N_nextline], al
  3108                              <1> 	;push	ax
  3109 000099ED 50                  <1> 	push	eax
  3110 000099EE BE[F1440100]        <1> 	mov	esi, Y_N_nextline
  3111 000099F3 E85DDBFFFF          <1> 	call	print_msg
  3112 000099F8 58                  <1> 	pop	eax
  3113                              <1> 	;pop	ax
  3114 000099F9 C3                  <1> 	retn
  3115                              <1> 
  3116                              <1> delete_directory:
  3117                              <1> 	; 29/12/2017
  3118                              <1> 	; 15/10/2016
  3119                              <1> 	; 01/03/2016, 06/03/2016
  3120                              <1> 	; 27/02/2016, 28/02/2016, 29/02/2016
  3121                              <1> 	; 26/02/2016 (TRDOS 386 = TRDOS v2.0)
  3122                              <1> 	; 16/10/2010 (CMD_INTR.ASM, 'cmp_cmd_rmdir')
  3123                              <1> 	; 05/06/2010
  3124                              <1> 	;
  3125                              <1> get_fchar:
  3126                              <1> 	; esi = directory name
  3127 000099FA 803E20              <1> 	cmp	byte [esi], 20h
  3128 000099FD 7701                <1>         ja	short loc_rmdir_parse_path_name
  3129                              <1> 
  3130                              <1> loc_rmdir_nodirname_retn:
  3131 000099FF C3                  <1> 	retn
  3132                              <1> 
  3133                              <1> loc_rmdir_parse_path_name:
  3134 00009A00 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  3135 00009A05 E8481C0000          <1> 	call	parse_path_name
  3136 00009A0A 0F8261F5FFFF        <1> 	jc	loc_cmd_failed
  3137                              <1> 
  3138                              <1> loc_rmdir_check_dirname_exists:
  3139 00009A10 BE[78930100]        <1> 	mov	esi, FindFile_Name
  3140 00009A15 803E20              <1> 	cmp	byte [esi], 20h
  3141 00009A18 0F8653F5FFFF        <1> 	jna	loc_cmd_failed
  3142 00009A1E 8935[F4930100]      <1> 	mov	[DelFile_FNPointer], esi 
  3143                              <1> 
  3144                              <1> loc_rmdir_drv:
  3145 00009A24 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  3146 00009A2A 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  3147                              <1> 
  3148 00009A30 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  3149 00009A36 38F2                <1> 	cmp	dl, dh
  3150 00009A38 740B                <1> 	je	short loc_rmdir_change_directory
  3151                              <1> 
  3152 00009A3A E89FE6FFFF          <1> 	call	change_current_drive
  3153 00009A3F 0F826AFEFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3154                              <1> 
  3155                              <1> loc_rmdir_change_directory:
  3156 00009A45 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3157 00009A4C 7614                <1> 	jna	short loc_rmdir_find_directory
  3158                              <1> 
  3159 00009A4E FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  3160 00009A54 BE[37930100]        <1> 	mov	esi, FindFile_Directory
  3161 00009A59 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3162 00009A5B E8DC150000          <1> 	call	change_current_directory
  3163 00009A60 7211                <1> 	jc	short loc_rmdir_check_error_code
  3164                              <1> 
  3165                              <1> ;loc_rmdir_change_prompt_dir_string:
  3166                              <1> 	;call	change_prompt_dir_string
  3167                              <1> 
  3168                              <1> loc_rmdir_find_directory:
  3169                              <1> 	;mov	esi, FindFile_Name
  3170 00009A62 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3171 00009A68 66B81008            <1> 	mov	ax, 0810h ; Only directories
  3172 00009A6C E810FAFFFF          <1> 	call	find_first_file
  3173 00009A71 730A                <1> 	jnc	short loc_rmdir_ambgfn_check
  3174                              <1> 
  3175                              <1> loc_rmdir_check_error_code:
  3176 00009A73 3C02                <1> 	cmp	al, 2
  3177 00009A75 740B                <1> 	je	short loc_rmdir_directory_not_found
  3178 00009A77 F9                  <1> 	stc
  3179 00009A78 E932FEFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3180                              <1> 
  3181                              <1> loc_rmdir_ambgfn_check:
  3182 00009A7D 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3183 00009A80 740F                <1> 	jz	short loc_rmdir_directory_found
  3184                              <1> 
  3185                              <1> loc_rmdir_directory_not_found:
  3186 00009A82 BE[65430100]        <1> 	mov	esi, Msg_Dir_Not_Found
  3187 00009A87 E8C9DAFFFF          <1> 	call	print_msg
  3188                              <1> 
  3189 00009A8C E91EFEFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3190                              <1> 
  3191                              <1> loc_rmdir_directory_found:
  3192 00009A91 80E307              <1> 	and	bl, 07h ; Attributes
  3193 00009A94 0F851FFEFFFF        <1> 	jnz	loc_permission_denied
  3194                              <1> 
  3195                              <1> loc_rmdir_save_lnel: ; 28/02/2016
  3196                              <1>        ;mov	bh, [LongName_EntryLength]
  3197 00009A9A 883D[FE930100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  3198                              <1> 	; edi = Directory Entry Offset (DirBuff)
  3199                              <1> 	; esi = Directory Entry (FFF Structure)
  3200                              <1> 	;mov	[DelFile_DirEntryAddr], edi ; not required
  3201                              <1> 	;mov	ax, [edi+20] ; First Cluster High Word
  3202                              <1>         ;shl	eax, 16
  3203                              <1> 	;mov	ax, [edi+26] ; First Cluster Low Word
  3204                              <1> 	; ROOT Dir First Cluster = 0
  3205                              <1>         ;cmp	eax, 2
  3206                              <1> 	;jb	loc_update_direntry_1
  3207                              <1> 
  3208                              <1> pass_rmdir_fc_check:
  3209 00009AA0 57                  <1> 	push	edi ; * (29/02/2016)
  3210                              <1> 
  3211 00009AA1 BE[FB440100]        <1> 	mov	esi, Msg_DoYouWantRmDir
  3212 00009AA6 E8AADAFFFF          <1> 	call	print_msg
  3213 00009AAB 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3214 00009AB1 E89FDAFFFF          <1> 	call	print_msg
  3215 00009AB6 BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  3216 00009ABB E895DAFFFF          <1> 	call	print_msg
  3217                              <1> 
  3218                              <1> loc_rmdir_ask_again:
  3219 00009AC0 30E4                <1> 	xor	ah, ah
  3220 00009AC2 E81E74FFFF          <1> 	call	int16h
  3221 00009AC7 3C1B                <1> 	cmp	al, 1Bh
  3222                              <1> 	;je	short loc_do_not_delete_directory
  3223 00009AC9 7433                <1>         je      loc_rmdir_y_n_escape ; 06/03/2016
  3224 00009ACB 24DF                <1> 	and	al, 0DFh
  3225 00009ACD A2[F1440100]        <1> 	mov	[Y_N_nextline], al
  3226 00009AD2 3C59                <1> 	cmp	al, 'Y'
  3227 00009AD4 7404                <1> 	je	short loc_rmdir_yes_delete_directory
  3228 00009AD6 3C4E                <1> 	cmp	al, 'N'
  3229 00009AD8 75E6                <1> 	jne	short loc_rmdir_ask_again
  3230                              <1> 
  3231                              <1> loc_do_not_delete_directory:
  3232                              <1> loc_rmdir_yes_delete_directory:
  3233 00009ADA E809FFFFFF          <1> 	call	y_n_answer ; 29/12/2017
  3234 00009ADF 5F                  <1> 	pop	edi ; * (29/02/2016)
  3235                              <1> 	;cmp	al, 'Y' ; 'yes'
  3236                              <1> 	;cmc
  3237                              <1>         ;jnc	loc_file_rw_restore_retn
  3238 00009AE0 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3239 00009AE2 0F84C7FDFFFF        <1>         je	loc_file_rw_restore_retn 
  3240                              <1> 
  3241                              <1> 	; 29/12/2017
  3242 00009AE8 E869000000          <1> 	call	delete_sub_directory
  3243 00009AED 7213                <1> 	jc	short loc_rmdir_cmd_failed
  3244                              <1> 
  3245                              <1> loc_rmdir_ok:
  3246 00009AEF BE[F5440100]        <1> 	mov	esi, Msg_OK
  3247 00009AF4 E85CDAFFFF          <1> 	call	print_msg
  3248 00009AF9 E9B1FDFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3249                              <1> 
  3250                              <1> loc_rmdir_y_n_escape:
  3251 00009AFE B04E                <1> 	mov	al, 'N' ; 'no'
  3252 00009B00 EBD8                <1>         jmp     loc_do_not_delete_directory
  3253                              <1> 
  3254                              <1> loc_rmdir_cmd_failed:
  3255                              <1> 	; 29/12/2017
  3256 00009B02 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
  3257 00009B04 7426                <1> 	jz	short loc_rmdir_directory_not_empty
  3258                              <1> 
  3259                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
  3260                              <1> 
  3261 00009B06 833D[B2910100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
  3262 00009B0D 0F829CFDFFFF        <1> 	jb	loc_file_rw_cmd_failed	
  3263 00009B13 F9                  <1> 	stc
  3264                              <1> loc_rmdir_cmd_return:
  3265                              <1> 	; 01/03/2016
  3266 00009B14 9C                  <1> 	pushf
  3267                              <1> 	; ESI = Logical DOS Drive Description Table address	
  3268 00009B15 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
  3269                              <1> 	           ; BL = 0 -> Recalculate free cluster count
  3270 00009B19 50                  <1> 	push	eax
  3271 00009B1A E8C3380000          <1> 	call	calculate_fat_freespace	
  3272 00009B1F 58                  <1> 	pop	eax
  3273 00009B20 9D                  <1> 	popf
  3274 00009B21 0F8288FDFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3275 00009B27 E983FDFFFF          <1> 	jmp	loc_file_rw_restore_retn
  3276                              <1> 
  3277                              <1> loc_rmdir_directory_not_empty:
  3278 00009B2C BE[1C450100]        <1> 	mov	esi, Msg_Dir_Not_Empty
  3279 00009B31 E81FDAFFFF          <1> 	call	print_msg
  3280                              <1> 	; 01/03/2016
  3281 00009B36 A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  3282 00009B3B 09C0                <1> 	or	eax, eax ; 0 ?
  3283 00009B3D 0F846CFDFFFF        <1> 	jz	loc_file_rw_restore_retn
  3284                              <1> 	; ESI = Logical DOS Drive Description Table address	
  3285 00009B43 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
  3286                              <1> 	           ; BL = 1 -> add free clusters
  3287 00009B47 E896380000          <1> 	call	calculate_fat_freespace
  3288 00009B4C 09C9                <1> 	or	ecx, ecx
  3289 00009B4E 0F845BFDFFFF        <1>         jz      loc_file_rw_restore_retn ; ecx = 0 -> OK
  3290                              <1> 	; ecx > 0 -> Error (Recalculation is needed)
  3291 00009B54 EBBE                <1> 	jmp	short loc_rmdir_cmd_return
  3292                              <1> 
  3293                              <1> 
  3294                              <1> delete_sub_directory:
  3295                              <1> 	; 29/12/2017 
  3296                              <1> 	; (moved here from 'delete_directory' for 'sysrmdir' )
  3297                              <1> 
  3298                              <1> 	; EDI = Directory buffer entry offset/address
  3299                              <1> 
  3300                              <1> loc_rmdir_delete_short_name_check_dir_empty:
  3301 00009B56 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  3302 00009B5A C1E010              <1>         shl	eax, 16
  3303 00009B5D 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  3304                              <1> 
  3305                              <1> 	;mov 	[DelFile_FCluster], eax
  3306                              <1> 
  3307                              <1> 	;;mov	bx, [DirBuff_EntryCounter]
  3308                              <1> 	;mov	bx, [FindFile_DirEntryNumber] ; 27/02/2016
  3309                              <1> 	;mov	[DelFile_EntryCounter], bx
  3310                              <1> 
  3311 00009B61 29DB                <1>     	sub	ebx, ebx
  3312                              <1> 	; 29/12/2017
  3313 00009B63 891D[B2910100]      <1> 	mov	[FAT_ClusterCounter], ebx ; 0 ; Reset
  3314                              <1> 
  3315 00009B69 8A3D[36930100]      <1> 	mov	bh, [FindFile_Drv]
  3316 00009B6F BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3317 00009B74 01DE                <1> 	add	esi, ebx
  3318                              <1> 
  3319 00009B76 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h
  3320 00009B7C 745A                <1> 	je	short loc_rmdir_check_fs_directory
  3321                              <1> 
  3322                              <1> 	;cmp	byte [esi+LD_FATType], 1
  3323                              <1> 	;jb	short loc_rmdir_get__last_cluster_0
  3324                              <1> 
  3325                              <1> 	; 29/12/2017
  3326 00009B7E 83F802              <1> 	cmp	eax, 2
  3327 00009B81 7306                <1> 	jnb	short loc_rmdir_get_last_cluster_1
  3328                              <1> 	; eax < 2
  3329                              <1> loc_rmdir_get_last_cluster_0:
  3330                              <1> 	;mov	eax, ERR_INV_FORMAT ; invalid format!
  3331 00009B83 B813000000          <1> 	mov	eax, ERR_NOT_DIR ; not a valid directory!
  3332                              <1> 	;stc
  3333 00009B88 C3                  <1> 	retn
  3334                              <1> 
  3335                              <1> loc_rmdir_get_last_cluster_1:
  3336 00009B89 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3 ; FAT32
  3337 00009B8D 750C                <1> 	jne	short loc_rmdir_get_last_cluster_2
  3338                              <1> 
  3339                              <1> 	; is it root directory ?
  3340 00009B8F 3B4632              <1> 	cmp	eax, [esi+LD_BPB+BPB_RootClus]
  3341 00009B92 7507                <1> 	jne	short loc_rmdir_get_last_cluster_2
  3342                              <1> 
  3343                              <1> 	; root directory can not be deleted !!
  3344                              <1> loc_rmdir_permission_denied:
  3345 00009B94 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; permission denied!
  3346 00009B99 F9                  <1> 	stc
  3347 00009B9A C3                  <1> 	retn		
  3348                              <1> 
  3349                              <1> loc_rmdir_get_last_cluster_2:
  3350                              <1> 	; 29/12/2017
  3351 00009B9B A3[F8930100]        <1> 	mov 	[DelFile_FCluster], eax
  3352                              <1> 	
  3353                              <1> 	;mov	dx, [DirBuff_EntryCounter]
  3354 00009BA0 668B15[B0930100]    <1> 	mov	dx, [FindFile_DirEntryNumber] ; 27/02/2016
  3355 00009BA7 668915[FC930100]    <1> 	mov	[DelFile_EntryCounter], dx
  3356                              <1> 	
  3357 00009BAE 8B15[C1910100]      <1> 	mov	edx, [DirBuff_Cluster]
  3358 00009BB4 8915[28940100]      <1> 	mov	[RmDir_ParentDirCluster], edx
  3359                              <1> 
  3360 00009BBA 893D[24940100]      <1> 	mov	[RmDir_DirEntryOffset], edi
  3361                              <1> 
  3362                              <1> 	; 01/03/2016
  3363                              <1> 	;mov	dword [FAT_ClusterCounter], 0 ; Reset
  3364                              <1> 
  3365                              <1> loc_rmdir_get_last_cluster_3:
  3366 00009BC0 E89C390000          <1> 	call	get_last_cluster
  3367                              <1>         ;jc	loc_rmdir_cmd_failed
  3368 00009BC5 721E                <1> 	jc	short loc_delete_sub_dir_retn ; 29/12/2017
  3369                              <1> 	
  3370 00009BC7 3B05[F8930100]      <1> 	cmp	eax, [DelFile_FCluster]
  3371 00009BCD 7517                <1> 	jne	short loc_rmdir_multi_dir_clusters
  3372                              <1> 
  3373 00009BCF C605[23940100]00    <1> 	mov	byte [RmDir_MultiClusters], 0
  3374 00009BD6 EB15                <1> 	jmp	short pass_rmdir_multi_dir_clusters
  3375                              <1> 
  3376                              <1> loc_rmdir_check_fs_directory:
  3377                              <1> 	; 29/12/2017
  3378 00009BD8 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  3379 00009BDC 75B6                <1> 	jne	short loc_rmdir_permission_denied
  3380                              <1> 
  3381                              <1> loc_rmdir_delete_fs_directory:
  3382 00009BDE E876130000          <1> 	call	delete_fs_directory
  3383                              <1> 	;jnc	loc_print_deleted_message
  3384 00009BE3 7300                <1> 	jnc	short loc_delete_sub_dir_retn ; 29/12/2017
  3385                              <1> 
  3386                              <1> 	; EAX=0 -> Directory not empty !
  3387                              <1> 	; EAX>0 -> Disk r/w error or another (misc) error
  3388                              <1> 	
  3389                              <1> 	;or	eax, eax
  3390                              <1> 	;jz	loc_rmdir_directory_not_empty_2         
  3391                              <1> 	;;stc
  3392                              <1> 	;;jmp	loc_file_rw_cmd_failed
  3393                              <1> 	
  3394                              <1> loc_delete_sub_dir_retn:
  3395 00009BE5 C3                  <1> 	retn
  3396                              <1>  
  3397                              <1> loc_rmdir_multi_dir_clusters:
  3398 00009BE6 C605[23940100]01    <1> 	mov	byte [RmDir_MultiClusters], 1
  3399                              <1> 
  3400                              <1> pass_rmdir_multi_dir_clusters:
  3401 00009BED A3[2C940100]        <1> 	mov 	[RmDir_DirLastCluster], eax
  3402 00009BF2 890D[30940100]      <1> 	mov	[RmDir_PreviousCluster], ecx
  3403                              <1> 
  3404                              <1> loc_rmdir_load_fat_sub_directory:
  3405 00009BF8 E84F330000          <1> 	call	load_FAT_sub_directory
  3406                              <1> 	;jc	loc_rmdir_cmd_failed
  3407 00009BFD 72E6                <1> 	jc	short loc_delete_sub_dir_retn
  3408                              <1> 
  3409                              <1> loc_rmdir_find_last_dir_entry:
  3410 00009BFF 56                  <1> 	push	esi
  3411 00009C00 BE[1A930100]        <1> 	mov	esi, Dir_File_Name
  3412 00009C05 C6062A              <1> 	mov	byte [esi], '*'
  3413 00009C08 C646082A            <1> 	mov	byte [esi+8], '*'
  3414 00009C0C 31DB                <1> 	xor	ebx, ebx ; Entry offset  = 0
  3415                              <1> loc_rmdir_find_last_dir_entry_next:
  3416 00009C0E 66B80008            <1> 	mov	ax, 0800h ; Except volume/long names
  3417 00009C12 6631C9              <1> 	xor	cx, cx ; 0 = Find a valid file or dir name
  3418 00009C15 E87A170000          <1> 	call	find_directory_entry
  3419 00009C1A 7225                <1> 	jc	short loc_rmdir_empty_dir_cluster
  3420 00009C1C 83FB01              <1> 	cmp	ebx, 1
  3421 00009C1F 771B                <1> 	ja	short loc_rmdir_directory_not_empty_1
  3422                              <1> loc_rmdir_dot_entry_check:
  3423 00009C21 80FD2E              <1> 	cmp	ch, '.' ; The first char of the dir entry
  3424 00009C24 7516                <1> 	jne	short loc_rmdir_directory_not_empty_1
  3425 00009C26 08DB                <1> 	or	bl, bl
  3426 00009C28 7506                <1> 	jnz	short loc_rmdir_dotdot_entry_check
  3427 00009C2A 807F0120            <1> 	cmp	byte [edi+1], 20h
  3428 00009C2E EB06                <1> 	jmp	short pass_rmdir_dot_entry_check
  3429                              <1> 
  3430                              <1> loc_rmdir_dotdot_entry_check:
  3431 00009C30 66817F012E20        <1> 	cmp	word [edi+1], '. '
  3432                              <1> pass_rmdir_dot_entry_check:	
  3433 00009C36 7504                <1> 	jne	short loc_rmdir_directory_not_empty_1 
  3434 00009C38 FEC3                <1> 	inc	bl
  3435 00009C3A EBD2                <1> 	jmp	short loc_rmdir_find_last_dir_entry_next 
  3436                              <1> 
  3437                              <1> loc_rmdir_directory_not_empty_1:
  3438 00009C3C 58                  <1> 	pop	eax ; pushed esi 
  3439 00009C3D 31C0                <1> 	xor	eax, eax ; 0
  3440                              <1> loc_rmdir_directory_not_empty_2:
  3441                              <1> loc_delete_sub_dir_stc_retn:
  3442 00009C3F F9                  <1> 	stc
  3443 00009C40 C3                  <1> 	retn
  3444                              <1> 
  3445                              <1> loc_rmdir_empty_dir_cluster:
  3446 00009C41 5E                  <1> 	pop	esi
  3447                              <1> 
  3448                              <1> loc_rmdir_set_prev_cluster_dir_last_cluster:
  3449 00009C42 803D[23940100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  3450 00009C49 7613                <1> 	jna	short loc_rmdir_unlink_dir_last_cluster
  3451                              <1> 
  3452 00009C4B A1[30940100]        <1> 	mov	eax, [RmDir_PreviousCluster]
  3453                              <1> 	;xor	ecx, ecx
  3454 00009C50 49                  <1> 	dec	ecx ; FFFFFFFFh
  3455 00009C51 E83A340000          <1> 	call	update_cluster
  3456 00009C56 7306                <1> 	jnc	short loc_rmdir_unlink_dir_last_cluster
  3457                              <1> 
  3458                              <1> 	; 01/03/2016
  3459                              <1> 	;cmp	eax, 1  ; eax = 0 -> end of cluster chain
  3460                              <1> 	;cmc 
  3461                              <1> 	;jc	short loc_rmdir_cmd_failed
  3462                              <1> 	;jmp	short loc_rmdir_save_fat_buffer
  3463                              <1> 	; 29/12/2017 
  3464 00009C58 21C0                <1> 	and	eax, eax
  3465 00009C5A 75E3                <1> 	jnz	short loc_delete_sub_dir_stc_retn
  3466 00009C5C EB12                <1> 	jmp	short loc_rmdir_save_fat_buffer	
  3467                              <1> 
  3468                              <1> loc_rmdir_unlink_dir_last_cluster:
  3469 00009C5E A1[2C940100]        <1> 	mov	eax, [RmDir_DirLastCluster]
  3470 00009C63 31C9                <1> 	xor	ecx, ecx ; 0
  3471 00009C65 E826340000          <1> 	call	update_cluster
  3472 00009C6A 7327                <1> 	jnc	short loc_rmdir_unlink_stc_retn_0Bh
  3473                              <1> 	; Because of it is the last cluster
  3474                              <1> 	; 'update_cluster' must return with eocc error 
  3475 00009C6C 09C0                <1> 	or	eax, eax
  3476                              <1> 	;jz	short loc_rmdir_save_fat_buffer ; eocc	
  3477                              <1> 	;stc
  3478                              <1>         ;jmp     short loc_rmdir_cmd_failed
  3479                              <1> 	; 29/12/2017
  3480 00009C6E 75CF                <1> 	jnz	short loc_delete_sub_dir_stc_retn
  3481                              <1> 	
  3482                              <1> loc_rmdir_save_fat_buffer:
  3483 00009C70 803D[AA910100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  3484 00009C77 7528                <1> 	jne	short loc_rmdir_calculate_FAT_freespace
  3485 00009C79 E8CF360000          <1> 	call	save_fat_buffer
  3486                              <1> 	;jc	short loc_rmdir_cmd_failed
  3487                              <1> 	; 29/12/2017
  3488 00009C7E 7219                <1> 	jc	short loc_rmdir_unlink_error_retn
  3489                              <1> 
  3490                              <1> 	; 01/03/2016
  3491 00009C80 803D[23940100]00    <1> 	cmp	byte [RmDir_MultiClusters], 0
  3492 00009C87 7618                <1> 	jna	short loc_rmdir_calculate_FAT_freespace
  3493                              <1> 
  3494 00009C89 A1[F8930100]        <1> 	mov	eax, [DelFile_FCluster]
  3495 00009C8E E92DFFFFFF          <1>         jmp     loc_rmdir_get_last_cluster_3
  3496                              <1> 
  3497                              <1> loc_rmdir_unlink_stc_retn_0Bh:
  3498                              <1> 	; 15/10/2016 (0Bh -> 28)
  3499 00009C93 B81C000000          <1> 	mov	eax, ERR_INV_FORMAT ; 28 = Invalid format
  3500                              <1> loc_rmdir_unlink_stc_retn:
  3501 00009C98 F9                  <1> 	stc
  3502                              <1> loc_rmdir_unlink_error_retn:
  3503 00009C99 C3                  <1> 	retn
  3504                              <1> 
  3505                              <1> loc_rmdir_delete_short_name_invalid_data:
  3506 00009C9A B81D000000          <1> 	mov	eax, 29 ; Invalid data (15/10/2016)
  3507                              <1> 	;stc
  3508                              <1>         ;jmp	loc_rmdir_cmd_failed
  3509                              <1> 	; 29/12/2017
  3510 00009C9F EBF7                <1> 	jmp	short loc_rmdir_unlink_stc_retn
  3511                              <1> 
  3512                              <1> loc_rmdir_calculate_FAT_freespace:
  3513                              <1> 	;mov	eax, [FAT_ClusterCounter]
  3514                              <1> 	; 29/12/2017
  3515 00009CA1 29C0                <1> 	sub	eax, eax ; 0
  3516 00009CA3 8705[B2910100]      <1> 	xchg	eax, [FAT_ClusterCounter]
  3517                              <1> 	;
  3518 00009CA9 66BB01FF            <1> 	mov	bx, 0FF01h
  3519                              <1> 	; BL = 1 -> Add EAX to free space count
  3520                              <1> 	; BH = FFh ->
  3521                              <1> 	; ESI = Logical DOS Drive Description Table address
  3522 00009CAD E830370000          <1> 	call	calculate_fat_freespace
  3523                              <1> 
  3524 00009CB2 21C9                <1> 	and	ecx, ecx ; ecx = 0 -> valid free sector count
  3525 00009CB4 7409                <1> 	jz 	short loc_rmdir_delete_short_name_continue
  3526                              <1> 
  3527                              <1> loc_rmdir_recalculate_FAT_freespace:
  3528 00009CB6 66BB00FF            <1>         mov     bx, 0FF00h ; BL = 0 -> Recalculate free space
  3529 00009CBA E823370000          <1> 	call	calculate_fat_freespace
  3530                              <1> 	          
  3531                              <1> loc_rmdir_delete_short_name_continue:
  3532 00009CBF A1[28940100]        <1> 	mov	eax, [RmDir_ParentDirCluster]
  3533 00009CC4 83F802              <1> 	cmp	eax, 2
  3534 00009CC7 7309                <1> 	jnb	short loc_rmdir_del_short_name_load_sub_dir
  3535 00009CC9 E8F3310000          <1> 	call	load_FAT_root_directory
  3536                              <1> 	;jc	loc_file_rw_cmd_failed
  3537                              <1> 	; 29/12/2017
  3538 00009CCE 72C9                <1> 	jc	short loc_rmdir_unlink_error_retn
  3539 00009CD0 EB07                <1> 	jmp	short loc_rmdir_del_short_name_ld_chk_fclust
  3540                              <1> 
  3541                              <1> loc_rmdir_del_short_name_load_sub_dir:	
  3542 00009CD2 E875320000          <1> 	call	load_FAT_sub_directory
  3543                              <1> 	;jc	loc_file_rw_cmd_failed
  3544                              <1> 	; 29/12/2017
  3545 00009CD7 72C0                <1> 	jc	short loc_rmdir_unlink_error_retn
  3546                              <1> 
  3547                              <1> loc_rmdir_del_short_name_ld_chk_fclust:
  3548 00009CD9 0FB73D[24940100]    <1> 	movzx	edi, word [RmDir_DirEntryOffset]
  3549 00009CE0 81C700000800        <1> 	add	edi, Directory_Buffer
  3550                              <1> 
  3551 00009CE6 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  3552 00009CEA C1E010              <1> 	shl	eax, 16
  3553 00009CED 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  3554                              <1>         ; Not necessary... 
  3555 00009CF1 3B05[F8930100]      <1> 	cmp	eax, [DelFile_FCluster]
  3556 00009CF7 75A1                <1> 	jne	short loc_rmdir_delete_short_name_invalid_data
  3557                              <1> 	;
  3558 00009CF9 C607E5              <1> 	mov	byte [edi], 0E5h ; 'Deleted' sign
  3559                              <1> 	; 27/02/2016
  3560                              <1> 	; TRDOS v1 has a bug here! it does not set
  3561                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  3562                              <1> 	; 'save_directory_buffer' would not save the change ! 
  3563 00009CFC C605[BC910100]02    <1>   	mov	byte [DirBuff_ValidData], 2 ; change sign
  3564                              <1> 	;
  3565 00009D03 E8AE1D0000          <1> 	call	save_directory_buffer
  3566                              <1> 	;jc	loc_file_rw_cmd_failed
  3567                              <1> 	; 29/12/2017
  3568 00009D08 728F                <1> 	jc	short loc_rmdir_unlink_error_retn
  3569                              <1> 
  3570                              <1> loc_rmdir_del_long_name:
  3571 00009D0A 0FB615[FE930100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  3572 00009D11 08D2                <1> 	or	dl, dl
  3573 00009D13 7410                <1> 	jz	short loc_rmdir_update_parent_dir_lmdt
  3574                              <1>              
  3575 00009D15 0FB705[FC930100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  3576 00009D1C 29D0                <1> 	sub	eax, edx
  3577                              <1> 	; 29/12/2017
  3578 00009D1E 7205                <1> 	jc	short loc_rmdir_update_parent_dir_lmdt
  3579                              <1>  
  3580                              <1>  	; EAX = Directory Entry Number of the long name last entry
  3581 00009D20 E8EF1E0000          <1> 	call	delete_longname
  3582                              <1> 
  3583                              <1> loc_rmdir_update_parent_dir_lmdt:
  3584 00009D25 E8271E0000          <1> 	call	update_parent_dir_lmdt
  3585                              <1> 	;jc	short loc_file_rw_cmd_failed
  3586                              <1> 	; 29/12/2017
  3587                              <1> 	;jc	short loc_rmdir_unlink_error_retn
  3588                              <1> 
  3589                              <1> loc_delete_sub_directory_ok:
  3590                              <1> 	; 29/12/2017
  3591 00009D2A 31C0                <1> 	xor	eax, eax ;  0 ;  cf = 0
  3592 00009D2C C3                  <1> 	retn
  3593                              <1> 
  3594                              <1> 
  3595                              <1> delete_file:
  3596                              <1> 	; 29/02/2016
  3597                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  3598                              <1> 	; 09/08/2010 (CMD_INTR.ASM, 'cmp_cmd_del')
  3599                              <1> 	; 28/02/2010
  3600                              <1> 
  3601                              <1> get_delfile_fchar:
  3602                              <1> 	; esi = file name
  3603 00009D2D 803E20              <1> 	cmp	byte [esi], 20h
  3604 00009D30 7701                <1>         ja	short loc_delfile_parse_path_name
  3605                              <1> 
  3606                              <1> loc_delfile_nofilename_retn:
  3607 00009D32 C3                  <1> 	retn
  3608                              <1> 
  3609                              <1> loc_delfile_parse_path_name:
  3610 00009D33 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  3611 00009D38 E815190000          <1> 	call	parse_path_name
  3612 00009D3D 0F822EF2FFFF        <1> 	jc	loc_cmd_failed
  3613                              <1> 
  3614                              <1> loc_delfile_check_filename_exists:
  3615 00009D43 BE[78930100]        <1> 	mov	esi, FindFile_Name
  3616 00009D48 803E20              <1> 	cmp	byte [esi], 20h
  3617 00009D4B 0F8620F2FFFF        <1> 	jna	loc_cmd_failed
  3618 00009D51 8935[F4930100]      <1> 	mov	[DelFile_FNPointer], esi 
  3619                              <1> 
  3620                              <1> loc_delfile_drv:
  3621 00009D57 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  3622 00009D5D 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  3623 00009D63 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  3624 00009D69 38F2                <1> 	cmp	dl, dh
  3625 00009D6B 740B                <1> 	je	short loc_delfile_change_directory
  3626                              <1> 
  3627 00009D6D E86CE3FFFF          <1> 	call	change_current_drive
  3628 00009D72 0F8237FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3629                              <1> 
  3630                              <1> loc_delfile_change_directory:
  3631 00009D78 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  3632 00009D7F 7618                <1> 	jna	short loc_delfile_find
  3633                              <1> 
  3634 00009D81 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  3635 00009D87 BE[37930100]        <1> 	mov	esi, FindFile_Directory
  3636 00009D8C 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3637 00009D8E E8A9120000          <1> 	call	change_current_directory
  3638 00009D93 0F8216FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3639                              <1> 
  3640                              <1> ;loc_delfile_change_prompt_dir_string:
  3641                              <1> 	;call	change_prompt_dir_string
  3642                              <1> 
  3643                              <1> loc_delfile_find:
  3644                              <1> 	;mov	esi, FindFile_Name
  3645 00009D99 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3646 00009D9F 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  3647 00009DA3 E8D9F6FFFF          <1> 	call	find_first_file
  3648 00009DA8 0F8201FBFFFF        <1> 	jc	loc_file_rw_cmd_failed
  3649                              <1> 
  3650                              <1> loc_delfile_ambgfn_check:
  3651 00009DAE 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3652 00009DB1 740B                <1> 	jz	short loc_delfile_found
  3653                              <1> 
  3654                              <1> loc_file_not_found:
  3655 00009DB3 B802000000          <1> 	mov	eax, 2 ; File not found sign
  3656 00009DB8 F9                  <1> 	stc
  3657 00009DB9 E9F1FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed   
  3658                              <1> 
  3659                              <1> loc_delfile_found:
  3660 00009DBE 80E307              <1> 	and	bl, 07h ; Attributes
  3661 00009DC1 0F85F2FAFFFF        <1>         jnz     loc_permission_denied
  3662                              <1> 
  3663                              <1> ;loc_delfile_found_save_lnel:
  3664                              <1> ;	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
  3665                              <1> 
  3666                              <1> loc_delfile_ask_for_delete:
  3667 00009DC7 57                  <1> 	push	edi ; * (29/02/2016)
  3668                              <1> 
  3669 00009DC8 BE[33450100]        <1> 	mov	esi, Msg_DoYouWantDelete
  3670 00009DCD E883D7FFFF          <1> 	call	print_msg
  3671 00009DD2 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3672 00009DD8 E878D7FFFF          <1> 	call	print_msg
  3673 00009DDD BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  3674 00009DE2 E86ED7FFFF          <1> 	call	print_msg
  3675                              <1> 
  3676                              <1> loc_delfile_ask_again:
  3677 00009DE7 30E4                <1> 	xor	ah, ah
  3678 00009DE9 E8F770FFFF          <1> 	call	int16h
  3679 00009DEE 3C1B                <1> 	cmp	al, 1Bh
  3680                              <1> 	;je	short loc_do_not_delete_file
  3681 00009DF0 7449                <1> 	je	short loc_delfile_y_n_escape ; 06/03/2016
  3682 00009DF2 24DF                <1> 	and	al, 0DFh
  3683 00009DF4 A2[F1440100]        <1> 	mov	[Y_N_nextline], al
  3684 00009DF9 3C59                <1> 	cmp	al, 'Y'
  3685 00009DFB 7404                <1> 	je	short loc_yes_delete_file
  3686 00009DFD 3C4E                <1> 	cmp	al, 'N'
  3687 00009DFF 75E6                <1> 	jne	short loc_delfile_ask_again
  3688                              <1> 
  3689                              <1> loc_do_not_delete_file:
  3690                              <1> loc_yes_delete_file:
  3691 00009E01 E8E2FBFFFF          <1> 	call	y_n_answer ; 29/12/2017
  3692 00009E06 5F                  <1> 	pop	edi ; * (29/02/2016)
  3693                              <1> 	;cmp	al, 'Y' ; 'yes'
  3694                              <1> 	;cmc
  3695                              <1>         ;jnc	loc_file_rw_restore_retn
  3696 00009E07 3C4E                <1> 	cmp	al, 'N' ; 'no'
  3697 00009E09 0F84A0FAFFFF        <1>         je	loc_file_rw_restore_retn  
  3698                              <1> 
  3699                              <1> loc_delete_file:
  3700 00009E0F 8A3D[36930100]      <1> 	mov	bh, [FindFile_Drv]
  3701                              <1> 	;mov	bl, [DelFile_LNEL]
  3702 00009E15 8A1D[85930100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  3703                              <1> 	;mov	cx, [DirBuff_EntryCounter]
  3704 00009E1B 668B0D[B0930100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  3705                              <1> 	; (*) EDI = Directory buffer entry offset/address 
  3706 00009E22 E8D71F0000          <1> 	call	remove_file ; (FILE.ASM, 'proc_delete_file')
  3707 00009E27 0F8378FAFFFF        <1> 	jnc	loc_print_deleted_message
  3708                              <1> 
  3709                              <1> 	;cmp	al, 05h
  3710 00009E2D 3C0B                <1> 	cmp	al, ERR_PERM_DENIED  ; 29/12/2017 (5 -> 11)
  3711 00009E2F 0F8484FAFFFF        <1> 	je	loc_permission_denied
  3712 00009E35 F9                  <1> 	stc
  3713 00009E36 E974FAFFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3714                              <1> 
  3715                              <1> loc_delfile_y_n_escape:
  3716 00009E3B B04E                <1> 	mov	al, 'N' ; 'no'
  3717 00009E3D EBC2                <1> 	jmp	short loc_do_not_delete_file
  3718                              <1> 
  3719                              <1> set_file_attributes:
  3720                              <1> 	; 06/03/2016
  3721                              <1> 	; 04/03/2016 (TRDOS 386 = TRDOS v2.0)
  3722                              <1> 	; 10/07/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_attrib')
  3723                              <1> 	; 23/05/2010 
  3724                              <1> 	; 17/12/2000 (P2000.ASM)
  3725                              <1> 
  3726                              <1> 	; esi = file or directory name
  3727 00009E3F 6631C0              <1> 	xor	ax, ax
  3728 00009E42 66A3[84450100]      <1> 	mov	[Attr_Chars], ax
  3729 00009E48 A2[4C940100]        <1> 	mov	[Attributes], al
  3730                              <1> 
  3731                              <1> get_attrib_fchar:
  3732                              <1> 	; esi = file name
  3733 00009E4D 8A06                <1> 	mov	al, [esi]
  3734 00009E4F 3C20                <1> 	cmp	al, 20h
  3735 00009E51 7623                <1> 	jna	short loc_attr_file_nofilename_retn
  3736                              <1> 
  3737                              <1> loc_scan_attrib_params:
  3738 00009E53 3C2D                <1> 	cmp	al, '-'
  3739 00009E55 0F871C010000        <1> 	ja	loc_attr_file_parse_path_name
  3740 00009E5B 7408                <1> 	je	short loc_attr_space
  3741                              <1> 
  3742 00009E5D 3C2B                <1> 	cmp	al, '+'
  3743 00009E5F 0F850CF1FFFF        <1> 	jne	loc_cmd_failed
  3744                              <1> 
  3745                              <1> loc_attr_space:
  3746 00009E65 8A6601              <1> 	mov	ah, [esi+1]
  3747 00009E68 80FC20              <1>  	cmp	ah, 20h
  3748 00009E6B 770A                <1> 	ja	short pass_attr_space
  3749 00009E6D 0F82FEF0FFFF        <1> 	jb	loc_cmd_failed
  3750 00009E73 46                  <1> 	inc	esi
  3751 00009E74 EBEF                <1> 	jmp	short loc_attr_space
  3752                              <1> 
  3753                              <1> loc_attr_file_nofilename_retn:
  3754 00009E76 C3                  <1> 	retn
  3755                              <1> 
  3756                              <1> pass_attr_space:
  3757 00009E77 80E4DF              <1> 	and	ah, 0DFh
  3758 00009E7A 80FC53              <1> 	cmp	ah, 'S'
  3759 00009E7D 0F87EEF0FFFF        <1> 	ja	loc_cmd_failed
  3760 00009E83 7204                <1> 	jb	short pass_attr_system
  3761 00009E85 B404                <1> 	mov	ah, 04h   ; System
  3762 00009E87 EB21                <1> 	jmp	short pass_attr_archive
  3763                              <1> 
  3764                              <1> pass_attr_system:
  3765 00009E89 80FC48              <1> 	cmp	ah, 'H'
  3766 00009E8C 7706                <1> 	ja	short pass_attr_hidden
  3767 00009E8E 7213                <1> 	jb	short pass_attr_read_only
  3768 00009E90 B402                <1> 	mov	ah, 02h    ; Hidden
  3769 00009E92 EB16                <1> 	jmp	short pass_attr_archive
  3770                              <1> 
  3771                              <1> pass_attr_hidden:
  3772 00009E94 80FC52              <1> 	cmp	ah, 'R'
  3773 00009E97 0F87D4F0FFFF        <1> 	ja	loc_cmd_failed
  3774 00009E9D 7204                <1> 	jb	short pass_attr_read_only ; Read only
  3775 00009E9F B401                <1> 	mov	ah, 01h
  3776 00009EA1 EB07                <1> 	jmp	short pass_attr_archive
  3777                              <1> 
  3778                              <1> pass_attr_read_only:
  3779 00009EA3 80FC41              <1> 	cmp	ah, 'A'
  3780 00009EA6 753B                <1> 	jne	short loc_chk_attr_enter
  3781 00009EA8 B420                <1> 	mov	ah, 20h    ; Archive
  3782                              <1> 
  3783                              <1> pass_attr_archive:
  3784 00009EAA 3C2D                <1> 	cmp	al, '-'
  3785 00009EAC 7508                <1> 	jne	short pass_reducing_attributes
  3786 00009EAE 0825[84450100]      <1> 	or	[Attr_Chars], ah
  3787 00009EB4 EB06                <1> 	jmp	short loc_change_attributes_inc
  3788                              <1> 
  3789                              <1> pass_reducing_attributes:
  3790 00009EB6 0825[85450100]      <1> 	or	[Attr_Chars+1], ah
  3791                              <1> 
  3792                              <1> loc_change_attributes_inc:
  3793 00009EBC 46                  <1> 	inc	esi
  3794 00009EBD 8A6601              <1> 	mov	ah, [esi+1]
  3795 00009EC0 80FC20              <1> 	cmp	ah, 20h
  3796 00009EC3 7227                <1> 	jb	short pass_change_attr
  3797 00009EC5 74F5                <1> 	je	short loc_change_attributes_inc
  3798 00009EC7 80FC2D              <1> 	cmp	ah, '-'
  3799 00009ECA 770D                <1> 	ja	short loc_chk_next_attr_char1
  3800 00009ECC 7405                <1> 	je	short loc_chk_next_attr_char0
  3801 00009ECE 80FC2B              <1> 	cmp	ah, '+'
  3802 00009ED1 7506                <1> 	jne	short loc_chk_next_attr_char1
  3803                              <1> 
  3804                              <1> loc_chk_next_attr_char0:
  3805 00009ED3 46                  <1> 	inc	esi
  3806 00009ED4 668B06              <1> 	mov	ax, [esi]
  3807 00009ED7 EB9E                <1> 	jmp	short pass_attr_space
  3808                              <1> 
  3809                              <1> loc_chk_next_attr_char1:
  3810 00009ED9 803E2D              <1> 	cmp	byte [esi], '-'
  3811 00009EDC 7799                <1> 	ja	short pass_attr_space
  3812 00009EDE E988000000          <1>         jmp     loc_attr_file_check_fname_fchar
  3813                              <1> 
  3814                              <1> loc_chk_attr_enter:
  3815 00009EE3 80FC0D              <1> 	cmp	ah, 0Dh
  3816 00009EE6 0F8585F0FFFF        <1> 	jne	loc_cmd_failed
  3817                              <1> 
  3818                              <1> pass_change_attr:
  3819 00009EEC A0[84450100]        <1> 	mov	al, [Attr_Chars]
  3820 00009EF1 F6D0                <1> 	not	al
  3821 00009EF3 2005[4C940100]      <1> 	and	[Attributes], al
  3822 00009EF9 A0[85450100]        <1> 	mov	al, [Attr_Chars+1]
  3823 00009EFE 0805[4C940100]      <1> 	or	[Attributes], al
  3824                              <1> 
  3825                              <1> loc_show_attributes:
  3826 00009F04 BE[FF4C0100]        <1> 	mov	esi, nextline
  3827 00009F09 E847D6FFFF          <1> 	call	print_msg
  3828                              <1> 
  3829                              <1> loc_show_attributes_no_nextline:
  3830 00009F0E C705[84450100]4E4F- <1> 	mov	dword [Attr_Chars], 'NORM'
  3830 00009F16 524D                <1>
  3831 00009F18 66C705[88450100]41- <1> 	mov	word [Attr_Chars+4], 'AL'
  3831 00009F20 4C                  <1>
  3832 00009F21 BE[84450100]        <1> 	mov	esi, Attr_Chars
  3833 00009F26 A0[4C940100]        <1> 	mov	al, [Attributes]
  3834 00009F2B A804                <1> 	test	al, 04h
  3835 00009F2D 7406                <1> 	jz	short pass_put_attr_s
  3836 00009F2F 66C7065300          <1> 	mov	word [esi], 0053h     ; S
  3837 00009F34 46                  <1> 	inc	esi
  3838                              <1> 
  3839                              <1> pass_put_attr_s:
  3840 00009F35 A802                <1> 	test	al, 02h
  3841 00009F37 7406                <1> 	jz	short pass_put_attr_h
  3842 00009F39 66C7064800          <1> 	mov	word [esi], 0048h     ; H
  3843 00009F3E 46                  <1> 	inc	esi
  3844                              <1> 
  3845                              <1> pass_put_attr_h:
  3846 00009F3F A801                <1> 	test	al, 01h
  3847 00009F41 7406                <1> 	jz	short pass_put_attr_r
  3848 00009F43 66C7065200          <1> 	mov	word [esi], 0052h     ; R
  3849 00009F48 46                  <1> 	inc	esi
  3850                              <1> 
  3851                              <1> pass_put_attr_r:
  3852 00009F49 3C20                <1> 	cmp	al, 20h
  3853 00009F4B 7205                <1> 	jb	short pass_put_attr_a
  3854 00009F4D 66C7064100          <1> 	mov	word [esi], 0041h     ; A
  3855                              <1> 
  3856                              <1> pass_put_attr_a:
  3857 00009F52 BE[77450100]        <1> 	mov	esi, Str_Attributes
  3858 00009F57 E8F9D5FFFF          <1> 	call	print_msg
  3859 00009F5C BE[FF4C0100]        <1> 	mov	esi, nextline
  3860 00009F61 E8EFD5FFFF          <1> 	call	print_msg
  3861 00009F66 E944F9FFFF          <1> 	jmp	loc_file_rw_restore_retn 
  3862                              <1> 
  3863                              <1> loc_attr_file_check_fname_fchar:
  3864 00009F6B 46                  <1> 	inc	esi
  3865 00009F6C 803E20              <1> 	cmp	byte [esi], 20h
  3866 00009F6F 74FA                <1> 	je	short loc_attr_file_check_fname_fchar
  3867 00009F71 0F8275FFFFFF        <1>         jb      pass_change_attr
  3868                              <1> 		   
  3869                              <1> loc_attr_file_parse_path_name:
  3870 00009F77 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  3871 00009F7C E8D1160000          <1> 	call	parse_path_name
  3872 00009F81 0F82EAEFFFFF        <1> 	jc	loc_cmd_failed
  3873                              <1> 
  3874                              <1> loc_attr_file_check_filename_exists:
  3875 00009F87 BE[78930100]        <1> 	mov	esi, FindFile_Name
  3876 00009F8C 803E20              <1> 	cmp	byte [esi], 20h
  3877 00009F8F 0F86DCEFFFFF        <1> 	jna	loc_cmd_failed
  3878 00009F95 8935[F4930100]      <1> 	mov	[DelFile_FNPointer], esi 
  3879                              <1> 
  3880                              <1> loc_attr_file_drv:
  3881 00009F9B 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  3882 00009FA1 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  3883                              <1> 
  3884 00009FA7 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  3885 00009FAD 38F2                <1> 	cmp	dl, dh
  3886 00009FAF 740B                <1> 	je	short loc_attr_file_change_directory
  3887                              <1> 
  3888 00009FB1 E828E1FFFF          <1> 	call	change_current_drive
  3889 00009FB6 0F82F3F8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3890                              <1> 
  3891                              <1> loc_attr_file_change_directory:
  3892 00009FBC 803D[37930100]20    <1>         cmp     byte [FindFile_Directory], 20h
  3893 00009FC3 7618                <1> 	jna	short loc_attr_file_find
  3894                              <1> 
  3895 00009FC5 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  3896                              <1> 	
  3897 00009FCB BE[37930100]        <1> 	mov	esi, FindFile_Directory
  3898 00009FD0 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3899 00009FD2 E865100000          <1> 	call	change_current_directory
  3900 00009FD7 0F82D2F8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3901                              <1> 
  3902                              <1> ;loc_attr_file_change_prompt_dir_string:
  3903                              <1> 	;call	change_prompt_dir_string
  3904                              <1> 
  3905                              <1> loc_attr_file_find:
  3906                              <1> 	;mov	esi, FindFile_Name
  3907 00009FDD 8B35[F4930100]      <1> 	mov	esi, [DelFile_FNPointer]
  3908 00009FE3 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  3909 00009FE7 E895F4FFFF          <1> 	call	find_first_file
  3910 00009FEC 0F82BDF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3911                              <1> 
  3912                              <1> loc_attr_file_ambgfn_check:
  3913 00009FF2 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3914                              <1> 	;	(Note: It was BX in TRDOS v1)
  3915                              <1> 	;jz	short loc_attr_file_found
  3916 00009FF5 0F85B8FDFFFF        <1>         jnz     loc_file_not_found ; 06/03/2016 
  3917                              <1> 
  3918                              <1> 	;mov	eax, 2 ; File not found sign
  3919                              <1> 	;stc
  3920                              <1> 	;jmp	loc_file_rw_cmd_failed   
  3921                              <1> 
  3922                              <1> loc_attr_file_found:
  3923                              <1> 	; EDI = Directory buffer entry offset/address
  3924                              <1> 	; BL = File (or Directory) Attributes 
  3925                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  3926                              <1> 	; mov	bl, [EDI+0Bh]
  3927                              <1> 	
  3928 00009FFB 66833D[84450100]00  <1> 	cmp	word [Attr_Chars], 0
  3929 0000A003 770B                <1> 	ja	short loc_attr_file_change_attributes
  3930 0000A005 881D[4C940100]      <1> 	mov	[Attributes], bl
  3931 0000A00B E9F4FEFFFF          <1> 	jmp	loc_show_attributes
  3932                              <1> 
  3933                              <1> loc_attr_file_change_attributes:
  3934 0000A010 A0[84450100]        <1> 	mov	al, [Attr_Chars]
  3935 0000A015 F6D0                <1> 	not	al
  3936 0000A017 20C3                <1> 	and	bl, al
  3937 0000A019 A0[85450100]        <1> 	mov	al, [Attr_Chars+1]
  3938 0000A01E 08C3                <1> 	or	bl, al
  3939                              <1> 
  3940 0000A020 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
  3941 0000A026 741D                <1> 	je	short loc_attr_file_fs_check
  3942                              <1> 
  3943 0000A028 881D[4C940100]      <1> 	mov	[Attributes], bl
  3944 0000A02E 885F0B              <1> 	mov	[edi+0Bh], bl    ; Attributes (New!)
  3945                              <1> 
  3946                              <1> 	; 04/03/2016
  3947                              <1> 	; TRDOS v1 has a bug here! it does not set
  3948                              <1> 	; 'DirBuff_ValidData' to 2; as result of this bug,
  3949                              <1> 	; 'save_directory_buffer' would not save the new attributes ! 
  3950                              <1> 	
  3951 0000A031 C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  3952                              <1> 
  3953 0000A038 E8791A0000          <1> 	call 	save_directory_buffer
  3954 0000A03D 0F826CF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3955                              <1> 
  3956 0000A043 EB33                <1> 	jmp	short loc_print_attr_changed_message
  3957                              <1> 
  3958                              <1> loc_attr_file_fs_check:
  3959 0000A045 29C0                <1> 	sub	eax, eax
  3960 0000A047 8A25[BA910100]      <1>         mov     ah, [DirBuff_DRV]
  3961 0000A04D BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3962 0000A052 01C6                <1>         add     esi, eax
  3963 0000A054 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
  3964 0000A058 7309                <1> 	jnc	short loc_attr_file_change_fs_file_attributes
  3965                              <1> 	; 29/12/2017 (0Dh -> 29)	
  3966 0000A05A 66B81D00            <1> 	mov	ax, 29 ; Invalid Data
  3967 0000A05E E94CF8FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  3968                              <1> 
  3969                              <1> loc_attr_file_change_fs_file_attributes:
  3970                              <1> 	; BL = New MS-DOS File Attributes
  3971 0000A063 88D8                <1> 	mov	al, bl ; File/Directory Attributes
  3972 0000A065 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
  3973 0000A067 E873050000          <1> 	call	change_fs_file_attributes
  3974 0000A06C 0F823DF8FFFF        <1> 	jc	loc_file_rw_cmd_failed
  3975                              <1> 
  3976 0000A072 881D[4C940100]      <1> 	mov	[Attributes], bl 
  3977                              <1> 
  3978                              <1> loc_print_attr_changed_message:
  3979 0000A078 BE[72450100]        <1> 	mov	esi, Msg_New
  3980 0000A07D E8D3D4FFFF          <1> 	call	print_msg
  3981 0000A082 E987FEFFFF          <1> 	jmp	loc_show_attributes_no_nextline
  3982                              <1> 
  3983                              <1> rename_file:
  3984                              <1> 	; 13/11/2017
  3985                              <1> 	; 06/11/2016
  3986                              <1> 	; 05/11/2016
  3987                              <1> 	; 16/10/2016
  3988                              <1> 	; 08/03/2016
  3989                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  3990                              <1> 	; 20/11/2010 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_rename')
  3991                              <1> 	; 16/11/2010 
  3992                              <1> 
  3993                              <1> get_rename_source_fchar:
  3994                              <1> 	; esi = file name
  3995 0000A087 803E20              <1> 	cmp	byte [esi], 20h
  3996 0000A08A 7614                <1>         jna	short loc_rename_nofilename_retn
  3997                              <1> 
  3998 0000A08C 8935[74940100]      <1> 	mov	[SourceFilePath], esi
  3999                              <1> 
  4000                              <1> rename_scan_source_file:
  4001 0000A092 46                  <1> 	inc	esi
  4002 0000A093 803E20              <1> 	cmp	byte [esi], 20h
  4003 0000A096 7409                <1> 	je	short rename_scan_destination_file_1
  4004                              <1> 	;jb	short loc_rename_nofilename_retn
  4005 0000A098 0F82D3EEFFFF        <1> 	jb	loc_cmd_failed
  4006 0000A09E EBF2                <1> 	jmp	short rename_scan_source_file
  4007                              <1> 
  4008                              <1> loc_rename_nofilename_retn: ; 08/03/2016
  4009 0000A0A0 C3                  <1> 	retn
  4010                              <1> 
  4011                              <1> rename_scan_destination_file_1:
  4012 0000A0A1 C60600              <1> 	mov	byte [esi], 0
  4013                              <1> 
  4014                              <1> rename_scan_destination_file_2:
  4015 0000A0A4 46                  <1> 	inc	esi  
  4016 0000A0A5 803E20              <1> 	cmp	byte [esi], 20h
  4017 0000A0A8 74FA                <1> 	je	short rename_scan_destination_file_2
  4018                              <1> 	;jb	short loc_rename_nofilename_retn
  4019 0000A0AA 0F82C1EEFFFF        <1> 	jb	loc_cmd_failed
  4020                              <1> 
  4021 0000A0B0 8935[78940100]      <1> 	mov	[DestinationFilePath], esi
  4022                              <1> 
  4023                              <1> rename_scan_destination_file_3:
  4024 0000A0B6 46                  <1> 	inc	esi  
  4025 0000A0B7 803E20              <1> 	cmp	byte [esi], 20h
  4026 0000A0BA 77FA                <1> 	ja	short rename_scan_destination_file_3
  4027                              <1> 
  4028 0000A0BC C60600              <1> 	mov	byte [esi], 0
  4029                              <1> 
  4030                              <1> loc_rename_save_current_drive:
  4031 0000A0BF 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  4032 0000A0C5 8835[F2910100]      <1> 	mov	byte [RUN_CDRV], dh
  4033                              <1> 
  4034                              <1> loc_rename_sf_parse_path_name:
  4035 0000A0CB 8B35[74940100]      <1> 	mov	esi, [SourceFilePath] 
  4036 0000A0D1 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  4037 0000A0D6 E877150000          <1> 	call	parse_path_name
  4038 0000A0DB 0F8290EEFFFF        <1> 	jc	loc_cmd_failed
  4039                              <1> 
  4040                              <1> loc_rename_sf_check_filename_exists:
  4041 0000A0E1 BE[78930100]        <1> 	mov	esi, FindFile_Name
  4042 0000A0E6 803E20              <1> 	cmp	byte [esi], 20h
  4043 0000A0E9 0F8682EEFFFF        <1> 	jna	loc_cmd_failed
  4044                              <1> 
  4045                              <1> 	;mov	[DelFile_FNPointer], esi 
  4046                              <1> 
  4047                              <1> loc_rename_sf_drv:
  4048                              <1> 	;mov	dh, [Current_Drv]
  4049                              <1> 	;mov	[RUN_CDRV], dh
  4050                              <1> 
  4051 0000A0EF 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  4052 0000A0F5 38F2                <1> 	cmp	dl, dh ; dh = [Current_Drv]
  4053 0000A0F7 740B                <1> 	je	short rename_sf_change_directory
  4054                              <1> 
  4055 0000A0F9 E8E0DFFFFF          <1> 	call	change_current_drive
  4056 0000A0FE 0F82ABF7FFFF        <1> 	jc	loc_file_rw_cmd_failed
  4057                              <1> 
  4058                              <1> rename_sf_change_directory:
  4059 0000A104 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  4060 0000A10B 7618                <1> 	jna	short rename_sf_find
  4061                              <1> 
  4062 0000A10D FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  4063 0000A113 BE[37930100]        <1> 	mov	esi, FindFile_Directory
  4064 0000A118 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  4065 0000A11A E81D0F0000          <1> 	call	change_current_directory
  4066 0000A11F 0F828AF7FFFF        <1>  	jc	loc_file_rw_cmd_failed
  4067                              <1> 
  4068                              <1> ;rename_sf_change_prompt_dir_string:
  4069                              <1> 	;call	change_prompt_dir_string
  4070                              <1> 
  4071                              <1> rename_sf_find:
  4072                              <1> 	;mov	esi, [DelFile_FNPointer]
  4073 0000A125 BE[78930100]        <1> 	mov	esi, FindFile_Name
  4074                              <1> 
  4075 0000A12A 66B80008            <1> 	mov	ax, 0800h ; Except volume labels
  4076 0000A12E E84EF3FFFF          <1> 	call	find_first_file
  4077 0000A133 0F8276F7FFFF        <1> 	jc	loc_file_rw_cmd_failed
  4078                              <1> 
  4079                              <1> loc_rename_sf_ambgfn_check:
  4080 0000A139 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  4081                              <1> 	;	(Note: It was BX in TRDOS v1)
  4082                              <1> 	;jz	short loc_rename_sf_found
  4083 0000A13C 0F8571FCFFFF        <1> 	jnz	loc_file_not_found
  4084                              <1> 
  4085                              <1> 	;mov	eax, 2 ; File not found sign
  4086                              <1> 	;stc
  4087                              <1> 	;jmp	loc_file_rw_cmd_failed   
  4088                              <1> 
  4089                              <1> loc_rename_sf_found:
  4090                              <1> 	; EDI = Directory buffer entry offset/address
  4091                              <1> 	; BL = File (or Directory) Attributes 
  4092                              <1> 	;	(Note: It was 'CL' in TRDOS v1)
  4093                              <1> 	; mov	bl, [EDI+0Bh]
  4094                              <1> 
  4095 0000A142 F6C307              <1> 	test	bl, 07h ; Attributes, S-H-R
  4096 0000A145 0F856EF7FFFF        <1> 	jnz	loc_permission_denied
  4097                              <1> 	
  4098 0000A14B BE[36930100]        <1>         mov     esi, FindFile_Drv
  4099 0000A150 BF[7C940100]        <1>         mov     edi, SourceFile_Drv
  4100 0000A155 B920000000          <1> 	mov	ecx, 32
  4101 0000A15A F3A5                <1> 	rep	movsd
  4102                              <1> 
  4103                              <1> loc_rename_df_parse_path_name:
  4104 0000A15C 8B35[78940100]      <1> 	mov	esi, [DestinationFilePath]
  4105 0000A162 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  4106 0000A167 E8E6140000          <1> 	call	parse_path_name
  4107 0000A16C 7219                <1> 	jc	short loc_rename_df_cmd_failed
  4108                              <1> 
  4109                              <1> 	;mov	dh, [RUN_CDRV]
  4110 0000A16E 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  4111                              <1> 
  4112                              <1> 	; 'rename' command is valid only for same dos drive and same dir!
  4113                              <1> 	; ('move' command must be used if source file and destination file
  4114                              <1> 	; directories are not same!) 
  4115 0000A174 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  4116 0000A17A 38F2                <1> 	cmp	dl, dh ; are source and destination drives different ?!
  4117 0000A17C 7509                <1> 	jne	short loc_rename_df_cmd_failed ; yes! 
  4118                              <1> 
  4119                              <1> rename_df_check_dirname_exists:
  4120 0000A17E 803D[37930100]00    <1> 	cmp	byte [FindFile_Directory], 0
  4121 0000A185 760B                <1> 	jna	short rename_df_check_filename_exists
  4122                              <1> 
  4123                              <1> 	; different source file and destination file directories !
  4124                              <1> loc_rename_df_cmd_failed:
  4125 0000A187 B801000000          <1> 	mov	eax, 1 ; TRDOS 'Bad command or file name' error
  4126 0000A18C F9                  <1> 	stc
  4127 0000A18D E91DF7FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4128                              <1> 	  
  4129                              <1> rename_df_check_filename_exists:
  4130 0000A192 BE[78930100]        <1> 	mov	esi, FindFile_Name
  4131 0000A197 E8A3F6FFFF          <1> 	call	check_filename
  4132 0000A19C 0F82BFF7FFFF        <1> 	jc	loc_mkdir_invalid_dir_name_chars
  4133                              <1> 
  4134                              <1> 	;mov	[DelFile_FNPointer], esi 
  4135                              <1> 	;cmp	byte [esi], 20h
  4136                              <1> 	;ja	short loc_rename_df_find
  4137                              <1> 
  4138                              <1> 	;mov	dh, [Current_Drv] ; dh has not been changed
  4139                              <1> 
  4140                              <1> rename_df_drv_check_writable:
  4141 0000A1A2 0FB6F6              <1> 	movzx	esi, dh
  4142                              <1> 	;movzx	esi, byte [Current_Drv]
  4143 0000A1A5 81C600010900        <1> 	add	esi, Logical_DOSDisks
  4144                              <1> 
  4145 0000A1AB 88F2                <1> 	mov	dl, dh ; dl = [Current_Drv]
  4146 0000A1AD 8A7601              <1> 	mov	dh, [esi+LD_DiskType]
  4147                              <1> 
  4148 0000A1B0 80FE01              <1> 	cmp	dh, 1 ; 0 = Invalid
  4149 0000A1B3 7310                <1> 	jnb	short rename_df_compare_sf_df_name
  4150                              <1> 
  4151                              <1> 	; 16/10/2016 (13h -> 30)
  4152 0000A1B5 B81E000000          <1> 	mov	eax, 30 ; 'Disk write-protected' error
  4153 0000A1BA 8B1D[78940100]      <1> 	mov	ebx, [DestinationFilePath] 
  4154 0000A1C0 E9EAF6FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4155                              <1> 
  4156                              <1> rename_df_compare_sf_df_name:
  4157 0000A1C5 BE[78930100]        <1> 	mov	esi, FindFile_Name
  4158 0000A1CA BF[BE940100]        <1> 	mov	edi, SourceFile_Name
  4159 0000A1CF B90C000000          <1> 	mov	ecx, 12
  4160                              <1> rename_df_compare_sf_df_name_next: 
  4161 0000A1D4 AC                  <1> 	lodsb
  4162 0000A1D5 AE                  <1> 	scasb
  4163 0000A1D6 7506                <1> 	jne	short loc_rename_df_find
  4164 0000A1D8 08C0                <1> 	or	al, al
  4165 0000A1DA 74AB                <1> 	jz	short loc_rename_df_cmd_failed
  4166 0000A1DC E2F6                <1> 	loop	rename_df_compare_sf_df_name_next 
  4167                              <1> 
  4168                              <1> loc_rename_df_find:
  4169                              <1> 	;mov	esi, [DelFile_FNPointer]
  4170 0000A1DE BE[78930100]        <1> 	mov	esi, FindFile_Name
  4171                              <1> 
  4172 0000A1E3 6631C0              <1> 	xor	ax, ax ; Any
  4173 0000A1E6 E896F2FFFF          <1> 	call	find_first_file
  4174                              <1> 	;jnc	short loc_rename_df_found
  4175                              <1> 	; 29/12/2017
  4176 0000A1EB 0F83C8F6FFFF        <1> 	jnc	loc_permission_denied
  4177                              <1> 
  4178                              <1> loc_rename_df_check_error_code:
  4179                              <1> 	;cmp	eax, 2
  4180 0000A1F1 3C02                <1> 	cmp	al, 2 ; Not found error
  4181 0000A1F3 7406                <1> 	je	short rename_df_move_find_struct_to_dest
  4182 0000A1F5 F9                  <1> 	stc
  4183 0000A1F6 E9B4F6FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4184                              <1> 
  4185                              <1> ;loc_rename_df_found:
  4186                              <1> 	; 05/11/2016
  4187                              <1> 	; Permission denied error
  4188                              <1> 	;mov	eax, ERR_PERM_DENIED ; 29/12/2017
  4189                              <1> 	;stc
  4190                              <1> 	;jmp	loc_permission_denied  ; 06/11/2016
  4191                              <1> 
  4192                              <1> rename_df_move_find_struct_to_dest:
  4193 0000A1FB BE[36930100]        <1>         mov     esi, FindFile_Drv
  4194 0000A200 BF[FC940100]        <1>         mov     edi, DestinationFile_Drv
  4195 0000A205 B920000000          <1> 	mov	ecx, 32
  4196 0000A20A F3A5                <1> 	rep	movsd
  4197                              <1> 
  4198                              <1> loc_rename_df_process_q_sf:
  4199                              <1> 	;mov	ecx, 12
  4200 0000A20C B10C                <1> 	mov	cl, 12
  4201 0000A20E BE[BE940100]        <1>  	mov	esi, SourceFile_Name
  4202 0000A213 BF[B3450100]        <1> 	mov	edi, Rename_OldName
  4203                              <1> rename_df_process_q_nml_1_sf:
  4204 0000A218 AC                  <1> 	lodsb
  4205 0000A219 3C20                <1>         cmp	al, 20h
  4206 0000A21B 7603                <1>         jna	short rename_df_process_q_nml_2_sf
  4207 0000A21D AA                  <1> 	stosb
  4208 0000A21E E2F8                <1> 	loop	rename_df_process_q_nml_1_sf
  4209                              <1> 
  4210                              <1> rename_df_process_q_nml_2_sf:
  4211 0000A220 C60700              <1> 	mov	byte [edi], 0
  4212                              <1> 
  4213                              <1> loc_rename_df_process_q_df:
  4214                              <1> 	;mov	ecx, 12
  4215 0000A223 B10C                <1> 	mov	cl, 12
  4216 0000A225 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
  4217 0000A22A BF[C4450100]        <1> 	mov	edi, Rename_NewName
  4218                              <1> rename_df_process_q_nml_1_df:
  4219 0000A22F AC                  <1> 	lodsb
  4220 0000A230 3C20                <1> 	cmp	al, 20h
  4221 0000A232 7603                <1> 	jna	short loc_rename_df_process_q_nml_2_df
  4222 0000A234 AA                  <1> 	stosb
  4223 0000A235 E2F8                <1> 	loop	rename_df_process_q_nml_1_df
  4224                              <1> 
  4225                              <1> loc_rename_df_process_q_nml_2_df:
  4226 0000A237 C60700              <1> 	mov	byte [edi], 0
  4227                              <1> 
  4228                              <1> loc_rename_confirmation_question:
  4229 0000A23A BE[8B450100]        <1> 	mov	esi, Msg_DoYouWantRename
  4230 0000A23F E811D3FFFF          <1> 	call	print_msg
  4231                              <1> 
  4232 0000A244 A0[D9940100]        <1> 	mov	al, [SourceFile_DirEntry+11] ; Attributes
  4233 0000A249 2410                <1> 	and	al, 10h
  4234 0000A24B 750C                <1> 	jnz	short rename_confirmation_question_dir
  4235                              <1> 
  4236                              <1> rename_confirmation_question_file:
  4237 0000A24D BE[A2450100]        <1> 	mov	esi, Rename_File
  4238 0000A252 E8FED2FFFF          <1> 	call	print_msg 
  4239 0000A257 EB0A                <1> 	jmp	short rename_confirmation_question_as 
  4240                              <1> 
  4241                              <1> rename_confirmation_question_dir:
  4242 0000A259 BE[A8450100]        <1> 	mov	esi, Rename_Directory
  4243 0000A25E E8F2D2FFFF          <1> 	call	print_msg
  4244                              <1> 
  4245                              <1> rename_confirmation_question_as:
  4246 0000A263 BE[B3450100]        <1> 	mov	esi, Rename_OldName
  4247 0000A268 E8E8D2FFFF          <1> 	call	print_msg
  4248 0000A26D BE[C0450100]        <1> 	mov	esi, Msg_File_rename_as
  4249 0000A272 E8DED2FFFF          <1> 	call	print_msg
  4250 0000A277 BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  4251 0000A27C E8D4D2FFFF          <1> 	call	print_msg
  4252                              <1> 
  4253                              <1> loc_rename_ask_again:
  4254 0000A281 30E4                <1> 	xor	ah, ah
  4255 0000A283 E85D6CFFFF          <1> 	call	int16h
  4256 0000A288 3C1B                <1> 	cmp	al, 1Bh
  4257 0000A28A 740F                <1> 	je	short loc_do_not_rename_file
  4258 0000A28C 24DF                <1> 	and	al, 0DFh
  4259 0000A28E A2[F1440100]        <1> 	mov	[Y_N_nextline], al
  4260 0000A293 3C59                <1> 	cmp	al, 'Y'
  4261 0000A295 7404                <1> 	je	short loc_yes_rename_file
  4262 0000A297 3C4E                <1> 	cmp	al, 'N'
  4263 0000A299 75E6                <1> 	jne	short loc_rename_ask_again
  4264                              <1> 
  4265                              <1> loc_do_not_rename_file:
  4266                              <1> loc_yes_rename_file:
  4267 0000A29B E848F7FFFF          <1> 	call	y_n_answer ; 29/12/2017
  4268                              <1> 	;cmp	al, 'Y' ; 'yes'
  4269                              <1> 	;cmc
  4270                              <1>         ;jnc	loc_file_rw_restore_retn
  4271 0000A2A0 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4272 0000A2A2 0F8407F6FFFF        <1>         je	loc_file_rw_restore_retn  
  4273                              <1> 
  4274 0000A2A8 BE[C4450100]        <1> 	mov	esi, Rename_NewName
  4275 0000A2AD 668B0D[F6940100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
  4276 0000A2B4 66A1[E2940100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
  4277 0000A2BA C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  4278 0000A2BD 66A1[E8940100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
  4279                              <1> 
  4280 0000A2C3 0FB61D[CB940100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
  4281 0000A2CA E8CB1B0000          <1>    	call	rename_directory_entry
  4282 0000A2CF E9FBF6FFFF          <1> 	jmp	loc_rename_file_ok	
  4283                              <1> ;loc_rename_file_ok:
  4284                              <1> ;	jc	loc_run_cmd_failed
  4285                              <1> ;	mov	esi, Msg_OK
  4286                              <1> ;	call	proc_printmsg
  4287                              <1> ;	jmp	loc_file_rw_restore_retn
  4288                              <1> 
  4289                              <1> move_file:
  4290                              <1> 	; 11/03/2016
  4291                              <1> 	; 09/03/2016
  4292                              <1> 	; 08/03/2016 (TRDOS 386 = TRDOS v2.0)
  4293                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_move')
  4294                              <1> 	; 23/04/2011
  4295                              <1> 
  4296                              <1> get_move_source_fchar:
  4297                              <1> 	; esi = file name
  4298 0000A2D4 803E20              <1> 	cmp	byte [esi], 20h
  4299 0000A2D7 7614                <1>         jna	short loc_move_nofilename_retn
  4300                              <1> 
  4301 0000A2D9 8935[74940100]      <1> 	mov	[SourceFilePath], esi
  4302                              <1> 
  4303                              <1> move_scan_source_file:
  4304 0000A2DF 46                  <1> 	inc	esi
  4305 0000A2E0 803E20              <1> 	cmp	byte [esi], 20h
  4306 0000A2E3 7409                <1>         je      short move_scan_destination_1
  4307                              <1> 	;jb	short loc_move_nofilename_retn
  4308 0000A2E5 0F8286ECFFFF        <1> 	jb	loc_cmd_failed
  4309 0000A2EB EBF2                <1> 	jmp	short move_scan_source_file
  4310                              <1> 
  4311                              <1> loc_move_nofilename_retn:
  4312 0000A2ED C3                  <1> 	retn
  4313                              <1> 
  4314                              <1> move_scan_destination_1:
  4315 0000A2EE C60600              <1> 	mov	byte [esi], 0
  4316                              <1> 
  4317                              <1> move_scan_destination_2:
  4318 0000A2F1 46                  <1> 	inc	esi  
  4319 0000A2F2 803E20              <1> 	cmp	byte [esi], 20h
  4320 0000A2F5 74FA                <1> 	je	short move_scan_destination_2
  4321                              <1> 	;jb	short loc_move_nofilename_retn
  4322 0000A2F7 0F8274ECFFFF        <1> 	jb	loc_cmd_failed
  4323                              <1> 
  4324 0000A2FD 8935[78940100]      <1> 	mov	[DestinationFilePath], esi
  4325                              <1> 
  4326                              <1> move_scan_destination_3:
  4327 0000A303 46                  <1> 	inc	esi  
  4328 0000A304 803E20              <1> 	cmp	byte [esi], 20h
  4329 0000A307 77FA                <1> 	ja	short move_scan_destination_3
  4330 0000A309 C60600              <1> 	mov	byte [esi], 0
  4331                              <1> 
  4332                              <1> loc_move_scan_destination_OK:
  4333 0000A30C 8B35[74940100]      <1> 	mov	esi, [SourceFilePath]
  4334 0000A312 8B3D[78940100]      <1> 	mov	edi, [DestinationFilePath]
  4335                              <1> 
  4336 0000A318 B001                <1> 	mov	al, 1  ; move procedure Phase 1
  4337 0000A31A E8F71B0000          <1> 	call	move_source_file_to_destination_file
  4338 0000A31F 7328                <1> 	jnc	short move_source_file_to_destination_question
  4339                              <1> 
  4340                              <1> loc_move_cmd_failed_1:
  4341 0000A321 08C0                <1> 	or	al, al
  4342 0000A323 0F8448ECFFFF        <1> 	jz	loc_cmd_failed 
  4343 0000A329 3C11                <1> 	cmp	al, 11h
  4344 0000A32B 740D                <1> 	je	short loc_msg_not_same_device   
  4345                              <1> 	;cmp	al, 05h
  4346                              <1> 	;cmp	al, ERR_PERM_DENIED ; 29/12/2017
  4347                              <1> 	;jne	loc_run_cmd_failed
  4348                              <1> 	;jmp	loc_permission_denied
  4349 0000A32D 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
  4350 0000A32F 0F8484F5FFFF        <1> 	je	loc_permission_denied
  4351 0000A335 E962ECFFFF          <1> 	jmp	loc_run_cmd_failed
  4352                              <1> 
  4353                              <1> 	;mov	esi, Msg_Permission_denied
  4354                              <1> 	;call	print_msg
  4355                              <1> 	;jmp	loc_file_rw_restore_retn
  4356                              <1> 
  4357                              <1> loc_msg_not_same_device:
  4358 0000A33A BE[D1450100]        <1> 	mov	esi, msg_not_same_drv 
  4359 0000A33F E811D2FFFF          <1> 	call	print_msg
  4360 0000A344 E966F5FFFF          <1> 	jmp	loc_file_rw_restore_retn
  4361                              <1> 
  4362                              <1> move_source_file_to_destination_question:
  4363 0000A349 A0[7C940100]        <1>         mov     al, [SourceFile_Drv]
  4364 0000A34E 0441                <1> 	add	al, 'A'
  4365 0000A350 A2[33460100]        <1> 	mov	[msg_source_file_drv], al
  4366 0000A355 A0[FC940100]        <1>         mov     al, [DestinationFile_Drv]
  4367 0000A35A 0441                <1> 	add	al, 'A'
  4368 0000A35C A2[52460100]        <1> 	mov	[msg_destination_file_drv], al
  4369                              <1> 
  4370 0000A361 57                  <1> 	push	edi ; *
  4371                              <1> 
  4372 0000A362 BE[17460100]        <1> 	mov	esi, msg_source_file
  4373 0000A367 E8E9D1FFFF          <1> 	call	print_msg
  4374 0000A36C BE[7D940100]        <1> 	mov	esi, SourceFile_Directory
  4375 0000A371 803E20              <1> 	cmp	byte [esi], 20h
  4376 0000A374 7605                <1> 	jna	short msftdfq_sfn
  4377 0000A376 E8DAD1FFFF          <1> 	call	print_msg
  4378                              <1> msftdfq_sfn:
  4379 0000A37B BE[BE940100]        <1> 	mov	esi, SourceFile_Name
  4380 0000A380 E8D0D1FFFF          <1> 	call	print_msg
  4381 0000A385 BE[36460100]        <1> 	mov	esi, msg_destination_file
  4382 0000A38A E8C6D1FFFF          <1> 	call	print_msg
  4383 0000A38F BE[FD940100]        <1> 	mov	esi, DestinationFile_Directory
  4384 0000A394 803E20              <1> 	cmp	byte [esi], 20h
  4385 0000A397 7605                <1> 	jna	short msftdfq_dfn
  4386 0000A399 E8B7D1FFFF          <1> 	call	print_msg
  4387                              <1> msftdfq_dfn:
  4388 0000A39E BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
  4389 0000A3A3 E8ADD1FFFF          <1> 	call	print_msg
  4390 0000A3A8 BE[55460100]        <1> 	mov	esi, msg_copy_nextline
  4391 0000A3AD E8A3D1FFFF          <1> 	call	print_msg
  4392 0000A3B2 BE[55460100]        <1> 	mov	esi, msg_copy_nextline
  4393 0000A3B7 E899D1FFFF          <1> 	call	print_msg
  4394                              <1> 
  4395                              <1> loc_move_ask_for_new_file_yes_no:
  4396 0000A3BC BE[E3450100]        <1> 	mov	esi, Msg_DoYouWantMoveFile
  4397 0000A3C1 E88FD1FFFF          <1> 	call	print_msg
  4398 0000A3C6 BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  4399 0000A3CB E885D1FFFF          <1> 	call	print_msg
  4400                              <1> loc_move_ask_for_new_file_again:
  4401 0000A3D0 30E4                <1> 	xor	ah, ah
  4402 0000A3D2 E80E6BFFFF          <1> 	call	int16h
  4403 0000A3D7 3C1B                <1> 	cmp	al, 1Bh
  4404                              <1> 	;je	short loc_do_not_move_file
  4405 0000A3D9 7441                <1> 	je	short loc_move_y_n_escape
  4406 0000A3DB 24DF                <1> 	and	al, 0DFh
  4407 0000A3DD A2[F1440100]        <1>         mov     [Y_N_nextline], al
  4408 0000A3E2 3C59                <1> 	cmp	al, 'Y'
  4409 0000A3E4 7404                <1> 	je	short loc_yes_move_file
  4410 0000A3E6 3C4E                <1> 	cmp	al, 'N'
  4411 0000A3E8 75E6                <1> 	jne	short loc_move_ask_for_new_file_again
  4412                              <1> 
  4413                              <1> loc_do_not_move_file:
  4414                              <1> loc_yes_move_file:
  4415 0000A3EA E8F9F5FFFF          <1> 	call	y_n_answer ; 29/12/2017
  4416 0000A3EF 5F                  <1> 	pop	edi ; *
  4417                              <1> 	;cmp	al, 'Y' ; 'yes'
  4418                              <1> 	;cmc
  4419                              <1>         ;jnc	loc_file_rw_restore_retn
  4420 0000A3F0 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4421 0000A3F2 0F84B7F4FFFF        <1>         je	loc_file_rw_restore_retn
  4422                              <1> 
  4423                              <1> loc_move_yes_move_file:
  4424 0000A3F8 B002                <1> 	mov	al, 2 ; move procedure Phase 2
  4425 0000A3FA E8171B0000          <1> 	call	move_source_file_to_destination_file
  4426                              <1> 	;jc	short loc_move_cmd_failed_2
  4427 0000A3FF 0F83D0F5FFFF        <1>         jnc     move_source_file_to_destination_OK
  4428                              <1> 
  4429                              <1> ;move_source_file_to_destination_OK:
  4430                              <1> ;	mov	esi, Msg_OK
  4431                              <1> ;	call	print_msg
  4432                              <1> ;	jmp	loc_file_rw_restore_retn
  4433                              <1> 
  4434                              <1> loc_move_cmd_failed_2:
  4435 0000A405 3C27                <1> 	cmp	al, 27h
  4436 0000A407 0F858FEBFFFF        <1> 	jne	loc_run_cmd_failed
  4437                              <1> 
  4438 0000A40D BE[FC450100]        <1> 	mov	esi, msg_insufficient_disk_space
  4439 0000A412 E83ED1FFFF          <1> 	call	print_msg
  4440                              <1> 
  4441 0000A417 E993F4FFFF          <1> 	jmp	loc_file_rw_restore_retn
  4442                              <1> 
  4443                              <1> loc_move_y_n_escape:
  4444 0000A41C B04E                <1> 	mov	al, 'N' ; 'no'
  4445 0000A41E EBCA                <1> 	jmp	short loc_do_not_move_file
  4446                              <1> 
  4447                              <1> copy_file:
  4448                              <1> 	; 15/10/2016
  4449                              <1> 	; 24/03/2016
  4450                              <1> 	; 21/03/2016
  4451                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  4452                              <1> 	; 21/05/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_copy')
  4453                              <1> 	; 01/08/2010
  4454                              <1> 
  4455                              <1> get_copy_source_fchar:
  4456                              <1> 	; esi = file name
  4457 0000A420 803E20              <1> 	cmp	byte [esi], 20h
  4458 0000A423 7614                <1>         jna     short loc_copy_nofilename_retn
  4459                              <1> 
  4460 0000A425 8935[74940100]      <1> 	mov	[SourceFilePath], esi
  4461                              <1> 
  4462                              <1> copy_scan_source_file:
  4463 0000A42B 46                  <1> 	inc	esi  
  4464 0000A42C 803E20              <1> 	cmp	byte [esi], 20h
  4465 0000A42F 7409                <1> 	je	short copy_scan_destination_1
  4466                              <1> 	;jb	short loc_copy_nofilename_retn
  4467 0000A431 0F823AEBFFFF        <1> 	jb	loc_cmd_failed
  4468 0000A437 EBF2                <1> 	jmp	short copy_scan_source_file
  4469                              <1> 
  4470                              <1> loc_copy_nofilename_retn:
  4471 0000A439 C3                  <1> 	retn
  4472                              <1> 
  4473                              <1> copy_scan_destination_1:
  4474 0000A43A C60600              <1> 	mov	byte [esi], 0
  4475                              <1> 
  4476                              <1> copy_scan_destination_2:
  4477 0000A43D 46                  <1> 	inc	esi  
  4478 0000A43E 803E20              <1> 	cmp	byte [esi], 20h
  4479 0000A441 74FA                <1> 	je	short copy_scan_destination_2
  4480                              <1> 	;jb	short loc_copy_nofilename_retn
  4481 0000A443 0F8228EBFFFF        <1> 	jb	loc_cmd_failed
  4482                              <1> 
  4483 0000A449 8935[78940100]      <1> 	mov	[DestinationFilePath], esi
  4484                              <1> 
  4485                              <1> copy_scan_destination_3:
  4486 0000A44F 46                  <1> 	inc	esi  
  4487 0000A450 803E20              <1> 	cmp	byte [esi], 20h
  4488 0000A453 77FA                <1> 	ja	short copy_scan_destination_3
  4489 0000A455 C60600              <1> 	mov	byte [esi], 0
  4490                              <1> 
  4491                              <1> loc_copy_save_current_drive:
  4492 0000A458 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  4493 0000A45E 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  4494                              <1> 
  4495                              <1> copy_source_file_to_destination_phase_1:
  4496 0000A464 8B35[74940100]      <1> 	mov	esi, [SourceFilePath]
  4497 0000A46A 8B3D[78940100]      <1> 	mov	edi, [DestinationFilePath]
  4498                              <1> 
  4499 0000A470 B001                <1> 	mov	al, 1  ; copy procedure Phase 1
  4500 0000A472 E83C1D0000          <1> 	call	copy_source_file_to_destination_file
  4501 0000A477 732B                <1> 	jnc	short copy_source_file_to_destination_question
  4502                              <1> 
  4503                              <1> loc_copy_cmd_failed_1:
  4504                              <1> 	; 18/03/2016 (restore current drive and directory)
  4505 0000A479 08C0                <1> 	or	al, al
  4506 0000A47B 7507                <1> 	jnz	short loc_copy_cmd_failed_2
  4507                              <1> 
  4508 0000A47D FEC0                <1>         inc     al ; mov al, 1 ; Bad command or file name !
  4509 0000A47F E918EBFFFF          <1> 	jmp	loc_run_cmd_failed
  4510                              <1> 
  4511                              <1> loc_copy_cmd_failed_2:
  4512 0000A484 3C27                <1> 	cmp	al, 27h ; Insufficient disk space 
  4513 0000A486 740D                <1> 	je	short loc_file_write_insuff_disk_space_msg
  4514                              <1>  
  4515                              <1> 	; 29/12/2017
  4516                              <1> 	;cmp	al, 05h
  4517 0000A488 3C0B                <1> 	cmp	al, ERR_PERM_DENIED
  4518 0000A48A 0F850CEBFFFF        <1> 	jne	loc_run_cmd_failed
  4519                              <1> 	
  4520 0000A490 E924F4FFFF          <1> 	jmp	loc_permission_denied
  4521                              <1> 
  4522                              <1> loc_file_write_insuff_disk_space_msg:
  4523 0000A495 BE[FC450100]        <1> 	mov	esi, msg_insufficient_disk_space
  4524 0000A49A E8B6D0FFFF          <1> 	call	print_msg
  4525 0000A49F E90BF4FFFF          <1>         jmp     loc_file_rw_restore_retn 
  4526                              <1> 
  4527                              <1> copy_source_file_to_destination_question:
  4528 0000A4A4 57                  <1> 	push	edi ; *
  4529                              <1> 
  4530                              <1> 	; dh = source file attributes
  4531                              <1> 	; dl > 0 -> destination file found
  4532 0000A4A5 20D2                <1> 	and	dl, dl            
  4533 0000A4A7 7449                <1> 	jz	short copy_source_file_to_destination_pass_owrq
  4534                              <1> 
  4535                              <1> loc_copy_ask_for_owr_yes_no:
  4536 0000A4A9 BE[58460100]        <1> 	mov	esi, Msg_DoYouWantOverWriteFile
  4537 0000A4AE E8A2D0FFFF          <1> 	call	print_msg
  4538 0000A4B3 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
  4539 0000A4B8 E898D0FFFF          <1> 	call	print_msg
  4540 0000A4BD BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  4541 0000A4C2 E88ED0FFFF          <1> 	call	print_msg
  4542                              <1> 
  4543                              <1> loc_copy_ask_for_owr_again:
  4544 0000A4C7 30E4                <1> 	xor	ah, ah
  4545 0000A4C9 E8176AFFFF          <1> 	call	int16h
  4546 0000A4CE 3C1B                <1> 	cmp	al, 1Bh
  4547                              <1>         ;je     loc_do_not_copy_file
  4548 0000A4D0 7419                <1>         je      short loc_copy_y_n_escape
  4549 0000A4D2 24DF                <1> 	and	al, 0DFh
  4550 0000A4D4 A2[F1440100]        <1>         mov     [Y_N_nextline], al
  4551 0000A4D9 3C59                <1> 	cmp	al, 'Y'
  4552 0000A4DB 0F84B1000000        <1>         je      loc_yes_copy_file
  4553 0000A4E1 3C4E                <1> 	cmp	al, 'N'
  4554 0000A4E3 0F84A9000000        <1>         je      loc_do_not_copy_file
  4555 0000A4E9 EBDC                <1> 	jmp	short loc_copy_ask_for_owr_again
  4556                              <1> 
  4557                              <1> loc_copy_y_n_escape:
  4558 0000A4EB B04E                <1> 	mov	al, 'N' ; 'no'
  4559 0000A4ED E9A0000000          <1>         jmp     loc_do_not_copy_file
  4560                              <1> 
  4561                              <1> copy_source_file_to_destination_pass_owrq:
  4562 0000A4F2 A0[7C940100]        <1> 	mov     al, [SourceFile_Drv]
  4563 0000A4F7 0441                <1> 	add	al, 'A'
  4564 0000A4F9 A2[33460100]        <1> 	mov	[msg_source_file_drv], al
  4565 0000A4FE A0[FC940100]        <1>         mov     al, [DestinationFile_Drv]
  4566 0000A503 0441                <1> 	add	al, 'A'
  4567 0000A505 A2[52460100]        <1> 	mov	[msg_destination_file_drv], al
  4568                              <1> 
  4569 0000A50A BE[17460100]        <1> 	mov	esi, msg_source_file
  4570 0000A50F E841D0FFFF          <1> 	call	print_msg
  4571 0000A514 BE[7D940100]        <1> 	mov	esi, SourceFile_Directory
  4572 0000A519 803E20              <1> 	cmp	byte [esi], 20h
  4573 0000A51C 7605                <1> 	jna	short csftdfq_sfn
  4574 0000A51E E832D0FFFF          <1> 	call	print_msg
  4575                              <1> csftdfq_sfn:
  4576 0000A523 BE[BE940100]        <1> 	mov	esi, SourceFile_Name
  4577 0000A528 E828D0FFFF          <1> 	call	print_msg
  4578 0000A52D BE[36460100]        <1> 	mov	esi, msg_destination_file
  4579 0000A532 E81ED0FFFF          <1> 	call	print_msg
  4580 0000A537 BE[FD940100]        <1> 	mov	esi, DestinationFile_Directory
  4581 0000A53C 803E20              <1> 	cmp	byte [esi], 20h
  4582 0000A53F 7605                <1> 	jna	short csftdfq_dfn
  4583 0000A541 E80FD0FFFF          <1> 	call	print_msg
  4584                              <1> csftdfq_dfn:
  4585 0000A546 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
  4586 0000A54B E805D0FFFF          <1> 	call	print_msg
  4587 0000A550 BE[55460100]        <1> 	mov	esi, msg_copy_nextline
  4588 0000A555 E8FBCFFFFF          <1> 	call	print_msg
  4589 0000A55A BE[55460100]        <1> 	mov	esi, msg_copy_nextline
  4590 0000A55F E8F1CFFFFF          <1> 	call	print_msg
  4591                              <1> 
  4592                              <1> loc_copy_ask_for_new_file_yes_no:
  4593 0000A564 BE[77460100]        <1> 	mov	esi, Msg_DoYouWantCopyFile
  4594 0000A569 E8E7CFFFFF          <1> 	call	print_msg
  4595 0000A56E BE[E7440100]        <1> 	mov	esi, Msg_YesNo
  4596 0000A573 E8DDCFFFFF          <1> 	call	print_msg
  4597                              <1> 
  4598                              <1> loc_copy_ask_for_new_file_again:
  4599 0000A578 30E4                <1> 	xor	ah, ah
  4600 0000A57A E86669FFFF          <1> 	call	int16h
  4601 0000A57F 3C1B                <1> 	cmp	al, 1Bh
  4602 0000A581 740F                <1> 	je	short loc_do_not_copy_file
  4603 0000A583 24DF                <1> 	and	al, 0DFh
  4604 0000A585 A2[F1440100]        <1>         mov     [Y_N_nextline], al
  4605 0000A58A 3C59                <1> 	cmp	al, 'Y'
  4606 0000A58C 7404                <1> 	je	short loc_yes_copy_file
  4607 0000A58E 3C4E                <1> 	cmp	al, 'N'
  4608 0000A590 75E6                <1> 	jne	short loc_copy_ask_for_new_file_again
  4609                              <1> 
  4610                              <1> loc_do_not_copy_file:
  4611                              <1> loc_yes_copy_file:
  4612 0000A592 E851F4FFFF          <1> 	call	y_n_answer ; 29/12/2017
  4613 0000A597 5F                  <1> 	pop	edi ; *
  4614                              <1> 	;cmp	al, 'Y' ; 'yes'
  4615                              <1> 	;cmc
  4616                              <1>         ;jnc	loc_file_rw_restore_retn
  4617 0000A598 3C4E                <1> 	cmp	al, 'N' ; 'no'
  4618 0000A59A 0F840FF3FFFF        <1>         je	loc_file_rw_restore_retn
  4619                              <1> 
  4620                              <1> copy_source_file_to_destination_pass_q:
  4621 0000A5A0 B002                <1> 	mov	al, 2  ; copy procedure Phase 2
  4622 0000A5A2 E80C1C0000          <1> 	call	copy_source_file_to_destination_file
  4623                              <1> 	;jc	short loc_file_write_check_disk_space_err
  4624                              <1> 
  4625                              <1> 	; 24/03/2016
  4626                              <1> 	;push	cx
  4627 0000A5A7 51                  <1> 	push	ecx ; 29/12/2017
  4628 0000A5A8 BE[55460100]        <1> 	mov	esi, msg_copy_nextline
  4629 0000A5AD E8A3CFFFFF          <1> 	call	print_msg
  4630 0000A5B2 58                  <1> 	pop	eax ; 29/12/2017
  4631                              <1> 	;;pop	cx
  4632                              <1> 	;pop	ax
  4633                              <1> 
  4634                              <1> 	;or	cl, cl
  4635 0000A5B3 08C0                <1> 	or	al, al
  4636 0000A5B5 7419                <1> 	jz	short copy_source_file_to_destination_OK
  4637                              <1> 	
  4638                              <1> 	; 15/10/2016 (1Dh -> 18)
  4639                              <1> 	; 18/03/2016 (1Dh)
  4640                              <1> 	;cmp	cl, 18 ; write error
  4641 0000A5B7 3C12                <1> 	cmp	al, 18
  4642 0000A5B9 7506                <1> 	jne	short copy_source_file_to_destination_not_OK
  4643                              <1> 	;
  4644                              <1> 	;mov	al, cl ; error number (write fault!)
  4645 0000A5BB F9                  <1> 	stc
  4646 0000A5BC E9EEF2FFFF          <1> 	jmp	loc_file_rw_cmd_failed
  4647                              <1> 
  4648                              <1> copy_source_file_to_destination_not_OK:
  4649 0000A5C1 BE[90460100]        <1> 	mov	esi, Msg_read_file_error_before_EOF
  4650 0000A5C6 E88ACFFFFF          <1> 	call	print_msg
  4651 0000A5CB E9DFF2FFFF          <1> 	jmp	loc_file_rw_restore_retn	      
  4652                              <1>  
  4653                              <1> copy_source_file_to_destination_OK:
  4654 0000A5D0 BE[F5440100]        <1> 	mov	esi, Msg_OK
  4655 0000A5D5 E87BCFFFFF          <1> 	call	print_msg
  4656                              <1> 
  4657 0000A5DA E9D0F2FFFF          <1> 	jmp	loc_file_rw_restore_retn
  4658                              <1> 
  4659                              <1> ;loc_file_write_check_disk_space_err:
  4660                              <1> 	;cmp	al, 27h ; Insufficient disk space 
  4661                              <1> 	;je	loc_file_write_insuff_disk_space_msg
  4662                              <1>         ;jb	loc_file_rw_cmd_failed
  4663                              <1> 
  4664                              <1> 	;call	print_misc_error_msg ; 15/03/2016
  4665                              <1>         ;jmp	loc_file_rw_restore_retn 
  4666                              <1> 
  4667                              <1> change_fs_file_attributes:
  4668                              <1> 	; 04/03/2016 ; Temporary
  4669                              <1> 	; AL = File or directory attributes
  4670                              <1> 	; AH = 0 -> Attributes are in MS-DOS format
  4671                              <1> 	; AH > 0 -> Attributes are in SINGLIX format
  4672                              <1> 	;push	ebx
  4673                              <1> 	; ... do somethings here ...
  4674                              <1> 	;pop	ebx
  4675                              <1> 	; BL = File or directory attributes
  4676 0000A5DF C3                  <1> 	retn
  4677                              <1> 
  4678                              <1> set_get_env:
  4679                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
  4680                              <1> 	; 02/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_set')
  4681                              <1> 	; 2005 - 28/08/2011 
  4682                              <1> get_setenv_fchar:
  4683                              <1> 	; esi = environment variable/string
  4684 0000A5E0 8A06                <1> 	mov	al, [esi]
  4685 0000A5E2 3C20                <1> 	cmp	al, 20h
  4686 0000A5E4 771E                <1> 	ja	short loc_find_env
  4687                              <1> 
  4688 0000A5E6 BE00300900          <1> 	mov	esi, Env_Page
  4689                              <1> loc_print_setline:
  4690 0000A5EB 803E00              <1> 	cmp	byte [esi], 0
  4691 0000A5EE 7613                <1> 	jna	short loc_setenv_retn
  4692 0000A5F0 E860CFFFFF          <1> 	call	print_msg
  4693 0000A5F5 56                  <1> 	push	esi
  4694 0000A5F6 BE[FF4C0100]        <1> 	mov	esi, nextline
  4695 0000A5FB E855CFFFFF          <1> 	call	print_msg 
  4696 0000A600 5E                  <1> 	pop	esi
  4697 0000A601 EBE8                <1> 	jmp	short loc_print_setline   
  4698                              <1> 
  4699                              <1> loc_setenv_retn: 
  4700 0000A603 C3                  <1> 	retn
  4701                              <1> 
  4702                              <1> loc_find_env:
  4703 0000A604 3C3D                <1> 	cmp	al, '='
  4704 0000A606 0F8465E9FFFF        <1> 	je	loc_cmd_failed
  4705                              <1> 
  4706 0000A60C 56                  <1> 	push	esi
  4707                              <1> loc_repeat_env_equal_check:
  4708 0000A60D 46                  <1> 	inc	esi
  4709 0000A60E 803E3D              <1> 	cmp	byte [esi], '='
  4710 0000A611 7431                <1> 	je	short pass_env_equal_check
  4711 0000A613 803E20              <1> 	cmp	byte [esi], 20h
  4712 0000A616 73F5                <1> 	jnb	short loc_repeat_env_equal_check
  4713 0000A618 C60600              <1> 	mov	byte [esi], 0 
  4714 0000A61B 5E                  <1> 	pop	esi
  4715 0000A61C BF[968B0100]        <1> 	mov	edi, TextBuffer ; out buffer
  4716 0000A621 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  4717 0000A626 30C0                <1> 	xor	al, al ; 0 -> use [ESI]
  4718 0000A628 E89E000000          <1> 	call	get_environment_string
  4719 0000A62D 72D4                <1> 	jc	short loc_setenv_retn
  4720                              <1> 
  4721 0000A62F BE[968B0100]        <1> 	mov	esi, TextBuffer
  4722 0000A634 E81CCFFFFF          <1> 	call	print_msg
  4723 0000A639 BE[FF4C0100]        <1> 	mov	esi, nextline
  4724 0000A63E E812CFFFFF          <1> 	call	print_msg
  4725                              <1> 
  4726 0000A643 C3                  <1> 	retn 
  4727                              <1>               
  4728                              <1> pass_env_equal_check:
  4729 0000A644 46                  <1> 	inc	esi
  4730 0000A645 803E20              <1> 	cmp	byte [esi], 20h
  4731 0000A648 73FA                <1> 	jnb	short pass_env_equal_check
  4732 0000A64A C60600              <1> 	mov	byte [esi], 0	
  4733                              <1> 
  4734                              <1> loc_call_set_env_string:
  4735 0000A64D 5E                  <1> 	pop	esi
  4736 0000A64E E83B010000          <1> 	call	set_environment_string
  4737 0000A653 73AE                <1> 	jnc	short loc_setenv_retn
  4738                              <1> 
  4739                              <1> loc_set_cmd_failed:
  4740 0000A655 3C08                <1> 	cmp	al, 08h
  4741 0000A657 0F8514E9FFFF        <1> 	jne	loc_cmd_failed
  4742                              <1> 
  4743 0000A65D BE[D0460100]        <1> 	mov	esi, Msg_No_Set_Space
  4744 0000A662 E8EECEFFFF          <1> 	call	print_msg
  4745                              <1> 
  4746 0000A667 C3                  <1> 	retn
  4747                              <1> 
  4748                              <1> set_get_path:
  4749                              <1> 	; 11/04/2016 (TRDOS 386 = TRDOS v2.0)
  4750                              <1> 	; 03/09/2011 (TRDOS v1, CMD_INTR.ASM, 'cmp_cmd_path')
  4751                              <1> 	; 2005
  4752                              <1> get_path_fchar:
  4753                              <1>  	; esi = path
  4754 0000A668 803E20              <1> 	cmp	byte [esi], 20h
  4755 0000A66B 7737                <1> 	ja	short loc_set_path
  4756                              <1> 
  4757 0000A66D BE00300900          <1> 	mov	esi, Env_Page
  4758                              <1> loc_print_path:
  4759 0000A672 803E00              <1> 	cmp	byte [esi], 0
  4760 0000A675 762C                <1> 	jna	short loc_path_retn
  4761                              <1> 
  4762 0000A677 BE[2F410100]        <1> 	mov	esi, Cmd_Path ; 'PATH' address
  4763 0000A67C BF[968B0100]        <1> 	mov	edi, TextBuffer ; out buffer
  4764 0000A681 30C0                <1> 	xor	al, al  ; use [ESI]
  4765 0000A683 B9FF000000          <1> 	mov	ecx, 255 ; maximum size (limit)
  4766 0000A688 E83E000000          <1> 	call	get_environment_string
  4767 0000A68D 7214                <1> 	jc	short loc_path_retn
  4768                              <1> 
  4769 0000A68F BE[968B0100]        <1> 	mov	esi, TextBuffer
  4770 0000A694 E8BCCEFFFF          <1> 	call	print_msg
  4771 0000A699 BE[FF4C0100]        <1> 	mov	esi, nextline
  4772 0000A69E E8B2CEFFFF          <1> 	call	print_msg   
  4773                              <1> 
  4774                              <1> loc_path_retn: 
  4775 0000A6A3 C3                  <1> 	retn
  4776                              <1> 
  4777                              <1> loc_set_path:
  4778 0000A6A4 56                  <1> 	push	esi 
  4779                              <1> loc_set_path_find_end:
  4780 0000A6A5 46                  <1> 	inc	esi
  4781 0000A6A6 803E20              <1> 	cmp	byte [esi], 20h
  4782 0000A6A9 73FA                <1> 	jnb	short loc_set_path_find_end
  4783 0000A6AB C60600              <1> 	mov	byte [esi], 0 
  4784                              <1> loc_set_path_header: 
  4785 0000A6AE 5E                  <1> 	pop	esi
  4786                              <1> set_path_x: ; 31/12/2017 ('syspath')	  
  4787 0000A6AF 4E                  <1> 	dec	esi
  4788 0000A6B0 C6063D              <1> 	mov	byte [esi], '='
  4789 0000A6B3 4E                  <1> 	dec	esi
  4790 0000A6B4 C60648              <1> 	mov	byte [esi], 'H'
  4791 0000A6B7 4E                  <1> 	dec	esi
  4792 0000A6B8 C60654              <1> 	mov	byte [esi], 'T'
  4793 0000A6BB 4E                  <1> 	dec	esi
  4794 0000A6BC C60641              <1> 	mov	byte [esi], 'A'
  4795 0000A6BF 4E                  <1> 	dec	esi
  4796 0000A6C0 C60650              <1> 	mov	byte [esi], 'P'   
  4797                              <1> 
  4798                              <1> loc_path_call_set_env_string:
  4799 0000A6C3 E8C6000000          <1> 	call	set_environment_string
  4800 0000A6C8 728B                <1>         jc	short loc_set_cmd_failed
  4801                              <1> 
  4802 0000A6CA C3                  <1> 	retn              
  4803                              <1> 
  4804                              <1> get_environment_string:
  4805                              <1> 	; 12/04/2016
  4806                              <1> 	; 11/04/2016
  4807                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  4808                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  4809                              <1> 	; 28/08/2011
  4810                              <1> 	; INPUT->
  4811                              <1> 	;	EDI = Output buffer
  4812                              <1> 	;	CX = Buffer length (<= ENV_PAGE_SIZE)
  4813                              <1> 	;
  4814                              <1> 	;	AL > 0 = AL = String sequence number
  4815                              <1> 	;	AL = 0 -> ESI = ASCIIZ Set word 
  4816                              <1> 	;		(environment variable)
  4817                              <1> 	; OUTPUT ->
  4818                              <1> 	;	ESI is not changed
  4819                              <1> 	;	EDI is not changed
  4820                              <1> 	;	EAX = String length (with zero tail)
  4821                              <1> 	;	EDX = Environment variables page address
  4822                              <1> 	;	CF = 1 -> Not found (EAX not valid)
  4823                              <1> 	;
  4824                              <1> 	; (Modified registers: EAX, EDX) 
  4825                              <1> 
  4826 0000A6CB BA00300900          <1> 	mov	edx, Env_Page
  4827 0000A6D0 803A00              <1> 	cmp	byte [edx], 0
  4828 0000A6D3 7474                <1> 	jz	short get_env_string_with_word_stc_retn
  4829                              <1> 
  4830 0000A6D5 66890D[00960100]    <1> 	mov	[env_var_length], cx
  4831                              <1> 
  4832 0000A6DC 51                  <1> 	push	ecx ; *
  4833 0000A6DD 56                  <1> 	push	esi ; **
  4834                              <1> 
  4835 0000A6DE 08C0                <1> 	or	al, al
  4836 0000A6E0 7449                <1> 	jz	short get_env_string_with_word
  4837                              <1> 
  4838                              <1> get_env_string_with_seq_number:
  4839 0000A6E2 B101                <1> 	mov	cl, 1
  4840 0000A6E4 88C5                <1> 	mov	ch, al
  4841 0000A6E6 31C0                <1> 	xor	eax, eax
  4842 0000A6E8 89D6                <1> 	mov	esi, edx ; Env_Page
  4843                              <1> 
  4844                              <1> get_env_string_seq_number_check:
  4845 0000A6EA 38CD                <1> 	cmp	ch, cl
  4846 0000A6EC 7726                <1> 	ja	short get_env_string_seq_number_next
  4847                              <1> 
  4848                              <1> get_env_string_move_to_buff:
  4849 0000A6EE 57                  <1> 	push	edi ; ***
  4850                              <1> 
  4851 0000A6EF 29D2                <1> 	sub	edx, edx
  4852                              <1> 
  4853                              <1> get_env_string_seq_number_repeat1:
  4854 0000A6F1 42                  <1> 	inc	edx
  4855 0000A6F2 AC                  <1> 	lodsb
  4856 0000A6F3 AA                  <1> 	stosb
  4857                              <1> 
  4858 0000A6F4 66FF0D[00960100]    <1> 	dec	word [env_var_length]
  4859 0000A6FB 7508                <1> 	jnz	short get_env_string_seq_number_repeat3
  4860                              <1> 
  4861                              <1> get_env_string_seq_number_repeat2:
  4862 0000A6FD 20C0                <1> 	and	al, al
  4863 0000A6FF 7408                <1> 	jz	short get_env_string_seq_number_ok
  4864 0000A701 42                  <1> 	inc	edx
  4865 0000A702 AC                  <1> 	lodsb
  4866 0000A703 EBF8                <1> 	jmp	short get_env_string_seq_number_repeat2
  4867                              <1> 
  4868                              <1> get_env_string_seq_number_repeat3:
  4869 0000A705 08C0                <1> 	or	al, al
  4870 0000A707 75E8                <1> 	jnz	short get_env_string_seq_number_repeat1
  4871                              <1> 
  4872                              <1> get_env_string_seq_number_ok:
  4873 0000A709 5F                  <1> 	pop	edi ; ***
  4874 0000A70A 89D0                <1> 	mov	eax, edx ; Length of the environment string
  4875                              <1> 			 ; (ASCIIZ, includes ZERO tail)
  4876 0000A70C BA00300900          <1> 	mov	edx, Env_Page
  4877                              <1> 
  4878                              <1> get_env_string_stc_retn:
  4879 0000A711 5E                  <1> 	pop	esi ; **
  4880 0000A712 59                  <1> 	pop	ecx ; *
  4881 0000A713 C3                  <1> 	retn   
  4882                              <1> 	
  4883                              <1> get_env_string_seq_number_next:
  4884 0000A714 AC                  <1> 	lodsb
  4885 0000A715 08C0                <1> 	or	al, al
  4886 0000A717 75FB                <1> 	jnz	short get_env_string_seq_number_next
  4887                              <1> 
  4888 0000A719 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; +512 (+4096)
  4889 0000A71F F5                  <1> 	cmc
  4890 0000A720 72EF                <1> 	jc	short get_env_string_stc_retn
  4891                              <1> 
  4892 0000A722 AC                  <1> 	lodsb
  4893 0000A723 3C01                <1> 	cmp	al, 1
  4894 0000A725 72EA                <1> 	jb	short get_env_string_stc_retn
  4895 0000A727 FEC1                <1> 	inc	cl
  4896 0000A729 EBBF                <1> 	jmp	short get_env_string_seq_number_check
  4897                              <1> 
  4898                              <1> get_env_string_with_word:
  4899 0000A72B 31C9                <1> 	xor	ecx, ecx
  4900                              <1> 
  4901                              <1> get_env_string_calc_word_length:
  4902 0000A72D AC                  <1> 	lodsb 
  4903 0000A72E 3C20                <1> 	cmp	al, 20h
  4904 0000A730 7211                <1> 	jb	short get_env_string_calc_word_length_ok
  4905                              <1> 	;inc	cx
  4906 0000A732 FEC1                <1> 	inc	cl
  4907                              <1> 
  4908 0000A734 3C61                <1> 	cmp	al, 'a'
  4909 0000A736 72F5                <1> 	jb	short get_env_string_calc_word_length
  4910 0000A738 3C7A                <1> 	cmp	al, 'z'
  4911 0000A73A 77F1                <1> 	ja	short get_env_string_calc_word_length
  4912 0000A73C 24DF                <1> 	and	al, 0DFh
  4913 0000A73E 8846FF              <1> 	mov	[esi-1], al
  4914 0000A741 EBEA                <1> 	jmp	short get_env_string_calc_word_length
  4915                              <1> 	
  4916                              <1> get_env_string_calc_word_length_ok:
  4917 0000A743 08C9                <1> 	or	cl, cl
  4918 0000A745 7506                <1> 	jnz	short get_env_string_calc_word_length_save
  4919                              <1>      
  4920 0000A747 5E                  <1> 	pop	esi ; **
  4921                              <1> 
  4922                              <1> get_env_string_stc_retn1:
  4923 0000A748 59                  <1> 	pop	ecx ; *
  4924                              <1>         
  4925                              <1> get_env_string_with_word_stc_retn:
  4926 0000A749 31C0                <1> 	xor	eax, eax  
  4927 0000A74B F9                  <1> 	stc
  4928 0000A74C C3                  <1> 	retn
  4929                              <1>   
  4930                              <1> get_env_string_calc_word_length_save:
  4931 0000A74D 871C24              <1> 	xchg	ebx, [esp] ; **
  4932 0000A750 89DE                <1> 	mov	esi, ebx 
  4933                              <1> 		; Start of the env string (to be searched)
  4934                              <1> 
  4935 0000A752 57                  <1> 	push	edi ; ***
  4936 0000A753 89D7                <1> 	mov	edi, edx ; Env_Page
  4937                              <1> 
  4938                              <1> get_env_string_compare:
  4939 0000A755 57                  <1> 	push	edi ; ****
  4940 0000A756 51                  <1> 	push	ecx ; ***** ; Variable name length
  4941                              <1> 
  4942                              <1> get_env_string_compare_rep:
  4943 0000A757 AC                  <1> 	lodsb
  4944 0000A758 AE                  <1> 	scasb
  4945 0000A759 7511                <1> 	jne	short get_env_string_compare_next1
  4946 0000A75B E2FA                <1> 	loop	get_env_string_compare_rep
  4947                              <1> 	
  4948 0000A75D 803F3D              <1> 	cmp	byte [edi], '='
  4949 0000A760 750A                <1> 	jne	short get_env_string_compare_next1
  4950                              <1>  
  4951 0000A762 59                  <1> 	pop	ecx ; *****
  4952 0000A763 5F                  <1> 	pop	edi ; ****
  4953 0000A764 89FE                <1> 	mov	esi, edi
  4954 0000A766 5F                  <1> 	pop	edi ; ***
  4955 0000A767 871C24              <1> 	xchg	ebx, [esp] ; **
  4956 0000A76A EB82                <1> 	jmp	short get_env_string_move_to_buff
  4957                              <1> 
  4958                              <1> get_env_string_compare_next1:
  4959 0000A76C 89FE                <1> 	mov	esi, edi
  4960 0000A76E 59                  <1> 	pop	ecx ; *****
  4961 0000A76F 5F                  <1> 	pop	edi ; ****
  4962                              <1> get_env_string_compare_next2:
  4963 0000A770 81FEFF310900        <1> 	cmp	esi, Env_Page + Env_Page_Size - 1 ; +511 (+4095)
  4964 0000A776 7310                <1> 	jnb	short get_env_string_compare_not_ok
  4965 0000A778 20C0                <1> 	and	al, al
  4966 0000A77A AC                  <1> 	lodsb
  4967 0000A77B 75F3                <1> 	jnz	short get_env_string_compare_next2
  4968 0000A77D 08C0                <1> 	or	al, al
  4969 0000A77F 7407                <1> 	jz	short get_env_string_compare_not_ok
  4970 0000A781 4E                  <1> 	dec	esi ; 12/04/2016
  4971 0000A782 89F7                <1> 	mov	edi, esi
  4972 0000A784 89DE                <1> 	mov	esi, ebx
  4973 0000A786 EBCD                <1> 	jmp	short get_env_string_compare
  4974                              <1> 
  4975                              <1> get_env_string_compare_not_ok:
  4976 0000A788 5F                  <1> 	pop	edi ; ***
  4977 0000A789 89DE                <1> 	mov	esi, ebx
  4978 0000A78B 5B                  <1> 	pop	ebx ; **
  4979 0000A78C EBBA                <1> 	jmp	short get_env_string_stc_retn1
  4980                              <1> 
  4981                              <1> set_environment_string:
  4982                              <1> 	; 13/04/2016
  4983                              <1> 	; 12/04/2016
  4984                              <1> 	; 11/04/2016
  4985                              <1> 	; 06/04/2016
  4986                              <1> 	; 05/04/2016 (TRDOS 386 = TRDOS v2.0)
  4987                              <1> 	; 02/09/2011 (TRDOS v1, MAINPROG.ASM)
  4988                              <1> 	; 29/08/2011
  4989                              <1> 	; 29/08/2011
  4990                              <1> 	; INPUT->
  4991                              <1> 	;	ESI = ASCIIZ environment string
  4992                              <1> 	; OUTPUT ->
  4993                              <1> 	;	ESI is not changed
  4994                              <1> 	;	CF = 1 -> Could not set, 
  4995                              <1> 	;	     insufficient environment space
  4996                              <1> 	;
  4997                              <1> 	; (EAX, EDX will be changed) 
  4998                              <1> 	;
  4999                              <1> 	;    (EAX = Start address of the env string if > 0)	
  5000                              <1> 	;    (EDX = Environment string length)	
  5001                              <1> 
  5002 0000A78E 56                  <1> 	push 	esi ; *
  5003                              <1> 
  5004 0000A78F 31C0                <1> 	xor	eax, eax
  5005                              <1> 
  5006                              <1> set_env_chk_validation1:
  5007 0000A791 FEC4                <1> 	inc	ah ; variable (string) length
  5008 0000A793 AC                  <1> 	lodsb
  5009 0000A794 3C3D                <1> 	cmp	al, '='
  5010 0000A796 7415                <1> 	je	short set_env_chk_validation2
  5011 0000A798 3C20                <1> 	cmp	al, 20h
  5012 0000A79A 720F                <1> 	jb	short set_env_string_stc
  5013                              <1> 
  5014                              <1> 	; 06/04/2016
  5015 0000A79C 3C61                <1> 	cmp	al, 'a'
  5016 0000A79E 72F1                <1> 	jb	short set_env_chk_validation1
  5017 0000A7A0 3C7A                <1> 	cmp	al, 'z'
  5018 0000A7A2 77ED                <1> 	ja	short set_env_chk_validation1
  5019 0000A7A4 2C20                <1> 	sub	al, 'a'-'A'
  5020 0000A7A6 8846FF              <1> 	mov	[esi-1], al
  5021 0000A7A9 EBE6                <1> 	jmp	short set_env_chk_validation1
  5022                              <1> 
  5023                              <1> set_env_string_stc:
  5024 0000A7AB 5E                  <1> 	pop	esi ; *
  5025                              <1> 	;stc
  5026 0000A7AC C3                  <1> 	retn 
  5027                              <1> 	   
  5028                              <1> set_env_chk_validation2:
  5029 0000A7AD 51                  <1> 	push	ecx ; **
  5030 0000A7AE 53                  <1> 	push	ebx ; *** 
  5031 0000A7AF 57                  <1> 	push	edi ; ****
  5032                              <1> 
  5033                              <1> 	; 12/04/2016
  5034 0000A7B0 8B5C240C            <1> 	mov	ebx, [esp+12]
  5035                              <1> 
  5036                              <1> set_env_chk_validation2w:
  5037 0000A7B4 89F7                <1> 	mov	edi, esi
  5038 0000A7B6 4F                  <1> 	dec	edi
  5039                              <1> 
  5040 0000A7B7 807FFF20            <1> 	cmp	byte [edi-1], 20h
  5041 0000A7BB 771A                <1> 	ja	short set_env_chk_validation2z
  5042                              <1> 	
  5043 0000A7BD 56                  <1> 	push	esi
  5044 0000A7BE 89FE                <1> 	mov	esi, edi
  5045 0000A7C0 4E                  <1> 	dec	esi
  5046                              <1> 
  5047                              <1> set_env_chk_validation2x:
  5048 0000A7C1 4E                  <1> 	dec	esi
  5049                              <1> 
  5050 0000A7C2 39DE                <1> 	cmp	esi, ebx
  5051 0000A7C4 7207                <1> 	jb	short set_env_chk_validation2y
  5052                              <1> 
  5053 0000A7C6 4F                  <1> 	dec	edi
  5054                              <1> 
  5055 0000A7C7 8A06                <1> 	mov	al, [esi]
  5056 0000A7C9 8807                <1> 	mov	[edi], al
  5057                              <1> 
  5058 0000A7CB EBF4                <1> 	jmp	short set_env_chk_validation2x
  5059                              <1> 
  5060                              <1> set_env_chk_validation2y:
  5061 0000A7CD 5E                  <1> 	pop	esi
  5062                              <1> 
  5063                              <1> 	;mov	byte [ebx], 20h
  5064                              <1> 	
  5065 0000A7CE 43                  <1> 	inc 	ebx
  5066 0000A7CF 895C240C            <1> 	mov	[esp+12], ebx
  5067                              <1> 
  5068 0000A7D3 FECC                <1> 	dec 	ah ; 13/04/2016
  5069                              <1> 
  5070 0000A7D5 EBDD                <1> 	jmp	short set_env_chk_validation2w
  5071                              <1> 	
  5072                              <1> set_env_chk_validation2z:	
  5073 0000A7D7 BA00300900          <1> 	mov	edx, Env_Page
  5074 0000A7DC 89D7                <1> 	mov	edi, edx
  5075                              <1> 
  5076                              <1> set_env_chk_validation3:
  5077 0000A7DE AC                  <1> 	lodsb
  5078 0000A7DF 3C20                <1> 	cmp	al, 20h
  5079 0000A7E1 74FB                <1> 	je	short set_env_chk_validation3
  5080                              <1> 
  5081 0000A7E3 9C                  <1> 	pushf
  5082                              <1> 
  5083                              <1> 	; 12/04/2016
  5084                              <1> set_env_chk_validation3n:
  5085 0000A7E4 3C61                <1> 	cmp	al, 'a'
  5086 0000A7E6 720C                <1> 	jb	short set_env_chk_validation3c
  5087 0000A7E8 3C7A                <1> 	cmp	al, 'z'
  5088 0000A7EA 7705                <1> 	ja	short set_env_chk_validation3x
  5089 0000A7EC 2C20                <1> 	sub	al, 'a'-'A'
  5090 0000A7EE 8846FF              <1> 	mov	[esi-1], al
  5091                              <1> 
  5092                              <1> set_env_chk_validation3x:
  5093 0000A7F1 AC                  <1> 	lodsb
  5094 0000A7F2 EBF0                <1> 	jmp	short set_env_chk_validation3n
  5095                              <1> 
  5096                              <1> set_env_chk_validation3c:
  5097 0000A7F4 3C20                <1> 	cmp	al, 20h
  5098 0000A7F6 73F9                <1> 	jnb	short set_env_chk_validation3x
  5099                              <1> 		
  5100 0000A7F8 803F00              <1> 	cmp	byte [edi], 0
  5101 0000A7FB 7731                <1> 	ja	short set_env_chk_validation4
  5102                              <1> 
  5103 0000A7FD 9D                  <1> 	popf
  5104 0000A7FE 7228                <1> 	jb	short set_env_string_nothing
  5105                              <1> 
  5106 0000A800 B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)
  5107                              <1> 
  5108 0000A805 89DE                <1> 	mov	esi, ebx ; 12/04/2016
  5109                              <1> 
  5110                              <1> set_env_string_copy_to_envb:
  5111 0000A807 AC                  <1> 	lodsb
  5112 0000A808 3C20                <1> 	cmp	al, 20h
  5113 0000A80A 720A                <1> 	jb	short set_env_string_copy_to_envb_z
  5114 0000A80C AA                  <1> 	stosb
  5115 0000A80D E2F8                <1> 	loop	set_env_string_copy_to_envb
  5116                              <1> 
  5117                              <1> 	; 11/04/2016
  5118 0000A80F 89D7                <1> 	mov	edi, edx ; Env_Page
  5119 0000A811 B900020000          <1> 	mov	ecx, Env_Page_Size 
  5120                              <1> 
  5121                              <1> set_env_string_copy_to_envb_z:
  5122 0000A816 52                  <1> 	push	edx  ; Start address of the variable
  5123 0000A817 BA00020000          <1> 	mov	edx, Env_Page_Size
  5124 0000A81C 29CA                <1> 	sub	edx, ecx ; variable (string) length
  5125                              <1> 
  5126 0000A81E 28C0                <1> 	sub	al, al ; 0
  5127 0000A820 F3AA                <1>  	rep	stosb ; clear remain bytes of the env page
  5128                              <1> 
  5129 0000A822 58                  <1> 	pop	eax  ; Start address of the variable
  5130                              <1> 
  5131                              <1> set_env_string_allocate_envb_retn:  ; stc or clc return
  5132 0000A823 5F                  <1> 	pop	edi ; ****
  5133 0000A824 5B                  <1> 	pop	ebx ; ***
  5134 0000A825 59                  <1> 	pop	ecx ; **
  5135 0000A826 5E                  <1> 	pop	esi ; *	
  5136 0000A827 C3                  <1> 	retn
  5137                              <1> 
  5138                              <1> set_env_string_nothing:
  5139 0000A828 31C0                <1> 	xor	eax, eax
  5140 0000A82A 31D2                <1> 	xor	edx, edx ; 11/04/2016
  5141 0000A82C EBF5                <1> 	jmp	short set_env_string_allocate_envb_retn
  5142                              <1> 
  5143                              <1> set_env_chk_validation4:
  5144                              <1> 	; 11/04/2016
  5145 0000A82E 9D                  <1> 	popf
  5146                              <1> 
  5147 0000A82F 89D6                <1> 	mov	esi, edx  ; Env_Page
  5148                              <1> 
  5149                              <1> set_env_chk_validation5:	
  5150 0000A831 89DF                <1> 	mov	edi, ebx  ; ASCIIZ environment string address	
  5151 0000A833 0FB6CC              <1> 	movzx	ecx, ah ; Variable (string) length (with '=')
  5152                              <1> 
  5153                              <1> set_env_chk_validation5_loop:
  5154 0000A836 AC                  <1> 	lodsb
  5155 0000A837 AE                  <1> 	scasb
  5156 0000A838 750A                <1> 	jne	short set_env_chk_validation6
  5157 0000A83A E2FA                <1> 	loop	set_env_chk_validation5_loop
  5158                              <1> 
  5159 0000A83C 3C3D                <1> 	cmp	al, '='
  5160 0000A83E 0F8483000000        <1>         je      set_env_change_variable
  5161                              <1> 
  5162                              <1> set_env_chk_validation6:
  5163 0000A844 08C0                <1> 	or	al, al ; 0
  5164 0000A846 7403                <1> 	jz	short set_env_chk_validation7
  5165                              <1> 
  5166 0000A848 AC                  <1> 	lodsb
  5167 0000A849 EBF9                <1> 	jmp	short set_env_chk_validation6
  5168                              <1> 
  5169                              <1> set_env_chk_validation7:
  5170 0000A84B 88E1                <1> 	mov	cl, ah
  5171 0000A84D 01F1                <1> 	add	ecx, esi
  5172 0000A84F 81F9FF310900        <1> 	cmp	ecx, Env_Page + Env_Page_Size - 1 
  5173                              <1> 		; 511 (4095) 
  5174                              <1> 		; strlen + '=' + 0
  5175 0000A855 72DA                <1> 	jb	short set_env_chk_validation5
  5176                              <1> 
  5177                              <1> set_env_chk_validation8: ; variable not found
  5178 0000A857 0FB6F4              <1> 	movzx	esi, ah  ; variable name length (with '=') 
  5179 0000A85A 01DE                <1> 	add	esi, ebx ; position just after of the '='
  5180                              <1> 
  5181                              <1> set_env_chk_validation8_loop:
  5182 0000A85C AC                  <1> 	lodsb
  5183 0000A85D 3C20                <1> 	cmp	al, 20h
  5184 0000A85F 74FB                <1> 	je	short set_env_chk_validation8_loop	
  5185 0000A861 72C5                <1> 	jb	short set_env_string_nothing
  5186                              <1> 
  5187                              <1> set_env_chk_validation9:
  5188 0000A863 AC                  <1> 	lodsb
  5189 0000A864 3C20                <1> 	cmp	al, 20h
  5190 0000A866 73FB                <1> 	jnb	short set_env_chk_validation9
  5191                              <1> 
  5192                              <1> 	; End of ASCIIZ environment string
  5193                              <1> 
  5194                              <1> set_env_add_variable:
  5195 0000A868 29DE                <1> 	sub	esi, ebx ; variable+definition length
  5196                              <1> 	
  5197 0000A86A 56                  <1> 	push	esi ; *****
  5198                              <1> 
  5199 0000A86B 89D6                <1> 	mov	esi, edx ; Environment page address
  5200                              <1> 
  5201 0000A86D B900020000          <1> 	mov	ecx, Env_Page_Size ; 512 (4096)	
  5202                              <1> 
  5203                              <1> set_env_add_variable_loop:
  5204 0000A872 AC                  <1> 	lodsb
  5205 0000A873 20C0                <1> 	and	al, al		
  5206 0000A875 7406                <1> 	jz	short set_env_add_variable_chk1 ; 0
  5207 0000A877 E2F9                <1> 	loop	set_env_add_variable_loop
  5208                              <1> 
  5209                              <1> 	; 11/04/2016
  5210 0000A879 884EFF              <1> 	mov	[esi-1], cl ; 0
  5211 0000A87C 41                  <1> 	inc	ecx
  5212                              <1> 	
  5213                              <1> set_env_add_variable_chk1: 
  5214 0000A87D 49                  <1> 	dec	ecx
  5215 0000A87E 7408                <1> 	jz	short set_env_add_variable_nspc
  5216 0000A880 AC                  <1> 	lodsb
  5217 0000A881 08C0                <1> 	or 	al, al
  5218 0000A883 740C                <1> 	jz	short set_env_add_variable_chk2 ; 00
  5219 0000A885 49                  <1> 	dec	ecx
  5220 0000A886 75EA                <1> 	jnz	short set_env_add_variable_loop
  5221                              <1> 
  5222                              <1> set_env_add_variable_nspc: ; no space on environment page
  5223 0000A888 58                  <1> 	pop	eax ; *****
  5224 0000A889 B808000000          <1> 	mov	eax, 8 ; No space for new environment string
  5225 0000A88E F9                  <1> 	stc
  5226 0000A88F EB92                <1>         jmp     short set_env_string_allocate_envb_retn
  5227                              <1> 
  5228                              <1> set_env_add_variable_chk2:
  5229 0000A891 8B0C24              <1> 	mov	ecx, [esp] ; *****
  5230 0000A894 4E                  <1> 	dec	esi ; beginning address of the new variable
  5231 0000A895 89F0                <1> 	mov	eax, esi
  5232 0000A897 01C8                <1> 	add	eax, ecx ; string length (with CR)
  5233 0000A899 81C200020000        <1> 	add	edx, Env_Page_Size ; 512 (4096)
  5234 0000A89F 39D0                <1> 	cmp	eax, edx 
  5235 0000A8A1 77E5                <1> 	ja	short set_env_add_variable_nspc
  5236 0000A8A3 49                  <1> 	dec	ecx ; except CR at the end
  5237 0000A8A4 89CA                <1> 	mov	edx, ecx ; 12/04/2016
  5238 0000A8A6 89F7                <1> 	mov	edi, esi
  5239 0000A8A8 893C24              <1> 	mov	[esp], edi ; ***** ; Start address of new variable
  5240 0000A8AB 89DE                <1> 	mov	esi, ebx ; ASCIIZ environment string address
  5241 0000A8AD F3A4                <1> 	rep	movsb
  5242 0000A8AF 28C0                <1> 	sub	al, al
  5243 0000A8B1 AA                  <1> 	stosb
  5244 0000A8B2 58                  <1> 	pop	eax ; ***** ; Beginning address of new variable			
  5245 0000A8B3 81FF00320900        <1>         cmp     edi, Env_Page + Env_Page_Size ; 12/04/2016
  5246 0000A8B9 0F8364FFFFFF        <1>         jnb     set_env_string_allocate_envb_retn ; OK !
  5247 0000A8BF 880F                <1> 	mov	[edi], cl ; 0
  5248 0000A8C1 F8                  <1> 	clc	; 13/04/2016
  5249 0000A8C2 E95CFFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5250                              <1> 
  5251                              <1> set_env_change_variable:
  5252                              <1> 	; 06/04/2016
  5253                              <1> 	; esi = Variable's address in environment page (after '=')
  5254                              <1> 	; edi = ASCIIZ environment string address (after '=')
  5255                              <1> 
  5256                              <1> 	; ah = variable length from start to the '='
  5257 0000A8C7 8825[00960100]      <1> 	mov	[env_var_length], ah
  5258                              <1> 
  5259 0000A8CD 28C9                <1> 	sub	cl, cl ; ecx = 0
  5260                              <1> 
  5261 0000A8CF 57                  <1> 	push	edi ; *****
  5262                              <1> 
  5263 0000A8D0 89F7                <1> 	mov	edi, esi ; 11/04/2016
  5264                              <1> 
  5265                              <1> set_env_change_variable_calc1:
  5266 0000A8D2 AC                  <1> 	lodsb
  5267 0000A8D3 08C0                <1> 	or	al, al
  5268 0000A8D5 7403                <1> 	jz	short set_env_change_variable_calc2
  5269                              <1> 
  5270 0000A8D7 41                  <1> 	inc	ecx ; length of environment string (after the '=')
  5271                              <1> 
  5272 0000A8D8 EBF8                <1> 	jmp	short set_env_change_variable_calc1	
  5273                              <1> 
  5274                              <1> set_env_change_variable_calc2:
  5275 0000A8DA 8B3424              <1> 	mov	esi, [esp] ; ASCIIZ environment string address
  5276                              <1> 	
  5277 0000A8DD 29D2                <1> 	sub	edx, edx
  5278                              <1> 
  5279                              <1> set_env_change_variable_calc3:
  5280 0000A8DF AC                  <1> 	lodsb
  5281 0000A8E0 3C20                <1> 	cmp	al, 20h
  5282 0000A8E2 7203                <1> 	jb	short set_env_change_variable_calc4
  5283                              <1> 
  5284 0000A8E4 42                  <1> 	inc	edx ; length of ASCIIZ string (after the '=')
  5285                              <1> 	
  5286 0000A8E5 EBF8                <1> 	jmp	short set_env_change_variable_calc3
  5287                              <1> 	
  5288                              <1> set_env_change_variable_calc4:
  5289 0000A8E7 C646FF00            <1> 	mov	byte [esi-1], 0  ; put ZERO instead of CR
  5290                              <1> 	
  5291 0000A8EB 5E                  <1> 	pop	esi ; ***** ; ASCIIZ string address (after '=')
  5292                              <1> 
  5293                              <1> 	; EDI = Old variable's address (after '=')
  5294                              <1> 	
  5295                              <1> 	; compare the new string with the old string
  5296 0000A8EC 39CA                <1> 	cmp	edx, ecx
  5297 0000A8EE 7717                <1> 	ja	short set_env_change_variable_calc5 ; longer
  5298 0000A8F0 0F828F000000        <1>         jb      set_env_change_variable_calc9 ; shorter
  5299                              <1> 	
  5300                              <1> 	;same length (simple copy)
  5301 0000A8F6 0FB6C4              <1> 	movzx	eax, ah
  5302 0000A8F9 01C2                <1> 	add	edx, eax
  5303 0000A8FB F7D8                <1> 	neg	eax
  5304 0000A8FD 01F8                <1> 	add	eax, edi
  5305                              <1> 	; EAX = Start address of the variable
  5306                              <1> 	; EDX = Variable length (without ZERO at the end of variable)
  5307                              <1> 
  5308 0000A8FF F3A4                <1> 	rep	movsb
  5309 0000A901 F8                  <1> 	clc	; 13/04/2016
  5310 0000A902 E91CFFFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5311                              <1> 
  5312                              <1> set_env_change_variable_calc5:
  5313                              <1> 	; 11/04/2016
  5314 0000A907 52                  <1> 	push	edx ; *****
  5315 0000A908 29CA                <1> 	sub	edx, ecx ; difference ; (the new string is longer)
  5316 0000A90A 89F3                <1> 	mov 	ebx, esi
  5317 0000A90C 89FE                <1> 	mov	esi, edi
  5318                              <1> 
  5319                              <1> set_env_change_variable_calc6:
  5320 0000A90E AC                  <1> 	lodsb 
  5321 0000A90F 20C0                <1> 	and	al, al
  5322 0000A911 75FB                <1> 	jnz	short set_env_change_variable_calc6
  5323                              <1> 
  5324 0000A913 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  5325 0000A919 0F8369FFFFFF        <1>         jnb     set_env_add_variable_nspc
  5326                              <1> 
  5327 0000A91F 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  5328 0000A921 89F7                <1> 	mov	edi, esi  ; next variable's address 
  5329                              <1> 
  5330 0000A923 AC                  <1> 	lodsb
  5331 0000A924 08C0                <1> 	or	al, al
  5332 0000A926 7416                <1> 	jz	short set_env_change_variable_calc8 ; 00
  5333                              <1> 
  5334                              <1> set_env_change_variable_calc7:
  5335 0000A928 AC                  <1> 	lodsb
  5336 0000A929 20C0                <1> 	and	al, al
  5337 0000A92B 75FB                <1> 	jnz	short set_env_change_variable_calc7
  5338                              <1> 
  5339 0000A92D 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size ; 512 (4096)
  5340 0000A933 0F834FFFFFFF        <1>         jnb     set_env_add_variable_nspc
  5341                              <1> 
  5342 0000A939 AC                  <1> 	lodsb
  5343 0000A93A 08C0                <1> 	or	al, al
  5344 0000A93C 75EA                <1> 	jnz	short set_env_change_variable_calc7
  5345                              <1> 
  5346                              <1> set_env_change_variable_calc8:
  5347 0000A93E 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  5348                              <1> 
  5349 0000A93F 01F2                <1> 	add	edx, esi ; final position of the last 0
  5350                              <1> 
  5351 0000A941 81FA00320900        <1> 	cmp	edx, Env_Page + Env_Page_Size ; 512 (4096)
  5352 0000A947 0F833BFFFFFF        <1>         jnb     set_env_add_variable_nspc
  5353                              <1> 
  5354 0000A94D 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  5355                              <1> 
  5356 0000A94F 89F1                <1> 	mov	ecx, esi 
  5357 0000A951 29F9                <1> 	sub	ecx, edi ; count of bytes to move forward
  5358                              <1> 
  5359                              <1> 	; 13/04/2016
  5360 0000A953 C60200              <1> 	mov	byte [edx], 0
  5361 0000A956 89D7                <1> 	mov	edi, edx
  5362 0000A958 29F2                <1> 	sub	edx, esi ; difference (additional byte count)
  5363 0000A95A 4F                  <1> 	dec	edi ; the last zero address (first byte of the 00)
  5364 0000A95B 89FE                <1> 	mov	esi, edi
  5365 0000A95D 29D6                <1> 	sub	esi, edx ; - displacement
  5366                              <1> 	
  5367 0000A95F FA                  <1> 	cli	; disable interrupts
  5368 0000A960 FD                  <1> 	std	; backward
  5369                              <1> 
  5370 0000A961 F3A4                <1> 	rep	movsb ; move ECX bytes from DS:ESI to ES:EDI
  5371                              <1> 
  5372 0000A963 FC                  <1> 	cld	; forward (default)
  5373 0000A964 FB                  <1> 	sti	; enable interrupts
  5374                              <1> 	
  5375 0000A965 89C7                <1> 	mov	edi, eax
  5376 0000A967 59                  <1> 	pop	ecx ; ***** ; byte count (after '=')
  5377 0000A968 89CA                <1> 	mov	edx, ecx
  5378 0000A96A 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  5379 0000A96C 89FB                <1> 	mov	ebx, edi
  5380                              <1> 
  5381 0000A96E F3A4                <1> 	rep	movsb
  5382                              <1> 
  5383 0000A970 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  5384                              <1> 
  5385 0000A972 0FB605[00960100]    <1> 	movzx	eax, byte [env_var_length]
  5386 0000A979 01C2                <1> 	add	edx, eax ; variable length (total)
  5387 0000A97B F7D8                <1> 	neg	eax
  5388 0000A97D 01D8                <1> 	add	eax, ebx ; start address of the variable
  5389 0000A97F F8                  <1> 	clc	; 13/04/2016
  5390 0000A980 E99EFEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5391                              <1> 
  5392                              <1> set_env_change_variable_calc9:
  5393                              <1> 	; 11/04/2016
  5394 0000A985 21D2                <1> 	and	edx, edx ; is empty ?
  5395 0000A987 753B                <1> 	jnz	short set_env_change_variable_calc15
  5396                              <1> 	
  5397 0000A989 0FB6DC              <1> 	movzx	ebx, ah
  5398 0000A98C F7DB                <1> 	neg	ebx
  5399 0000A98E 01FB                <1> 	add	ebx, edi
  5400                              <1> 
  5401                              <1> 	; EBX = Start address of the variable (in env page)
  5402                              <1> 	; EDX = Variable length = 0
  5403                              <1> 	
  5404 0000A990 89FE                <1> 	mov	esi, edi
  5405                              <1> 
  5406                              <1> set_env_change_variable_calc10:
  5407 0000A992 AC                  <1> 	lodsb
  5408 0000A993 08C0                <1> 	or	al, al
  5409 0000A995 75FB                <1> 	jnz	short set_env_change_variable_calc10
  5410                              <1> 
  5411 0000A997 B9FF310900          <1> 	mov	ecx, Env_Page + Env_Page_Size - 1
  5412                              <1> 
  5413 0000A99C 39CE                <1> 	cmp	esi, ecx ; +511 (+4095)
  5414 0000A99E 7604                <1> 	jna	short set_env_change_variable_calc11
  5415                              <1> 
  5416 0000A9A0 89CE                <1> 	mov	esi, ecx
  5417 0000A9A2 8806                <1> 	mov	[esi], al ; 0
  5418                              <1> 
  5419                              <1> set_env_change_variable_calc11:
  5420 0000A9A4 89DF                <1> 	mov	edi, ebx ; old variable's start address
  5421                              <1> 
  5422                              <1> set_env_change_variable_calc12:
  5423 0000A9A6 AC                  <1> 	lodsb
  5424 0000A9A7 AA                  <1> 	stosb
  5425 0000A9A8 20C0                <1> 	and	al, al
  5426 0000A9AA 75FA                <1> 	jnz	short set_env_change_variable_calc12
  5427 0000A9AC 39CE                <1> 	cmp	esi, ecx
  5428 0000A9AE 7706                <1> 	ja	short set_env_change_variable_calc13
  5429 0000A9B0 AC                  <1> 	lodsb
  5430 0000A9B1 AA                  <1> 	stosb
  5431 0000A9B2 20C0                <1> 	and	al, al
  5432 0000A9B4 75F0                <1> 	jnz	short set_env_change_variable_calc12	
  5433                              <1> 
  5434                              <1> set_env_change_variable_calc13:
  5435 0000A9B6 29F9                <1> 	sub	ecx, edi
  5436 0000A9B8 7203                <1> 	jb	short set_env_change_variable_calc14
  5437 0000A9BA 41                  <1> 	inc	ecx ; 1-512 (1-4096)
  5438 0000A9BB F3AA                <1> 	rep	stosb ; al = 0	
  5439                              <1> 
  5440                              <1> set_env_change_variable_calc14:
  5441 0000A9BD 29C0                <1> 	sub	eax, eax ; Start address of the variable
  5442                              <1> 	; EAX = 0 -> Variable is removed
  5443                              <1> 	; EDX = Variable length = 0	
  5444                              <1> 
  5445 0000A9BF E95FFEFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5446                              <1> 	    
  5447                              <1> set_env_change_variable_calc15:	
  5448 0000A9C4 52                  <1> 	push	edx ; *****
  5449 0000A9C5 F7DA                <1> 	neg	edx
  5450 0000A9C7 01CA                <1> 	add	edx, ecx ; difference (the old string is longer)
  5451 0000A9C9 89F3                <1> 	mov 	ebx, esi
  5452 0000A9CB 89FE                <1> 	mov	esi, edi
  5453                              <1> 
  5454                              <1> set_env_change_variable_calc16:
  5455 0000A9CD AC                  <1> 	lodsb 
  5456 0000A9CE 20C0                <1> 	and	al, al
  5457 0000A9D0 75FB                <1> 	jnz	short set_env_change_variable_calc16
  5458                              <1> 
  5459 0000A9D2 B900320900          <1> 	mov	ecx, Env_Page + Env_Page_Size
  5460                              <1> 
  5461 0000A9D7 39CE                <1> 	cmp	esi, ecx ; +512 (+4096)
  5462 0000A9D9 7605                <1> 	jna	short set_env_change_variable_calc17
  5463                              <1> 
  5464 0000A9DB 89CE                <1> 	mov	esi, ecx
  5465 0000A9DD 8846FF              <1> 	mov	[esi-1], al ; 0
  5466                              <1> 
  5467                              <1> set_env_change_variable_calc17:
  5468 0000A9E0 89F9                <1> 	mov	ecx, edi  ; current (old) variable's address
  5469 0000A9E2 89F7                <1> 	mov	edi, esi  ; next variable's address 
  5470                              <1> 
  5471 0000A9E4 AC                  <1> 	lodsb
  5472 0000A9E5 08C0                <1> 	or	al, al
  5473 0000A9E7 741D                <1> 	jz	short set_env_change_variable_calc20
  5474                              <1> 
  5475                              <1> set_env_change_variable_calc18:
  5476 0000A9E9 AC                  <1> 	lodsb
  5477 0000A9EA 20C0                <1> 	and	al, al
  5478 0000A9EC 75FB                <1> 	jnz	short set_env_change_variable_calc18
  5479                              <1> 
  5480 0000A9EE 81FE00320900        <1> 	cmp	esi, Env_Page + Env_Page_Size
  5481 0000A9F4 720B                <1> 	jb	short set_env_change_variable_calc19
  5482 0000A9F6 740E                <1> 	je	short set_env_change_variable_calc20
  5483                              <1> 
  5484 0000A9F8 BEFF310900          <1> 	mov	esi, Env_Page + Env_Page_Size - 1
  5485 0000A9FD 8806                <1> 	mov	[esi], al ; 0
  5486 0000A9FF EB06                <1> 	jmp	short set_env_change_variable_calc21
  5487                              <1> 
  5488                              <1> set_env_change_variable_calc19:
  5489 0000AA01 AC                  <1> 	lodsb
  5490 0000AA02 08C0                <1> 	or	al, al
  5491 0000AA04 75E3                <1> 	jnz	short set_env_change_variable_calc18
  5492                              <1> 
  5493                              <1> set_env_change_variable_calc20:
  5494 0000AA06 4E                  <1> 	dec	esi ; address of the second (last) 0 of the 00
  5495                              <1> 
  5496                              <1> set_env_change_variable_calc21:
  5497                              <1> 	; edx = difference (byte count)
  5498                              <1> 	
  5499 0000AA07 89C8                <1> 	mov	eax, ecx ; old variable's address (after '=')
  5500                              <1> 
  5501 0000AA09 89F1                <1> 	mov	ecx, esi 
  5502 0000AA0B 29F9                <1> 	sub	ecx, edi ; count of bytes to move backward
  5503                              <1> 
  5504 0000AA0D 89FE                <1> 	mov	esi, edi ; next variable's address
  5505 0000AA0F 29D7                <1> 	sub	edi, edx ; (displacement)
  5506                              <1> 	
  5507 0000AA11 F3A4                <1> 	rep	movsb
  5508                              <1> 
  5509 0000AA13 880F                <1> 	mov	[edi], cl ; 0 ; 00 ; end of environment variables
  5510                              <1> 
  5511 0000AA15 89C7                <1> 	mov	edi, eax
  5512 0000AA17 5A                  <1> 	pop	edx ; ***** ; byte count (after '=')
  5513 0000AA18 89D1                <1> 	mov	ecx, edx
  5514 0000AA1A 89DE                <1> 	mov	esi, ebx ; ASCIIZ string address (after '=')
  5515 0000AA1C 89FB                <1> 	mov	ebx, edi
  5516                              <1> 	
  5517 0000AA1E F3A4                <1> 	rep	movsb
  5518                              <1> 
  5519 0000AA20 880F                <1> 	mov	[edi], cl ; 0 ; end of variable
  5520                              <1> 
  5521 0000AA22 0FB605[00960100]    <1> 	movzx	eax, byte [env_var_length]
  5522 0000AA29 01C2                <1> 	add	edx, eax ; variable length (total)
  5523 0000AA2B F7D8                <1> 	neg	eax
  5524 0000AA2D 01D8                <1> 	add	eax, ebx ; start address of the variable
  5525 0000AA2F F8                  <1> 	clc	; 13/04/2016
  5526 0000AA30 E9EEFDFFFF          <1>         jmp     set_env_string_allocate_envb_retn ; OK !
  5527                              <1> 
  5528                              <1> mainprog_startup_configuration:
  5529                              <1> 	; 22/11/2017
  5530                              <1> 	; 06/05/2016
  5531                              <1> 	; 14/04/2016 (TRDOS 386 = TRDOS v2.0)
  5532                              <1> 	; 17/09/2011 (TRDOS v1, MAINPROG.ASM)
  5533                              <1> 	;
  5534                              <1> loc_load_mainprog_cfg_file:
  5535 0000AA35 BE[A9400100]        <1> 	mov	esi, MainProgCfgFile
  5536 0000AA3A 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  5537 0000AA3E E83EEAFFFF          <1> 	call	find_first_file
  5538 0000AA43 7256                <1> 	jc	short loc_load_mainprog_cfg_exit
  5539                              <1> 
  5540                              <1> 	;or	eax, eax
  5541                              <1> 	;jz	short loc_load_mainprog_cfg_exit
  5542                              <1> 
  5543                              <1> loc_start_mainprog_configuration:
  5544                              <1> 	; ESI = FindFile_DirEntry Location
  5545                              <1> 	; EAX = File Size
  5546                              <1> 
  5547 0000AA45 A3[848A0100]        <1> 	mov	[MainProgCfg_FileSize], eax
  5548                              <1> 
  5549 0000AA4A 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  5550 0000AA4E C1E210              <1> 	shl	edx, 16
  5551 0000AA51 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  5552 0000AA55 8915[B4950100]      <1> 	mov	[csftdf_sf_cluster], edx
  5553                              <1> 
  5554 0000AA5B 89C1                <1> 	mov	ecx, eax
  5555 0000AA5D 29C0                <1> 	sub	eax, eax
  5556                              <1> 
  5557                              <1> 	; TRDOS 386 (TRDOS v2.0)
  5558                              <1> 	; Allocate contiguous memory block for loading the file
  5559                              <1> 	
  5560                              <1> 	; eax = 0 (Allocate memory from the beginning)
  5561                              <1> 	; ecx = File (Allocation) size in bytes
  5562                              <1> 	
  5563 0000AA5F E819BAFFFF          <1> 	call	allocate_memory_block
  5564 0000AA64 7235                <1> 	jc	short loc_load_mainprog_cfg_exit
  5565                              <1> 
  5566 0000AA66 A3[AC950100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  5567 0000AA6B 890D[B0950100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  5568                              <1> 
  5569 0000AA71 31DB                <1> 	xor	ebx, ebx
  5570                              <1> 	;mov	[csftdf_sf_rbytes], ebx ; 0, reset
  5571                              <1> 
  5572 0000AA73 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv] ; [FindFile_Drv]
  5573 0000AA79 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  5574 0000AA7E 01DE                <1> 	add	esi, ebx
  5575                              <1> 
  5576 0000AA80 8B1D[AC950100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  5577                              <1> 
  5578 0000AA86 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  5579 0000AA8A 7710                <1>         ja	short loc_mcfg_load_fat_file
  5580                              <1> 
  5581 0000AA8C C705[BC950100]0000- <1> 	mov	dword [csftdf_r_size], 65536
  5581 0000AA94 0100                <1>
  5582 0000AA96 E9A1010000          <1>         jmp     loc_mcfg_load_fs_file
  5583                              <1> 
  5584                              <1> loc_load_mainprog_cfg_exit:
  5585 0000AA9B C3                  <1> 	retn 
  5586                              <1> 
  5587                              <1> loc_mcfg_load_fat_file:
  5588 0000AA9C 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
  5589 0000AAA0 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  5590 0000AAA4 F7E1                <1> 	mul	ecx
  5591 0000AAA6 A3[BC950100]        <1> 	mov	[csftdf_r_size], eax
  5592                              <1> 
  5593                              <1> loc_mcfg_load_fat_file_next:
  5594 0000AAAB E822010000          <1> 	call	mcfg_read_fat_file_sectors
  5595 0000AAB0 0F8206010000        <1>         jc      mcfg_deallocate_mem
  5596                              <1> 
  5597 0000AAB6 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  5598 0000AAB8 74F1                <1> 	jz	short loc_mcfg_load_fat_file_next
  5599                              <1> 
  5600                              <1> loc_mcfg_load_fat_file_ok:
  5601                              <1> 	; 06/05/2016
  5602 0000AABA C705[50960100]-     <1> 	mov	dword [mainprog_return_addr], loc_mcfg_ci_return_addr 
  5602 0000AAC0 [7DAB0000]          <1>
  5603                              <1> 	;
  5604 0000AAC4 8B35[AC950100]      <1> 	mov	esi, [csftdf_sf_mem_addr]
  5605 0000AACA 8935[888A0100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  5606                              <1> 	
  5607 0000AAD0 A1[848A0100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  5608 0000AAD5 89C2                <1> 	mov	edx, eax
  5609 0000AAD7 01F2                <1> 	add	edx, esi
  5610                              <1> 
  5611                              <1> loc_mcfg_process_next_line_check:
  5612 0000AAD9 89C1                <1> 	mov	ecx, eax
  5613                              <1> 
  5614 0000AADB 803E2A              <1> 	cmp	byte [esi], "*" ; Remark sign
  5615 0000AADE 7503                <1> 	jne	short loc_mcfg_process_next_line
  5616 0000AAE0 46                  <1> 	inc	esi
  5617 0000AAE1 EB17                <1> 	jmp	short loc_move_mainprog_cfg_nl1
  5618                              <1> 
  5619                              <1> loc_mcfg_process_next_line:
  5620 0000AAE3 83F94F              <1> 	cmp	ecx, 79
  5621 0000AAE6 7605                <1> 	jna	short loc_start_mainprog_cfg_process
  5622                              <1> 	
  5623 0000AAE8 B94F000000          <1> 	mov	ecx, 79 
  5624                              <1> 
  5625                              <1> loc_start_mainprog_cfg_process:
  5626 0000AAED BF[468B0100]        <1> 	mov	edi, CommandBuffer
  5627                              <1> 
  5628                              <1> loc_move_mainprog_cfg_line:
  5629 0000AAF2 AC                  <1> 	lodsb
  5630 0000AAF3 3C20                <1> 	cmp	al, 20h
  5631 0000AAF5 720C                <1> 	jb	short loc_move_mainprog_cfg_nl2
  5632 0000AAF7 AA                  <1> 	stosb
  5633 0000AAF8 E2F8                <1> 	loop	loc_move_mainprog_cfg_line
  5634                              <1> 
  5635                              <1> loc_move_mainprog_cfg_nl1:
  5636 0000AAFA 39D6                <1> 	cmp	esi, edx ; + configuration file size
  5637 0000AAFC 7312                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  5638 0000AAFE AC                  <1> 	lodsb
  5639 0000AAFF 3C20                <1> 	cmp	al, 20h
  5640 0000AB01 73F7                <1> 	jnb	short loc_move_mainprog_cfg_nl1
  5641                              <1> 
  5642                              <1> loc_move_mainprog_cfg_nl2:
  5643 0000AB03 39D6                <1> 	cmp	esi, edx
  5644 0000AB05 7309                <1> 	jnb	short loc_end_of_mainprog_cfg_line
  5645 0000AB07 8A06                <1> 	mov	al, [esi]
  5646 0000AB09 3C20                <1> 	cmp	al, 20h
  5647 0000AB0B 7703                <1>  	ja	short loc_end_of_mainprog_cfg_line
  5648 0000AB0D 46                  <1> 	inc	esi
  5649 0000AB0E EBF3                <1> 	jmp	short loc_move_mainprog_cfg_nl2	               
  5650                              <1> 
  5651                              <1> loc_end_of_mainprog_cfg_line:
  5652 0000AB10 C60700              <1> 	mov	byte [edi], 0
  5653                              <1> 
  5654 0000AB13 8935[888A0100]      <1> 	mov	[MainProgCfg_LineOffset], esi
  5655                              <1> 
  5656                              <1> 	; 22/11/2017
  5657 0000AB19 BE[4E8B0100]        <1> 	mov	esi, CommandBuffer + 8
  5658 0000AB1E 29FE                <1> 	sub	esi, edi
  5659 0000AB20 7606                <1> 	jna	short loc_move_mainprog_cfg_command
  5660 0000AB22 30C0                <1> 	xor	al, al
  5661                              <1> loc_mainprog_cfg_clear_chrs:
  5662 0000AB24 AA                  <1> 	stosb
  5663 0000AB25 4E                  <1> 	dec	esi
  5664 0000AB26 75FC                <1> 	jnz	short loc_mainprog_cfg_clear_chrs	
  5665                              <1> 
  5666                              <1> loc_move_mainprog_cfg_command:
  5667 0000AB28 BE[468B0100]        <1> 	mov	esi, CommandBuffer
  5668 0000AB2D 89F7                <1> 	mov	edi, esi
  5669 0000AB2F 31DB                <1> 	xor	ebx, ebx
  5670                              <1> 	;xor	ecx, ecx
  5671 0000AB31 30C9                <1> 	xor	cl, cl
  5672                              <1> 
  5673                              <1> loc_move_mcfg_first_cmd_char:
  5674 0000AB33 8A041E              <1> 	mov	al, [esi+ebx]
  5675 0000AB36 FEC3                <1> 	inc	bl 
  5676 0000AB38 3C20                <1> 	cmp	al, 20h
  5677 0000AB3A 7712                <1> 	ja	short loc_move_mcfg_cmd_capitalizing
  5678 0000AB3C 7237                <1> 	jb	short loc_move_mcfg_cmd_arguments_ok
  5679 0000AB3E 80FB4F              <1> 	cmp	bl, 79
  5680 0000AB41 72F0                <1> 	jb	short loc_move_mcfg_first_cmd_char
  5681 0000AB43 EB30                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  5682                              <1> 
  5683                              <1> loc_move_mcfg_next_cmd_char:
  5684 0000AB45 8A041E              <1> 	mov	al, [esi+ebx]
  5685 0000AB48 FEC3                <1> 	inc	bl
  5686 0000AB4A 3C20                <1> 	cmp	al, 20h
  5687 0000AB4C 7614                <1> 	jna	short loc_move_mcfg_cmd_ok
  5688                              <1> 
  5689                              <1> loc_move_mcfg_cmd_capitalizing:
  5690 0000AB4E 3C61                <1> 	cmp	al, 61h ; 'a'
  5691 0000AB50 7206                <1> 	jb	short loc_move_mcfg_cmd_caps_ok
  5692 0000AB52 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  5693 0000AB54 7702                <1> 	ja	short loc_move_mcfg_cmd_caps_ok
  5694 0000AB56 24DF                <1> 	and	al, 0DFh ; sub	al, 'a'-'A'
  5695                              <1> 
  5696                              <1> loc_move_mcfg_cmd_caps_ok:
  5697 0000AB58 AA                  <1> 	stosb 
  5698 0000AB59 FEC1                <1> 	inc	cl
  5699 0000AB5B 80FB4F              <1> 	cmp	bl, 79
  5700 0000AB5E 72E5                <1> 	jb	short loc_move_mcfg_next_cmd_char
  5701 0000AB60 EB13                <1> 	jmp	short loc_move_mcfg_cmd_arguments_ok
  5702                              <1> 
  5703                              <1> loc_move_mcfg_cmd_ok:
  5704 0000AB62 30C0                <1> 	xor	al, al ; 0
  5705                              <1> 
  5706                              <1> loc_move_mcfg_cmd_arguments:
  5707 0000AB64 8807                <1> 	mov	[edi], al
  5708 0000AB66 47                  <1> 	inc	edi
  5709 0000AB67 80FB4F              <1> 	cmp	bl, 79
  5710 0000AB6A 7309                <1> 	jnb	short loc_move_mcfg_cmd_arguments_ok
  5711 0000AB6C 8A041E              <1> 	mov	al, [esi+ebx]
  5712 0000AB6F FEC3                <1> 	inc	bl
  5713 0000AB71 3C20                <1> 	cmp	al, 20h
  5714 0000AB73 73EF                <1> 	jnb	short loc_move_mcfg_cmd_arguments
  5715                              <1> 	
  5716                              <1> loc_move_mcfg_cmd_arguments_ok:
  5717 0000AB75 C60700              <1> 	mov	byte [edi], 0
  5718                              <1>        
  5719                              <1> loc_mcfg_process_cmd_interpreter:
  5720 0000AB78 E825E0FFFF          <1> 	call    command_interpreter
  5721                              <1> 
  5722                              <1> loc_mcfg_ci_return_addr: 
  5723 0000AB7D A1[848A0100]        <1> 	mov	eax, [MainProgCfg_FileSize]
  5724 0000AB82 89C2                <1> 	mov	edx, eax
  5725 0000AB84 8B35[888A0100]      <1> 	mov	esi, [MainProgCfg_LineOffset]
  5726 0000AB8A 01F2                <1> 	add	edx, esi
  5727 0000AB8C 0305[AC950100]      <1> 	add	eax, [csftdf_sf_mem_addr]
  5728 0000AB92 29F0                <1> 	sub	eax, esi
  5729 0000AB94 0F873FFFFFFF        <1>         ja      loc_mcfg_process_next_line_check
  5730                              <1> 
  5731 0000AB9A E81D000000          <1> 	call	mcfg_deallocate_mem
  5732                              <1>  
  5733 0000AB9F B94F000000          <1>  	mov	ecx, 79 ; 80 ?
  5734 0000ABA4 BF[468B0100]        <1> 	mov	edi, CommandBuffer
  5735 0000ABA9 30C0                <1> 	xor	al, al
  5736 0000ABAB F3AA                <1> 	rep	stosb
  5737                              <1> 
  5738                              <1> 	; 06/05/2016
  5739 0000ABAD BE[FF4C0100]        <1> 	mov	esi, nextline
  5740 0000ABB2 E89EC9FFFF          <1> 	call	print_msg
  5741 0000ABB7 E963D6FFFF          <1> 	jmp	dos_prompt
  5742                              <1> 
  5743                              <1> mcfg_deallocate_mem:
  5744 0000ABBC A1[AC950100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  5745 0000ABC1 8B0D[B0950100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  5746                              <1> 	;call	deallocate_memory_block
  5747                              <1> 	;retn
  5748 0000ABC7 E9BEBAFFFF          <1> 	jmp	deallocate_memory_block
  5749                              <1> 
  5750                              <1> mcfg_read_file_sectors:
  5751                              <1> 	; 14/04/2016
  5752 0000ABCC 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  5753 0000ABD0 7669                <1>         jna	short mcfg_read_fs_file_sectors
  5754                              <1> 
  5755                              <1> mcfg_read_fat_file_sectors:
  5756                              <1> 	; return:
  5757                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  5758                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  5759                              <1> 	;   CF = 1 -> read error (error code in AL)	
  5760                              <1> 
  5761                              <1> mcfg_read_fat_file_secs_0:
  5762 0000ABD2 8B15[848A0100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  5763 0000ABD8 2B15[C4950100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  5764 0000ABDE 3B15[BC950100]      <1> 	cmp	edx, [csftdf_r_size]	
  5765 0000ABE4 7306                <1> 	jnb	short mcfg_read_fat_file_secs_1
  5766 0000ABE6 8915[BC950100]      <1> 	mov	[csftdf_r_size], edx
  5767                              <1> 		
  5768                              <1> mcfg_read_fat_file_secs_1:
  5769 0000ABEC A1[BC950100]        <1> 	mov	eax, [csftdf_r_size]
  5770 0000ABF1 29D2                <1> 	sub	edx, edx
  5771 0000ABF3 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  5772 0000ABF7 01C8                <1> 	add	eax, ecx
  5773 0000ABF9 48                  <1> 	dec	eax
  5774 0000ABFA F7F1                <1> 	div	ecx
  5775 0000ABFC 89C1                <1> 	mov	ecx, eax ; sector count
  5776 0000ABFE A1[B4950100]        <1> 	mov	eax, [csftdf_sf_cluster]
  5777                              <1> 
  5778                              <1> 	; EBX = memory block address (current)
  5779                              <1> 	
  5780 0000AC03 E88C230000          <1> 	call	read_fat_file_sectors
  5781 0000AC08 7230                <1> 	jc	short mcfg_read_fat_file_secs_3
  5782                              <1> 
  5783                              <1> 	; EBX = next memory address
  5784                              <1> 
  5785 0000AC0A A1[C4950100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  5786 0000AC0F 0305[BC950100]      <1> 	add	eax, [csftdf_r_size]
  5787 0000AC15 8B15[848A0100]      <1> 	mov	edx, [MainProgCfg_FileSize]
  5788 0000AC1B 39D0                <1> 	cmp	eax, edx
  5789 0000AC1D 731B                <1> 	jnb	short mcfg_read_fat_file_secs_3 ; edx > 0
  5790 0000AC1F A3[C4950100]        <1> 	mov	[csftdf_sf_rbytes], eax
  5791                              <1> 
  5792 0000AC24 53                  <1> 	push	ebx ; *
  5793                              <1> 	; get next cluster (csftdf_r_size! bytes)
  5794 0000AC25 A1[B4950100]        <1> 	mov	eax, [csftdf_sf_cluster]
  5795 0000AC2A E837210000          <1> 	call	get_next_cluster
  5796 0000AC2F 5B                  <1> 	pop	ebx ; *
  5797 0000AC30 7301                <1> 	jnc	short mcfg_read_fat_file_secs_2
  5798                              <1> 
  5799                              <1> 	;mov	eax, 17; Read error !
  5800 0000AC32 C3                  <1> 	retn
  5801                              <1> 
  5802                              <1> mcfg_read_fat_file_secs_2:
  5803 0000AC33 29D2                <1> 	sub	edx, edx ; 0
  5804 0000AC35 A3[B4950100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  5805                              <1> 
  5806                              <1> mcfg_read_fat_file_secs_3:
  5807 0000AC3A C3                  <1> 	retn
  5808                              <1> 
  5809                              <1> mcfg_read_fs_file_sectors:
  5810 0000AC3B C3                  <1> 	retn
  5811                              <1> 
  5812                              <1> loc_mcfg_load_fs_file:
  5813 0000AC3C C3                  <1> 	retn
  5814                              <1> 
  5815                              <1> load_and_execute_file:
  5816                              <1> 	; 04/01/2017
  5817                              <1> 	; 06/05/2016, 07/05/2016, 11/05/2016
  5818                              <1> 	; 23/04/2016, 24/04/2016
  5819                              <1> 	; 22/04/2016 (TRDOS 386 = TRDOS v2.0)
  5820                              <1> 	; 05/11/2011 
  5821                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'cmp_cmd_run', 'cmp_cmd_external')
  5822                              <1> 	; ('loc_run_check_filename')
  5823                              <1> 	; 29/08/2011
  5824                              <1> 	; 10/09/2011
  5825                              <1> 	; INPUT->
  5826                              <1> 	;	ESI = Path Name address (CommandBuffer address)
  5827                              <1> 	; OUTPUT ->
  5828                              <1> 	;	none (error message will be shown if an error will occur)
  5829                              <1> 	;
  5830                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI, EBP will be changed) 
  5831                              <1> 	;
  5832                              <1> loc_run_check_filename:
  5833 0000AC3D 803E20              <1> 	cmp	byte [esi], 20h
  5834 0000AC40 0F822BE3FFFF        <1> 	jb	loc_cmd_failed
  5835 0000AC46 7703                <1> 	ja	short loc_run_check_filename_ok
  5836 0000AC48 46                  <1> 	inc	esi
  5837 0000AC49 EBF2                <1> 	jmp	short loc_run_check_filename
  5838                              <1> 
  5839                              <1> loc_run_check_filename_ok:
  5840 0000AC4B C605[F78A0100]00    <1> 	mov	byte [CmdArgStart], 0 ; reset
  5841 0000AC52 56                  <1> 	push	esi ; *
  5842                              <1> loc_run_get_first_arg_pos:
  5843 0000AC53 46                  <1> 	inc	esi
  5844 0000AC54 8A06                <1> 	mov	al, [esi]
  5845 0000AC56 3C20                <1> 	cmp	al, 20h
  5846 0000AC58 77F9                <1> 	ja	short loc_run_get_first_arg_pos
  5847 0000AC5A C60600              <1> 	mov	byte [esi], 0
  5848                              <1> loc_run_get_external_arg_pos:
  5849                              <1> 	; 11/05/2016
  5850 0000AC5D 46                  <1> 	inc	esi
  5851 0000AC5E 8A06                <1> 	mov	al, [esi]
  5852 0000AC60 3C20                <1> 	cmp	al, 20h
  5853 0000AC62 760C                <1> 	jna	short loc_run_parse_path_name
  5854 0000AC64 89F0                <1> 	mov	eax, esi
  5855 0000AC66 2D[468B0100]        <1> 	sub	eax, CommandBuffer
  5856 0000AC6B A2[F78A0100]        <1> 	mov	byte [CmdArgStart], al
  5857                              <1> loc_run_parse_path_name:
  5858 0000AC70 5E                  <1> 	pop	esi ; *
  5859 0000AC71 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  5860 0000AC76 E8D7090000          <1> 	call	parse_path_name
  5861 0000AC7B 0F82F0E2FFFF        <1> 	jc	loc_cmd_failed
  5862                              <1> 
  5863                              <1> loc_run_check_filename_exists:
  5864 0000AC81 BE[78930100]        <1> 	mov	esi, FindFile_Name
  5865 0000AC86 803E20              <1> 	cmp	byte [esi], 20h
  5866 0000AC89 0F86E2E2FFFF        <1> 	jna	loc_cmd_failed
  5867                              <1> 
  5868                              <1> loc_run_check_exe_filename_ext:
  5869 0000AC8F E890020000          <1> 	call	check_prg_filename_ext
  5870 0000AC94 0F82D7E2FFFF        <1> 	jc	loc_cmd_failed
  5871                              <1> 	
  5872                              <1> loc_run_check_exe_filename_ext_ok:
  5873 0000AC9A 66A3[4E960100]      <1> 	mov	word [EXE_ID], ax
  5874                              <1> 
  5875                              <1> loc_run_drv:
  5876 0000ACA0 C605[4D960100]00    <1> 	mov	byte [Run_Manual_Path], 0
  5877 0000ACA7 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  5878 0000ACAC A3[48960100]        <1>         mov     [Run_CDirFC], eax
  5879                              <1> 	;
  5880 0000ACB1 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  5881 0000ACB7 8835[F2910100]      <1> 	mov	[RUN_CDRV], dh
  5882                              <1> 
  5883 0000ACBD 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  5884 0000ACC3 38F2                <1> 	cmp	dl, dh
  5885 0000ACC5 7412                <1> 	je	short loc_run_change_directory
  5886                              <1>                
  5887 0000ACC7 8005[4D960100]02    <1> 	add	byte [Run_Manual_Path], 2
  5888                              <1> 
  5889 0000ACCE E80BD4FFFF          <1> 	call	change_current_drive
  5890 0000ACD3 0F82C3E2FFFF        <1> 	jc	loc_run_cmd_failed
  5891                              <1> 
  5892                              <1> loc_run_change_directory:
  5893 0000ACD9 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  5894 0000ACE0 7623                <1> 	jna	short loc_run_find_executable_file
  5895                              <1> 
  5896 0000ACE2 FE05[4D960100]      <1> 	inc	byte [Run_Manual_Path]
  5897                              <1>      
  5898 0000ACE8 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  5899                              <1> 
  5900 0000ACEE BE[37930100]        <1> 	mov	esi, FindFile_Directory
  5901 0000ACF3 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  5902 0000ACF5 E842030000          <1> 	call	change_current_directory
  5903 0000ACFA 0F829CE2FFFF        <1> 	jc	loc_run_cmd_failed
  5904                              <1> 
  5905                              <1> loc_run_change_prompt_dir_string:
  5906 0000AD00 E857020000          <1> 	call	change_prompt_dir_string
  5907                              <1> 
  5908                              <1> loc_run_find_executable_file:
  5909 0000AD05 66C705[4C960100]00- <1> 	mov	word [Run_Auto_Path], 0
  5909 0000AD0D 00                  <1>
  5910                              <1> 
  5911                              <1> loc_run_find_executable_file_next:
  5912 0000AD0E BE[78930100]        <1> 	mov	esi, FindFile_Name
  5913                              <1> loc_run_find_program_file_next:
  5914 0000AD13 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  5915 0000AD17 E865E7FFFF          <1> 	call	find_first_file
  5916                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  5917                              <1> 	; EDI = Directory Buffer Directory Entry Location
  5918                              <1> 	; EAX = File size
  5919 0000AD1C 0F835C010000        <1> 	jnc	loc_load_and_run_file
  5920                              <1> 	 
  5921 0000AD22 3C02                <1> 	cmp	al, 2 ; file not found
  5922 0000AD24 0F8572E2FFFF        <1> 	jne	loc_run_cmd_failed
  5923                              <1> 
  5924 0000AD2A 66A1[4E960100]      <1> 	mov	ax, word [EXE_ID]
  5925 0000AD30 80FC2E              <1> 	cmp	ah, '.' ; File name has extension sign
  5926 0000AD33 7424                <1> 	je	short loc_run_check_auto_path
  5927                              <1> 
  5928 0000AD35 08C0                <1> 	or	al, al
  5929 0000AD37 7520                <1> 	jnz	short loc_run_check_auto_path
  5930                              <1> 
  5931 0000AD39 80FC08              <1> 	cmp	ah, 8 ; count of file name chars
  5932 0000AD3C 771B                <1> 	ja	short loc_run_check_auto_path
  5933                              <1> 
  5934                              <1> loc_run_change_file_ext_to_prg:
  5935 0000AD3E 0FB6DC              <1> 	movzx	ebx, ah ; count of file name chars
  5936 0000AD41 BE[78930100]        <1> 	mov	esi, FindFile_Name
  5937 0000AD46 01F3                <1> 	add	ebx, esi	
  5938                              <1> 	; 07/05/2016
  5939 0000AD48 C7032E505247        <1> 	mov	dword [ebx],  '.PRG'
  5940 0000AD4E 66C705[4E960100]50- <1> 	mov	word [EXE_ID], 'P.'
  5940 0000AD56 2E                  <1>
  5941 0000AD57 EBBA                <1> 	jmp	short loc_run_find_program_file_next	
  5942                              <1> 
  5943                              <1> loc_run_check_auto_path:
  5944                              <1> 	; NOTE: /// 07/05/2016 ///
  5945                              <1> 	; If the path is given, value of byte [Run_Manual_Path]
  5946                              <1> 	; will not be ZERO. If so, file searching by using
  5947                              <1> 	; Automatic Path (via 'PATH' environment variable)
  5948                              <1> 	; will not be applicable, because the program file 
  5949                              <1> 	; is already/absolutely not found.
  5950                              <1> 
  5951 0000AD59 A0[4D960100]        <1> 	mov	al, [Run_Manual_Path]
  5952 0000AD5E 08C0                <1> 	or	al, al
  5953 0000AD60 0F850BE2FFFF        <1> 	jnz	loc_cmd_failed
  5954                              <1> 
  5955                              <1> loc_run_check_auto_path_again:
  5956 0000AD66 66833D[4C960100]FF  <1> 	cmp	word [Run_Auto_Path], 0FFFFh		 
  5957                              <1> 		; 0FFFFh = Not a valid run path (in ENV block) 
  5958 0000AD6E 0F83FDE1FFFF        <1> 	jnb	loc_cmd_failed
  5959                              <1> 	; xor	al, al 
  5960 0000AD74 BE[2F410100]        <1> 	mov	esi, Cmd_Path ; 'PATH'
  5961 0000AD79 BF[968B0100]        <1> 	mov	edi, TextBuffer
  5962 0000AD7E E848F9FFFF          <1> 	call	get_environment_string
  5963 0000AD83 730E                <1> 	jnc	short loc_run_chk_filename_ext_again
  5964 0000AD85 66C705[4C960100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; invalid
  5964 0000AD8D FF                  <1>
  5965 0000AD8E E9DEE1FFFF          <1> 	jmp	loc_cmd_failed
  5966                              <1> 
  5967                              <1> loc_run_chk_filename_ext_again:
  5968 0000AD93 89C1                <1> 	mov	ecx, eax ; string length (with zero tail)
  5969 0000AD95 49                  <1> 	dec	ecx ; without zero tail
  5970 0000AD96 66A1[4E960100]      <1> 	mov	ax, [EXE_ID]
  5971 0000AD9C 80FC2E              <1> 	cmp	ah, '.'
  5972 0000AD9F 740E                <1> 	je	short loc_run_chk_auto_path_pos
  5973                              <1> 	 
  5974                              <1> loc_run_change_file_ext_to_noext_again:
  5975 0000ADA1 0FB6DC              <1> 	movzx	ebx, ah
  5976 0000ADA4 BE[78930100]        <1> 	mov	esi, FindFile_Name
  5977 0000ADA9 01F3                <1> 	add 	ebx, esi
  5978 0000ADAB 29C0                <1> 	sub	eax, eax
  5979 0000ADAD 8903                <1> 	mov	[ebx], eax ; 0 ; erase extension (.PRG)
  5980                              <1> 
  5981                              <1> loc_run_chk_auto_path_pos:
  5982                              <1> 	;movzx	eax,  word [Run_Auto_Path]
  5983 0000ADAF 66A1[4C960100]      <1> 	mov	ax, [Run_Auto_Path]
  5984 0000ADB5 39C8                <1> 	cmp	eax, ecx ; ecx = string length (except zero tail)
  5985 0000ADB7 0F83B4E1FFFF        <1> 	jnb	loc_cmd_failed
  5986                              <1> 	;or	eax, eax
  5987 0000ADBD 6609C0              <1> 	or	ax, ax
  5988 0000ADC0 7502                <1> 	jnz	short loc_run_auto_path_pos_move
  5989 0000ADC2 B005                <1> 	mov	al, 5
  5990                              <1> 
  5991                              <1> loc_run_auto_path_pos_move:
  5992 0000ADC4 89FE                <1> 	mov	esi, edi ; offset TextBuffer
  5993 0000ADC6 01C6                <1> 	add	esi, eax
  5994                              <1> 
  5995                              <1> loc_run_auto_path_pos_space_loop:
  5996 0000ADC8 AC                  <1> 	lodsb
  5997 0000ADC9 3C20                <1> 	cmp	al, 20h 
  5998 0000ADCB 74FB                <1> 	je	short loc_run_auto_path_pos_space_loop
  5999 0000ADCD 0F829EE1FFFF        <1> 	jb	loc_cmd_failed 
  6000 0000ADD3 AA                  <1> 	stosb
  6001                              <1> loc_run_auto_path_pos_move_next: 
  6002 0000ADD4 AC                  <1> 	lodsb
  6003 0000ADD5 3C3B                <1> 	cmp	al, ';'
  6004 0000ADD7 7414                <1> 	je	short loc_run_auto_path_pos_move_last_byte
  6005 0000ADD9 3C20                <1> 	cmp	al, 20h
  6006 0000ADDB 74F7                <1> 	je	short loc_run_auto_path_pos_move_next
  6007 0000ADDD 7203                <1> 	jb	short loc_byte_ptr_end_of_path
  6008 0000ADDF AA                  <1> 	stosb
  6009 0000ADE0 EBF2                <1> 	jmp	short loc_run_auto_path_pos_move_next 
  6010                              <1> 
  6011                              <1> loc_byte_ptr_end_of_path: 
  6012 0000ADE2 66C705[4C960100]FF- <1> 	mov	word [Run_Auto_Path], 0FFFFh ; end of path
  6012 0000ADEA FF                  <1>
  6013 0000ADEB EB0D                <1> 	jmp	short loc_run_auto_path_move_ok 
  6014                              <1> 
  6015                              <1> loc_run_auto_path_pos_move_last_byte:
  6016 0000ADED 89F0                <1> 	mov	eax, esi
  6017 0000ADEF 2D[968B0100]        <1> 	sub	eax, TextBuffer 
  6018 0000ADF4 66A3[4C960100]      <1> 	mov	[Run_Auto_Path], ax ; next path position
  6019                              <1> 
  6020                              <1> loc_run_auto_path_move_ok:
  6021 0000ADFA 4F                  <1> 	dec	edi
  6022 0000ADFB B02F                <1> 	mov	al, '/'
  6023 0000ADFD 3807                <1> 	cmp	[edi], al
  6024 0000ADFF 7403                <1> 	je	short loc_run_auto_path_move_file_name
  6025 0000AE01 47                  <1> 	inc	edi
  6026 0000AE02 8807                <1> 	mov	[edi], al
  6027                              <1> 
  6028                              <1> loc_run_auto_path_move_file_name:
  6029 0000AE04 47                  <1> 	inc	edi   
  6030 0000AE05 BE[78930100]        <1> 	mov	esi, FindFile_Name
  6031                              <1> 
  6032                              <1> loc_run_auto_path_move_fn_loop:
  6033 0000AE0A AC                  <1> 	lodsb
  6034 0000AE0B AA                  <1> 	stosb
  6035 0000AE0C 08C0                <1> 	or	al, al
  6036 0000AE0E 75FA                <1> 	jnz	short loc_run_auto_path_move_fn_loop
  6037                              <1> 
  6038 0000AE10 BE[968B0100]        <1> 	mov	esi, TextBuffer
  6039 0000AE15 BF[36930100]        <1> 	mov	edi, FindFile_Drv
  6040 0000AE1A E833080000          <1> 	call	parse_path_name
  6041 0000AE1F 0F824CE1FFFF        <1> 	jc	loc_cmd_failed
  6042                              <1> 
  6043 0000AE25 8A35[968A0100]      <1> 	mov	dh, [Current_Drv]
  6044 0000AE2B 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  6045 0000AE31 38F2                <1> 	cmp	dl, dh
  6046 0000AE33 740B                <1> 	je	short loc_run_change_directory_again
  6047                              <1>                
  6048 0000AE35 E8A4D2FFFF          <1> 	call	change_current_drive
  6049 0000AE3A 0F825CE1FFFF        <1> 	jc	loc_run_cmd_failed
  6050                              <1> 
  6051                              <1> loc_run_change_directory_again:
  6052 0000AE40 803D[37930100]20    <1> 	cmp	byte [FindFile_Directory], 20h
  6053 0000AE47 761D                <1> 	jna	short loc_load_executable_cdir_chk_again
  6054                              <1> 
  6055 0000AE49 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  6056 0000AE4F BE[37930100]        <1> 	mov	esi, FindFile_Directory
  6057 0000AE54 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  6058 0000AE56 E8E1010000          <1> 	call	change_current_directory
  6059 0000AE5B 0F823BE1FFFF        <1> 	jc	loc_run_cmd_failed
  6060                              <1> 
  6061                              <1> loc_run_chg_prompt_dir_str_again:
  6062 0000AE61 E8F6000000          <1> 	call	change_prompt_dir_string
  6063                              <1> 
  6064                              <1> loc_load_executable_cdir_chk_again:
  6065 0000AE66 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  6066 0000AE6B 3B05[48960100]      <1> 	cmp	eax, [Run_CDirFC]
  6067 0000AE71 0F8597FEFFFF        <1> 	jne	loc_run_find_executable_file_next
  6068 0000AE77 30C0                <1> 	xor	al, al ; 0
  6069 0000AE79 E9E8FEFFFF          <1> 	jmp	loc_run_check_auto_path_again
  6070                              <1> 
  6071                              <1> loc_load_and_run_file:
  6072                              <1> 	; 13/11/2017
  6073                              <1> 	; 04/01/2017
  6074                              <1> 	; 23/04/2016
  6075 0000AE7E BE[78930100]        <1> 	mov	esi, FindFile_Name
  6076 0000AE83 BF[968B0100]        <1> 	mov	edi, TextBuffer
  6077                              <1> 
  6078                              <1>  	; 24/04/2016
  6079 0000AE88 31D2                <1> 	xor	edx, edx
  6080 0000AE8A 668915[4A040300]    <1> 	mov	word [argc], dx ; 0
  6081 0000AE91 8915[8C030300]      <1> 	mov	dword [u.nread], edx ; 0
  6082                              <1> 
  6083                              <1> loc_load_and_run_file_1:
  6084 0000AE97 AC                  <1> 	lodsb	
  6085 0000AE98 AA                  <1> 	stosb
  6086 0000AE99 FF05[8C030300]      <1> 	inc	dword [u.nread]
  6087 0000AE9F 20C0                <1> 	and	al, al
  6088 0000AEA1 75F4                <1> 	jnz 	short loc_load_and_run_file_1
  6089                              <1> 	
  6090 0000AEA3 A0[F78A0100]        <1> 	mov	al, [CmdArgStart]
  6091 0000AEA8 20C0                <1> 	and	al, al
  6092 0000AEAA 7445                <1> 	jz	short loc_load_and_run_file_7
  6093                              <1> 
  6094 0000AEAC 0FB6F0              <1> 	movzx	esi, al ; 11/05/2016
  6095 0000AEAF B950000000          <1> 	mov	ecx, 80
  6096 0000AEB4 29F1                <1> 	sub	ecx, esi
  6097 0000AEB6 81C6[468B0100]      <1> 	add	esi, CommandBuffer
  6098                              <1> 
  6099 0000AEBC 66FF05[4A040300]    <1> 	inc	word [argc] ; 11/05/2016
  6100                              <1> 
  6101                              <1> loc_load_and_run_file_2:
  6102 0000AEC3 AC                  <1> 	lodsb
  6103 0000AEC4 3C20                <1> 	cmp	al, 20h
  6104 0000AEC6 7717                <1> 	ja	short loc_load_and_run_file_5	
  6105 0000AEC8 721E                <1> 	jb	short loc_load_and_run_file_6
  6106                              <1> 
  6107                              <1> loc_load_and_run_file_3:
  6108 0000AECA 803E20              <1> 	cmp	byte [esi], 20h
  6109 0000AECD 7707                <1> 	ja	short loc_load_and_run_file_4
  6110 0000AECF 7217                <1> 	jb	short loc_load_and_run_file_6
  6111 0000AED1 46                  <1> 	inc	esi
  6112 0000AED2 E2F6                <1> 	loop	loc_load_and_run_file_3
  6113 0000AED4 EB12                <1> 	jmp	short loc_load_and_run_file_6
  6114                              <1> 
  6115                              <1> loc_load_and_run_file_4:
  6116 0000AED6 28C0                <1> 	sub	al, al ; 0
  6117 0000AED8 66FF05[4A040300]    <1> 	inc	word [argc]
  6118                              <1> loc_load_and_run_file_5:
  6119 0000AEDF AA                  <1> 	stosb
  6120 0000AEE0 FF05[8C030300]      <1> 	inc	dword [u.nread]
  6121 0000AEE6 E2DB                <1> 	loop	loc_load_and_run_file_2
  6122                              <1> 			
  6123                              <1> loc_load_and_run_file_6:
  6124 0000AEE8 30C0                <1> 	xor	al, al ; 0
  6125 0000AEEA AA                  <1> 	stosb
  6126 0000AEEB FF05[8C030300]      <1> 	inc	dword [u.nread]
  6127                              <1> loc_load_and_run_file_7:
  6128 0000AEF1 8807                <1> 	mov 	[edi], al ; 0
  6129 0000AEF3 66FF05[4A040300]    <1> 	inc	word [argc] ; 24/04/2016
  6130 0000AEFA FF05[8C030300]      <1> 	inc	dword [u.nread] ; 24/04/2016
  6131 0000AF00 BE[968B0100]        <1> 	mov	esi, TextBuffer
  6132 0000AF05 8B15[A4930100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
  6133 0000AF0B 66A1[9C930100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
  6134 0000AF11 C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  6135 0000AF14 66A1[A2930100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
  6136                              <1> 	; EAX = First Cluster number
  6137                              <1> 	; EDX = File Size
  6138                              <1> 	; ESI = Argument list address
  6139                              <1> 	; [argc] = argument count
  6140                              <1> 	; [u.nread] = argument list length
  6141 0000AF1A E80A640000          <1> 	call	load_and_run_file ; trdosk6.s
  6142                              <1>         ;jc	loc_run_cmd_failed ; 04/01/2017
  6143                              <1> loc_load_and_run_file_8: ; 06/05/2016
  6144 0000AF1F E98BE9FFFF          <1> 	jmp	loc_file_rw_restore_retn
  6145                              <1> 
  6146                              <1> check_prg_filename_ext:
  6147                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
  6148                              <1> 	; 10/09/2011 
  6149                              <1> 	; (TRDOS v1, CMDINTR.ASM, 'proc_check_exe_filename_ext')
  6150                              <1> 	; 14/11/2009
  6151                              <1> 	; INPUT -> 
  6152                              <1> 	;	ESI = Dot File Name
  6153                              <1> 	; OUTPUT ->
  6154                              <1> 	;     cf = 0 -> EXE_ID in AL
  6155                              <1> 	;	ESI = Last char + 1 position
  6156                              <1> 	;     cf = 1 -> Invalid executable file name
  6157                              <1> 	;	or no file name extension if AH<=8
  6158                              <1> 	;	AL = Last file name char     
  6159                              <1> 	;     cf = 0 -> AL='P' (PRG), AL=0 (no extension)
  6160                              <1> 	;
  6161                              <1> 	; (Modified registers: EAX, ESI)
  6162                              <1>   
  6163 0000AF24 30E4                <1> 	xor	ah, ah
  6164                              <1> loc_run_check_filename_ext:	
  6165 0000AF26 AC                  <1> 	lodsb
  6166 0000AF27 3C21                <1> 	cmp	al, 21h
  6167 0000AF29 7229                <1> 	jb	short loc_check_exe_fn_retn 
  6168 0000AF2B FEC4                <1> 	inc	ah
  6169 0000AF2D 3C2E                <1> 	cmp	al, '.'
  6170 0000AF2F 75F5                <1> 	jne	short loc_run_check_filename_ext	
  6171                              <1> 		 
  6172                              <1> loc_run_check_filename_ext_dot:
  6173 0000AF31 80FC02              <1> 	cmp	ah, 2 ; .??? is not valid
  6174 0000AF34 88C4                <1> 	mov	ah, al ; '.' 
  6175 0000AF36 7219                <1> 	jb	short loc_check_prg_fn_retn
  6176                              <1> 
  6177                              <1> loc_run_check_filename_ext_dot_ok:
  6178 0000AF38 AC                  <1> 	lodsb
  6179 0000AF39 24DF                <1> 	and	al, 0DFh 
  6180                              <1> 
  6181                              <1> loc_run_check_filename_ext_prg:
  6182 0000AF3B 3C50                <1> 	cmp	al, 'P'
  6183 0000AF3D 7212                <1> 	jb	short loc_check_prg_fn_retn
  6184 0000AF3F 7711                <1> 	ja	short loc_check_prg_fn_stc
  6185 0000AF41 AC                  <1> 	lodsb
  6186 0000AF42 24DF                <1> 	and	al, 0DFh 
  6187 0000AF44 3C52                <1> 	cmp	al, 'R'
  6188 0000AF46 750A                <1> 	jne	short loc_check_prg_fn_stc
  6189 0000AF48 AC                  <1> 	lodsb
  6190 0000AF49 24DF                <1> 	and	al, 0DFh
  6191 0000AF4B 3C47                <1> 	cmp	al, 'G'
  6192 0000AF4D 7503                <1> 	jne	short loc_check_prg_fn_stc
  6193                              <1> 
  6194 0000AF4F B050                <1> 	mov	al, 'P'
  6195                              <1> loc_check_prg_fn_retn:
  6196 0000AF51 C3                  <1> 	retn
  6197                              <1> 
  6198                              <1> loc_check_prg_fn_stc:
  6199 0000AF52 F9                  <1> 	stc
  6200 0000AF53 C3                  <1> 	retn
  6201                              <1>  
  6202                              <1> loc_check_exe_fn_retn:
  6203 0000AF54 28C0                <1> 	sub	al, al ; 0
  6204 0000AF56 C3                  <1> 	retn
  6205                              <1>               
  6206                              <1> find_and_list_files:
  6207 0000AF57 C3                  <1> 	retn
  6208                              <1> set_exec_arguments:
  6209 0000AF58 C3                  <1> 	retn
  6210                              <1> delete_fs_directory:
  6211 0000AF59 31C0                <1> 	xor eax, eax
  6212 0000AF5B C3                  <1> 	retn
  3082                                  %include 'trdosk4.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - Directory Functions : trdosk4.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 29/12/2017
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; DIR.ASM (09/10/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> 
    14                              <1> ; DIR.ASM  [ TRDOS KERNEL - COMMAND EXECUTER SECTION - DIRECTORY FUNCTIONS ]
    15                              <1> ; (c) 2004-2010  Erdogan TAN  [ 17/01/2004 ]  Last Update: 09/10/2011
    16                              <1> ; FILE.ASM [ FILE FUNCTIONS ] Last Update: 09/10/2011
    17                              <1> 
    18                              <1> change_prompt_dir_string:
    19                              <1> 	; 05/10/2016
    20                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
    21                              <1> 	; 27/03/2011
    22                              <1> 	; 09/10/2009
    23                              <1> 	; INPUT/OUTPUT => none
    24                              <1> 	; this procedure changes current directory string/text  
    25                              <1> 	; 2005
    26                              <1> 
    27 0000AF5C BE[F3910100]        <1> 	mov	esi, PATH_Array
    28                              <1> change_prompt_dir_str: ; 05/10/2016 (call from 'set_working_path')
    29 0000AF61 BF[9A8A0100]        <1> 	mov	edi, Current_Directory
    30 0000AF66 8A25[948A0100]      <1> 	mov	ah, [Current_Dir_Level]
    31 0000AF6C E807000000          <1> 	call	set_current_directory_string
    32 0000AF71 880D[F58A0100]      <1> 	mov	[Current_Dir_StrLen], cl
    33                              <1> 
    34 0000AF77 C3                  <1> 	retn
    35                              <1> 
    36                              <1> set_current_directory_string:
    37                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
    38                              <1> 	; 27/03/2011
    39                              <1> 	; 09/10/2009
    40                              <1> 	; INPUT:
    41                              <1> 	;    ESI = Path Array Address 
    42                              <1> 	;    EDI = Current Directory String Buffer
    43                              <1> 	;    AH = Current Directory Level
    44                              <1> 	; OUTPUT => EAX, EBX, ESI will be changed
    45                              <1> 	;    EDI will be same with input
    46                              <1> 	;    ECX = Current Directory String Length 
    47                              <1> 
    48 0000AF78 57                  <1> 	push    edi
    49 0000AF79 80FC00              <1> 	cmp     ah, 0
    50 0000AF7C 7652                <1> 	jna	short pass_write_path
    51 0000AF7E 83C610              <1> 	add	esi, 16
    52 0000AF81 89F3                <1> 	mov	ebx, esi
    53                              <1> loc_write_path:
    54 0000AF83 B908000000          <1> 	mov	ecx, 8
    55                              <1> path_write_dirname1:
    56 0000AF88 AC                  <1> 	lodsb
    57 0000AF89 3C20                <1> 	cmp	al, 20h
    58 0000AF8B 7612                <1> 	jna	short pass_write_dirname1
    59 0000AF8D AA                  <1> 	stosb
    60 0000AF8E 81FF[F48A0100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
    61 0000AF94 733A                <1> 	jnb	short pass_write_path
    62 0000AF96 E2F0                <1> 	loop	path_write_dirname1
    63 0000AF98 803E20              <1> 	cmp	byte [esi], 20h
    64 0000AF9B 7624                <1> 	jna	short pass_write_dirname2
    65 0000AF9D EB0A                <1> 	jmp     short loc_put_dot_cont_ext
    66                              <1> pass_write_dirname1:
    67 0000AF9F 89DE                <1> 	mov	esi, ebx
    68 0000AFA1 83C608              <1> 	add	esi, 8
    69 0000AFA4 803E20              <1> 	cmp	byte [esi], 20h
    70 0000AFA7 7618                <1> 	jna	short pass_write_dirname2
    71                              <1> loc_put_dot_cont_ext:
    72 0000AFA9 C6072E              <1> 	mov	byte [edi], "."
    73                              <1> 	;mov	ecx, 3
    74 0000AFAC B103                <1> 	mov	cl, 3
    75                              <1> loc_check_dir_name_ext:
    76 0000AFAE AC                  <1> 	lodsb
    77 0000AFAF 47                  <1> 	inc	edi
    78 0000AFB0 3C20                <1> 	cmp	al, 20h
    79 0000AFB2 760D                <1> 	jna	short pass_write_dirname2
    80 0000AFB4 8807                <1> 	mov	[edi], al
    81 0000AFB6 81FF[F48A0100]      <1> 	cmp	edi, End_Of_Current_Dir_Str
    82 0000AFBC 7312                <1> 	jnb	short pass_write_path
    83 0000AFBE E2EE                <1> 	loop    loc_check_dir_name_ext
    84 0000AFC0 47                  <1> 	inc	edi
    85                              <1> pass_write_dirname2:
    86 0000AFC1 FECC                <1> 	dec	ah
    87 0000AFC3 740B                <1> 	jz      short pass_write_path
    88 0000AFC5 83C310              <1> 	add	ebx, 16
    89 0000AFC8 89DE                <1> 	mov	esi, ebx
    90 0000AFCA C6072F              <1> 	mov	byte [edi],"/"
    91 0000AFCD 47                  <1> 	inc	edi
    92 0000AFCE EBB3                <1> 	jmp	short loc_write_path
    93                              <1> pass_write_path:
    94 0000AFD0 C60700              <1> 	mov	byte [edi], 0
    95 0000AFD3 47                  <1> 	inc	edi
    96 0000AFD4 89F9                <1> 	mov	ecx, edi
    97 0000AFD6 5F                  <1> 	pop	edi
    98 0000AFD7 29F9                <1> 	sub	ecx, edi
    99                              <1> 	; ECX = Current Directory String Length
   100 0000AFD9 C3                  <1> 	retn
   101                              <1> 
   102                              <1> get_current_directory:
   103                              <1> 	; 15/10/2016
   104                              <1> 	; 14/02/2016
   105                              <1> 	; 24/01/2016 (TRDOS 386 = TRDOS v2.0)
   106                              <1> 	; 27/03/2011
   107                              <1> 	;
   108                              <1> 	; INPUT-> ESI = Current Directory Buffer
   109                              <1> 	;         DL = TRDOS Logical Dos Drive Number + 1
   110                              <1> 	;              (0= Default/Current Drive)
   111                              <1> 	;           
   112                              <1> 	;   Note: Required dir buffer length may be <= 92 bytes
   113                              <1> 	;         for TRDOS (7*12 name chars + 7 slash + 0)
   114                              <1> 	; OUTPUT ->  ESI = Current Directory Buffer
   115                              <1> 	;            EAX, EBX, ECX, EDX, EDI will be changed
   116                              <1> 	;            CX/CL = Current Directory String Length
   117                              <1> 	;	     DL = Drive Number (0 based)
   118                              <1> 	;            (If input is 0, output is current drv number) 
   119                              <1> 	;            DH = same with input 
   120                              <1> 	;   cf = 0 -> AL = 0
   121                              <1> 	;   cf = 1 -> error code in AL 
   122                              <1>               
   123                              <1> loc_get_current_drive_0:
   124 0000AFDA 80FA00              <1> 	cmp	dl, 0
   125 0000AFDD 7708                <1> 	ja	short loc_get_current_drive_1
   126 0000AFDF 8A15[968A0100]      <1> 	mov	dl, [Current_Drv]
   127 0000AFE5 EB17                <1> 	jmp	short loc_get_current_drive_2
   128                              <1> loc_get_current_drive_1:
   129 0000AFE7 FECA                <1> 	dec 	dl
   130 0000AFE9 3A15[62400100]      <1> 	cmp	dl, [Last_DOS_DiskNo]
   131 0000AFEF 760D                <1> 	jna	short loc_get_current_drive_2
   132 0000AFF1 B80F000000          <1> 	mov	eax, 0Fh ; Invalid drive (Drive not ready!)
   133 0000AFF6 F5                  <1> 	cmc 	; stc
   134 0000AFF7 C3                  <1> 	retn
   135                              <1> 
   136                              <1> loc_get_current_drive_not_ready_retn:
   137 0000AFF8 5E                  <1> 	pop	esi
   138                              <1> 	;mov	eax, 15
   139 0000AFF9 66B80F00            <1> 	mov	ax, 15 ; Drive not ready
   140 0000AFFD C3                  <1> 	retn  
   141                              <1>  
   142                              <1> loc_get_current_drive_2:
   143 0000AFFE 31C0                <1> 	xor	eax, eax
   144 0000B000 88D4                <1> 	mov	ah, dl
   145 0000B002 56                  <1> 	push	esi
   146 0000B003 BE00010900          <1> 	mov	esi, Logical_DOSDisks
   147 0000B008 01C6                <1> 	add	esi, eax
   148 0000B00A 8A06                <1> 	mov	al, [esi+LD_Name] 
   149 0000B00C 3C41                <1> 	cmp	al, 'A'
   150 0000B00E 72E8                <1> 	jb	short loc_get_current_drive_not_ready_retn
   151                              <1> 
   152 0000B010 8A667F              <1> 	mov	ah, [esi+LD_CDirLevel]
   153 0000B013 08E4                <1> 	or	ah, ah
   154 0000B015 7506                <1> 	jnz	short loc_get_current_drive_3
   155                              <1> 
   156                              <1> 	;xor	ah, ah ; mov ah, 0
   157 0000B017 8826                <1> 	mov	[esi], ah
   158 0000B019 31C9                <1> 	xor	ecx, ecx
   159 0000B01B EB1C                <1> 	jmp	short loc_get_current_drive_4
   160                              <1> 
   161                              <1> loc_get_current_drive_3:
   162 0000B01D BF[F3910100]        <1>         mov     edi, PATH_Array
   163 0000B022 57                  <1> 	push	edi
   164 0000B023 81C680000000        <1> 	add	esi, LD_CurrentDirectory
   165 0000B029 B920000000          <1> 	mov	ecx, 32
   166 0000B02E F3A5                <1> 	rep	movsd
   167 0000B030 5E                  <1> 	pop	esi ; Path Array Address
   168 0000B031 5F                  <1> 	pop	edi ; pushed esi (current dir buffer offset) 
   169                              <1> 	;
   170 0000B032 E841FFFFFF          <1> 	call	set_current_directory_string
   171 0000B037 89FE                <1> 	mov	esi, edi
   172                              <1> 
   173                              <1> loc_get_current_drive_4:
   174 0000B039 30C0                <1> 	xor	al, al
   175 0000B03B C3                  <1> 	retn
   176                              <1> 
   177                              <1> change_current_directory:
   178                              <1> 	; 19/02/2016
   179                              <1> 	; 11/02/2016
   180                              <1> 	; 10/02/2016
   181                              <1> 	; 08/02/2016
   182                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   183                              <1> 	; 18/09/2011 (DIR.ASM, 09/10/2011)	
   184                              <1> 	; 04/10/2009
   185                              <1> 	; 2005
   186                              <1> 	; INPUT -> 
   187                              <1> 	;	ESI = Directory string
   188                              <1> 	;	ah = CD command (CDh = save current dir string)
   189                              <1> 	; OUTPUT -> 
   190                              <1> 	; 	EDI = DOS Drive Description Table
   191                              <1> 	; 	cf = 1 -> error
   192                              <1> 	;	   EAX = Error code
   193                              <1> 	;	cf = 0 -> successful
   194                              <1> 	;	   ESI = PATH_Array
   195                              <1> 	;	   EAX = Current Directory First Cluster
   196                              <1> 	;
   197                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
   198                              <1> 	
   199 0000B03C 8825[81920100]      <1> 	mov	[CD_COMMAND], ah
   200 0000B042 803E2F              <1> 	cmp	byte [esi], '/'
   201 0000B045 7505                <1> 	jne	short loc_ccd_cdir_level
   202 0000B047 46                  <1> 	inc	esi
   203 0000B048 30C0                <1> 	xor	al, al
   204 0000B04A EB05                <1> 	jmp	short loc_ccd_parse_path_name
   205                              <1> loc_ccd_cdir_level:
   206 0000B04C A0[948A0100]        <1> 	mov	al, [Current_Dir_Level]
   207                              <1> loc_ccd_parse_path_name:
   208 0000B051 88C4                <1> 	mov	ah, al
   209 0000B053 BF[F3910100]        <1> 	mov	edi, PATH_Array
   210                              <1> 
   211                              <1> ; Reset directory levels > cdir level
   212                              <1> 	; is this required !?
   213                              <1> 	;
   214                              <1> 	; Relations:
   215                              <1> 	; MAINPROG.ASM (pass_ccdrv_reset_cdir_FAT_fcluster)
   216                              <1> 	; proc_parse_dir_name,
   217                              <1> 	; proc_change_current_directory (this procedure)
   218                              <1> 	; proc_change_prompt_dir_string 
   219                              <1>  
   220 0000B058 0FB6C8              <1> 	movzx	ecx, al
   221 0000B05B FEC1                <1> 	inc	cl
   222 0000B05D C0E104              <1> 	shl	cl, 4
   223 0000B060 01CF                <1> 	add	edi, ecx
   224 0000B062 B107                <1> 	mov	cl, 7
   225 0000B064 28C1                <1> 	sub	cl, al
   226 0000B066 C0E102              <1> 	shl	cl, 2
   227 0000B069 89C3                <1> 	mov	ebx, eax
   228 0000B06B 31C0                <1> 	xor	eax, eax ; 0
   229 0000B06D F3AB                <1> 	rep	stosd
   230 0000B06F 89D8                <1> 	mov	eax, ebx
   231                              <1> 
   232 0000B071 BF[F3910100]        <1> 	mov	edi, PATH_Array
   233                              <1> 
   234 0000B076 803E20              <1> 	cmp	byte [esi], 20h
   235 0000B079 F5                  <1> 	cmc
   236 0000B07A 7305                <1> 	jnc	short pass_ccd_parse_dir_name
   237                              <1> 
   238                              <1> 		; ESI = Path name
   239                              <1> 		; AL = CCD_Level
   240 0000B07C E872010000          <1>         call    parse_dir_name
   241                              <1> 		; AL = CCD_Level 
   242                              <1> 		; AH = Last_Dir_Level
   243                              <1> 		; (EDI = PATH_Array)
   244                              <1> 
   245                              <1> pass_ccd_parse_dir_name:
   246 0000B081 9C                  <1> 	pushf
   247                              <1> 
   248                              <1> 	;mov	[CCD_Level], al
   249                              <1>         ;mov	[Last_Dir_Level], ah
   250 0000B082 66A3[77920100]      <1> 	mov	[CCD_Level], ax
   251                              <1> 
   252 0000B088 31DB                <1> 	xor	ebx, ebx
   253 0000B08A 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
   254 0000B090 BE00010900          <1> 	mov	esi, Logical_DOSDisks
   255 0000B095 01DE                <1> 	add	esi, ebx
   256                              <1> 
   257 0000B097 9D                  <1> 	popf 
   258 0000B098 720A                <1> 	jc	short loc_ccd_bad_path_name_retn
   259                              <1> 
   260 0000B09A 8935[73920100]      <1> 	mov	[CCD_DriveDT], esi
   261                              <1> 
   262 0000B0A0 3C07                <1> 	cmp	al, 7
   263 0000B0A2 7209                <1> 	jb	short loc_ccd_load_child_dir
   264                              <1> 
   265                              <1> loc_ccd_bad_path_name_retn:
   266 0000B0A4 87F7                <1> 	xchg	esi, edi
   267 0000B0A6 B813000000          <1> 	mov	eax, 19 ; Bad directory/path name 
   268 0000B0AB F9                  <1> 	stc
   269                              <1> loc_ccd_retn_p:
   270 0000B0AC C3                  <1> 	retn
   271                              <1> 
   272                              <1> loc_ccd_load_child_dir:
   273                              <1> 	; AL = CCD_Level
   274 0000B0AD 08C0                <1> 	or	al, al
   275 0000B0AF 7468                <1> 	jz	short loc_ccd_load_root_dir
   276                              <1> 
   277 0000B0B1 6689C1              <1> 	mov	cx, ax
   278 0000B0B4 C0E004              <1> 	shl	al, 4
   279 0000B0B7 0FB6F0              <1> 	movzx	esi, al
   280 0000B0BA 01FE                <1>      	add	esi, edi  ; offset PATH_Array
   281                              <1> 
   282 0000B0BC 8B460C              <1> 	mov	eax, [esi+12]
   283 0000B0BF 38E9                <1> 	cmp	cl, ch
   284 0000B0C1 0F84FA000000        <1>         je      loc_ccd_load_sub_directory
   285 0000B0C7 A3[908A0100]        <1> 	mov	[Current_Dir_FCluster], eax
   286                              <1> 
   287                              <1> loc_ccd_load_child_dir_next:
   288 0000B0CC 83C610              <1> 	add	esi, 16 ; DOS DirEntry Format FileName Address
   289                              <1> 
   290                              <1>  	; Directory attribute : 10h
   291 0000B0CF B010                <1> 	mov	al, 00010000b ; 10h (Attrib AND mask)
   292                              <1> 	;mov	ah, 11001000b ; C8h
   293                              <1> 	; Volume name attribute: 8h
   294 0000B0D1 B408                <1> 	mov	ah, 00001000b ; 08h (Attrib NAND, AND --> zero mask)
   295                              <1> 
   296 0000B0D3 6631C9              <1> 	xor	cx, cx  
   297 0000B0D6 E8B5010000          <1> 	call	locate_current_dir_file
   298 0000B0DB 7353                <1> 	jnc	short loc_ccd_set_dir_cluster_ptr
   299                              <1> 
   300                              <1> 	 ; 19/02/2016
   301                              <1> 	;mov	edi, [CCD_DriveDT]
   302 0000B0DD 8A25[77920100]      <1> 	mov	ah, [CCD_Level]
   303 0000B0E3 803D[81920100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
   304 0000B0EA 7509                <1> 	jne	short loc_ccd_load_child_dir_err
   305                              <1> 	; It is better to save recent successful part 
   306                              <1> 	; of the (requested) path as current directory.
   307                              <1> 	; (Otherwise the path would be reset to back
   308                              <1> 	; on the next 'CD' command.)
   309 0000B0EC 88E1                <1> 	mov	cl, ah
   310 0000B0EE 50                  <1> 	push	eax
   311 0000B0EF E8E3000000          <1> 	call	loc_ccd_save_current_dir
   312 0000B0F4 58                  <1> 	pop	eax
   313                              <1> loc_ccd_load_child_dir_err:            
   314 0000B0F5 3C03                <1> 	cmp	al, 3	; AL = 2 => File not found error
   315 0000B0F7 7202                <1> 	jb	short loc_ccd_path_not_found_retn
   316 0000B0F9 F9                  <1> 	stc
   317 0000B0FA C3                  <1> 	retn
   318                              <1> 
   319                              <1> loc_ccd_path_not_found_retn:
   320 0000B0FB B003                <1> 	mov	al, 3	; Path not found
   321 0000B0FD C3                  <1> 	retn
   322                              <1> 
   323                              <1> loc_ccd_load_FAT_root_dir:
   324 0000B0FE 803D[958A0100]02    <1> 	cmp	byte [Current_FATType], 2
   325 0000B105 776B                <1> 	ja	short loc_ccd_load_FAT32_root_dir
   326                              <1> 
   327                              <1> 	;mov	esi, [CCD_DriveDT]
   328                              <1> 	;push	esi
   329 0000B107 E8B51D0000          <1> 	call	load_FAT_root_directory
   330                              <1> 	;pop	edi ; Dos Drv Description Table
   331                              <1> 
   332 0000B10C 89F7                <1> 	mov	edi, esi
   333 0000B10E BE[F3910100]        <1> 	mov	esi, PATH_Array
   334 0000B113 7297                <1> 	jc	short loc_ccd_retn_p
   335                              <1> 
   336 0000B115 31C0                <1> 	xor	eax, eax
   337 0000B117 EB78                <1>         jmp	short loc_ccd_set_cdfc
   338                              <1> 
   339                              <1> loc_ccd_load_root_dir:
   340 0000B119 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
   341 0000B120 73DC                <1> 	jnb	short loc_ccd_load_FAT_root_dir
   342                              <1> 
   343                              <1> loc_ccd_load_FS_root_dir:
   344 0000B122 E8611E0000          <1> 	call	load_FS_root_directory
   345 0000B127 EB5C                <1> 	jmp	short pass_ccd_load_FAT_sub_directory
   346                              <1> 
   347                              <1> loc_ccd_load_FS_sub_directory_next:
   348 0000B129 E85B1E0000          <1> 	call	load_FS_sub_directory
   349 0000B12E EB1F                <1> 	jmp	short pass_ccd_set_dir_cluster_ptr  
   350                              <1> 
   351                              <1> loc_ccd_set_dir_cluster_ptr:
   352                              <1> 	; EDI = Directory Entry
   353 0000B130 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
   354 0000B134 C1E010              <1> 	shl	eax, 16
   355 0000B137 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
   356                              <1> 
   357 0000B13B 8B35[73920100]      <1> 	mov	esi, [CCD_DriveDT]
   358 0000B141 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
   359 0000B148 72DF                <1> 	jb	short loc_ccd_load_FS_sub_directory_next
   360                              <1> 	;push	esi
   361 0000B14A E8FD1D0000          <1> 	call	load_FAT_sub_directory
   362                              <1> 	;pop	edi ; Dos Drv Description Table
   363                              <1> 
   364                              <1> pass_ccd_set_dir_cluster_ptr:
   365                              <1> 	;mov	edi, esi
   366 0000B14F BE[F3910100]        <1> 	mov	esi, PATH_Array
   367 0000B154 7264                <1> 	jc	short loc_ccd_retn_c
   368                              <1> 
   369 0000B156 A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
   370                              <1> 
   371 0000B15B FE05[77920100]      <1> 	inc	byte [CCD_Level]
   372 0000B161 0FB61D[77920100]    <1> 	movzx	ebx, byte [CCD_Level]
   373 0000B168 C0E304              <1> 	shl	bl, 4 ; * 16 (<= 128)   
   374 0000B16B 01DE                <1> 	add	esi, ebx ; 19/02/2016
   375 0000B16D 89460C              <1> 	mov	[esi+12], eax
   376 0000B170 EB1F                <1> 	jmp	short loc_ccd_set_cdfc
   377                              <1> 
   378                              <1> loc_ccd_load_FAT32_root_dir:
   379 0000B172 BE[F3910100]        <1> 	mov	esi, PATH_Array
   380 0000B177 8B460C              <1> 	mov	eax, [esi+12]
   381 0000B17A 8B35[73920100]      <1> 	mov	esi, [CCD_DriveDT]
   382                              <1>  
   383                              <1> loc_ccd_load_FAT_sub_directory:
   384                              <1> 	;push	esi
   385 0000B180 E8C71D0000          <1> 	call	load_FAT_sub_directory
   386                              <1> 	;pop	edi ; Dos Drv Description Table
   387                              <1> 
   388                              <1> pass_ccd_load_FAT_sub_directory:
   389                              <1> 	;mov	edi, esi
   390 0000B185 BE[F3910100]        <1> 	mov	esi, PATH_Array
   391 0000B18A 722E                <1> 	jc	short loc_ccd_retn_c
   392                              <1> 
   393 0000B18C A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
   394                              <1> 
   395                              <1> loc_ccd_set_cdfc:
   396 0000B191 8A0D[77920100]      <1> 	mov	cl, [CCD_Level]
   397 0000B197 880D[948A0100]      <1> 	mov	[Current_Dir_Level], cl
   398 0000B19D A3[908A0100]        <1> 	mov	[Current_Dir_FCluster], eax
   399                              <1> 
   400 0000B1A2 8A2D[78920100]      <1> 	mov	ch, [Last_Dir_Level]
   401 0000B1A8 38E9                <1> 	cmp	cl, ch 
   402 0000B1AA 0F821CFFFFFF        <1> 	jb	loc_ccd_load_child_dir_next
   403                              <1> 	
   404 0000B1B0 803D[81920100]CD    <1> 	cmp	byte [CD_COMMAND], 0CDh ;'CD' command or another
   405 0000B1B7 741E                <1> 	je	short loc_ccd_save_current_dir
   406                              <1> 
   407                              <1>         ; jne -> don't save, restore (the previous cdir) later !
   408                              <1>         ; (saving the cdir would prevent previous cdir restoration!)
   409                              <1> 
   410 0000B1B9 F8                  <1> 	clc
   411                              <1> 
   412                              <1> loc_ccd_retn_c:
   413 0000B1BA 8B3D[73920100]      <1> 	mov	edi, [CCD_DriveDT]
   414 0000B1C0 C3                  <1> 	retn
   415                              <1> 
   416                              <1> loc_ccd_load_sub_directory:
   417 0000B1C1 8B35[73920100]      <1> 	mov	esi, [CCD_DriveDT]
   418 0000B1C7 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
   419 0000B1CE 73B0                <1> 	jnb	short loc_ccd_load_FAT_sub_directory 
   420 0000B1D0 E8B41D0000          <1> 	call	load_FS_sub_directory
   421 0000B1D5 EBAE                <1> 	jmp	short pass_ccd_load_FAT_sub_directory 
   422                              <1> 
   423                              <1> loc_ccd_save_current_dir:
   424 0000B1D7 BE[F3910100]        <1> 	mov	esi, PATH_Array ; 19/02/2016
   425 0000B1DC 8B3D[73920100]      <1> 	mov	edi, [CCD_DriveDT]
   426 0000B1E2 57                  <1> 	push	edi
   427 0000B1E3 83C77F              <1>         add     edi, LD_CDirLevel
   428 0000B1E6 880F                <1> 	mov	[edi], cl
   429 0000B1E8 47                  <1> 	inc	edi ; LD_CurrentDirectory 
   430 0000B1E9 56                  <1> 	push	esi
   431                              <1> 	;mov	ecx, 32  ; always < 65536 (in this procedure)
   432 0000B1EA 66B92000            <1> 	mov	cx, 32
   433 0000B1EE F3A5                <1> 	rep	movsd
   434                              <1> 	; Current directory has been saved to 
   435                              <1> 	; the DOS drive description table, cdir area !
   436 0000B1F0 5E                  <1> 	pop	esi  ; PATH_Array
   437 0000B1F1 5F                  <1> 	pop	edi  ; Dos Drv Description Table
   438                              <1> 
   439 0000B1F2 C3                  <1> 	retn
   440                              <1> 
   441                              <1> parse_dir_name:
   442                              <1> 	; 11/02/2016
   443                              <1> 	; 10/02/2016
   444                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
   445                              <1> 	; 18/09/2011
   446                              <1> 	; 17/10/2009
   447                              <1> 	; INPUT ->
   448                              <1> 	;	ESI = ASCIIZ Directory String Address
   449                              <1> 	;	AL = Current Directory Level
   450                              <1> 	;	EDI = Destination Adress
   451                              <1> 	;	     (8 levels, each one 12+4 byte)
   452                              <1> 	; OUTPUT ->
   453                              <1> 	;	EDI = Dir Entry Formatted Array
   454                              <1> 	;	     with zero cluster pointer at the last level
   455                              <1> 	;	AH = Last Dir Level
   456                              <1> 	;	AL = Current Dir Level
   457                              <1> 	;
   458                              <1> 	; (esi, ebx, ecx will be changed) 
   459                              <1> 
   460                              <1> 	;mov	[PATH_Array_Ptr], edi
   461 0000B1F3 88C4                <1> 	mov	ah, al
   462 0000B1F5 66A3[18930100]      <1> 	mov	[PATH_CDLevel], ax
   463                              <1> repeat_ppdn_check_slash:
   464 0000B1FB AC                  <1> 	lodsb
   465 0000B1FC 3C2F                <1> 	cmp	al, '/'
   466 0000B1FE 74FB                <1> 	je	short repeat_ppdn_check_slash
   467 0000B200 3C21                <1> 	cmp	al, 21h
   468 0000B202 7219                <1> 	jb	short loc_ppdn_retn
   469 0000B204 57                  <1> 	push	edi
   470                              <1> loc_ppdn_get_dir_name:
   471 0000B205 B90C000000          <1> 	mov	ecx, 12
   472 0000B20A BF[1A930100]        <1> 	mov	edi, Dir_File_Name
   473                              <1> repeat_ppdn_get_dir_name:
   474 0000B20F AA                  <1> 	stosb
   475 0000B210 AC                  <1> 	lodsb
   476 0000B211 3C2F                <1> 	cmp	al, '/'
   477 0000B213 740A                <1> 	je	short loc_check_level_dot_conv_dir_name
   478 0000B215 3C20                <1> 	cmp	al, 20h
   479 0000B217 7605                <1> 	jna	short loc_ppdn_end_of_path_scan
   480 0000B219 E2F4                <1> 	loop	repeat_ppdn_get_dir_name
   481 0000B21B 5F                  <1> 	pop	edi
   482 0000B21C F9                  <1> 	stc
   483                              <1> loc_ppdn_retn:
   484 0000B21D C3                  <1> 	retn
   485                              <1> 
   486                              <1> loc_ppdn_end_of_path_scan:
   487 0000B21E 4E                  <1> 	dec	esi
   488                              <1> loc_check_level_dot_conv_dir_name:
   489 0000B21F 31C0                <1> 	xor	eax, eax
   490 0000B221 AA                  <1> 	stosb
   491 0000B222 89F3                <1> 	mov	ebx, esi
   492 0000B224 BE[1A930100]        <1> 	mov	esi, Dir_File_Name
   493 0000B229 AC                  <1> 	lodsb
   494                              <1> repeat_ppdn_name_check_dot:
   495 0000B22A 3C2E                <1> 	cmp	al, '.'
   496 0000B22C 7509                <1> 	jne	short loc_ppdn_convert_sub_dir_name
   497                              <1> repeat_ppdn_name_dot_dot:
   498 0000B22E AC                  <1> 	lodsb
   499 0000B22F 3C2E                <1> 	cmp	al, '.'
   500 0000B231 743E                <1> 	je	short loc_ppdn_dot_dot
   501 0000B233 3C21                <1> 	cmp	al, 21h
   502 0000B235 7226                <1> 	jb	short pass_ppdn_convert_sub_dir_name
   503                              <1> loc_ppdn_convert_sub_dir_name:
   504 0000B237 8A25[19930100]      <1> 	mov	ah, [PATH_Level]
   505 0000B23D 80FC07              <1> 	cmp	ah, 7
   506 0000B240 731B                <1> 	jnb	short pass_ppdn_convert_sub_dir_name
   507 0000B242 FEC4                <1> 	inc	ah  
   508 0000B244 8825[19930100]      <1> 	mov	[PATH_Level], ah
   509 0000B24A BE[1A930100]        <1> 	mov	esi, Dir_File_Name
   510                              <1> 	;mov	edi, [PATH_Array_Ptr]
   511 0000B24F B010                <1> 	mov	al, 16
   512 0000B251 F6E4                <1> 	mul	ah
   513 0000B253 8B3C24              <1> 	mov	edi, [esp]
   514                              <1> 	;push	edi 
   515 0000B256 01C7                <1> 	add	edi, eax
   516 0000B258 E82A030000          <1> 	call	convert_file_name
   517                              <1> 	;pop	edi
   518                              <1> pass_ppdn_convert_sub_dir_name:
   519 0000B25D 89DE                <1> 	mov	esi, ebx
   520                              <1> repeat_ppdn_check_last_slash:
   521 0000B25F AC                  <1> 	lodsb
   522 0000B260 3C2F                <1> 	cmp	al, '/'
   523 0000B262 74FB                <1> 	je	short repeat_ppdn_check_last_slash
   524 0000B264 3C21                <1> 	cmp	al, 21h
   525 0000B266 739D                <1> 	jnb	short loc_ppdn_get_dir_name
   526                              <1> end_of_parse_dir_name:
   527 0000B268 5F                  <1> 	pop	edi
   528 0000B269 F5                  <1> 	cmc  
   529                              <1> 	;mov	al, [PATH_CDLevel]
   530                              <1> 	;mov	ah, [PATH_Level]
   531 0000B26A 66A1[18930100]      <1> 	mov	ax, [PATH_CDLevel]
   532 0000B270 C3                  <1> 	retn
   533                              <1> 
   534                              <1> loc_ppdn_dot_dot:
   535 0000B271 AC                  <1> 	lodsb
   536 0000B272 3C21                <1> 	cmp	al, 21h
   537 0000B274 73F2                <1> 	jnb	short end_of_parse_dir_name 
   538                              <1> loc_ppdn_dot_dot_prev_level:
   539 0000B276 66A1[18930100]      <1> 	mov	ax, [PATH_CDLevel]
   540 0000B27C 80EC01              <1> 	sub	ah, 1
   541 0000B27F 80D400              <1> 	adc	ah, 0
   542 0000B282 38E0                <1> 	cmp	al, ah
   543 0000B284 7602                <1> 	jna	short pass_ppdn_set_al_to_ah
   544 0000B286 88E0                <1> 	mov	al, ah
   545                              <1> pass_ppdn_set_al_to_ah:
   546 0000B288 66A3[18930100]      <1> 	mov	[PATH_CDLevel], ax
   547 0000B28E EBCD                <1> 	jmp	short pass_ppdn_convert_sub_dir_name
   548                              <1> 
   549                              <1> locate_current_dir_file:
   550                              <1> 	; 20/11/2017
   551                              <1> 	; 14/02/2016
   552                              <1> 	; 13/02/2016
   553                              <1> 	; 10/02/2016
   554                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   555                              <1> 	; 14/08/2010
   556                              <1> 	; 19/09/2009
   557                              <1>         ; 2005
   558                              <1> 	; INPUT ->
   559                              <1> 	;	ESI = DOS DirEntry Format FileName Address
   560                              <1> 	;	AL = Attributes Mask 
   561                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
   562                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
   563                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
   564                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
   565                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
   566                              <1> 	;	CL = E5h -> Return the 1st deleted entry
   567                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
   568                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
   569                              <1> 	;	     proper entry (which fits with Atributes Masks)
   570                              <1> 	;	CX = 0 Find Valid File/Directory/VolumeName
   571                              <1> 	;	? = Any One Char
   572                              <1> 	;	* = Every Chars
   573                              <1> 	; OUTPUT ->
   574                              <1> 	;	EDI = Directory Entry Address (in Directory Buffer)
   575                              <1> 	;	ESI = DOS DirEntry Format FileName Address
   576                              <1> 	;	CF = 0 -> No Error, Proper Entry,
   577                              <1> 	;	DL = Attributes
   578                              <1> 	;	DH = Previous Entry Attr (LongName Check)
   579                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
   580                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
   581                              <1> 	;	AX = 0 -> Filename full fits with directory entry
   582                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
   583                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in EAX/AL
   584                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
   585                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
   586                              <1> 	;	CL > 0 -> Entry not found, CH invalid
   587                              <1> 	;	CF = 0 -> 
   588                              <1> 	;	EBX = Current Directory Entry Index/Number (BX)
   589                              <1> 
   590                              <1> 	;mov	word [DirBuff_EntryCounter], 0 ; Zero Based
   591                              <1> 
   592 0000B290 8935[7B920100]      <1> 	mov	[CDLF_FNAddress], esi
   593 0000B296 66A3[79920100]      <1> 	mov	[CDLF_AttributesMask], ax
   594 0000B29C 66890D[7F920100]    <1> 	mov	[CDLF_DEType], cx
   595                              <1> 
   596 0000B2A3 31DB                <1> 	xor	ebx, ebx
   597 0000B2A5 881D[90920100]      <1> 	mov	[PreviousAttr], bl ; 0  ; 13/02/2016
   598                              <1> 
   599 0000B2AB 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
   600 0000B2B1 381D[BC910100]      <1> 	cmp	byte [DirBuff_ValidData], bl ; 0
   601 0000B2B7 761D                <1> 	jna	short loc_lcdf_reload_current_dir2
   602 0000B2B9 8A1D[BA910100]      <1>         mov     bl, [DirBuff_DRV]
   603 0000B2BF 80EB41              <1> 	sub	bl, 'A'
   604 0000B2C2 38DF                <1> 	cmp	bh, bl
   605 0000B2C4 750E                <1> 	jne	short loc_lcdf_reload_current_dir1
   606 0000B2C6 8B15[C1910100]      <1> 	mov	edx, [DirBuff_Cluster]
   607 0000B2CC 3B15[908A0100]      <1> 	cmp	edx, [Current_Dir_FCluster]
   608 0000B2D2 7412                <1> 	je	short loc_cdir_locatefile_search
   609                              <1> 
   610                              <1> loc_lcdf_reload_current_dir1:
   611 0000B2D4 30DB                <1> 	xor	bl, bl
   612                              <1> loc_lcdf_reload_current_dir2:
   613 0000B2D6 89DE                <1> 	mov	esi, ebx
   614 0000B2D8 81C600010900        <1>         add     esi, Logical_DOSDisks
   615 0000B2DE E874000000          <1> 	call	reload_current_directory 
   616 0000B2E3 735D                <1> 	jnc	short loc_locatefile_search_again 
   617 0000B2E5 C3                  <1> 	retn  
   618                              <1> 
   619                              <1> loc_cdir_locatefile_search:
   620 0000B2E6 31DB                <1> 	xor	ebx, ebx
   621 0000B2E8 55                  <1> 	push	ebp ; 20/11/2017
   622 0000B2E9 E8A6000000          <1> 	call	find_directory_entry
   623 0000B2EE 5D                  <1> 	pop	ebp ; 20/11/2017
   624 0000B2EF 7349                <1> 	jnc	short loc_cdir_locate_file_retn
   625                              <1> 
   626                              <1> loc_locatefile_check_stc_reason:
   627 0000B2F1 08ED                <1> 	or	ch, ch
   628 0000B2F3 7444                <1> 	jz	short loc_cdir_locate_file_stc_retn
   629                              <1> 
   630                              <1> loc_locatefile_check_next_entryblock:
   631 0000B2F5 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
   632 0000B2FB 28DB                <1> 	sub	bl, bl
   633 0000B2FD 0FB7F3              <1> 	movzx	esi, bx
   634 0000B300 81C600010900        <1>         add     esi, Logical_DOSDisks
   635                              <1> 
   636 0000B306 803D[948A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0
   637 0000B30D 760A                <1> 	jna	short loc_locatefile_check_FAT_type
   638                              <1>             
   639 0000B30F 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
   640 0000B316 730A                <1> 	jnb	short loc_locatefile_load_subdir_cluster
   641 0000B318 C3                  <1> 	retn  
   642                              <1> 
   643                              <1> loc_locatefile_check_FAT_type:
   644 0000B319 803D[958A0100]03    <1> 	cmp	byte [Current_FATType], 3
   645 0000B320 7218                <1> 	jb	short loc_cdir_locate_file_retn
   646                              <1> 
   647                              <1> loc_locatefile_load_subdir_cluster:
   648 0000B322 A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
   649 0000B327 E83A1A0000          <1> 	call	get_next_cluster
   650 0000B32C 730D                <1> 	jnc	short loc_locatefile_next_cluster
   651 0000B32E 09C0                <1> 	or	eax, eax
   652 0000B330 7507                <1> 	jnz	short loc_locatefile_drive_not_ready_read_err
   653 0000B332 F9                  <1> 	stc
   654                              <1> loc_locatefile_file_notfound:
   655 0000B333 B802000000          <1> 	mov	eax, 2 ; File/Directory/VolName not found
   656 0000B338 C3                  <1> 	retn
   657                              <1> 
   658                              <1> loc_locatefile_drive_not_ready_read_err:
   659                              <1> 	;mov	eax, 17 ;Drive not ready or read error
   660                              <1> loc_cdir_locate_file_stc_retn:
   661 0000B339 F5                  <1> 	cmc ;stc
   662                              <1> loc_cdir_locate_file_retn:
   663 0000B33A C3                  <1> 	retn
   664                              <1> 
   665                              <1> loc_locatefile_next_cluster:
   666 0000B33B E80C1C0000          <1> 	call	load_FAT_sub_directory
   667                              <1> 	;jc	short loc_locatefile_drive_not_ready_read_err
   668 0000B340 72F8                <1> 	jc	short loc_cdir_locate_file_retn 
   669                              <1> 
   670                              <1> loc_locatefile_search_again:
   671 0000B342 8B35[7B920100]      <1> 	mov	esi, [CDLF_FNAddress] 
   672 0000B348 66A1[79920100]      <1> 	mov	ax, [CDLF_AttributesMask]
   673 0000B34E 668B0D[7F920100]    <1> 	mov	cx, [CDLF_DEType] 
   674 0000B355 EB8F                <1> 	jmp	short loc_cdir_locatefile_search
   675                              <1> 
   676                              <1> reload_current_directory:
   677                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   678                              <1> 	; 13/06/2010
   679                              <1> 	; 22/09/2009
   680                              <1>         ;
   681                              <1> 	; INPUT ->
   682                              <1> 	;	ESI = Dos drive description table address
   683                              <1> 	
   684                              <1> 	;mov	al, [esi+LD_FATType]
   685 0000B357 A0[958A0100]        <1> 	mov	al, [Current_FATType]
   686 0000B35C 3C02                <1> 	cmp	al, 2
   687 0000B35E 7729                <1> 	ja	short loc_reload_FAT_sub_directory
   688 0000B360 8A25[948A0100]      <1> 	mov	ah, [Current_Dir_Level]
   689 0000B366 08C0                <1> 	or	al, al
   690 0000B368 740A                <1> 	jz	short loc_reload_FS_directory
   691 0000B36A 08E4                <1> 	or	ah, ah
   692 0000B36C 751B                <1> 	jnz	short loc_reload_FAT_sub_directory
   693                              <1> loc_reload_FAT_12_16_root_directory:
   694 0000B36E E84E1B0000          <1> 	call	load_FAT_root_directory
   695 0000B373 C3                  <1> 	retn
   696                              <1> loc_reload_FS_directory:
   697 0000B374 20E4                <1> 	and	ah, ah
   698 0000B376 7506                <1> 	jnz	short loc_reload_FS_sub_directory 
   699                              <1> loc_reload_FS_root_directory: 
   700 0000B378 E80B1C0000          <1> 	call	load_FS_root_directory
   701 0000B37D C3                  <1> 	retn
   702                              <1> loc_reload_FS_sub_directory:
   703 0000B37E A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
   704 0000B383 E8011C0000          <1> 	call	load_FS_sub_directory
   705 0000B388 C3                  <1> 	retn 
   706                              <1> loc_reload_FAT_sub_directory:
   707 0000B389 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
   708 0000B38E E8B91B0000          <1> 	call	load_FAT_sub_directory
   709 0000B393 C3                  <1> 	retn
   710                              <1> 
   711                              <1> find_directory_entry:
   712                              <1> 	; 14/02/2016
   713                              <1> 	; 13/02/2016
   714                              <1> 	; 10/02/2016
   715                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
   716                              <1> 	; 14/08/2010 (DIR.ASM, "proc_find_direntry")
   717                              <1> 	; 19/09/2009
   718                              <1> 	; 2005
   719                              <1> 	; INPUT ->
   720                              <1> 	;	ESI = Sub Dir or File Name Address
   721                              <1> 	;	AL = Attributes Mask 
   722                              <1> 	;	(<AL AND EntryAttrib> must be equal to AL)
   723                              <1> 	;	AH = Negative Attributes Mask (If AH>0)
   724                              <1> 	;	(<AH AND EntryAttrib> must be ZERO)
   725                              <1> 	;	CH > 0 Find First Free Dir Entry or Deleted Entry
   726                              <1> 	;	CL = 0 -> Return the First Free Dir Entry
   727                              <1> 	;	CL = E5h -> Return the 1st deleted entry
   728                              <1> 	;	CL = FFh -> Return the 1st deleted or free entry
   729                              <1> 	;	CL > 0 and CL <> E5h and CL <> FFh -> Return the first 
   730                              <1> 	;            proper entry (which fits with Atributes Masks)
   731                              <1> 	;	CX = 0 -> Find Valid File/Directory/VolumeName
   732                              <1> 	;	? = Any One Char
   733                              <1> 	;	* = Every Chars
   734                              <1> 	;	EBX = Current Dir Entry (BX)
   735                              <1> 	;
   736                              <1> 	; OUTPUT -> 
   737                              <1> 	;	EDI = Directory Entry Address (in DirectoryBuffer)
   738                              <1> 	;	ESI = Sub Dir or File Name Address
   739                              <1> 	;	CF = 0 -> No Error, Proper Entry,
   740                              <1> 	;	DL = Attributes
   741                              <1> 	;	DH = Previous Entry Attr (LongName Check)
   742                              <1> 	;	AL > 0 -> Ambiguous filename wildcard "?" used
   743                              <1> 	;	AH > 0 -> Ambiguous filename wildcard "*" used
   744                              <1> 	;	AX = 0 -> Filename full fits with directory entry
   745                              <1> 	;	EBX = CurrentDirEntry (BX)
   746                              <1> 	;	CH = The 1st Name Char of Current Dir Entry
   747                              <1> 	;	CF = 1 -> Proper entry not found, Error Code in AX/AL
   748                              <1> 	;	CL = 0 and CH = 0 -> Free Entry (End Of Dir)
   749                              <1> 	;	CL = 0 and CH = E5h -> Deleted Entry fits with filters
   750                              <1> 	;	CL > 0 -> Entry not found, CH invalid
   751                              <1> 	;
   752                              <1> 	; (EAX, EBX, ECX, EDX, EDI, EBP will be changed)	 
   753                              <1> 
   754 0000B394 663B1D[BF910100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   755 0000B39B 0F8739010000        <1>         ja      loc_ffde_stc_retn_255
   756                              <1> 
   757                              <1> 	;mov    [DirBuff_CurrentEntry], bx  
   758                              <1> 
   759 0000B3A1 BF00000800          <1>   	mov	edi, Directory_Buffer
   760 0000B3A6 66A3[8C920100]      <1> 	mov	[FDE_AttrMask], ax
   761                              <1> 
   762 0000B3AC 29C0                <1> 	sub	eax, eax
   763                              <1>             
   764                              <1> 	;;mov	[PreviousAttr], al ; 0 ;; 13/02/2016
   765 0000B3AE 66A3[8E920100]      <1> 	mov	[AmbiguousFileName], ax ; 0
   766                              <1> 
   767 0000B3B4 6689D8              <1> 	mov	ax, bx
   768 0000B3B7 66C1E005            <1> 	shl	ax, 5 ; ; * 32 ; Directory entry size
   769 0000B3BB 01C7                <1> 	add     edi, eax
   770                              <1> 
   771 0000B3BD 08ED                <1> 	or	ch, ch
   772 0000B3BF 0F852C010000        <1>         jnz     loc_find_free_deleted_entry_0
   773                              <1> 
   774 0000B3C5 08C9                <1> 	or      cl, cl
   775 0000B3C7 0F850D010000        <1>         jnz     loc_ffde_stc_retn_255
   776                              <1>  
   777                              <1> check_find_dir_entry:
   778 0000B3CD 66A1[8C920100]      <1> 	mov	ax, [FDE_AttrMask]
   779 0000B3D3 8A2F                <1> 	mov	ch, [edi]
   780 0000B3D5 80FD00              <1> 	cmp     ch, 0 ; Is it never used entry?
   781 0000B3D8 0F86FF000000        <1> 	jna	loc_find_direntry_stc_retn 
   782 0000B3DE 56                  <1> 	push	esi
   783 0000B3DF 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
   784 0000B3E2 80FDE5              <1> 	cmp	ch, 0E5h ; Is it a deleted file?
   785 0000B3E5 746D                <1> 	je	short loc_find_dir_next_entry_prevdeleted
   786                              <1> 
   787 0000B3E7 80FA0F              <1> 	cmp     dl, 0Fh ; longname sub component check
   788 0000B3EA 7505                <1> 	jne     short loc_check_attributes_mask
   789 0000B3EC E8ED010000          <1> 	call	save_longname_sub_component
   790                              <1> 
   791                              <1> loc_check_attributes_mask:
   792 0000B3F1 88C6                <1> 	mov	dh, al
   793 0000B3F3 20D6                <1> 	and	dh, dl    
   794 0000B3F5 38F0                <1> 	cmp	al, dh
   795 0000B3F7 0F85BA000000        <1>         jne     loc_find_dir_next_entry
   796 0000B3FD 20D4                <1> 	and	ah, dl
   797 0000B3FF 0F85B2000000        <1>         jnz     loc_find_dir_next_entry
   798 0000B405 80FA0F              <1> 	cmp	dl, 0Fh
   799 0000B408 751A                <1> 	jne	short pass_direntry_attr_check
   800                              <1> 
   801 0000B40A 3C0F                <1> 	cmp	al, 0Fh ; AL = 0Fh -> find long name
   802 0000B40C 0F85A5000000        <1>         jne     loc_find_dir_next_entry
   803                              <1> 
   804 0000B412 5E                  <1> 	pop	esi
   805 0000B413 6631C0              <1> 	xor	ax, ax
   806 0000B416 8A35[90920100]      <1> 	mov	dh, [PreviousAttr]
   807 0000B41C 66891D[BD910100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   808 0000B423 C3                  <1> 	retn
   809                              <1> 
   810                              <1> pass_direntry_attr_check:
   811 0000B424 89FD                <1> 	mov	ebp, edi ; 14/02/2016
   812 0000B426 B908000000          <1> 	mov	ecx, 8
   813                              <1> loc_lodsb_find_dir:
   814 0000B42B AC                  <1> 	lodsb
   815 0000B42C 3C2A                <1> 	cmp	al, '*'
   816 0000B42E 7508                <1> 	jne	short pass_fde_ambiguous1_check
   817 0000B430 FE05[8F920100]      <1>         inc     byte [AmbiguousFileName+1]
   818 0000B436 EB28                <1> 	jmp	short loc_check_direntry_extension
   819                              <1> 
   820                              <1> pass_fde_ambiguous1_check:
   821 0000B438 3C3F                <1> 	cmp	al, '?'
   822 0000B43A 750D                <1> 	jne	short pass_fde_ambiguous2_check
   823 0000B43C FE05[8E920100]      <1> 	inc	byte [AmbiguousFileName]
   824 0000B442 803F20              <1> 	cmp	byte [edi], 20h
   825 0000B445 764E                <1> 	jna	short loc_find_dir_next_entry_ebp
   826 0000B447 EB14                <1> 	jmp	short loc_scasb_find_dir_inc_di
   827                              <1> 
   828                              <1> pass_fde_ambiguous2_check:
   829 0000B449 3C20                <1> 	cmp	al, 20h
   830 0000B44B 750C                <1> 	jne	short loc_scasb_find_dir
   831 0000B44D 803F20              <1> 	cmp	byte [edi], 20h
   832 0000B450 7543                <1> 	jne	short loc_find_dir_next_entry_ebp
   833 0000B452 EB0C                <1> 	jmp	short loc_check_direntry_extension
   834                              <1> 
   835                              <1> loc_find_dir_next_entry_prevdeleted:
   836 0000B454 80CA80              <1> 	or	dl, 80h  ; Bit 7 -> deleted entry sign
   837 0000B457 EB5E                <1> 	jmp	short loc_find_dir_next_entry
   838                              <1> 
   839                              <1> loc_scasb_find_dir:
   840 0000B459 3A07                <1> 	cmp	al, [edi]
   841 0000B45B 7538                <1> 	jne	short loc_find_dir_next_entry_ebp
   842                              <1> loc_scasb_find_dir_inc_di:
   843 0000B45D 47                  <1> 	inc	edi
   844 0000B45E E2CB                <1> 	loop	loc_lodsb_find_dir
   845                              <1> 
   846                              <1> loc_check_direntry_extension:
   847 0000B460 BE08000000          <1> 	mov	esi, 8
   848 0000B465 89F7                <1> 	mov	edi, esi ; 8
   849 0000B467 033424              <1> 	add	esi, [esp] ; Sub Dir or File Name Address
   850 0000B46A 01EF                <1> 	add	edi, ebp
   851 0000B46C B103                <1> 	mov	cl, 3
   852                              <1> loc_lodsb_find_dir_ext:
   853 0000B46E AC                  <1> 	lodsb
   854 0000B46F 3C2A                <1> 	cmp	al, '*'
   855 0000B471 7508                <1> 	jne	short pass_fde_ambiguous3_check
   856 0000B473 FE05[8F920100]      <1> 	inc	byte [AmbiguousFileName+1]
   857 0000B479 EB1E                <1> 	jmp	short loc_find_dir_proper_direntry
   858                              <1> 
   859                              <1> pass_fde_ambiguous3_check:
   860 0000B47B 3C3F                <1> 	cmp	al, '?'
   861 0000B47D 750D                <1> 	jne	short pass_fde_ambiguous4_check
   862 0000B47F FE05[8E920100]      <1> 	inc	byte [AmbiguousFileName]
   863 0000B485 803F20              <1> 	cmp	byte [edi], 20h
   864 0000B488 760B                <1> 	jna	short loc_find_dir_next_entry_ebp
   865 0000B48A EB49                <1> 	jmp	short loc_scasb_find_dir_ext_inc_di
   866                              <1> 
   867                              <1> pass_fde_ambiguous4_check:
   868 0000B48C 3C20                <1> 	cmp	al, 20h
   869 0000B48E 7541                <1> 	jne	short loc_scasb_find_dir_ext
   870 0000B490 803F20              <1> 	cmp	byte [edi], 20h
   871 0000B493 7404                <1> 	je	short loc_find_dir_proper_direntry
   872                              <1> 
   873                              <1> loc_find_dir_next_entry_ebp:
   874 0000B495 89EF                <1> 	mov	edi, ebp ; 14/02/2016
   875 0000B497 EB1E                <1> 	jmp	short loc_find_dir_next_entry
   876                              <1> 
   877                              <1> loc_find_dir_proper_direntry:
   878 0000B499 30C9                <1> 	xor	cl, cl
   879                              <1> loc_find_dir_proper_direntry_1:
   880 0000B49B 5E                  <1> 	pop	esi
   881 0000B49C 89EF                <1>         mov     edi, ebp
   882 0000B49E 8A2F                <1> 	mov	ch, [edi]
   883 0000B4A0 8A570B              <1> 	mov     dl, [edi+0Bh] ; Dir entry attributes
   884 0000B4A3 66A1[8E920100]      <1> 	mov	ax, [AmbiguousFileName]
   885                              <1> loc_find_dir_proper_direntry_2:
   886 0000B4A9 8A35[90920100]      <1> 	mov     dh, [PreviousAttr]
   887 0000B4AF 66891D[BD910100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   888 0000B4B6 C3                  <1> 	retn
   889                              <1> 
   890                              <1> loc_find_dir_next_entry:
   891 0000B4B7 8815[90920100]      <1> 	mov	byte [PreviousAttr], dl ; LongName check
   892                              <1> loc_find_dir_next_entry_1:
   893 0000B4BD 5E                  <1> 	pop	esi
   894 0000B4BE 83C720              <1> 	add	edi, 32
   895                              <1> 	;inc	word [DirBuff_EntryCounter]
   896 0000B4C1 6643                <1> 	inc	bx
   897 0000B4C3 663B1D[BF910100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   898 0000B4CA 770E                <1> 	ja	short loc_ffde_stc_retn_255
   899 0000B4CC E9FCFEFFFF          <1>         jmp     check_find_dir_entry 
   900                              <1> 
   901                              <1> loc_scasb_find_dir_ext:
   902 0000B4D1 3A07                <1> 	cmp	al, [edi]
   903 0000B4D3 75C0                <1> 	jne	short loc_find_dir_next_entry_ebp
   904                              <1> loc_scasb_find_dir_ext_inc_di:
   905 0000B4D5 47                  <1> 	inc	edi
   906 0000B4D6 E296                <1> 	loop    loc_lodsb_find_dir_ext
   907 0000B4D8 EBC1                <1> 	jmp	short loc_find_dir_proper_direntry_1
   908                              <1> 
   909                              <1> loc_ffde_stc_retn_255:
   910                              <1> 	;mov	cx, 0FFFFh
   911 0000B4DA 31C9                <1> 	xor	ecx, ecx
   912 0000B4DC 49                  <1> 	dec	ecx ; 0FFFFFFFFh
   913                              <1> 	;xor	eax, eax
   914                              <1> loc_find_direntry_stc_retn:
   915                              <1> loc_check_ffde_retn_1:
   916                              <1> 	;mov	ax, 2
   917 0000B4DD B802000000          <1> 	mov	eax, 2 ; File Not Found
   918 0000B4E2 8A35[90920100]      <1> 	mov	dh, [PreviousAttr]
   919 0000B4E8 66891D[BD910100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   920 0000B4EF F9                  <1> 	stc
   921 0000B4F0 C3                  <1> 	retn
   922                              <1> 
   923                              <1> loc_find_free_deleted_entry_0:
   924 0000B4F1 66A1[8C920100]      <1> 	mov	ax, [FDE_AttrMask]
   925 0000B4F7 8A2F                <1> 	mov	ch, [edi]
   926 0000B4F9 8A570B              <1> 	mov	dl, [edi+0Bh] ; File attributes
   927 0000B4FC 08C9                <1> 	or	cl, cl 
   928 0000B4FE 7407                <1> 	jz	short loc_check_ffde_0_repeat
   929                              <1> 	;cmp	cl, 0E5h
   930                              <1> 	;je	short pass_loc_check_ffde_0_err
   931 0000B500 80F9FF              <1> 	cmp	cl, 0FFh
   932 0000B503 7432                <1> 	je	short loc_find_free_deleted_entry_1
   933 0000B505 EB4D                <1> 	jmp	short pass_loc_check_ffde_0_err
   934                              <1> 
   935                              <1> loc_check_ffde_0_repeat:
   936 0000B507 08ED                <1> 	or	ch, ch
   937 0000B509 7511                <1> 	jnz	short loc_check_ffde_0_next
   938                              <1> 
   939                              <1> loc_check_ffde_retn_2:
   940 0000B50B 6629C0              <1> 	sub	ax, ax
   941 0000B50E 8A35[90920100]      <1> 	mov	dh, [PreviousAttr]
   942 0000B514 66891D[BD910100]    <1> 	mov	[DirBuff_CurrentEntry], bx
   943 0000B51B C3                  <1> 	retn
   944                              <1>  
   945                              <1> loc_check_ffde_0_next:
   946 0000B51C 6643                <1> 	inc	bx
   947 0000B51E 83C720              <1> 	add	edi, 32
   948                              <1> 	;inc	word [DirBuff_EntryCounter]
   949                              <1> 	 
   950 0000B521 663B1D[BF910100]    <1>         cmp	bx, [DirBuff_LastEntry]
   951 0000B528 77B0                <1> 	ja	short loc_ffde_stc_retn_255
   952 0000B52A 8815[90920100]      <1> 	mov	[PreviousAttr], dl
   953 0000B530 8A2F                <1> 	mov	ch, [edi]
   954 0000B532 8A570B              <1> 	mov	dl, [edi+0Bh] ; file attributes
   955 0000B535 EBD0                <1> 	jmp	short loc_check_ffde_0_repeat
   956                              <1> 
   957                              <1> loc_find_free_deleted_entry_1:
   958 0000B537 28D2                <1> 	sub	dl, dl      
   959                              <1> loc_find_free_deleted_entry_2:
   960 0000B539 20ED                <1> 	and	ch, ch  
   961 0000B53B 74CE                <1> 	jz	short loc_check_ffde_retn_2
   962 0000B53D 80FDE5              <1> 	cmp	ch, 0E5h
   963 0000B540 74C9                <1> 	je	short loc_check_ffde_retn_2
   964 0000B542 6643                <1> 	inc	bx
   965 0000B544 83C720              <1> 	add	edi, 32
   966 0000B547 663B1D[BF910100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   967 0000B54E 778A                <1> 	ja	short loc_ffde_stc_retn_255
   968 0000B550 8A2F                <1> 	mov	ch, [edi]
   969 0000B552 EBE5                <1> 	jmp	short loc_find_free_deleted_entry_2
   970                              <1> 
   971                              <1> pass_loc_check_ffde_0_err:
   972 0000B554 38CD                <1> 	cmp	ch, cl
   973 0000B556 741F                <1> 	je	short loc_check_ffde_attrib 
   974                              <1> 
   975 0000B558 6643                <1> 	inc	bx
   976 0000B55A 83C720              <1> 	add	edi, 32
   977 0000B55D 663B1D[BF910100]    <1> 	cmp	bx, [DirBuff_LastEntry]
   978 0000B564 0F8770FFFFFF        <1>         ja      loc_ffde_stc_retn_255
   979 0000B56A 8815[90920100]      <1> 	mov	[PreviousAttr], dl
   980 0000B570 8A2F                <1> 	mov	ch, [edi]
   981 0000B572 8A570B              <1> 	mov	dl, [edi+0Bh]
   982 0000B575 EBDD                <1> 	jmp	short pass_loc_check_ffde_0_err
   983                              <1> 
   984                              <1> loc_check_ffde_attrib:
   985 0000B577 88C6                <1> 	mov	dh, al
   986 0000B579 20D6                <1> 	and	dh, dl    
   987 0000B57B 38F0                <1> 	cmp	al, dh
   988 0000B57D 759D                <1> 	jne	short loc_check_ffde_0_next
   989 0000B57F 20D4                <1> 	and	ah, dl
   990 0000B581 7599                <1> 	jnz	short loc_check_ffde_0_next
   991 0000B583 30C9                <1> 	xor	cl, cl 
   992 0000B585 EB84                <1>         jmp     loc_check_ffde_retn_2
   993                              <1> 
   994                              <1> convert_file_name:
   995                              <1> 	; 06/03/2016
   996                              <1> 	; 11/02/2016
   997                              <1> 	; 07/02/2016 (TRDOS 386 = TRDOS v2.0)
   998                              <1> 	; 06/10/2009
   999                              <1> 	; 2005
  1000                              <1> 	;
  1001                              <1> 	; INPUT  ->
  1002                              <1> 	;	ESI = Dot File Name Location
  1003                              <1> 	;	EDI = Dir Entry Format File Name Location
  1004                              <1> 	; OUTPUT ->
  1005                              <1> 	;	EDI = Dir Entry Format File Name Location
  1006                              <1> 	;	ESI = Dot File Name Location (capitalized)
  1007                              <1> 	;
  1008                              <1> 	; (ECX, AL will be changed) 
  1009                              <1>      
  1010 0000B587 56                  <1> 	push	esi  
  1011 0000B588 57                  <1> 	push	edi
  1012                              <1> 
  1013 0000B589 B90B000000          <1> 	mov	ecx, 11
  1014 0000B58E B020                <1> 	mov	al, 20h
  1015 0000B590 F3AA                <1> 	rep	stosb
  1016                              <1> 
  1017 0000B592 8B3C24              <1> 	mov	edi, [esp]
  1018                              <1> 
  1019 0000B595 B10C                <1> 	mov	cl, 12 ; file name length (max.)
  1020                              <1> 	; 06/03/2016
  1021                              <1> 	; Directory entry name limit (11 bytes) check for
  1022                              <1> 	; 'rename_directory_entry' procedure.
  1023                              <1> 	; (EDI points to Directory Entry)
  1024                              <1> 	; (If the file name would not contain a dot
  1025                              <1> 	; and file name length would be 12, this would cause to
  1026                              <1> 	; overwrite the attributes byte of the directory entry.)
  1027                              <1> 	;
  1028 0000B597 B50B                <1> 	mov	ch, 11 ; directory entry's name length
  1029                              <1> loc_check_first_dot:
  1030 0000B599 8A06                <1> 	mov	al, [esi]
  1031 0000B59B 3C2E                <1> 	cmp	al, 2Eh
  1032 0000B59D 750C                <1> 	jne	short pass_check_first_dot
  1033 0000B59F 8807                <1> 	mov	[edi], al
  1034 0000B5A1 47                  <1> 	inc	edi
  1035 0000B5A2 46                  <1> 	inc	esi
  1036 0000B5A3 FEC9                <1> 	dec	cl
  1037 0000B5A5 75F2                <1> 	jnz	short loc_check_first_dot
  1038                              <1> 	;;(ecx <= 12)
  1039                              <1> 	;;loop	loc_check_first_dot 
  1040 0000B5A7 EB30                <1> 	jmp	short stop_convert_file
  1041                              <1> 
  1042                              <1> loc_get_fchar:
  1043 0000B5A9 8A06                <1> 	mov	al, [esi]
  1044                              <1> pass_check_first_dot:
  1045 0000B5AB 3C61                <1> 	cmp	al, 61h ; 'a'
  1046 0000B5AD 7208                <1> 	jb	short pass_name_capitalize
  1047 0000B5AF 3C7A                <1> 	cmp	al, 7Ah ; 'z'
  1048 0000B5B1 7704                <1> 	ja	short pass_name_capitalize
  1049 0000B5B3 24DF                <1> 	and	al, 0DFh
  1050 0000B5B5 8806                <1> 	mov	[esi], al
  1051                              <1> pass_name_capitalize:
  1052 0000B5B7 3C21                <1> 	cmp	al, 21h
  1053 0000B5B9 721E                <1> 	jb	short stop_convert_file
  1054 0000B5BB 3C2E                <1> 	cmp	al, 2Eh ; '.'
  1055 0000B5BD 750C                <1> 	jne	short pass_dot_space
  1056                              <1> add_dot_space: 
  1057 0000B5BF 80F904              <1> 	cmp	cl, 4
  1058 0000B5C2 760E                <1> 	jna	short inc_and_loop
  1059 0000B5C4 47                  <1> 	inc	edi
  1060 0000B5C5 FECD                <1> 	dec	ch ; 06/03/2016
  1061 0000B5C7 FEC9                <1> 	dec	cl
  1062 0000B5C9 EBF4                <1> 	jmp	short add_dot_space
  1063                              <1> 	
  1064                              <1> 	;mov	al, 4
  1065                              <1> 	;cmp	cl, al
  1066                              <1> 	;jna	short inc_and_loop
  1067                              <1> 	;sub	cl, al
  1068                              <1> 	;add	edi, ecx
  1069                              <1> 	;mov	cl, al
  1070                              <1> 	;jmp	short inc_and_loop	
  1071                              <1> 
  1072                              <1> pass_dot_space:
  1073 0000B5CB 8807                <1> 	mov	[edi], al
  1074                              <1> loc_after_double_dot:
  1075                              <1> 	; 06/03/2016
  1076 0000B5CD FECD                <1> 	dec	ch ; count down for 11 bytes dir entry limit
  1077 0000B5CF 740A                <1> 	jz	short stop_convert_file_x
  1078 0000B5D1 47                  <1> 	inc	edi
  1079                              <1> inc_and_loop:
  1080 0000B5D2 FEC9                <1> 	dec	cl ; count down for 12 bytes filename limit 
  1081 0000B5D4 7403                <1> 	jz	short stop_convert_file	
  1082 0000B5D6 46                  <1> 	inc	esi
  1083                              <1> 	;;(ecx <= 12)
  1084                              <1> 	;;loop	loc_get_fchar
  1085 0000B5D7 EBD0                <1> 	jmp	short loc_get_fchar
  1086                              <1> 
  1087                              <1> stop_convert_file:
  1088                              <1> 	; 06/03/2016
  1089 0000B5D9 30ED                <1> 	xor	ch, ch
  1090                              <1> 	; ECX < 256 ; 'find_first_file' -> xor cl, cl
  1091                              <1> stop_convert_file_x:
  1092 0000B5DB 5F                  <1> 	pop	edi
  1093 0000B5DC 5E                  <1> 	pop	esi
  1094 0000B5DD C3                  <1> 	retn
  1095                              <1>  
  1096                              <1> save_longname_sub_component:
  1097                              <1> 	; 13/02/2016
  1098                              <1> 	; 06/02/2016 (TRDOS 386 = TRDOS v2.0)
  1099                              <1> 	; 28/02/2010
  1100                              <1> 	; 17/10/2009
  1101                              <1> 	; INPUT ->
  1102                              <1> 	;	EDI = Directory Entry    
  1103                              <1> 	;     	// This procedure is called
  1104                              <1> 	;	// from 'find_directory_entry' procedure.
  1105                              <1> 	;	// If the last entry returns with
  1106                              <1> 	;	// a non-zero LongnameFound value and
  1107                              <1> 	;	// if LFN_CheckSum value is equal to
  1108                              <1> 	;	// the next shortname checksum,
  1109                              <1> 	;	// long name is valid.
  1110                              <1> 	;	// If a longname is longer than 65 bytes,
  1111                              <1> 	;	// it is invalid for trdos. (>45h)
  1112                              <1>  
  1113 0000B5DE 57                  <1> 	push	edi
  1114 0000B5DF 56                  <1> 	push	esi
  1115                              <1> 	;push	ebx
  1116                              <1> 	;push	ecx
  1117                              <1> 	;push	edx
  1118 0000B5E0 50                  <1> 	push	eax
  1119                              <1>            
  1120 0000B5E1 29C9                <1> 	sub	ecx, ecx
  1121                              <1> 	;sub	eax, eax
  1122 0000B5E3 B11A                <1> 	mov	cl, 26
  1123                              <1> 
  1124 0000B5E5 0FB607              <1> 	movzx	eax, byte [edi] ; LDIR_Order
  1125 0000B5E8 3C41                <1> 	cmp	al, 41h  ; 40h (last long entry sign) + 1
  1126 0000B5EA 722B                <1> 	jb	short pass_pslnsc_last_long_entry
  1127                              <1> 
  1128 0000B5EC 88C4                <1> 	mov	ah, al
  1129 0000B5EE 80EC40              <1> 	sub	ah, 40h
  1130 0000B5F1 8825[92920100]      <1> 	mov	[LFN_EntryLength], ah
  1131                              <1> 	
  1132 0000B5F7 3C45                <1> 	cmp	al, 45h  ; 40h (last long entry sign) + 5
  1133                              <1>  		; Max 130 byte length is usable in TRDOS
  1134                              <1> ; 26*5 = 130
  1135 0000B5F9 7753                <1> 	ja	short loc_pslnsc_retn
  1136                              <1> 
  1137 0000B5FB 2407                <1> 	and	al, 07h ; 0Fh
  1138 0000B5FD A2[91920100]        <1> 	mov	[LongNameFound], al
  1139                              <1> 
  1140 0000B602 FEC8                <1> 	dec	al
  1141                              <1> 	;mov	cl, 26
  1142 0000B604 F6E1                <1> 	mul	cl
  1143                              <1> 
  1144 0000B606 89C6                <1> 	mov	esi, eax
  1145 0000B608 01CE                <1> 	add	esi, ecx
  1146                              <1> 		; to make is an ASCIIZ string
  1147                              <1> 		; with ax+26 bytes length
  1148 0000B60A 81C6[94920100]      <1> 	add	esi, LongFileName
  1149 0000B610 66C7060000          <1> 	mov	word [esi], 0   
  1150 0000B615 EB16                <1> 	jmp	short loc_pslsc_move_ldir_name2 
  1151                              <1> 
  1152                              <1> pass_pslnsc_last_long_entry:
  1153 0000B617 3C04                <1> 	cmp	al, 04h
  1154 0000B619 7733                <1> 	ja	short loc_pslnsc_retn
  1155 0000B61B FE0D[91920100]      <1> 	dec	byte [LongNameFound]
  1156 0000B621 3A05[91920100]      <1> 	cmp	al, [LongNameFound]
  1157 0000B627 7525                <1> 	jne	short loc_pslnsc_retn
  1158                              <1> 
  1159                              <1> loc_pslsc_move_ldir_name1:
  1160 0000B629 FEC8                <1> 	dec	al
  1161                              <1> 	;mov	cl, 26
  1162 0000B62B F6E1                <1> 	mul	cl
  1163                              <1> 
  1164                              <1> loc_pslsc_move_ldir_name2:
  1165 0000B62D 8A4F0D              <1> 	mov	cl, [edi+0Dh] ; long name checksum
  1166 0000B630 880D[93920100]      <1> 	mov	[LFN_CheckSum], cl 
  1167 0000B636 89FE                <1> 	mov	esi, edi ; LDIR_Order
  1168 0000B638 BF[94920100]        <1> 	mov	edi, LongFileName
  1169 0000B63D 01C7                <1> 	add	edi, eax
  1170 0000B63F 46                  <1> 	inc	esi
  1171 0000B640 B105                <1> 	mov	cl, 5 ; chars 1 to 5
  1172 0000B642 F366A5              <1> 	rep	movsw
  1173 0000B645 83C603              <1> 	add	esi, 3
  1174 0000B648 A5                  <1> 	movsd	; char 6 & 7 
  1175 0000B649 A5                  <1> 	movsd	; char 8 & 9
  1176 0000B64A A5                  <1> 	movsd	; char 10 & 11
  1177 0000B64B 46                  <1> 	inc	esi
  1178 0000B64C 46                  <1> 	inc	esi 
  1179 0000B64D A5                  <1> 	movsd   ; char 12 & 13 
  1180                              <1> 
  1181                              <1> loc_pslnsc_retn:
  1182 0000B64E 58                  <1>  	pop	eax
  1183                              <1> 	;pop	edx
  1184                              <1> 	;pop	ecx
  1185                              <1> 	;pop	ebx
  1186 0000B64F 5E                  <1> 	pop	esi  
  1187 0000B650 5F                  <1> 	pop	edi
  1188                              <1>  
  1189 0000B651 C3                  <1>     	retn
  1190                              <1> 
  1191                              <1> parse_path_name:
  1192                              <1> 	; 10/02/2016
  1193                              <1> 	; 08/02/2016 (TRDOS 386 = TRDOS v2.0)
  1194                              <1> 	; 10/009/2011 ('proc_parse_pathname')
  1195                              <1> 	; 27/11/2009
  1196                              <1> 	; 05/12/2004
  1197                              <1> 	;
  1198                              <1> 	; INPUT ->
  1199                              <1> 	;	ESI = Beginning of ASCIIZ pathname string
  1200                              <1> 	;       EDI = Destination Address
  1201                              <1> 	;	      (which is TR-DOS FindFile data buffer)
  1202                              <1> 	; OUTPUT ->
  1203                              <1> 	;	CF = 1 -> Error
  1204                              <1> 	;	     EAX = Error Code (AL)
  1205                              <1> 	;
  1206                              <1> 	; (Modified registers: eax, ecx, esi, edi) 
  1207                              <1> 	
  1208                              <1> 	; Clear the pathname bytes in TR-DOS Findfile data buffer 
  1209 0000B652 57                  <1> 	push	edi
  1210 0000B653 B914000000          <1> 	mov	ecx, 20  ; 80 bytes
  1211 0000B658 31C0                <1> 	xor	eax, eax
  1212 0000B65A F3AB                <1> 	rep	stosd 
  1213 0000B65C 5F                  <1> 	pop	edi
  1214                              <1> 
  1215 0000B65D 668B06              <1> 	mov	ax, [esi]
  1216 0000B660 80FC3A              <1> 	cmp	ah, ':'
  1217 0000B663 741C                <1> 	je	short loc_ppn_change_drive
  1218 0000B665 A0[968A0100]        <1> 	mov	al, [Current_Drv]
  1219 0000B66A EB33                <1> 	jmp	short pass_ppn_change_drive
  1220                              <1> 
  1221                              <1> pass_ppn_cdir:
  1222 0000B66C 8B35[B6930100]      <1> 	mov	esi, [First_Path_Pos]
  1223 0000B672 AC                  <1> 	lodsb
  1224                              <1> loc_ppn_get_filename:
  1225 0000B673 83C741              <1> 	add	edi, 65 ; FindFile_Name location
  1226                              <1> 	; TRDOS Filename length must not be more than 12 bytes
  1227                              <1> 	;mov	ecx, 12
  1228 0000B676 B10C                <1> 	mov	cl, 12
  1229                              <1> loc_ppn_get_fnchar_next:
  1230 0000B678 AA                  <1> 	stosb
  1231 0000B679 AC                  <1> 	lodsb
  1232 0000B67A 3C21                <1> 	cmp	al, 21h
  1233 0000B67C 7274                <1> 	jb	short loc_ppn_clc_return 
  1234 0000B67E E2F8                <1>         loop    loc_ppn_get_fnchar_next
  1235                              <1> loc_ppn_return:
  1236 0000B680 C3                  <1> 	retn
  1237                              <1> 
  1238                              <1> loc_ppn_change_drive:
  1239 0000B681 24DF                <1> 	and	al, 0DFh
  1240 0000B683 2C41                <1> 	sub	al, 'A'; A:
  1241 0000B685 726F                <1> 	jc	short loc_ppn_invalid_drive
  1242 0000B687 3805[62400100]      <1> 	cmp	[Last_DOS_DiskNo], al
  1243 0000B68D 7267                <1> 	jb	short loc_ppn_invalid_drive
  1244                              <1> 
  1245 0000B68F 46                  <1> 	inc	esi
  1246 0000B690 46                  <1> 	inc	esi
  1247 0000B691 8A26                <1> 	mov	ah, [esi]
  1248 0000B693 80FC21              <1> 	cmp	ah, 21h
  1249 0000B696 7307                <1> 	jnb	short pass_ppn_change_drive
  1250                              <1> 
  1251                              <1> loc_ppn_cmd_failed:
  1252                              <1> 	; File or directory name is not existing
  1253 0000B698 8807                <1> 	mov	[edi], al ; Drv 
  1254 0000B69A 66B80100            <1> 	mov	ax, 1 ; eax = 1
  1255                              <1> 	; TR-DOS Error Code 01h = Bad Command Argument
  1256                              <1> 	; MS-DOS Error Code 01h : Invalid Function Number
  1257                              <1> 	;stc
  1258                              <1> 	; (MainProg ErrMsg: "Bad command or file name!")
  1259 0000B69E C3                  <1> 	retn
  1260                              <1> 
  1261                              <1> pass_ppn_change_drive:
  1262 0000B69F 8935[B6930100]      <1> 	mov	[First_Path_Pos], esi
  1263 0000B6A5 C705[BA930100]0000- <1> 	mov	dword [Last_Slash_Pos], 0
  1263 0000B6AD 0000                <1>
  1264 0000B6AF AA                  <1> 	stosb
  1265 0000B6B0 8A06                <1> 	mov	al, [esi]
  1266                              <1> loc_scan_ppn_dslash:
  1267 0000B6B2 3C2F                <1> 	cmp	al, '/'
  1268 0000B6B4 7506                <1>   	jne	short loc_scan_next_slash_pos
  1269 0000B6B6 8935[BA930100]      <1> 	mov	[Last_Slash_Pos], esi
  1270                              <1> loc_scan_next_slash_pos:
  1271 0000B6BC 46                  <1> 	inc	esi
  1272 0000B6BD 8A06                <1> 	mov	al, [esi]
  1273 0000B6BF 3C20                <1> 	cmp	al, 20h
  1274 0000B6C1 77EF                <1> 	ja	short loc_scan_ppn_dslash
  1275 0000B6C3 833D[BA930100]00    <1> 	cmp	dword [Last_Slash_Pos], 0
  1276 0000B6CA 76A0                <1> 	jna	short pass_ppn_cdir
  1277                              <1> 	
  1278 0000B6CC 8B0D[BA930100]      <1> 	mov	ecx, [Last_Slash_Pos]
  1279 0000B6D2 8B35[B6930100]      <1> 	mov	esi, [First_Path_Pos]
  1280 0000B6D8 29F1                <1> 	sub	ecx, esi
  1281 0000B6DA 41                  <1> 	inc	ecx
  1282                              <1> 	;cmp	ecx, 64
  1283 0000B6DB 80F940              <1> 	cmp	cl, 64
  1284 0000B6DE 7715                <1> 	ja	short loc_ppn_invalid_drive_stc
  1285                              <1> 
  1286 0000B6E0 89F8                <1> 	mov	eax, edi ; Dest Dir String Location (65 byte)
  1287 0000B6E2 F3A4                <1> 	rep	movsb
  1288                              <1> 	;mov	[edi], cl ; 0, End of Dir String
  1289 0000B6E4 8B35[BA930100]      <1> 	mov	esi, [Last_Slash_Pos]
  1290 0000B6EA 46                  <1> 	inc	esi
  1291 0000B6EB 89C7                <1> 	mov	edi, eax
  1292 0000B6ED AC                  <1> 	lodsb
  1293 0000B6EE 3C21                <1> 	cmp	al, 21h
  1294 0000B6F0 7381                <1> 	jnb	short loc_ppn_get_filename
  1295                              <1> loc_ppn_clc_return:
  1296                              <1> 	;clc
  1297 0000B6F2 31C0                <1> 	xor	eax, eax
  1298 0000B6F4 C3                  <1> 	retn
  1299                              <1> 
  1300                              <1> loc_ppn_invalid_drive_stc:
  1301 0000B6F5 F5                  <1> 	cmc	 ; stc
  1302                              <1> loc_ppn_invalid_drive:
  1303                              <1> 	; cf = 1
  1304                              <1> 	; The Drive Letter/Char < "A" or > "Z"
  1305 0000B6F6 66B80F00            <1> 	mov	ax, 0Fh
  1306                              <1> 	; MS-DOS Error Code 0Fh = Disk Drive Invalid 
  1307                              <1> 	; (MainProg ErrMsg: "Drive not ready or read error!")
  1308 0000B6FA C3                  <1> 	retn
  1309                              <1> 
  1310                              <1> find_longname:
  1311                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  1312                              <1> 	; 24/01/2010 (DIR.ASM, 'proc_find_longname')
  1313                              <1> 	; 17/10/2009
  1314                              <1> 	
  1315                              <1> 	; INPUT -> 
  1316                              <1> 	;	ESI = DOS short file name address
  1317                              <1> 	; 	for example: "filename.ext"
  1318                              <1> 	;
  1319                              <1> 	; OUTPUT ->
  1320                              <1> 	; 	ESI = ASCIIZ longname address (cf = 0)
  1321                              <1> 	;	cf = 1 -> error number returns in EAX (AL)
  1322                              <1> 	;	AL = 0 & CF=1 -> longname not found
  1323                              <1> 	;	     the file/directory has no longname
  1324                              <1> 	; 	cf = 0 -> AL = FAT Type 
  1325                              <1>  
  1326                              <1> 	; 17/10/2009
  1327                              <1> 	; ASCIIZ string will be returned
  1328                              <1> 	; as LongFileName
  1329                              <1> 	; clearing/reset is not needed
  1330                              <1> 	;mov	ecx, 33
  1331                              <1> 	;mov	edi, LongFileName
  1332                              <1> 	;sub	ax, ax ; 0
  1333                              <1> 	;rep	stosw
  1334                              <1> 
  1335                              <1> 	;mov	byte [LongNameFound], 0
  1336                              <1> 
  1337                              <1> 	; ESI = ASCIIZ file/directory name address
  1338                              <1> 	;   AL = Attributes AND mask 
  1339                              <1> 	;	(Result of AND must be equal to AL)
  1340                              <1> 	;   AH = Negative attributes mask 
  1341                              <1> 	;	(Result of AND must be ZERO)
  1342 0000B6FB 66B80008            <1> 	mov	ax, 0800h 
  1343                              <1> 		; it must not be volume name or longname
  1344 0000B6FF E87DDDFFFF          <1> 	call	find_first_file
  1345 0000B704 7216                <1> 	jc	short loc_fln_retn
  1346                              <1>  
  1347                              <1> loc_fln_check_FAT_Type:
  1348 0000B706 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
  1349 0000B70D 7306                <1> 	jnb	short loc_fln_check_longname_yes_sign
  1350                              <1> 
  1351 0000B70F E839000000          <1> 	call	get_fs_longname
  1352 0000B714 C3                  <1> 	retn
  1353                              <1> 
  1354                              <1> loc_fln_check_longname_yes_sign:
  1355 0000B715 08FF                <1> 	or	bh, bh
  1356 0000B717 7504                <1> 	jnz	short loc_fln_check_longnamefound_number
  1357                              <1> loc_fln_longname_not_found_retn:
  1358 0000B719 31C0                <1> 	xor	eax, eax 
  1359                              <1> 	; cf = 1 & al = 0 -> longname not found
  1360 0000B71B F9                  <1> 	stc
  1361                              <1> loc_fln_retn:
  1362 0000B71C C3                  <1> 	retn
  1363                              <1> 
  1364                              <1> loc_fln_check_longnamefound_number:
  1365                              <1> 	; 'LongNameFound' is set by
  1366                              <1>         ; by 'save_longname_sub_component'
  1367                              <1> 	; which is called from
  1368                              <1> 	; 'find_directory_entry' 
  1369                              <1> 	; which is called from 
  1370                              <1> 	; 'find_first_file'
  1371                              <1> 	; It must 1 if the longname is valid
  1372 0000B71D 803D[91920100]01    <1>         cmp     byte [LongNameFound], 1
  1373 0000B724 75F3                <1> 	jne	short loc_fln_longname_not_found_retn
  1374                              <1>              
  1375                              <1> loc_fln_calculate_checksum: 
  1376 0000B726 E813000000          <1> 	call	calculate_checksum
  1377                              <1> 	; AL = shortname checksum
  1378                              <1> 
  1379                              <1> loc_fln_longname_validation:
  1380                              <1> 	; 'LFN_CheckSum' has been set already
  1381                              <1> 	; by 'save_longname_sub_component'
  1382                              <1> 	; which is called from
  1383                              <1> 	; 'find_directory_entry' 
  1384                              <1> 	; which is called from 
  1385                              <1> 	; 'find_first_file'
  1386 0000B72B 3805[93920100]      <1> 	cmp	[LFN_CheckSum], al
  1387 0000B731 75E6                <1> 	jne	short loc_fln_longname_not_found_retn
  1388                              <1> 
  1389 0000B733 BE[94920100]        <1> 	mov	esi, LongFileName
  1390 0000B738 A0[958A0100]        <1> 	mov	al, [Current_FATType]
  1391 0000B73D C3                  <1> 	retn
  1392                              <1> 
  1393                              <1> calculate_checksum:
  1394                              <1> 	; 13/02/2016 (TRDOS 386 = TRDOS v2.0)
  1395                              <1> 	; 17/10/2009 (DIR.ASM, 'proc_calculate_checksum')
  1396                              <1>         ;    
  1397                              <1> 	; INPUT ->
  1398                              <1> 	;	ESI = 11 byte DOS File Name location
  1399                              <1> 	;	(in DOS Directory Entry Format)
  1400                              <1> 	; OUTPUT ->
  1401                              <1> 	;	 AL = 8 bit checksum (CRC) value
  1402                              <1> 	;
  1403                              <1> 	; (Modified registers: EAX, ECX, ESI)
  1404                              <1> 
  1405                              <1> 	; Erdogan Tan [ 17-10-2009 ]
  1406                              <1> 	;  'ror al, 1' instruction
  1407                              <1> 
  1408                              <1> 	; Erdogan Tan [ 20-06-2004 ]
  1409                              <1> 	; This 8086 assembly code is an original code
  1410                              <1> 	; which is adapted from C code in
  1411                              <1> 	; Microsoft FAT32 File System Specification
  1412                              <1> 	; Version 1.03, December 6, 2000
  1413                              <1> 	; Page 28
  1414                              <1> 
  1415 0000B73E 30C0                <1> 	xor	al, al
  1416 0000B740 B90B000000          <1> 	mov	ecx, 11
  1417                              <1> loc_next_sum:
  1418                              <1> 	;xor	ah, ah
  1419                              <1> 	;test	al, 1
  1420                              <1> 	;jz	short pass_ah_80h
  1421                              <1> 	;mov	ah, 80h
  1422                              <1> ;pass_ah_80h:
  1423                              <1> 	;shr	al, 1
  1424 0000B745 D0C8                <1> 	ror	al, 1 ; 17/10/2009  
  1425 0000B747 0206                <1> 	add	al, [esi]
  1426 0000B749 46                  <1> 	inc	esi
  1427                              <1> 	;add	al, ah
  1428 0000B74A E2F9                <1> 	loop	loc_next_sum
  1429 0000B74C C3                  <1> 	retn
  1430                              <1> 
  1431                              <1> get_fs_longname:
  1432                              <1> 	; temporary (13/02/2016)
  1433 0000B74D 31C0                <1> 	xor eax, eax
  1434 0000B74F F9                  <1> 	stc
  1435 0000B750 C3                  <1> 	retn
  1436                              <1> 
  1437                              <1> make_sub_directory:
  1438                              <1> 	; 16/10/2016
  1439                              <1> 	; 02/03/2016, 03/03/2016
  1440                              <1> 	; 26/02/2016, 27/02/2016
  1441                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1442                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_make_directory')
  1443                              <1> 	; 10/07/2010
  1444                              <1> 	; INPUT ->
  1445                              <1> 	; 	ESI = ASCIIZ Directory Name
  1446                              <1> 	;	CL = Directory Attributes
  1447                              <1> 	; OUTPUT ->
  1448                              <1> 	;	EAX = New sub dir's first cluster
  1449                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  1450                              <1> 	;	CF = 1 -> error code in AL (EAX)
  1451                              <1> 
  1452                              <1> 	;test	cl, 10h  ; directory
  1453                              <1> 	;jz	short loc_make_directory_access_denied
  1454                              <1> 	;test	cl, 08h ; volume name
  1455                              <1> 	;jnz	short loc_make_directory_access_denied
  1456                              <1> 
  1457 0000B751 80E107              <1> 	and	cl, 07h
  1458 0000B754 880D[10940100]      <1> 	mov	byte [mkdir_attrib], cl
  1459                              <1> 
  1460 0000B75A 56                  <1> 	push	esi
  1461 0000B75B 31DB                <1> 	xor	ebx, ebx
  1462 0000B75D 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  1463 0000B763 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1464 0000B768 01DE                <1> 	add	esi, ebx
  1465 0000B76A 5B                  <1> 	pop	ebx
  1466                              <1> 
  1467                              <1> 	; 10/07/2010 -> 1st writable disk check for trdos
  1468                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  1469 0000B76B 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  1470 0000B76F 730B                <1> 	jnb	short loc_mkdir_check_file_sytem
  1471                              <1> 	; 16/10/2016 (13h -> 30)
  1472 0000B771 B81E000000          <1> 	mov	eax, 30 ; 'Disk write-protected' error
  1473 0000B776 BA00000000          <1> 	mov	edx, 0
  1474                              <1> 	; err retn: EDX = 0, EBX = Dir name offset
  1475                              <1> 	;ESI = Logical DOS drive description table address
  1476 0000B77B C3                  <1> 	retn
  1477                              <1> 
  1478                              <1> ;loc_make_directory_access_denied:
  1479                              <1> 	;mov	ax, 05h ; access denied (invalid attributes input)
  1480                              <1> 	;stc
  1481                              <1> 	;retn
  1482                              <1> 
  1483                              <1> loc_mkdir_check_file_sytem:
  1484 0000B77C 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  1485 0000B780 730B                <1> 	jnb	short loc_mkdir_check_free_sectors
  1486                              <1> 
  1487                              <1> loc_make_fs_directory:
  1488 0000B782 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  1489                              <1> 	; EAX = Parent directory DDT Address
  1490                              <1> 	; ESI = Logical DOS Drive DT Address
  1491                              <1> 	; EBX = Directory name offset (as ASCIIZ name)
  1492 0000B787 E8D5150000          <1> 	call	make_fs_directory
  1493 0000B78C C3                  <1> 	retn
  1494                              <1> 
  1495                              <1> loc_mkdir_check_free_sectors:
  1496 0000B78D 0FB64613            <1>         movzx   eax, byte [esi+LD_BPB+SecPerClust]
  1497 0000B791 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1498 0000B794 39C1                <1> 	cmp	ecx, eax
  1499 0000B796 7255                <1> 	jb	short loc_mkdir_insufficient_disk_space
  1500                              <1> 
  1501                              <1> loc_make_fat_directory:
  1502 0000B798 891D[00940100]      <1> 	mov	[mkdir_DirName_Offset], ebx
  1503 0000B79E 890D[0C940100]      <1> 	mov	[mkdir_FreeSectors], ecx
  1504                              <1> 
  1505                              <1> 	;mov	al, [esi+LD_BPB+SecPerClust]
  1506 0000B7A4 A2[12940100]        <1> 	mov	byte [mkdir_SecPerClust], al
  1507                              <1> 
  1508                              <1> loc_mkdir_gffc_1:
  1509 0000B7A9 E80F180000          <1> 	call	get_first_free_cluster
  1510 0000B7AE 722A                <1> 	jc	short loc_mkdir_gffc_retn
  1511                              <1> 
  1512                              <1> ;loc_mkdir_gffc_1_cont: 
  1513                              <1> 	;cmp	eax, 2
  1514                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  1515                              <1> 
  1516                              <1> ;loc_mkdir_gffc_1_save_fcluster:  
  1517 0000B7B0 A3[04940100]        <1> 	mov	[mkdir_FFCluster], eax
  1518                              <1> 
  1519                              <1> loc_mkdir_locate_ffe:
  1520                              <1> 	; Current directory fcluster <> Directory buffer cluster
  1521                              <1> 	; Current directory will be reloaded by
  1522                              <1> 	; 'locate_current_dir_file' procedure
  1523                              <1> 	;
  1524                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  1525                              <1> 	;push	esi ; 27/02/2016
  1526 0000B7B5 31C0                <1> 	xor	eax, eax
  1527 0000B7B7 89C1                <1>         mov	ecx, eax
  1528 0000B7B9 6649                <1> 	dec	cx ; FFFFh  
  1529                              <1> 	; CX = FFFFh -> find first deleted or free entry
  1530                              <1> 	; ESI would be ASCIIZ filename address if the call
  1531                              <1> 	; would not be for first free or deleted dir entry
  1532 0000B7BB E8D0FAFFFF          <1> 	call	locate_current_dir_file
  1533 0000B7C0 734C                <1> 	jnc	short loc_mkdir_set_ff_dir_entry_1
  1534                              <1> 	;pop	esi 
  1535                              <1> 	; ESI = Logical DOS Drive Description Table Address 
  1536 0000B7C2 83F802              <1> 	cmp	eax, 2  ; cmp al, 2 ; File/Dir not found !
  1537 0000B7C5 752B                <1> 	jne	short loc_mkdir_stc_return
  1538                              <1> 
  1539                              <1> loc_mkdir_add_new_cluster:
  1540 0000B7C7 3805[958A0100]      <1> 	cmp	byte [Current_FATType], al ; 2
  1541                              <1> 	;cmp	byte ptr [esi+LD_FATType], 2
  1542 0000B7CD 770C                <1> 	ja	short loc_mkdir_add_new_cluster_check_fsc
  1543 0000B7CF 803D[948A0100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  1544                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  1545 0000B7D6 7303                <1> 	jnb	short loc_mkdir_add_new_cluster_check_fsc
  1546                              <1> 
  1547 0000B7D8 B00C                <1> 	mov	al, 12 ; No more files 
  1548                              <1> loc_mkdir_gffc_retn:
  1549 0000B7DA C3                  <1> 	retn
  1550                              <1> 
  1551                              <1> loc_mkdir_add_new_cluster_check_fsc:
  1552 0000B7DB 8B0D[0C940100]      <1> 	mov	ecx, [mkdir_FreeSectors]
  1553                              <1> 	;movzx	eax, byte [mkdir_SecPerClust]
  1554 0000B7E1 A0[12940100]        <1> 	mov	al, [mkdir_SecPerClust]
  1555 0000B7E6 66D1E0              <1> 	shl	ax, 1 ; AX = 2 * AX
  1556 0000B7E9 39C1                <1> 	cmp	ecx, eax
  1557 0000B7EB 7350                <1> 	jnb	short loc_mkdir_add_new_subdir_cluster
  1558                              <1> 
  1559                              <1> loc_mkdir_insufficient_disk_space:
  1560                              <1> 	;mov	edx, ecx
  1561                              <1> ;loc_mkdir_gffc_insufficient_disk_space:
  1562 0000B7ED 66B82700            <1> 	mov	ax, 27h ; MSDOS err => insufficient disk space
  1563                              <1> 	; err retn: EDX = Free sectors, EBX = Dir name offset
  1564                              <1>         ; ESI -> Dos drive description table address
  1565                              <1> 	;; ecx = edx
  1566                              <1> 	;
  1567 0000B7F1 C3                  <1> 	retn
  1568                              <1> 
  1569                              <1> loc_mkdir_stc_return:
  1570 0000B7F2 F9                  <1> 	stc
  1571 0000B7F3 C3                  <1> 	retn 
  1572                              <1> 
  1573                              <1> loc_mkdir_gffc_2:
  1574 0000B7F4 E8C4170000          <1> 	call	get_first_free_cluster
  1575 0000B7F9 72DF                <1> 	jc	short loc_mkdir_gffc_retn
  1576                              <1> 
  1577                              <1> ;loc_mkdir_gffc_1_cont: 
  1578                              <1> 	;cmp	eax, 2
  1579                              <1> 	;jb	short loc_mkdir_gffc_insufficient_disk_space
  1580                              <1> 
  1581                              <1> ;loc_mkdir_gffc_2_save_fcluster:  
  1582 0000B7FB A3[04940100]        <1> 	mov	[mkdir_FFCluster], eax
  1583                              <1> 
  1584 0000B800 A1[08940100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  1585                              <1> 
  1586 0000B805 E842170000          <1> 	call	load_FAT_sub_directory 
  1587 0000B80A 72CE                <1> 	jc	short loc_mkdir_gffc_retn
  1588                              <1> 
  1589 0000B80C 31FF                <1> 	xor	edi, edi
  1590                              <1> loc_mkdir_set_ff_dir_entry_1:
  1591                              <1> 	; 27/02/2016
  1592 0000B80E 56                  <1> 	push	esi ; Logical DOS Drv Desc. Tbl. address
  1593                              <1> 	; EDI = Directory Entry Address
  1594 0000B80F 8B35[00940100]      <1> 	mov	esi, [mkdir_DirName_Offset]
  1595 0000B815 A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1596                              <1> 
  1597 0000B81A 66B91000            <1> 	mov	cx, 10h	; CL = Directory attribute
  1598                              <1> 			; CH = 0 -> File size is 0
  1599 0000B81E 0A0D[10940100]      <1> 	or	cl, [mkdir_attrib] ; S, H, R  
  1600 0000B824 E8B0010000          <1> 	call	make_directory_entry
  1601                              <1> 
  1602 0000B829 5E                  <1> 	pop	esi
  1603                              <1> 
  1604 0000B82A C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1605 0000B831 E880020000          <1> 	call	save_directory_buffer
  1606 0000B836 0F83DA000000        <1>         jnc     loc_mkdir_set_ff_dir_entry_2
  1607                              <1> 
  1608                              <1> loc_mkdir_return:
  1609 0000B83C C3                  <1> 	retn
  1610                              <1> 
  1611                              <1> loc_mkdir_add_new_subdir_cluster:
  1612 0000B83D 8B15[C1910100]      <1> 	mov	edx, [DirBuff_Cluster]
  1613 0000B843 8915[08940100]      <1> 	mov	[mkdir_LastDirCluster], edx       
  1614                              <1> 
  1615 0000B849 A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1616 0000B84E E8F9160000          <1> 	call	load_FAT_sub_directory 
  1617 0000B853 72E7                <1> 	jc	short loc_mkdir_return
  1618                              <1> 	; eax = 0
  1619                              <1> 	; ecx =  directory buffer sector count (<= 128)
  1620                              <1> 
  1621                              <1> pass_mkdir_add_new_subdir_cluster:
  1622 0000B855 29FF                <1> 	sub	edi, edi ; 0
  1623                              <1> 	;mov	al, 128 ; double word
  1624                              <1> 	;mul	ecx ; ecx =  directory buffer sector count
  1625                              <1> 	;mov	ecx, eax
  1626                              <1> 	;shl	cx, 7 ; 128 * sector count	
  1627 0000B857 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  1628 0000B85B 66C1E802            <1> 	shr	ax, 2 ; 'byte count / 4' for 'stosd'
  1629 0000B85F 66F7E1              <1> 	mul	cx ; max = 128*(512/4) -> 16384 (stosd)
  1630 0000B862 6689C1              <1> 	mov	cx, ax
  1631 0000B865 6629C0              <1> 	sub	ax, ax ; 0
  1632 0000B868 F3AB                <1> 	rep	stosd ; clear directory buffer
  1633                              <1> 
  1634 0000B86A C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1635 0000B871 E840020000          <1> 	call	save_directory_buffer 
  1636 0000B876 72C4                <1> 	jc	short loc_mkdir_return
  1637                              <1> 
  1638                              <1> loc_mkdir_save_added_cluster:
  1639 0000B878 A1[08940100]        <1> 	mov	eax, [mkdir_LastDirCluster]
  1640 0000B87D 8B0D[04940100]      <1> 	mov	ecx, [mkdir_FFCluster]
  1641                              <1> 	; 01/03/2016
  1642 0000B883 31D2                <1> 	xor	edx, edx
  1643 0000B885 8915[B2910100]      <1> 	mov	[FAT_ClusterCounter], edx ; 0 ; reset
  1644 0000B88B E800180000          <1> 	call	update_cluster
  1645 0000B890 7304                <1> 	jnc	short loc_mkdir_save_fat_buffer_0
  1646 0000B892 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1647 0000B894 7518                <1> 	jnz	short loc_mkdir_save_fat_buffer_stc_retn
  1648                              <1> 
  1649                              <1> loc_mkdir_save_fat_buffer_0:
  1650 0000B896 A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1651 0000B89B A3[08940100]        <1> 	mov	[mkdir_LastDirCluster], eax
  1652                              <1> 
  1653 0000B8A0 31C9                <1> 	xor	ecx, ecx
  1654 0000B8A2 49                  <1> 	dec	ecx ; FFFFFFFFh
  1655                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1656 0000B8A3 E8E8170000          <1> 	call	update_cluster
  1657 0000B8A8 731A                <1> 	jnc	short loc_mkdir_save_fat_buffer_1
  1658 0000B8AA 09C0                <1> 	or	eax, eax
  1659 0000B8AC 7416                <1> 	jz	short loc_mkdir_save_fat_buffer_1
  1660                              <1> 
  1661                              <1> loc_mkdir_save_fat_buffer_stc_retn:
  1662                              <1> 	; 01/03/2016
  1663 0000B8AE 803D[B2910100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1664 0000B8B5 720C                <1> 	jb	short loc_mkdir_save_fat_buffer_retn
  1665                              <1> 
  1666 0000B8B7 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  1667                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  1668 0000B8BB 50                  <1> 	push	eax
  1669 0000B8BC E8211B0000          <1> 	call	calculate_fat_freespace
  1670 0000B8C1 58                  <1> 	pop	eax
  1671 0000B8C2 F9                  <1> 	stc
  1672                              <1> loc_mkdir_save_fat_buffer_retn:
  1673 0000B8C3 C3                  <1> 	retn
  1674                              <1> 
  1675                              <1> loc_mkdir_save_fat_buffer_1:
  1676                              <1> 	; byte [FAT_BuffValidData] = 2 
  1677 0000B8C4 E8841A0000          <1> 	call	save_fat_buffer
  1678 0000B8C9 72E3                <1> 	jc	short loc_mkdir_save_fat_buffer_stc_retn
  1679                              <1> 
  1680                              <1> 	; 01/03/2016
  1681 0000B8CB 803D[B2910100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1682 0000B8D2 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_2
  1683                              <1> 
  1684                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1685 0000B8D4 A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1686 0000B8D9 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  1687 0000B8DD E8001B0000          <1> 	call	calculate_fat_freespace
  1688                              <1> 
  1689                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  1690                              <1> 	;jnz	short loc_mkdir_save_fat_buffer_2
  1691                              <1> 
  1692                              <1> 	; ecx > 0 -> Recalculation is needed
  1693 0000B8E2 09C9                <1> 	or	ecx, ecx 
  1694 0000B8E4 7409                <1> 	jz	short loc_mkdir_save_fat_buffer_2
  1695                              <1> 
  1696 0000B8E6 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  1697 0000B8EA E8F31A0000          <1> 	call	calculate_fat_freespace
  1698                              <1> 
  1699                              <1> loc_mkdir_save_fat_buffer_2:
  1700 0000B8EF C605[13940100]01    <1> 	mov	byte [mkdir_add_new_cluster], 1
  1701 0000B8F6 E9C4000000          <1> 	jmp	loc_mkdir_upd_parent_dir_lmdt
  1702                              <1> 
  1703                              <1> loc_mkdir_update_sub_dir_cluster:
  1704 0000B8FB A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1705 0000B900 29C9                <1> 	sub	ecx, ecx ; 0
  1706                              <1> 	; 01/03/2016
  1707 0000B902 890D[B2910100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; Reset
  1708 0000B908 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  1709                              <1> 
  1710                              <1> 	; ESI = Logical DOS Drive Descisption Table address  
  1711 0000B909 E882170000          <1> 	call	update_cluster
  1712 0000B90E 7379                <1> 	jnc	short loc_mkdir_save_fat_buffer_3
  1713 0000B910 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1714 0000B912 7475                <1> 	jz	short loc_mkdir_save_fat_buffer_3
  1715                              <1> 	; 01/03/2016
  1716 0000B914 EB98                <1> 	jmp	short loc_mkdir_save_fat_buffer_stc_retn
  1717                              <1> 
  1718                              <1> loc_mkdir_set_ff_dir_entry_2:
  1719                              <1> 	; ESI = Logical DOS Drive Description Table address  
  1720 0000B916 A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1721                              <1> 	; Load disk sectors as a directory cluster
  1722 0000B91B E82C160000          <1> 	call	load_FAT_sub_directory 
  1723 0000B920 7266                <1> 	jc	short retn_make_fat_directory
  1724                              <1> 	
  1725                              <1> 	; eax = 0
  1726                              <1> 	; ecx =  directory buffer sector count (<= 128)
  1727                              <1> 
  1728 0000B922 BF40000800          <1> 	mov	edi, Directory_Buffer + 64 ; 26/02/2016
  1729                              <1> 
  1730                              <1> 	; 02/03/2016
  1731 0000B927 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec] ; 512
  1732 0000B92B 66C1E802            <1> 	shr	ax, 2 ; 'byte count / 4' for 'stosd'
  1733 0000B92F F7E1                <1> 	mul 	ecx
  1734 0000B931 89C1                <1> 	mov	ecx, eax
  1735 0000B933 6629C0              <1> 	sub	ax, ax
  1736 0000B936 F3AB                <1> 	rep	stosd
  1737                              <1> 
  1738                              <1> 	;;mov	al, 128 ; double word
  1739                              <1> 	;;mul	ecx ; ecx =  directory buffer sector count
  1740                              <1> 	;;mov	ecx, eax
  1741                              <1> 	;shl	cx, 7 ; 128 * sector count	
  1742                              <1> 	;;sub	eax, eax
  1743                              <1> 	;;sub	al, al ; 0
  1744                              <1> 	;rep	stosd ; clear directory buffer
  1745                              <1> 
  1746 0000B938 BF00000800          <1> 	mov	edi, Directory_Buffer ; 26/02/2016
  1747                              <1> 	
  1748 0000B93D 56                  <1> 	push	esi
  1749                              <1> 
  1750 0000B93E BE[14940100]        <1> 	mov	esi, mkdir_Name
  1751 0000B943 66C7062E00          <1> 	mov	word [esi], 2Eh ; db '.', '0'
  1752                              <1> 
  1753 0000B948 A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1754 0000B94D 66B91000            <1> 	mov	cx, 10h ; CL = Directory attribute
  1755                              <1> 			; CH = 0 -> File size is 0
  1756 0000B951 E883000000          <1> 	call	make_directory_entry
  1757                              <1> 
  1758 0000B956 BF20000800          <1> 	mov	edi, Directory_Buffer + 32 ; 26/02/2016
  1759                              <1> 
  1760                              <1> 	; 03/03/2016
  1761                              <1> 	; Following modification has been done according to 
  1762                              <1> 	; 'Microsoft Extensible Firmware Initiative
  1763                              <1> 	; FAT32 File System Specification' document,
  1764                              <1> 	; 'FAT: General Overview of On-Disk FormatPage 25'.
  1765                              <1> 	; "Finally, you set DIR_FstClusLO and DIR_FstClusHI
  1766                              <1> 	; for the dotdot entry (the second entry) to the
  1767                              <1> 	; first cluster number of the directory in which you 
  1768                              <1> 	; just created the directory (value is 0 if this directory
  1769                              <1> 	; is the root directory even for FAT32 volumes)."
  1770                              <1> 	; (Correctness of this modification has been verified
  1771                              <1> 	;  by using Windows 98 'scandisk.exe'.)
  1772                              <1> 
  1773 0000B95B 29C0                <1> 	sub	eax, eax
  1774 0000B95D 3805[948A0100]      <1> 	cmp	byte [Current_Dir_Level], al ; 0
  1775 0000B963 7605                <1> 	jna	short loc_mkdir_set_ff_dir_entry_3
  1776 0000B965 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster] ; parent dir
  1777                              <1> loc_mkdir_set_ff_dir_entry_3:
  1778 0000B96A 66C746012E00        <1> 	mov	word [esi+1], 2Eh ; db '.', '0'
  1779                              <1> 
  1780                              <1> 	;mov	cx, 10h
  1781 0000B970 E864000000          <1> 	call	make_directory_entry
  1782                              <1> 
  1783 0000B975 5E                  <1> 	pop	esi
  1784                              <1> 
  1785 0000B976 C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  1786 0000B97D E834010000          <1> 	call	save_directory_buffer
  1787 0000B982 0F8373FFFFFF        <1>         jnc     loc_mkdir_update_sub_dir_cluster
  1788                              <1>  
  1789                              <1> retn_make_fat_directory:
  1790 0000B988 C3                  <1> 	retn
  1791                              <1> 
  1792                              <1> loc_mkdir_save_fat_buffer_3:
  1793                              <1> 	; 01/03/2016
  1794                              <1> 	; byte [FAT_BuffValidData] = 2 
  1795 0000B989 E8BF190000          <1> 	call	save_fat_buffer
  1796 0000B98E 0F821AFFFFFF        <1>         jc      loc_mkdir_save_fat_buffer_stc_retn
  1797                              <1> 
  1798 0000B994 803D[B2910100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  1799 0000B99B 721B                <1> 	jb	short loc_mkdir_save_fat_buffer_4
  1800                              <1> 
  1801                              <1> 	; ESI = Logical DOS Drive Description Table address 
  1802 0000B99D A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1803 0000B9A2 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  1804 0000B9A6 E8371A0000          <1> 	call	calculate_fat_freespace
  1805                              <1> 
  1806                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  1807                              <1>         ;jnz    short loc_mkdir_save_fat_buffer_4
  1808                              <1> 
  1809                              <1> 	; ecx > 0 -> Recalculation is needed
  1810 0000B9AB 09C9                <1> 	or	ecx, ecx 
  1811 0000B9AD 7409                <1>         jz      short loc_mkdir_save_fat_buffer_4
  1812                              <1> 
  1813 0000B9AF 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space
  1814 0000B9B3 E82A1A0000          <1> 	call	calculate_fat_freespace
  1815                              <1> 
  1816                              <1> loc_mkdir_save_fat_buffer_4:	
  1817 0000B9B8 C605[13940100]00    <1> 	mov	byte [mkdir_add_new_cluster], 0
  1818                              <1> 
  1819                              <1> loc_mkdir_upd_parent_dir_lmdt:
  1820 0000B9BF E88D010000          <1> 	call	update_parent_dir_lmdt
  1821                              <1> 
  1822                              <1> 	; 01/03/2016
  1823 0000B9C4 803D[13940100]00    <1> 	cmp	byte [mkdir_add_new_cluster], 0
  1824 0000B9CB 0F8723FEFFFF        <1>         ja      loc_mkdir_gffc_2
  1825                              <1> 
  1826                              <1> loc_mkdir_retn_new_dir_cluster:
  1827 0000B9D1 A1[04940100]        <1> 	mov	eax, [mkdir_FFCluster]
  1828 0000B9D6 31D2                <1> 	xor	edx, edx
  1829                              <1> loc_mkdir_retn:
  1830 0000B9D8 C3                  <1> 	retn
  1831                              <1> 
  1832                              <1> make_directory_entry:
  1833                              <1> 	; 02/03/2016
  1834                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1835                              <1> 	; 09/08/2010 (DIR.ASM, 'proc_make_directory_entry')
  1836                              <1> 	; 17/07/2010
  1837                              <1> 	; INPUT ->
  1838                              <1> 	; 	EDI = Directory Entry Address
  1839                              <1> 	;	ESI = Dot File Name Location
  1840                              <1> 	;	EAX = First Cluster
  1841                              <1> 	;	File Size = 0 (Must be set later)
  1842                              <1> 	;	CL = Attributes
  1843                              <1> 	;	CH = 0 (File size = 0) 
  1844                              <1> 	;	(If CH>0, File size is in dword [EBX]) (*)
  1845                              <1> 	; OUTPUT -> 
  1846                              <1> 	;	EDI = Directory Entry Address
  1847                              <1> 	;	ESI = Dot File Name Location (Capitalized)
  1848                              <1> 	;	If CH input = 0, File Size = 0
  1849                              <1> 	;	Otherwise file size is as dword [EBX] (*)
  1850                              <1> 	;	DX = Date, AX = Time in DOS Dir Entry format
  1851                              <1> 	;	EBX = same
  1852                              <1> 	;	ECX = same
  1853                              <1> 
  1854 0000B9D9 51                  <1> 	push	ecx
  1855                              <1> 
  1856 0000B9DA 884F0B              <1> 	mov	[edi+11], cl ; Attributes
  1857 0000B9DD 6689471A            <1> 	mov	[edi+26], ax ; FClusterLw, 26
  1858 0000B9E1 C1E810              <1> 	shr	eax, 16
  1859 0000B9E4 66894714            <1> 	mov	[edi+20], ax ; FClusterHw, 20
  1860 0000B9E8 6631C0              <1> 	xor	ax, ax 
  1861 0000B9EB 6689470C            <1> 	mov	[edi+12], ax ; NTReserved, 12
  1862                              <1> 			     ; CrtTimeTenth, 13
  1863 0000B9EF 08ED                <1> 	or	ch, ch
  1864 0000B9F1 7402                <1> 	jz	short loc_make_direntry_set_filesize
  1865                              <1> 
  1866 0000B9F3 8B03                <1> 	mov	eax, [ebx]
  1867                              <1>         
  1868                              <1> loc_make_direntry_set_filesize:
  1869 0000B9F5 89471C              <1> 	mov	[edi+28], eax ; FileSize, 28
  1870                              <1> 	
  1871 0000B9F8 E88AFBFFFF          <1> 	call	convert_file_name
  1872                              <1> 	;EDI = Dir Entry Format File Name Location
  1873                              <1> 	;ESI = Dot File Name Location (capitalized)
  1874                              <1> 
  1875 0000B9FD E816000000          <1> 	call	convert_current_date_time
  1876                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  1877                              <1>         ; 	    AX = Time in dos dir entry format
  1878 0000BA02 6689470E            <1> 	mov	[edi+14], ax ; CrtTime, 14
  1879 0000BA06 66895710            <1> 	mov	[edi+16], dx ; CrtDate, 16
  1880 0000BA0A 66895712            <1> 	mov	[edi+18], dx ; LastAccDate, 18
  1881 0000BA0E 66894716            <1> 	mov	[edi+22], ax ; WrtTime, 14
  1882 0000BA12 66895718            <1> 	mov	[edi+24], dx ; WrtDate, 16
  1883 0000BA16 59                  <1> 	pop	ecx
  1884                              <1> 
  1885 0000BA17 C3                  <1> 	retn
  1886                              <1> 
  1887                              <1> convert_current_date_time:
  1888                              <1> 	; 21/02/2016 (TRDOS 386 = TRDOS v2.0)
  1889                              <1> 	; 13/06/2010 (DIR.ASM, 'proc_convert_current_date_time')
  1890                              <1> 	; converts date&time to dos dir entry format
  1891                              <1> 	; INPUT -> none
  1892                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  1893                              <1> 	;           AX = Time in dos dir entry format
  1894                              <1>  
  1895 0000BA18 B404                <1> 	mov	ah, 04h ; Return Current Date
  1896 0000BA1A E817B0FFFF          <1> 	call	int1Ah 
  1897                              <1> 
  1898 0000BA1F 88E8                <1> 	mov	al, ch ; <- century BCD
  1899 0000BA21 240F                <1> 	and	al, 0Fh
  1900 0000BA23 88EC                <1> 	mov	ah, ch
  1901 0000BA25 C0EC04              <1> 	shr	ah, 4
  1902 0000BA28 D50A                <1> 	aad
  1903 0000BA2A 88C5                <1> 	mov	ch, al ; -> century 
  1904                              <1> 
  1905 0000BA2C 88C8                <1> 	mov	al, cl ; <- year BCD
  1906 0000BA2E 240F                <1> 	and	al, 0Fh
  1907 0000BA30 88CC                <1> 	mov	ah, cl
  1908 0000BA32 C0EC04              <1> 	shr	ah, 4
  1909 0000BA35 D50A                <1> 	aad
  1910 0000BA37 88C1                <1> 	mov	cl, al ; -> year
  1911                              <1> 
  1912 0000BA39 88E8                <1> 	mov	al, ch
  1913 0000BA3B B464                <1> 	mov	ah, 100
  1914 0000BA3D F6E4                <1> 	mul	ah
  1915 0000BA3F 30ED                <1> 	xor	ch, ch
  1916 0000BA41 6601C8              <1> 	add	ax, cx
  1917 0000BA44 662DBC07            <1> 	sub	ax, 1980 ; ms-dos epoch
  1918 0000BA48 6689C1              <1> 	mov	cx, ax
  1919                              <1> 
  1920 0000BA4B 88F0                <1> 	mov	al, dh ; <- month in bcd
  1921 0000BA4D 240F                <1> 	and	al, 0Fh
  1922 0000BA4F 88F4                <1> 	mov	ah, dh
  1923 0000BA51 C0EC04              <1> 	shr	ah, 4
  1924 0000BA54 D50A                <1> 	aad
  1925 0000BA56 88C6                <1> 	mov	dh, al ; -> month
  1926                              <1> 
  1927 0000BA58 88D0                <1> 	mov	al, dl ; <- day BCD
  1928 0000BA5A 240F                <1> 	and	al, 0Fh
  1929 0000BA5C 88D4                <1> 	mov	ah, dl
  1930 0000BA5E C0EC04              <1> 	shr	ah, 4
  1931 0000BA61 D50A                <1> 	aad
  1932 0000BA63 88C2                <1> 	mov	dl, al ; -> day
  1933                              <1> 
  1934 0000BA65 88C8                <1> 	mov	al, cl ; count of years from 1980
  1935 0000BA67 66C1E004            <1> 	shl	ax, 4
  1936 0000BA6B 08F0                <1> 	or	al, dh ; month of year, 1 to 12
  1937 0000BA6D 66C1E005            <1> 	shl	ax, 5
  1938 0000BA71 08D0                <1> 	or	al, dl ; day of year, 1 to 31
  1939                              <1> 	
  1940 0000BA73 6650                <1> 	push	ax ; push date
  1941                              <1> 
  1942 0000BA75 B402                <1> 	mov	ah, 02h ; Return Current Time
  1943 0000BA77 E8BAAFFFFF          <1> 	call	int1Ah
  1944                              <1> 
  1945 0000BA7C 88E8                <1> 	mov	al, ch ; <- hours BCD
  1946 0000BA7E 240F                <1> 	and	al, 0Fh
  1947 0000BA80 88EC                <1> 	mov	ah, ch
  1948 0000BA82 C0EC04              <1> 	shr	ah, 4
  1949 0000BA85 D50A                <1> 	aad
  1950 0000BA87 88C5                <1> 	mov	ch, al ; -> hours
  1951                              <1> 
  1952 0000BA89 88C8                <1> 	mov	al, cl ; <- minutes BCD
  1953 0000BA8B 240F                <1> 	and	al, 0Fh
  1954 0000BA8D 88CC                <1> 	mov	ah, cl
  1955 0000BA8F C0EC04              <1> 	shr	ah, 4
  1956 0000BA92 D50A                <1> 	aad
  1957 0000BA94 88C1                <1> 	mov	cl, al ; -> minutes
  1958                              <1> 
  1959 0000BA96 88F0                <1> 	mov	al, dh ; <- seconds BCD
  1960 0000BA98 240F                <1> 	and	al, 0Fh
  1961 0000BA9A 88F4                <1> 	mov	ah, dh
  1962 0000BA9C C0EC04              <1> 	shr	ah, 4
  1963 0000BA9F D50A                <1> 	aad
  1964 0000BAA1 88C6                <1> 	mov	dh, al ; -> seconds
  1965                              <1> 
  1966 0000BAA3 88E8                <1> 	mov	al, ch ; hours
  1967 0000BAA5 66C1E006            <1> 	shl	ax, 6
  1968 0000BAA9 08C8                <1> 	or	al, cl ; minutes
  1969 0000BAAB 66C1E005            <1> 	shl	ax, 5
  1970 0000BAAF D0EE                <1> 	shr	dh, 1 ; 2 seconds
  1971                              <1> 	; There is a bug in TRDOS v1 here !
  1972                              <1> 	; it was 'or al, dl' ! 
  1973 0000BAB1 08F0                <1> 	or	al, dh ; seconds
  1974                              <1> 
  1975 0000BAB3 665A                <1> 	pop	dx ; pop date
  1976                              <1> 	
  1977 0000BAB5 C3                  <1> 	retn
  1978                              <1> 
  1979                              <1> save_directory_buffer:
  1980                              <1> 	; 15/10/2016
  1981                              <1> 	; 23/03/2016
  1982                              <1> 	; 26/02/2016
  1983                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  1984                              <1> 	; 01/08/2011
  1985                              <1> 	; 14/03/2010
  1986                              <1> 	; INPUT ->
  1987                              <1> 	; 	 none
  1988                              <1> 	; OUTPUT ->
  1989                              <1> 	;  cf = 0 -> write OK...
  1990                              <1> 	;  cf = 1 -> error code in AL (EAX)
  1991                              <1> 	;  cf = 1 & AL = 0Dh => CH & CL = FS & FAT type
  1992                              <1> 	;  EBX = Directory Buffer Address
  1993                              <1> 	;
  1994                              <1> 	;  (EAX, ECX, EDX will be modified)
  1995                              <1>  
  1996 0000BAB6 BB00000800          <1> 	mov	ebx, Directory_Buffer
  1997 0000BABB 803D[BC910100]02    <1> 	cmp	byte [DirBuff_ValidData], 2
  1998 0000BAC2 7403                <1> 	je	short loc_save_dir_buffer
  1999 0000BAC4 31C0                <1> 	xor	eax, eax
  2000 0000BAC6 C3                  <1> 	retn            
  2001                              <1> 
  2002                              <1> loc_save_dir_buffer:
  2003 0000BAC7 56                  <1> 	push	esi
  2004 0000BAC8 31DB                <1> 	xor	ebx, ebx 
  2005 0000BACA 8A3D[BA910100]      <1>         mov     bh, [DirBuff_DRV]
  2006 0000BAD0 80EF41              <1> 	sub	bh, 'A'
  2007 0000BAD3 BE00010900          <1>         mov     esi, Logical_DOSDisks
  2008 0000BAD8 01DE                <1> 	add	esi, ebx
  2009 0000BADA 668B4E03            <1>         mov     cx, [esi+LD_FATType]
  2010                              <1> 	; CH = FS Type (A1h for FS)
  2011                              <1> 	; CL = FAT Type (0 for FS)
  2012 0000BADE 08C9                <1> 	or	cl, cl
  2013 0000BAE0 7433                <1> 	jz	short loc_save_dir_buff_stc_retn
  2014                              <1> 
  2015                              <1> loc_save_dir_buffer_check_cluster_no:    
  2016 0000BAE2 A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
  2017 0000BAE7 28FF                <1> 	sub	bh, bh ; ebx = 0
  2018 0000BAE9 09C0                <1> 	or	eax, eax
  2019 0000BAEB 7540                <1> 	jnz	short loc_save_sub_dir_buffer
  2020 0000BAED 8A25[BB910100]      <1> 	mov	ah, [DirBuff_FATType]
  2021 0000BAF3 FEC3                <1> 	inc	bl ;  bl = 1
  2022 0000BAF5 38DC                <1> 	cmp	ah, bl
  2023 0000BAF7 721D                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  2024 0000BAF9 FEC3                <1> 	inc	bl ; bl = 2
  2025 0000BAFB 38E3                <1> 	cmp	bl, ah
  2026 0000BAFD 7217                <1> 	jb	short loc_save_dir_buff_inv_data_retn
  2027                              <1> 
  2028                              <1> loc_save_root_dir_buffer:
  2029 0000BAFF 668B5E17            <1> 	mov	bx, [esi+LD_BPB+RootDirEnts]
  2030 0000BB03 6683C30F            <1> 	add	bx, 15
  2031 0000BB07 66C1EB04            <1> 	shr	bx, 4 ; 16 dir entries per sector
  2032 0000BB0B 6609DB              <1> 	or	bx, bx
  2033 0000BB0E 7405                <1> 	jz	short loc_save_dir_buff_stc_retn
  2034                              <1> 	;mov	ecx, ebx 
  2035 0000BB10 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin] ; 26/02/2016
  2036 0000BB13 EB23                <1> 	jmp	short loc_write_directory_to_disk
  2037                              <1> 
  2038                              <1> loc_save_dir_buff_stc_retn:
  2039 0000BB15 F9                  <1> 	stc
  2040                              <1> loc_save_dir_buff_inv_data_retn:
  2041                              <1> 	; 15/10/2016 (0Dh -> 29)
  2042 0000BB16 B01D                <1> 	mov	al, 29 ; Invalid data !
  2043 0000BB18 C605[BC910100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  2044 0000BB1F EB05                <1> 	jmp	short loc_save_dir_buff_retn 
  2045                              <1> 
  2046                              <1> loc_write_directory_to_disk_err:
  2047                              <1> 	; 15/10/2016 (disk write error code, 1Dh -> 18)
  2048 0000BB21 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error 
  2049                              <1> 
  2050                              <1> loc_save_dir_buff_retn:
  2051 0000BB26 BB00000800          <1> 	mov	ebx, Directory_Buffer
  2052 0000BB2B 5E                  <1> 	pop	esi
  2053 0000BB2C C3                  <1> 	retn
  2054                              <1>  
  2055                              <1> loc_save_sub_dir_buffer:
  2056                              <1> 	; ebx  = 0
  2057 0000BB2D 83E802              <1> 	sub	eax, 2
  2058 0000BB30 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  2059 0000BB33 F7E3                <1> 	mul	ebx
  2060 0000BB35 034668              <1>         add     eax, [esi+LD_DATABegin]
  2061                              <1>  	;mov	ecx, ebx
  2062                              <1> 
  2063                              <1> loc_write_directory_to_disk:
  2064 0000BB38 89D9                <1>  	mov	ecx, ebx
  2065 0000BB3A BB00000800          <1> 	mov	ebx, Directory_Buffer
  2066 0000BB3F E80A700000          <1> 	call	disk_write
  2067 0000BB44 72DB                <1> 	jc	short loc_write_directory_to_disk_err
  2068                              <1> 
  2069                              <1> loc_save_dir_buff_validate_retn:
  2070 0000BB46 C605[BC910100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  2071 0000BB4D 31C0                <1> 	xor	eax, eax
  2072                              <1> 	; 26/02/2016
  2073 0000BB4F EBD5                <1> 	jmp	short loc_save_dir_buff_retn
  2074                              <1> 
  2075                              <1> update_parent_dir_lmdt:
  2076                              <1> 	; 29/12/2017
  2077                              <1> 	; 22/02/2016 (TRDOS 386 = TRDOS v2.0)
  2078                              <1> 	; 01/08/2011
  2079                              <1> 	; 16/10/2010 
  2080                              <1> 	; 
  2081                              <1> 	; INPUT -> 
  2082                              <1> 	;	none
  2083                              <1>  	; OUTPUT ->
  2084                              <1> 	;	(last modification date & time of the parent dir
  2085                              <1> 	;	will be changed/updated)
  2086                              <1> 	;
  2087                              <1> 	; (EAX, EBX, ECX, EDX, EDI will be changed)
  2088                              <1> 
  2089 0000BB51 29C0                <1> 	sub	eax, eax
  2090 0000BB53 8A25[948A0100]      <1> 	mov	ah, [Current_Dir_Level]
  2091 0000BB59 A0[958A0100]        <1> 	mov	al, [Current_FATType]
  2092 0000BB5E 3C01                <1> 	cmp	al, 1
  2093 0000BB60 723A                <1> 	jb	short loc_UPDLMDT_proc_retn
  2094                              <1>     
  2095                              <1> loc_update_parent_dir_lm_date_time:
  2096 0000BB62 08E4                <1> 	or	ah, ah
  2097 0000BB64 7436                <1> 	jz	short loc_UPDLMDT_proc_retn
  2098                              <1> 
  2099 0000BB66 56                  <1> 	push	esi ; *
  2100 0000BB67 8825[34940100]      <1> 	mov	[UPDLMDT_CDirLevel], ah
  2101 0000BB6D 8B15[908A0100]      <1> 	mov	edx, [Current_Dir_FCluster]
  2102 0000BB73 8915[35940100]      <1> 	mov	[UPDLMDT_CDirFCluster], edx
  2103                              <1> 
  2104 0000BB79 FECC                <1> 	dec	ah
  2105 0000BB7B B90C000000          <1> 	mov	ecx, 12
  2106 0000BB80 BE[F3910100]        <1>         mov     esi, PATH_Array
  2107                              <1> 
  2108 0000BB85 8825[948A0100]      <1> 	mov	[Current_Dir_Level], ah
  2109 0000BB8B 08E4                <1> 	or	ah, ah
  2110 0000BB8D 750E                <1> 	jnz	short loc_update_parent_dir_lmdt_load_sub_dir_1
  2111 0000BB8F 803D[958A0100]02    <1> 	cmp	byte [Current_FATType], 2
  2112 0000BB96 770B                <1> 	ja	short loc_update_parent_dir_lmdt_load_sub_dir_2
  2113 0000BB98 28C0                <1> 	sub	al, al ; eax = 0
  2114 0000BB9A EB0A                <1> 	jmp	short loc_update_parent_dir_lmdt_load_sub_dir_3
  2115                              <1> 
  2116                              <1> loc_UPDLMDT_proc_retn:
  2117 0000BB9C C3                  <1> 	retn
  2118                              <1>          
  2119                              <1> loc_update_parent_dir_lmdt_load_sub_dir_1:
  2120 0000BB9D B010                <1> 	mov	al, 16
  2121 0000BB9F F6E4                <1> 	mul	ah 
  2122 0000BBA1 01C6                <1> 	add	esi, eax
  2123                              <1> 
  2124                              <1> loc_update_parent_dir_lmdt_load_sub_dir_2:  
  2125 0000BBA3 8B460C              <1> 	mov	eax, [esi+12] ; Parent Dir First Cluster
  2126                              <1> 
  2127                              <1> loc_update_parent_dir_lmdt_load_sub_dir_3:
  2128 0000BBA6 A3[908A0100]        <1> 	mov	[Current_Dir_FCluster], eax
  2129                              <1> 
  2130 0000BBAB 83C610              <1> 	add	esi, 16
  2131 0000BBAE 66BF[1A93]          <1> 	mov	di, Dir_File_Name  
  2132 0000BBB2 F3A4                <1> 	rep	movsb
  2133                              <1> 	
  2134 0000BBB4 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2135 0000BBB9 29DB                <1> 	sub	ebx, ebx
  2136 0000BBBB 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  2137 0000BBC1 01DE                <1> 	add	esi, ebx
  2138 0000BBC3 E88FF7FFFF          <1> 	call	reload_current_directory
  2139 0000BBC8 7230                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2140                              <1> 
  2141                              <1> loc_update_parent_dir_lmdt_locate_dir: 
  2142 0000BBCA BE[1A930100]        <1> 	mov	esi, Dir_File_Name        
  2143 0000BBCF 6631C9              <1> 	xor	cx, cx
  2144 0000BBD2 66B81008            <1> 	mov	ax, 0810h ; Only directories
  2145 0000BBD6 E8B5F6FFFF          <1>         call    locate_current_dir_file
  2146                              <1> 	; EDI = DirBuff Directory Entry Address
  2147 0000BBDB 721D                <1> 	jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2148                              <1> 
  2149 0000BBDD E836FEFFFF          <1> 	call	convert_current_date_time
  2150 0000BBE2 66895712            <1> 	mov	[edi+18], dx ; Last Access Date
  2151 0000BBE6 66895718            <1> 	mov	[edi+24], dx ; Last Write Date
  2152 0000BBEA 66894716            <1> 	mov	[edi+22], ax ; Last Write Time
  2153                              <1> 
  2154 0000BBEE C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  2155 0000BBF5 E8BCFEFFFF          <1> 	call	save_directory_buffer
  2156                              <1> 	; 29/12/2017
  2157                              <1> 	;jc	short loc_update_parent_dir_lmdt_restore_cdirlevel
  2158                              <1> 	;xor	al, al 
  2159                              <1> loc_update_parent_dir_lmdt_restore_cdirlevel:
  2160                              <1>  	;current directory level restoration
  2161 0000BBFA 8A25[34940100]      <1> 	mov	ah, [UPDLMDT_CDirLevel]
  2162 0000BC00 8825[948A0100]      <1> 	mov	[Current_Dir_Level], ah
  2163 0000BC06 8B15[35940100]      <1>         mov     edx, [UPDLMDT_CDirFCluster]
  2164 0000BC0C 8915[908A0100]      <1> 	mov	[Current_Dir_FCluster], edx
  2165                              <1> 
  2166 0000BC12 5E                  <1> 	pop	esi ; *
  2167 0000BC13 C3                  <1> 	retn
  2168                              <1> 
  2169                              <1> delete_longname:
  2170                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  2171                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_longname')
  2172                              <1> 	; 14/03/2010
  2173                              <1> 	; INPUT ->
  2174                              <1> 	; 	EAX = Directory Entry (Index) Number (< 65536)
  2175                              <1> 	; OUTPUT ->
  2176                              <1> 	;	cf = 0 -> OK  (EAX = 0)
  2177                              <1> 	; 	cf = 1 -> error code in EAX (AL)
  2178                              <1> 	;
  2179                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  2180                              <1> 
  2181 0000BC14 66A3[64940100]      <1> 	mov	[DLN_EntryNumber], ax
  2182 0000BC1A C605[66940100]40    <1>         mov     byte [DLN_40h], 40h
  2183                              <1> 
  2184 0000BC21 E858000000          <1> 	call	locate_current_dir_entry
  2185 0000BC26 7308                <1> 	jnc	short loc_dln_check_attributes
  2186 0000BC28 C3                  <1> 	retn
  2187                              <1> 
  2188                              <1> loc_dln_longname_not_found:
  2189 0000BC29 B802000000          <1> 	mov	eax, 2
  2190 0000BC2E F9                  <1> 	stc
  2191 0000BC2F C3                  <1> 	retn
  2192                              <1> 
  2193                              <1> loc_dln_check_attributes:
  2194 0000BC30 B00F                <1> 	mov	al, 0Fh  ; long name
  2195 0000BC32 8A670B              <1> 	mov	ah, [edi+0Bh] ; dir entry attributes
  2196 0000BC35 38C4                <1> 	cmp	ah, al
  2197 0000BC37 75F0                <1> 	jne	short loc_dln_longname_not_found
  2198 0000BC39 8A27                <1> 	mov	ah, [edi]
  2199 0000BC3B 2A25[66940100]      <1> 	sub	ah, [DLN_40h]
  2200 0000BC41 76E6                <1> 	jna	short loc_dln_longname_not_found         
  2201 0000BC43 80FC14              <1> 	cmp	ah, 14h ; 84-64=20 -> 20*13=260 bytes
  2202 0000BC46 77E1                <1> 	ja	short loc_dln_longname_not_found
  2203                              <1>              
  2204 0000BC48 C607E5              <1> 	mov	byte [edi], 0E5h  ; deleted sign
  2205 0000BC4B C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; changed/write sign
  2206 0000BC52 C605[66940100]00    <1> 	mov	byte [DLN_40h], 0 ; 40h -> 0
  2207                              <1> 	  
  2208                              <1> loc_dln_delete_next_ln_entry:
  2209 0000BC59 80FC01              <1> 	cmp	ah, 1
  2210 0000BC5C 7616                <1> 	jna	short loc_dln_longname_retn
  2211                              <1> loc_dln_delete_next_ln_entry_0:
  2212 0000BC5E 66FF05[64940100]    <1> 	inc	word [DLN_EntryNumber]
  2213 0000BC65 0FB705[64940100]    <1> 	movzx	eax, word [DLN_EntryNumber] 
  2214 0000BC6C E80D000000          <1> 	call	locate_current_dir_entry
  2215 0000BC71 73BD                <1> 	jnc	short loc_dln_check_attributes
  2216                              <1> 
  2217                              <1> loc_dln_longname_stc_retn:
  2218 0000BC73 C3                  <1> 	retn 
  2219                              <1> 	   
  2220                              <1> loc_dln_longname_retn:
  2221                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  2222                              <1> 	;jne	short loc_dln_longname_retn_xor_eax
  2223 0000BC74 E83DFEFFFF          <1> 	call	save_directory_buffer
  2224 0000BC79 72F8                <1> 	jc	short loc_dln_longname_stc_retn
  2225                              <1> 
  2226                              <1> loc_dln_longname_retn_xor_eax:
  2227 0000BC7B 31C0                <1> 	xor	eax, eax
  2228 0000BC7D C3                  <1> 	retn
  2229                              <1> 
  2230                              <1> locate_current_dir_entry:
  2231                              <1> 	; 16/10/2016
  2232                              <1> 	; 15/10/2016
  2233                              <1> 	; 23/03/2016
  2234                              <1> 	; 27/02/2016 (TRDOS 386 = TRDOS v2.0)
  2235                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_locate_current_dir_entry')
  2236                              <1> 	; 07/03/2010
  2237                              <1> 	; INPUT ->
  2238                              <1> 	;	EAX = Directory Entry (Index) Number (< 65536) 
  2239                              <1> 	; OUTPUT ->
  2240                              <1> 	;	EDI = Directory Entry Address
  2241                              <1> 	; 	EAX = Cluster Number of Directory Buffer
  2242                              <1> 	;	EBX = Directory Buffer Entry Offset
  2243                              <1> 	;	ECX = DirBuff Valid Data identifier (CL)
  2244                              <1> 	;   	If CF = 0 and CL = 2 then
  2245                              <1> 	;	   directory buffer modified and
  2246                              <1> 	;	   must be written to disk.
  2247                              <1> 	; 	If CF = 0  and CL = 1 then
  2248                              <1> 	;	   dir buffer has been written to disk, already.
  2249                              <1> 	;	CF = 1 -> Error code in EAX (AL)
  2250                              <1> 	;
  2251                              <1> 	; (Modified registers: EAX, EDX, ECX, EBX, EDI) 
  2252                              <1> 
  2253                              <1> loc_locate_current_dir_entry:
  2254 0000BC7E 56                  <1> 	push	esi
  2255 0000BC7F 89C1                <1> 	mov	ecx, eax
  2256 0000BC81 BA20000000          <1> 	mov	edx, 32
  2257 0000BC86 F7E2                <1> 	mul	edx 
  2258 0000BC88 A3[70940100]        <1> 	mov	[LCDE_ByteOffset], eax
  2259 0000BC8D 31DB                <1> 	xor	ebx, ebx
  2260 0000BC8F 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  2261 0000BC95 A0[BA910100]        <1>         mov     al, [DirBuff_DRV]
  2262 0000BC9A 2C41                <1> 	sub	al, 'A'
  2263 0000BC9C BE00010900          <1>         mov     esi, Logical_DOSDisks
  2264 0000BCA1 01DE                <1> 	add	esi, ebx
  2265 0000BCA3 38C7                <1> 	cmp	bh, al
  2266 0000BCA5 0F8592000000        <1>         jne     loc_lcde_reload_current_directory
  2267                              <1> loc_lcde_cdl_check:
  2268 0000BCAB 803D[948A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0
  2269 0000BCB2 772A                <1> 	ja	short loc_lcde_calc_dirbuff_cluster_offset
  2270                              <1> 	; 27/02/2016
  2271                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  2272                              <1> 	; (Root Directory Entries for FAT32 = 0)
  2273 0000BCB4 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  2274 0000BCB8 7324                <1> 	jnb	short loc_lcde_calc_dirbuff_cluster_offset
  2275                              <1> 
  2276                              <1> loc_lcde_cdl_check_FAT12_16:
  2277 0000BCBA 668B4617            <1> 	mov	ax, [esi+LD_BPB+RootDirEnts]
  2278 0000BCBE 6648                <1> 	dec	ax
  2279                              <1> 	;xor	dx, dx  
  2280 0000BCC0 6639C8              <1> 	cmp	ax, cx ; cx = Directory Entry (Index) Number
  2281 0000BCC3 720E                <1> 	jb	short loc_lcde_stc_12h_retn
  2282 0000BCC5 66890D[68940100]    <1> 	mov	[LCDE_EntryIndex], cx
  2283 0000BCCC 31C0                <1> 	xor	eax, eax
  2284 0000BCCE E993000000          <1>         jmp     loc_lcde_check_dir_buffer_cluster
  2285                              <1> 
  2286                              <1> loc_lcde_stc_12h_retn:
  2287 0000BCD3 5E                  <1> 	pop	esi
  2288 0000BCD4 89CB                <1> 	mov	ebx, ecx
  2289 0000BCD6 89D1                <1> 	mov	ecx, edx
  2290                              <1> 	; 16/10/2016 (12h -> 12)
  2291 0000BCD8 B80C000000          <1> 	mov	eax, 12 ; No more files
  2292 0000BCDD C3                  <1> 	retn 
  2293                              <1> 
  2294                              <1> loc_lcde_calc_dirbuff_cluster_offset:
  2295 0000BCDE 8A5E13              <1> 	mov	bl, [esi+LD_BPB+SecPerClust]
  2296 0000BCE1 30FF                <1> 	xor	bh, bh
  2297 0000BCE3 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  2298 0000BCE7 66F7E3              <1> 	mul	bx
  2299 0000BCEA 6609D2              <1>  	or	dx, dx ; If bytes per cluster > 32KB it is invalid
  2300 0000BCED 755D                <1> 	jnz	short loc_lcde_invalid_format
  2301                              <1> 	;mov	ecx, eax
  2302 0000BCEF 6689C1              <1> 	mov	cx, ax ; BYTES PER CLUSTER
  2303 0000BCF2 A1[70940100]        <1> 	mov	eax, [LCDE_ByteOffset]
  2304                              <1> 	;sub	edx, edx
  2305 0000BCF7 F7F1                <1> 	div	ecx
  2306 0000BCF9 3DFFFF0000          <1> 	cmp	eax, 65535
  2307 0000BCFE 774C                <1> 	ja	short loc_lcde_invalid_format
  2308                              <1> 
  2309                              <1> 	; cluster sequence number of directory (< 65536)
  2310 0000BD00 66A3[6A940100]      <1> 	mov	[LCDE_ClusterSN], ax 
  2311                              <1> 
  2312 0000BD06 6689D0              <1> 	mov	ax, dx ; byte offset in cluster (directory buffer)
  2313 0000BD09 66BB2000            <1> 	mov	bx, 32 ; ; 1 dir entry = 32 bytes
  2314 0000BD0D 6629D2              <1>         sub     dx, dx  ; 0
  2315 0000BD10 66F7F3              <1> 	div	bx 
  2316 0000BD13 66A3[68940100]      <1> 	mov	[LCDE_EntryIndex], ax ; dir entry index/sequence number
  2317                              <1> 				      ; (in directory buffer/cluster)	  
  2318                              <1> loc_lcde_get_current_sub_dir_fcluster:
  2319 0000BD19 A1[908A0100]        <1> 	mov	eax, [Current_Dir_FCluster]
  2320                              <1> 
  2321                              <1> loc_lcde_get_next_cluster:
  2322 0000BD1E 66833D[6A940100]00  <1> 	cmp	word [LCDE_ClusterSN], 0
  2323 0000BD26 763E                <1> 	jna	short loc_lcde_check_dir_buffer_cluster
  2324 0000BD28 A3[6C940100]        <1> 	mov	[LCDE_Cluster], eax
  2325 0000BD2D E834100000          <1> 	call	get_next_cluster
  2326 0000BD32 7220                <1> 	jc	short loc_lcde_check_gnc_error
  2327 0000BD34 66FF0D[6A940100]    <1>   	dec	word [LCDE_ClusterSN]
  2328 0000BD3B EBE1                <1> 	jmp	short loc_lcde_get_next_cluster
  2329                              <1> 
  2330                              <1> loc_lcde_reload_current_directory:
  2331 0000BD3D 51                  <1> 	push	ecx
  2332 0000BD3E E814F6FFFF          <1> 	call	reload_current_directory
  2333 0000BD43 59                  <1> 	pop	ecx
  2334 0000BD44 0F8361FFFFFF        <1>         jnc     loc_lcde_cdl_check
  2335 0000BD4A 5E                  <1> 	pop	esi
  2336 0000BD4B C3                  <1> 	retn
  2337                              <1> 
  2338                              <1> loc_lcde_invalid_format:
  2339                              <1> 	; 15/10/2016 (0Bh -> 28)
  2340 0000BD4C B81C000000          <1> 	mov	eax, 28 ; Invalid Format !
  2341                              <1> loc_lcde_drive_not_ready_read_err:
  2342 0000BD51 F9                  <1> 	stc
  2343 0000BD52 5E                  <1> 	pop	esi 
  2344 0000BD53 C3                  <1> 	retn  
  2345                              <1> 
  2346                              <1> loc_lcde_check_gnc_error:
  2347 0000BD54 09C0                <1> 	or	eax, eax
  2348 0000BD56 75F9                <1> 	jnz	short loc_lcde_drive_not_ready_read_err
  2349 0000BD58 66FF0D[6A940100]    <1> 	dec	word [LCDE_ClusterSN]
  2350 0000BD5F 75EB                <1> 	jnz	short loc_lcde_invalid_format 
  2351 0000BD61 A1[6C940100]        <1> 	mov	eax, [LCDE_Cluster]
  2352                              <1> 
  2353                              <1> loc_lcde_check_dir_buffer_cluster:
  2354 0000BD66 3B05[C1910100]      <1> 	cmp	eax, [DirBuff_Cluster]
  2355 0000BD6C 755C                <1> 	jne	short loc_lcde_load_dir_cluster
  2356 0000BD6E 803D[BC910100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
  2357 0000BD75 7727                <1> 	ja	short lcde_check_dir_buffer_cluster_next
  2358 0000BD77 803D[948A0100]00    <1> 	cmp	byte [Current_Dir_Level], 0    
  2359 0000BD7E 775F                <1> 	ja	short loc_lcde_load_dir_cluster_0
  2360                              <1> 	; 27/02/2016
  2361                              <1> 	; TRDOS v1 has bug here for FAT32 fs !
  2362 0000BD80 807E0303            <1> 	cmp	byte [esi+LD_FATType], 3  ; FAT32
  2363 0000BD84 7359                <1> 	jnb	short loc_lcde_load_dir_cluster_0
  2364                              <1> 	;
  2365 0000BD86 0FB74E17            <1> 	movzx	ecx, word [esi+LD_BPB+RootDirEnts]
  2366 0000BD8A 6683C10F            <1> 	add	cx, 15 ; round up (16 entries per sector)
  2367 0000BD8E 66C1E904            <1> 	shr	cx, 4 ; 1 sector contains 16 dir entries	
  2368                              <1> 
  2369 0000BD92 8B4664              <1>         mov     eax, [esi+LD_ROOTBegin]
  2370 0000BD95 EB54                <1> 	jmp	short loc_lcde_load_dir_cluster_1 
  2371                              <1> 
  2372                              <1> loc_lcde_validate_dirBuff:
  2373 0000BD97 C605[BC910100]01    <1> 	mov	byte [DirBuff_ValidData], 1
  2374                              <1> 
  2375                              <1> lcde_check_dir_buffer_cluster_next:
  2376 0000BD9E 0FB71D[68940100]    <1> 	movzx	ebx, word [LCDE_EntryIndex]
  2377 0000BDA5 663B1D[BF910100]    <1> 	cmp	bx, [DirBuff_LastEntry]
  2378 0000BDAC 779E                <1> 	ja	short loc_lcde_invalid_format 
  2379 0000BDAE B820000000          <1> 	mov	eax, 32
  2380 0000BDB3 F7E3                <1> 	mul	ebx
  2381                              <1> 	;or	edx, edx
  2382                              <1> 	;jnz	short loc_lcde_invalid_format
  2383                              <1> 
  2384 0000BDB5 BF00000800          <1> 	mov	edi, Directory_Buffer  
  2385 0000BDBA 01C7                <1> 	add	edi, eax ; add entry offset to buffer address
  2386                              <1> 
  2387                              <1> loc_lcde_dir_buffer_last_check:
  2388 0000BDBC A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
  2389 0000BDC1 0FB60D[BC910100]    <1> 	movzx	ecx, byte [DirBuff_ValidData]
  2390                              <1> 
  2391                              <1> loc_lcde_retn:
  2392 0000BDC8 5E                  <1> 	pop	esi
  2393 0000BDC9 C3                  <1> 	retn
  2394                              <1> 
  2395                              <1> loc_lcde_load_dir_cluster:
  2396                              <1> 	;cmp	byte [DirBuff_ValidData], 2
  2397                              <1> 	;jne	short loc_lcde_load_dir_cluster_n2
  2398 0000BDCA 50                  <1> 	push	eax
  2399 0000BDCB E8E6FCFFFF          <1> 	call	save_directory_buffer
  2400 0000BDD0 58                  <1> 	pop	eax
  2401 0000BDD1 72F5                <1> 	jc	short loc_lcde_retn
  2402                              <1> 
  2403                              <1> loc_lcde_load_dir_cluster_n2:
  2404 0000BDD3 C605[BC910100]00    <1> 	mov	byte [DirBuff_ValidData], 0
  2405 0000BDDA A3[C1910100]        <1> 	mov	[DirBuff_Cluster], eax
  2406                              <1> 
  2407                              <1> loc_lcde_load_dir_cluster_0:
  2408 0000BDDF 83E802              <1> 	sub	eax, 2
  2409 0000BDE2 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  2410 0000BDE6 F7E1                <1> 	mul	ecx
  2411 0000BDE8 034668              <1>         add     eax, [esi+LD_DATABegin]
  2412                              <1> 
  2413                              <1> loc_lcde_load_dir_cluster_1:
  2414 0000BDEB BB00000800          <1> 	mov	ebx, Directory_Buffer
  2415                              <1> 	; ecx = sector count
  2416 0000BDF0 E8686D0000          <1> 	call	disk_read
  2417 0000BDF5 73A0                <1> 	jnc	short loc_lcde_validate_dirBuff
  2418                              <1> 
  2419                              <1> 	; 15/10/2016 
  2420                              <1> 	; (Disk read error instead of drv not ready err)
  2421 0000BDF7 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
  2422 0000BDFC EBCA                <1> 	jmp	short loc_lcde_retn
  2423                              <1> 
  2424                              <1> 
  2425                              <1> remove_file:
  2426                              <1> 	; 15/10/2016
  2427                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  2428                              <1> 	; 10/04/2011 (FILE.ASM, 'proc_delete_file')
  2429                              <1> 	; 09/08/2010
  2430                              <1> 	; INPUT ->
  2431                              <1> 	;	EDI = Directory Buffer Entry Address
  2432                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  2433                              <1> 	;	 BL = Longname Entry Length
  2434                              <1> 	;	 BH = Logical DOS Drive Number 
  2435                              <1> 
  2436 0000BDFE 29C0                <1> 	sub	eax, eax
  2437 0000BE00 88FC                <1> 	mov	ah, bh
  2438 0000BE02 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  2439 0000BE07 01C6                <1> 	add	esi, eax
  2440                              <1> 
  2441 0000BE09 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  2442 0000BE0D 7312                <1> 	jnb	short loc_del_fat_file 
  2443                              <1>               
  2444 0000BE0F 807E04A1            <1> 	cmp	byte [esi+LD_FSType], 0A1h
  2445 0000BE13 7406                <1> 	je	short loc_del_fs_file
  2446                              <1> 
  2447                              <1> loc_del_file_invalid_format:
  2448 0000BE15 30E4                <1> 	xor	ah, ah
  2449                              <1> 	; 15/10/2016 (0Bh -> 28)
  2450 0000BE17 B01C                <1> 	mov	al, 28  ; Invalid Format
  2451 0000BE19 F9                  <1> 	stc 
  2452 0000BE1A C3                  <1> 	retn
  2453                              <1> 
  2454                              <1> loc_del_fs_file:
  2455 0000BE1B E83F0F0000          <1> 	call	delete_fs_file
  2456 0000BE20 C3                  <1> 	retn
  2457                              <1> 
  2458                              <1> loc_del_fat_file:
  2459 0000BE21 E808000000          <1> 	call	delete_directory_entry
  2460 0000BE26 7205                <1> 	jc	short loc_del_file_err_retn 
  2461                              <1> 
  2462                              <1> loc_delfile_unlink_cluster_chain:
  2463 0000BE28 E863170000          <1> 	call	truncate_cluster_chain
  2464                              <1> 	;jc	short loc_del_file_err_retn
  2465                              <1> 
  2466                              <1> loc_delfile_return:
  2467                              <1> loc_del_file_err_retn:
  2468 0000BE2D C3                  <1> 	retn
  2469                              <1> 
  2470                              <1> delete_directory_entry:
  2471                              <1> 	; 15/10/2016
  2472                              <1> 	; 28/02/2016 (TRDOS 386 = TRDOS v2.0)
  2473                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_delete_directory_entry')
  2474                              <1> 	; 10/04/2011 
  2475                              <1> 	; INPUT ->
  2476                              <1> 	; 	ESI = Logical Dos Drive Descripton Table Address 
  2477                              <1> 	;	EDI = Directory Buffer Entry Address
  2478                              <1> 	;	 CX = Directory Buffer Entry Counter/Index
  2479                              <1> 	;	 BL = Longname Entry Length
  2480                              <1> 	; OUTPUT ->
  2481                              <1> 	; 	ESI = Logical dos drive descripton table address 
  2482                              <1> 	;	EAX = First cluster to be truncated/unlinked
  2483                              <1> 	;       CF = 1 -> Error code in EAX (AL)
  2484                              <1> 	;       CF = 0 & BH <> 0 -> LMDT write error  (BH = 1)
  2485                              <1> 	;       CF = 0 & BL <> 0 -> Long name delete error (BL = FFh) 
  2486                              <1> 	;
  2487                              <1> 	;  (EDI, EBX, ECX register contents will be changed)
  2488                              <1> 
  2489 0000BE2E 881D[FE930100]      <1> 	mov	[DelFile_LNEL], bl
  2490 0000BE34 66890D[FC930100]    <1> 	mov	[DelFile_EntryCounter], cx
  2491                              <1> 
  2492 0000BE3B 668B4714            <1> 	mov	ax, [edi+20] ; First Cluster High Word
  2493 0000BE3F C1E010              <1> 	shl	eax, 16
  2494 0000BE42 668B471A            <1> 	mov	ax, [edi+26] ; First Cluster Low Word
  2495                              <1> 
  2496 0000BE46 A3[F8930100]        <1> 	mov	[DelFile_FCluster], eax
  2497                              <1> 
  2498                              <1> loc_del_short_name:
  2499 0000BE4B C607E5              <1> 	mov	byte [edi], 0E5h  ; Deleted sign
  2500                              <1> 
  2501 0000BE4E C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  2502 0000BE55 E85CFCFFFF          <1> 	call	save_directory_buffer
  2503 0000BE5A 723D                <1> 	jc	short loc_delete_direntry_err_return
  2504                              <1>  
  2505                              <1> loc_del_long_name:
  2506 0000BE5C 0FB615[FE930100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  2507 0000BE63 08D2                <1> 	or	dl, dl
  2508 0000BE65 7416                <1> 	jz	short loc_del_dir_entry_update_parent_dir_lm_date
  2509                              <1> 
  2510 0000BE67 8835[FE930100]      <1> 	mov	byte [DelFile_LNEL], dh ; 0              
  2511                              <1>   
  2512 0000BE6D 0FB705[FC930100]    <1> 	movzx	eax,  word [DelFile_EntryCounter]
  2513 0000BE74 29D0                <1> 	sub	eax, edx
  2514                              <1> 	;jnc	short loc_del_long_name_continue
  2515 0000BE76 7205                <1> 	jc	short loc_del_dir_entry_update_parent_dir_lm_date   
  2516                              <1> 
  2517                              <1> ;loc_del_direntry_inv_data_return: ; 15/10/2016 (0Dh -> 29)
  2518                              <1> ;	mov	eax, 29 ; 0Dh (TRDOS 8086) ; Invalid data
  2519                              <1> ;	retn
  2520                              <1> 
  2521                              <1> loc_del_long_name_continue: 
  2522                              <1> 	; AX = Directory Entry Number of the long name last entry
  2523 0000BE78 E897FDFFFF          <1> 	call	delete_longname
  2524                              <1> 	;jc	short loc_delete_direntry_err_return
  2525                              <1> 
  2526                              <1> loc_del_dir_entry_update_parent_dir_lm_date:
  2527 0000BE7D 801D[FE930100]00    <1> 	sbb	byte [DelFile_LNEL], 0 ; 0FFh if cf = 1
  2528                              <1> 
  2529 0000BE84 E8C8FCFFFF          <1> 	call	update_parent_dir_lmdt
  2530 0000BE89 B700                <1> 	mov	bh, 0
  2531 0000BE8B 80D700              <1> 	adc	bh, 0
  2532                              <1> 
  2533 0000BE8E 8A1D[FE930100]      <1> 	mov	bl, byte [DelFile_LNEL]
  2534                              <1>  
  2535                              <1> loc_delete_direntry_return:
  2536 0000BE94 A1[F8930100]        <1> 	mov	eax, [DelFile_FCluster]
  2537                              <1> loc_delete_direntry_err_return:
  2538 0000BE99 C3                  <1> 	retn
  2539                              <1> 
  2540                              <1> rename_directory_entry:
  2541                              <1> 	; 13/11/2017
  2542                              <1> 	; 15/10/2016
  2543                              <1> 	; 06/03/2016 (TRDOS 386 = TRDOS v2.0)
  2544                              <1> 	; 01/08/2011 (DIR.ASM, 'proc_rename_directory_entry')
  2545                              <1> 	; 19/11/2010
  2546                              <1> 	; INPUT -> (Current Directory)
  2547                              <1> 	;	CX = Directory Entry Number
  2548                              <1> 	;      EAX = First Cluster number of file or directory
  2549                              <1> 	;      EBX = Longname Length (dir entry count) (< 256)
  2550                              <1> 	;      ESI = New file (or directory) name (no path).
  2551                              <1> 	;           (ASCIIZ string)  
  2552                              <1> 	; OUTPUT -> 
  2553                              <1> 	;      CF = 0 -> successfull
  2554                              <1> 	;      CF = 1 -> error code in EAX (AL)
  2555                              <1> 	;
  2556                              <1> 	; (EAX, EBX, ECX, EDX, ESI, EDI will be changed)
  2557                              <1> 
  2558 0000BE9A 803D[958A0100]00    <1> 	cmp	byte [Current_FATType], 0
  2559 0000BEA1 7706                <1> 	ja	short loc_rename_directory_entry
  2560                              <1> 
  2561 0000BEA3 E8B80E0000          <1> 	call	rename_fs_file_or_directory
  2562 0000BEA8 C3                  <1> 	retn 
  2563                              <1> 	
  2564                              <1> loc_rename_directory_entry:
  2565 0000BEA9 881D[FE930100]      <1> 	mov	[DelFile_LNEL], bl
  2566 0000BEAF 66890D[FC930100]    <1> 	mov	[DelFile_EntryCounter], cx
  2567 0000BEB6 A3[F8930100]        <1> 	mov	[DelFile_FCluster], eax
  2568                              <1> 
  2569 0000BEBB 0FB7C1              <1> 	movzx	eax, cx
  2570 0000BEBE E8BBFDFFFF          <1> 	call	locate_current_dir_entry
  2571 0000BEC3 7308                <1> 	jnc	short loc_rename_direntry_check_fcluster
  2572                              <1> 
  2573                              <1> loc_rename_direntry_pop_retn:
  2574 0000BEC5 C3                  <1> 	retn
  2575                              <1> 
  2576                              <1> loc_rename_direntry_pop_invd_retn:
  2577 0000BEC6 F9                  <1> 	stc
  2578                              <1> loc_rename_direntry_invd_retn:
  2579                              <1> 	; 15/10/2016 (0Dh -> 29)
  2580 0000BEC7 B81D000000          <1> 	mov	eax, 29 ; Invalid data
  2581                              <1> loc_rename_retn:
  2582 0000BECC C3                  <1> 	retn 
  2583                              <1> 
  2584                              <1> loc_rename_direntry_check_fcluster:
  2585 0000BECD 668B5714            <1> 	mov	dx, [edi+20] ; First Cluster HW
  2586 0000BED1 C1E210              <1> 	shl	edx, 16 ; 13/11/2017
  2587 0000BED4 668B571A            <1> 	mov	dx, [edi+26] ; First Cluster LW
  2588 0000BED8 3B15[F8930100]      <1> 	cmp	edx, [DelFile_FCluster]
  2589 0000BEDE 75E6                <1> 	jne	short loc_rename_direntry_pop_invd_retn
  2590                              <1> 	; ESI = New file (or directory) name. (ASCIIZ string)
  2591                              <1> 	; 06/03/2016
  2592                              <1> 	; TRDOS v2 - NOTE: 'convert_file_name' procedure
  2593                              <1> 	; has been modified for eliminating following situation.
  2594                              <1> 	; 
  2595                              <1> 	; TRDOS v1 - NOTE: If file/dir name is more than 11 bytes
  2596                              <1> 	; without a dot, attributes (edi+11) byte will be overwritten !
  2597                              <1> 	; (Dot file name input must be proper for 11 byte dir entry
  2598                              <1> 	;  type file name output.) 
  2599 0000BEE0 E8A2F6FFFF          <1> 	call	convert_file_name
  2600                              <1> 
  2601 0000BEE5 C605[BC910100]02    <1>         mov     byte [DirBuff_ValidData], 2
  2602 0000BEEC E8C5FBFFFF          <1> 	call	save_directory_buffer
  2603 0000BEF1 72D9                <1> 	jc	short loc_rename_retn
  2604                              <1> 
  2605                              <1> loc_rename_direntry_del_ln:
  2606 0000BEF3 0FB615[FE930100]    <1> 	movzx	edx, byte [DelFile_LNEL]
  2607 0000BEFA 08D2                <1> 	or	dl, dl
  2608 0000BEFC 7410                <1> 	jz	short loc_rename_direntry_update_parent_dir_lm_date
  2609                              <1> 
  2610 0000BEFE 0FB705[FC930100]    <1> 	movzx	eax, word [DelFile_EntryCounter]
  2611 0000BF05 29D0                <1> 	sub	eax, edx
  2612 0000BF07 72BE                <1> 	jc	short loc_rename_direntry_invd_retn
  2613                              <1> 
  2614                              <1> loc_rename_direntry_del_ln_continue: 
  2615                              <1> 	; EAX = Directory Entry Number of the long name last entry
  2616 0000BF09 E806FDFFFF          <1> 	call	delete_longname
  2617                              <1> 
  2618                              <1> loc_rename_direntry_update_parent_dir_lm_date:
  2619 0000BF0E E83EFCFFFF          <1> 	call	update_parent_dir_lmdt
  2620 0000BF13 31C0                <1> 	xor	eax, eax 
  2621 0000BF15 C3                  <1> 	retn
  2622                              <1> 
  2623                              <1> move_source_file_to_destination_file:
  2624                              <1> 	; 15/10/2016
  2625                              <1> 	; 11/03/2016
  2626                              <1> 	; 10/03/2016 (TRDOS 386 = TRDOS v2.0)
  2627                              <1> 	; 01/08/2011 (FILE.ASM)
  2628                              <1> 	; 04/08/2010
  2629                              <1> 	;
  2630                              <1> 	;   Phase 1 -> Check destination file, 
  2631                              <1> 	;              'not found' is required
  2632                              <1> 	;   Phase 2 -> Check source file
  2633                              <1> 	;              'found' and proper attributes is required
  2634                              <1> 	;   Phase 3 -> Make destination directory entry,
  2635                              <1> 	;           add new dir cluster or section if it is required
  2636                              <1> 	;   Phase 4 -> Delete source directory entry.
  2637                              <1> 	;       cf = 1 causes to return before the phase 4.
  2638                              <1> 	;    (source file protection against any possible errors)    
  2639                              <1> 	;
  2640                              <1> 	; 08/05/2011 major modification
  2641                              <1> 	;            -> destination file deleting is removed   
  2642                              <1> 	;            for msdos move/rename compatibility.
  2643                              <1> 	;            (Access denied error will return if
  2644                              <1> 	;            the destination file is found...)
  2645                              <1> 	; INPUT ->
  2646                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  2647                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  2648                              <1> 	;        AL = 0 --> Interrupt (System call)
  2649                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  2650                              <1> 	;        AL = 1 --> Question Phase
  2651                              <1> 	;        AL = 2 --> Progress Phase        
  2652                              <1> 	; OUTPUT -> 
  2653                              <1> 	;	 cf = 0 -> OK
  2654                              <1> 	;        EAX = Destination directory first cluster
  2655                              <1> 	;        ESI = Logical DOS drive description table 
  2656                              <1> 	;        EBX = Destination file structure offset
  2657                              <1> 	;        CX = 0 (CX > 0 --> calculate free space error)
  2658                              <1> 	;        cf = 1 -> Error code in EAX (AL) 
  2659                              <1> 	;
  2660                              <1> 	;  (EDX, ECX, EBX, ESI, EDI will be changed)
  2661                              <1> 
  2662 0000BF16 3C02                <1> 	cmp	al, 2
  2663 0000BF18 0F847F010000        <1> 	je	msftdf_df2_check_directory
  2664 0000BF1E A2[7E950100]        <1> 	mov	[move_cmd_phase], al
  2665                              <1> 
  2666                              <1> msftdf_parse_sf_path:
  2667                              <1> 	; ESI = ASCIIZ pathname (Source)
  2668 0000BF23 57                  <1> 	push	edi 
  2669 0000BF24 BF[7C940100]        <1> 	mov	edi, SourceFile_Drv
  2670 0000BF29 E824F7FFFF          <1> 	call	parse_path_name
  2671 0000BF2E 5E                  <1> 	pop	esi
  2672 0000BF2F 7211                <1> 	jc	short msftdf_psf_retn
  2673                              <1> 
  2674                              <1> msftdf_parse_df_path:
  2675                              <1> 	; ESI = ASCIIZ pathname	(Destination)
  2676 0000BF31 BF[FC940100]        <1> 	mov	edi, DestinationFile_Drv
  2677 0000BF36 E817F7FFFF          <1> 	call	parse_path_name
  2678 0000BF3B 7306                <1> 	jnc	short msftdf_check_sf_drv
  2679                              <1> 
  2680 0000BF3D 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  2681 0000BF3F 7602                <1> 	jna	short msftdf_check_sf_drv
  2682                              <1> 
  2683                              <1> msftdf_stc_retn:
  2684 0000BF41 F9                  <1> 	stc
  2685                              <1> msftdf_psf_retn:
  2686 0000BF42 C3                  <1> 	retn 
  2687                              <1> 
  2688                              <1> msftdf_check_sf_drv:
  2689 0000BF43 A0[7C940100]        <1> 	mov	al, [SourceFile_Drv]
  2690                              <1> 
  2691                              <1> msftdf_check_df_drv:
  2692 0000BF48 8A15[FC940100]      <1> 	mov	dl, [DestinationFile_Drv]
  2693                              <1> 
  2694                              <1> msftdf_compare_sf_df_drv:
  2695 0000BF4E 29DB                <1> 	sub	ebx, ebx
  2696 0000BF50 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  2697 0000BF56 38C2                <1> 	cmp	dl, al
  2698 0000BF58 7409                <1> 	je	short msftdf_check_sf_df_drv_ok
  2699                              <1> 
  2700                              <1> msftdf_not_same_drv:
  2701                              <1>         ; DL = source file's drive number
  2702 0000BF5A 88C6                <1> 	mov	dh, al ; destination file's drive number
  2703                              <1> 	; 15/10/2016 (11h -> 21)
  2704 0000BF5C B815000000          <1> 	mov	eax, 21 ; Not the same drive
  2705 0000BF61 F9                  <1> 	stc
  2706 0000BF62 C3                  <1> 	retn 
  2707                              <1> 
  2708                              <1> msftdf_check_sf_df_drv_ok:
  2709 0000BF63 8815[7F950100]      <1> 	mov	[msftdf_sf_df_drv], dl
  2710                              <1> 
  2711 0000BF69 29C0                <1>         sub	eax, eax
  2712 0000BF6B 88D4                <1> 	mov	ah, dl
  2713 0000BF6D 0500010900          <1> 	add	eax, Logical_DOSDisks
  2714 0000BF72 A3[80950100]        <1> 	mov	[msftdf_drv_offset], eax
  2715                              <1> 
  2716 0000BF77 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  2717 0000BF79 7407                <1> 	je	short msftdf_df_check_directory
  2718                              <1> 
  2719                              <1> msftdf_change_drv:
  2720 0000BF7B E85EC1FFFF          <1> 	call 	change_current_drive
  2721 0000BF80 726D                <1> 	jc	short msftdf_df_error_retn
  2722                              <1> 	  
  2723                              <1> msftdf_check_destination_file:
  2724                              <1> msftdf_df_check_directory:
  2725 0000BF82 BE[FD940100]        <1> 	mov	esi, DestinationFile_Directory
  2726 0000BF87 803E20              <1> 	cmp	byte [esi], 20h
  2727 0000BF8A 760F                <1> 	jna	short msftdf_df_find_1
  2728                              <1> 
  2729                              <1> msftdf_df_change_directory:
  2730 0000BF8C FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  2731 0000BF92 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2732 0000BF94 E8A3F0FFFF          <1> 	call	change_current_directory
  2733 0000BF99 7254                <1> 	jc	short msftdf_df_error_retn
  2734                              <1> 
  2735                              <1> ;msftdf_df_change_prompt_dir_string:
  2736                              <1> ;	call 	change_prompt_dir_string
  2737                              <1> 
  2738                              <1> msftdf_df_find_1:
  2739 0000BF9B BE[3E950100]        <1>         mov     esi, DestinationFile_Name
  2740 0000BFA0 803E20              <1> 	cmp	byte [esi], 20h
  2741 0000BFA3 7631                <1> 	jna	short msftdf_df_copy_sf_name
  2742                              <1> 
  2743                              <1> msftdf_df_find_2:
  2744 0000BFA5 6631C0              <1> 	xor	ax, ax ; DestinationFile_AttributesMask -> any/zero
  2745 0000BFA8 E8D4D4FFFF          <1> 	call	find_first_file
  2746 0000BFAD 0F838D000000        <1> 	jnc	msftdf_permission_denied_retn
  2747                              <1> 
  2748                              <1> msftdf_df_check_error_code:
  2749                              <1> 	;cmp	eax, 2 ; File not found error
  2750 0000BFB3 3C02                <1> 	cmp	al, 2
  2751 0000BFB5 7537                <1> 	jne	short msftdf_df_stc_retn
  2752                              <1>               
  2753                              <1> msftdf_df_check_fname:
  2754                              <1> 	; 15/10/2016
  2755 0000BFB7 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name ; *
  2756 0000BFBC E87ED8FFFF          <1> 	call	check_filename
  2757 0000BFC1 7307                <1> 	jnc	short msftdf_convert_df_direntry_name
  2758                              <1> 	; invalid file name chars !
  2759 0000BFC3 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26
  2760 0000BFC8 EB24                <1> 	jmp	short msftdf_df_stc_retn
  2761                              <1> 
  2762                              <1> msftdf_convert_df_direntry_name:
  2763                              <1> 	; mov	esi, DestinationFile_Name ; *
  2764 0000BFCA BF[4E950100]        <1> 	mov	edi, DestinationFile_DirEntry
  2765 0000BFCF E8B3F5FFFF          <1> 	call	convert_file_name
  2766 0000BFD4 EB1A                <1>   	jmp	short msftdf_restore_current_dir_1
  2767                              <1> 
  2768                              <1> msftdf_df_copy_sf_name:
  2769 0000BFD6 89F7                <1> 	mov	edi, esi
  2770 0000BFD8 57                  <1> 	push	edi 
  2771 0000BFD9 BE[BE940100]        <1>         mov     esi, SourceFile_Name
  2772 0000BFDE B90C000000          <1> 	mov	ecx, 12
  2773                              <1> msftdf_df_copy_sf_name_loop:
  2774 0000BFE3 AC                  <1> 	lodsb
  2775 0000BFE4 AA                  <1>         stosb
  2776 0000BFE5 08C0                <1> 	or	al, al
  2777 0000BFE7 7402                <1> 	jz	short msftdf_df_copy_sf_name_ok	
  2778 0000BFE9 E2F8                <1>         loop    msftdf_df_copy_sf_name_loop
  2779                              <1> msftdf_df_copy_sf_name_ok:	
  2780 0000BFEB 5E                  <1> 	pop	esi  
  2781 0000BFEC EBB7                <1> 	jmp	short msftdf_df_find_2
  2782                              <1> 
  2783                              <1> msftdf_df_stc_retn:
  2784 0000BFEE F9                  <1> 	stc
  2785                              <1> msftdf_restore_cdir_failed:
  2786                              <1> msftdf_df_error_retn:
  2787 0000BFEF C3                  <1> 	retn
  2788                              <1> 
  2789                              <1> msftdf_restore_current_dir_1:
  2790 0000BFF0 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  2791 0000BFF7 760D                <1> 	jna	short msftdf_sf_check_directory
  2792 0000BFF9 8B35[80950100]      <1> 	mov	esi, [msftdf_drv_offset] 
  2793 0000BFFF E891C1FFFF          <1> 	call	restore_current_directory
  2794 0000C004 72E9                <1> 	jc	short msftdf_restore_cdir_failed
  2795                              <1> 
  2796                              <1> msftdf_sf_check_directory:
  2797 0000C006 BE[7D940100]        <1> 	mov	esi, SourceFile_Directory
  2798 0000C00B 803E20              <1> 	cmp	byte [esi], 20h
  2799 0000C00E 760F                <1> 	jna	short msftdf_sf_find
  2800                              <1> msftdf_sf_change_directory:
  2801 0000C010 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  2802 0000C016 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2803 0000C018 E81FF0FFFF          <1> 	call	change_current_directory
  2804 0000C01D 7227                <1> 	jc	short msftdf_return
  2805                              <1> 
  2806                              <1> ;msftdf_sf_change_prompt_dir_string:
  2807                              <1> ;	call	change_prompt_dir_string
  2808                              <1> 
  2809                              <1> msftdf_sf_find:
  2810 0000C01F BE[BE940100]        <1>         mov     esi, SourceFile_Name  ; Offset 66
  2811 0000C024 66B80018            <1> 	mov	ax, 1800h ; Only files
  2812 0000C028 E854D4FFFF          <1> 	call	find_first_file
  2813 0000C02D 7217                <1> 	jc	short msftdf_return
  2814                              <1> 
  2815                              <1> msftdf_sf_ambgfn_check:
  2816 0000C02F 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  2817 0000C032 7407                <1> 	jz	short msftdf_sf_found
  2818                              <1> 
  2819                              <1> msftdf_ambiguous_file_name_error:
  2820 0000C034 B802000000          <1> 	mov	eax, 2 ; File not found error
  2821 0000C039 F9                  <1> 	stc
  2822 0000C03A C3                  <1> 	retn
  2823                              <1> 
  2824                              <1> msftdf_sf_found:
  2825 0000C03B 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  2826 0000C03E 7416                <1> 	jz	short msftdf_save_sf_structure
  2827                              <1> 
  2828                              <1> msftdf_permission_denied_retn:
  2829 0000C040 B805000000          <1> 	mov	eax, 05h ; Access (Permission) denied !
  2830 0000C045 F9                  <1> 	stc
  2831                              <1> msftdf_rest_cdir_err_retn:
  2832                              <1> msftdf_return:
  2833 0000C046 C3                  <1> 	retn
  2834                              <1> 
  2835                              <1> msftdf_phase_1_return:
  2836 0000C047 31C0                <1> 	xor	eax, eax
  2837 0000C049 A2[7E950100]        <1> 	mov	[move_cmd_phase], al ; 0
  2838 0000C04E FEC0                <1> 	inc	al ; mov al, 1
  2839 0000C050 BB[9DC00000]        <1> 	mov	ebx, msftdf_df2_check_directory
  2840                              <1> 	;mov	edx, 0FFFFFFFFh 
  2841 0000C055 C3                  <1> 	retn
  2842                              <1> 
  2843                              <1> msftdf_save_sf_structure:
  2844 0000C056 BE[88930100]        <1> 	mov	esi, FindFile_DirEntry
  2845 0000C05B BF[CE940100]        <1> 	mov	edi, SourceFile_DirEntry
  2846 0000C060 B908000000          <1> 	mov	ecx, 8
  2847 0000C065 F3A5                <1> 	rep	movsd
  2848                              <1> 
  2849                              <1> msftdf_df_copy_sf_parameters:
  2850 0000C067 BE0B000000          <1> 	mov	esi, 11
  2851 0000C06C 89F7                <1> 	mov	edi, esi
  2852 0000C06E 81C6[CE940100]      <1> 	add	esi, SourceFile_DirEntry
  2853 0000C074 81C7[4E950100]      <1> 	add	edi, DestinationFile_DirEntry
  2854                              <1> 	;mov	ecx, 21
  2855 0000C07A B115                <1> 	mov	cl, 21
  2856 0000C07C F3A4                <1> 	rep	movsb
  2857                              <1> 
  2858                              <1> msftdf_restore_current_dir_2:
  2859 0000C07E 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  2860 0000C085 760D                <1> 	jna	short msftdf_df2_check_move_cmd_phase
  2861 0000C087 8B35[80950100]      <1>  	mov	esi, [msftdf_drv_offset]
  2862 0000C08D E803C1FFFF          <1> 	call	restore_current_directory
  2863 0000C092 72B2                <1> 	jc	short msftdf_rest_cdir_err_retn
  2864                              <1> 
  2865                              <1> msftdf_df2_check_move_cmd_phase:
  2866 0000C094 803D[7E950100]01    <1> 	cmp	byte [move_cmd_phase], 1
  2867 0000C09B 74AA                <1> 	je	short msftdf_phase_1_return
  2868                              <1> 
  2869                              <1> msftdf_df2_check_directory:
  2870 0000C09D BE[FD940100]        <1> 	mov	esi, DestinationFile_Directory
  2871 0000C0A2 803E20              <1> 	cmp	byte [esi], 20h
  2872 0000C0A5 760F                <1> 	jna	short msftdf_make_dfde_locate_ffe_on_directory
  2873                              <1> msftdf_df2_change_directory:
  2874 0000C0A7 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  2875 0000C0AD 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  2876 0000C0AF E888EFFFFF          <1> 	call	change_current_directory
  2877 0000C0B4 7290                <1> 	jc	short msftdf_return
  2878                              <1> 
  2879                              <1> ;msftdf_df2_change_prompt_dir_string:
  2880                              <1> ;	call	change_prompt_dir_string
  2881                              <1> 
  2882                              <1> msftdf_make_dfde_locate_ffe_on_directory:
  2883                              <1> 	; Current directory fcluster <> Directory buffer cluster
  2884                              <1> 	; Current directory will be reloaded by
  2885                              <1> 	; 'locate_current_dir_file' procedure
  2886                              <1> 	;
  2887                              <1> 	;xor	ax, ax
  2888 0000C0B6 31C0                <1> 	xor	eax, eax
  2889 0000C0B8 89C1                <1> 	mov	ecx, eax
  2890 0000C0BA 6649                <1> 	dec	cx ; FFFFh  
  2891                              <1> 		; CX = FFFFh -> find first deleted or free entry
  2892                              <1> 		; ESI would be ASCIIZ filename address if the call
  2893                              <1> 		; would not be for first free or deleted dir entry  
  2894 0000C0BC E8CFF1FFFF          <1> 	call	locate_current_dir_file
  2895 0000C0C1 733F                <1> 	jnc	msftdf_make_dfde_set_ff_dir_entry
  2896                              <1> 	
  2897                              <1> 	;cmp	eax, 2
  2898 0000C0C3 3C02                <1>         cmp	al, 2
  2899 0000C0C5 7537                <1> 	jne	short msftdf_error_retn
  2900                              <1> 
  2901                              <1> msftdf_add_new_dir_entry_check_fs:
  2902 0000C0C7 8B35[80950100]      <1> 	mov	esi, [msftdf_drv_offset]
  2903 0000C0CD A1[C1910100]        <1> 	mov 	eax, [DirBuff_Cluster]
  2904 0000C0D2 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  2905 0000C0D6 7711                <1> 	ja	short msftdf_add_new_subdir_cluster
  2906                              <1> 
  2907                              <1> msftdf_add_new_fs_subdir_section:
  2908                              <1> 	;CL=0, CH=E5h --> deleted entry, CH=0 --> free entry
  2909                              <1>         ;xor	cx, cx
  2910 0000C0D8 30ED                <1> 	xor	ch, ch ; cx = 0 --> add a new subdir section
  2911 0000C0DA E8830C0000          <1> 	call	add_new_fs_section
  2912 0000C0DF 721E                <1>         jc	short msftdf_dsfde_error_retn
  2913                              <1> 	;mov	[createfile_LastDirCluster], eax
  2914                              <1> 
  2915 0000C0E1 E8A30E0000          <1> 	call	load_FS_sub_directory 
  2916                              <1> 	;mov	ebx, Directory_Buffer 
  2917 0000C0E6 7318                <1> 	jnc	short msftdf_add_new_fs_subdir_section_ok
  2918 0000C0E8 C3                  <1> 	retn	 
  2919                              <1> 
  2920                              <1> msftdf_add_new_subdir_cluster:
  2921 0000C0E9 E881150000          <1> 	call	add_new_cluster
  2922 0000C0EE 720F                <1> 	jc	short msftdf_dsfde_error_retn
  2923                              <1> 	
  2924                              <1> 	;mov	[createfile_LastDirCluster], eax
  2925                              <1> 
  2926 0000C0F0 E8570E0000          <1> 	call	load_FAT_sub_directory
  2927 0000C0F5 7309                <1> 	jnc	short msftdf_add_new_subdir_cluster_ok
  2928                              <1> 	; EBX = Directory buffer address
  2929                              <1> 
  2930                              <1> msftdf_ansdc_update_parent_dir_lmdt:
  2931                              <1> msftdf_make_dfde_err_upd_pdir_lmdt:
  2932 0000C0F7 50                  <1> 	push	eax
  2933 0000C0F8 E854FAFFFF          <1> 	call	update_parent_dir_lmdt
  2934 0000C0FD 58                  <1> 	pop	eax
  2935                              <1> 
  2936                              <1> msftdf_error_retn:
  2937 0000C0FE F9                  <1> 	stc
  2938                              <1> msftdf_dsfde_restore_cdir_failed:
  2939                              <1> msftdf_dsfde_error_retn:
  2940 0000C0FF C3                  <1> 	retn
  2941                              <1> 
  2942                              <1> msftdf_add_new_fs_subdir_section_ok:
  2943                              <1> msftdf_add_new_subdir_cluster_ok:
  2944 0000C100 89DF                <1> 	mov	edi, ebx ; Directory buffer address
  2945                              <1> 
  2946                              <1> msftdf_make_dfde_set_ff_dir_entry:
  2947 0000C102 8B15[908A0100]      <1> 	mov	edx, [Current_Dir_FCluster]
  2948 0000C108 8915[E4950100]      <1> 	mov	[createfile_FFCluster], edx
  2949                              <1> 	; EDI = Directory entry offset
  2950 0000C10E BE[4E950100]        <1> 	mov	esi, DestinationFile_DirEntry
  2951 0000C113 B908000000          <1> 	mov	ecx, 8
  2952 0000C118 F3A5                <1> 	rep	movsd
  2953                              <1> 
  2954 0000C11A C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  2955 0000C121 E890F9FFFF          <1> 	call	save_directory_buffer
  2956 0000C126 72CF                <1> 	jc	short msftdf_make_dfde_err_upd_pdir_lmdt
  2957                              <1> 
  2958                              <1> msftdf_make_dfde_update_pdir_lmdt:
  2959 0000C128 E824FAFFFF          <1> 	call	update_parent_dir_lmdt
  2960                              <1> 
  2961                              <1> msftdf_dsfde_restore_current_dir_1:
  2962 0000C12D 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  2963 0000C134 760D                <1> 	jna	short msftdf_dsfde_check_directory
  2964 0000C136 8B35[80950100]      <1>  	mov	esi, [msftdf_drv_offset]
  2965 0000C13C E854C0FFFF          <1> 	call	restore_current_directory
  2966 0000C141 72BC                <1> 	jc	short msftdf_dsfde_restore_cdir_failed
  2967                              <1> 
  2968                              <1> msftdf_dsfde_check_directory:
  2969 0000C143 BE[7D940100]        <1> 	mov	esi, SourceFile_Directory
  2970 0000C148 803E20              <1> 	cmp	byte [esi], 20h
  2971 0000C14B 760F                <1> 	jna	short msftdf_dsfde_find_file
  2972                              <1> 
  2973                              <1> msftdf_dsfde_change_directory:
  2974 0000C14D FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  2975 0000C153 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  2976 0000C155 E8E2EEFFFF          <1> 	call	change_current_directory
  2977 0000C15A 72A3                <1> 	jc	short msftdf_dsfde_error_retn
  2978                              <1> 
  2979                              <1> ;msftdf_dsfde_sf_change_prompt_dir_string:
  2980                              <1> ;	call	change_prompt_dir_string
  2981                              <1> 
  2982                              <1> msftdf_dsfde_find_file:
  2983 0000C15C BE[BE940100]        <1> 	mov	esi, SourceFile_Name  ; Offset 66
  2984 0000C161 668B460E            <1> 	mov	ax, [esi+14] ; 80 -> SourceFile_AttributesMask
  2985 0000C165 E817D3FFFF          <1> 	call	find_first_file
  2986 0000C16A 7293                <1> 	jc	short msftdf_dsfde_error_retn
  2987                              <1> 
  2988                              <1> msftdf_dsfde_delete_direntry:
  2989 0000C16C 8B35[80950100]      <1> 	mov	esi, [msftdf_drv_offset]
  2990                              <1> 	
  2991 0000C172 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  2992 0000C176 770A                <1> 	ja	short msftdf_delete_FAT_direntry
  2993                              <1> 	
  2994 0000C178 30DB                <1> 	xor	bl, bl
  2995                              <1> 	; BL = 0 -> File
  2996                              <1> 	; EDI -> Directory buffer entry offset/address 
  2997 0000C17A E8E40B0000          <1> 	call	delete_fs_directory_entry
  2998 0000C17F 7315                <1> 	jnc	short msftdf_dsfde_restore_current_dir_2
  2999 0000C181 C3                  <1> 	retn
  3000                              <1> 
  3001                              <1> msftdf_delete_FAT_direntry:	
  3002 0000C182 8A1D[85930100]      <1> 	mov	bl, [FindFile_LongNameEntryLength]
  3003 0000C188 668B0D[B0930100]    <1> 	mov	cx, [FindFile_DirEntryNumber]
  3004                              <1> 	; ESI = Logical DOS drive description table address
  3005                              <1> 	; EDI = Directory buffer entry offset/address 
  3006 0000C18F E89AFCFFFF          <1> 	call	delete_directory_entry
  3007 0000C194 721C                <1> 	jc	short msftdf_retn
  3008                              <1> 
  3009                              <1> msftdf_dsfde_restore_current_dir_2:
  3010 0000C196 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3011 0000C19D 7607                <1> 	jna	short msftdf_new_dir_fcluster_retn
  3012                              <1> 	;mov	esi, [msftdf_drv_offset]
  3013 0000C19F E8F1BFFFFF          <1> 	call	restore_current_directory
  3014 0000C1A4 720C                <1> 	jc	short msftdf_retn
  3015                              <1> 
  3016                              <1> msftdf_new_dir_fcluster_retn:
  3017 0000C1A6 31C9                <1> 	xor	ecx, ecx 
  3018 0000C1A8 A1[E4950100]        <1> 	mov	eax, [createfile_FFCluster]
  3019 0000C1AD BB[FC940100]        <1> 	mov	ebx, DestinationFile_Drv
  3020                              <1> 
  3021                              <1> msftdf_retn:
  3022 0000C1B2 C3                  <1> 	retn
  3023                              <1> 
  3024                              <1> 
  3025                              <1> copy_source_file_to_destination_file:
  3026                              <1> 	; 17/10/2016
  3027                              <1> 	; 16/10/2016
  3028                              <1> 	; 15/10/2016
  3029                              <1> 	; 30/03/2016, 31/03/2016
  3030                              <1> 	; 24/03/2016, 25/03/2016, 28/03/2016
  3031                              <1> 	; 21/03/2016, 22/03/2016, 23/03/2016
  3032                              <1> 	; 16/03/2016, 17/03/2016, 18/03/2016
  3033                              <1> 	; 15/03/2016 (TRDOS 386 = TRDOS v2.0)
  3034                              <1> 	; 02/09/2011 (FILE.ASM 'copy_source_file_to_destination_file')
  3035                              <1> 	; 01/08/2010 - 18/05/2011
  3036                              <1> 	;
  3037                              <1> 	;   Command Interpreter phase 1 enter ->
  3038                              <1> 	;           AL = 1 -> Caller is command interpreter
  3039                              <1> 	;           AL = 2 -> The second call, re-enter/continue
  3040                              <1> 	;   Phase 1 -> Check source file
  3041                              <1> 	;              'found' is required
  3042                              <1> 	;   Phase 2 -> Check destination file, 
  3043                              <1> 	;              save 'found' or 'not found' status
  3044                              <1> 	;              'permission denied' error will be return
  3045                              <1> 	;              if attributes have not for ordinary file 
  3046                              <1> 	;              without readonly attribute
  3047                              <1> 	;   Command Interpreter phase 1 return ->
  3048                              <1> 	;              DH = Source file attributes
  3049                              <1> 	;              DL = Destination file found status
  3050                              <1> 	;              EAX = 0 
  3051                              <1> 	;   Command Interpreter phase 2 enter ->
  3052                              <1> 	;              AL = 2 -> Continue from the last position
  3053                              <1> 	;              AH = 
  3054                              <1> 	;   Phase 3 -> Load source file or use read/write cluster method
  3055                              <1> 	;   Phase 4 -> Create destination file if it is not found
  3056                              <1> 	;   Phase 5 -> Open destination file
  3057                              <1> 	;   Phase 6 -> Read from source and write to destination
  3058                              <1> 	;   Phase 7 -> Unload source file, if it is loaded at memory
  3059                              <1> 	;       cf = 1 causes to return before the phase 7
  3060                              <1> 	;              but loaded file will be unloaded
  3061                              <1> 	;	       (allocated memory block will be deallocated) 
  3062                              <1> 	;
  3063                              <1> 	; INPUT -> 
  3064                              <1> 	;	 ESI = Source File Pathname (Asciiz)
  3065                              <1> 	;        EDI = Destination File Pathname (Asciiz)
  3066                              <1> 	;        AL = 0 --> Interrupt (System call)
  3067                              <1> 	;        AL > 0 --> Command Interpreter (Question)
  3068                              <1> 	;        AL = 1 --> Question Phase
  3069                              <1> 	;        AL = 2 --> Progress Phase        
  3070                              <1> 	;
  3071                              <1> 	; OUTPUT -> 
  3072                              <1> 	;	cf = 0 -> OK
  3073                              <1> 	;	EAX = Destination file first cluster
  3074                              <1> 	;
  3075                              <1> 	;        CL > 0 if there is file reading error before EOF
  3076                              <1> 	;	        (incomplete copy) 
  3077                              <1> 	;        CH > 0 if file is (full) loaded at memory
  3078                              <1> 	;
  3079                              <1> 	;	cf = 1 -> Error code in AL (EAX) 
  3080                              <1> 	;
  3081                              <1> 	; (EBX, ECX, ESI, EDI register contents will be changed)           
  3082                              <1> 
  3083                              <1> 
  3084 0000C1B3 3C02                <1> 	cmp	al, 2
  3085 0000C1B5 0F845A020000        <1> 	je	csftdf2_check_cdrv
  3086                              <1> 
  3087                              <1> ; Phase 1
  3088                              <1> 
  3089 0000C1BB A2[A4950100]        <1> 	mov	byte [copy_cmd_phase], al
  3090                              <1> 
  3091 0000C1C0 57                  <1> 	push	edi ; *
  3092                              <1> 
  3093                              <1> csftdf_parse_sf_path:
  3094 0000C1C1 BF[7C940100]        <1> 	mov	edi, SourceFile_Drv
  3095 0000C1C6 E887F4FFFF          <1> 	call	parse_path_name
  3096 0000C1CB 721C                <1> 	jc	short csftdf_parse_sf_path_failed
  3097                              <1> 
  3098                              <1> csftdf_parse_df_path:	
  3099 0000C1CD 5E                  <1> 	pop	esi ; * (pushed edi) 
  3100                              <1> 
  3101                              <1> csftdf_sf_check_filename_exists:
  3102 0000C1CE 803D[BE940100]21    <1> 	cmp	byte [SourceFile_Name], 21h
  3103 0000C1D5 7215                <1> 	jb	short csftdf_sf_file_not_found_error
  3104                              <1> 
  3105 0000C1D7 BF[FC940100]        <1> 	mov	edi, DestinationFile_Drv
  3106 0000C1DC E871F4FFFF          <1> 	call	parse_path_name
  3107 0000C1E1 7310                <1> 	jnc	short csftdf_check_sf_cdrv
  3108                              <1> 	
  3109 0000C1E3 3C01                <1> 	cmp	al, 1 ; File or directory name is not existing
  3110 0000C1E5 760C                <1> 	jna	short csftdf_check_sf_cdrv
  3111                              <1> 
  3112                              <1> csftdf_parse_df_path_failed:
  3113 0000C1E7 F9                  <1> 	stc 
  3114                              <1> csftdf_sf_error_retn: 
  3115 0000C1E8 C3                  <1> 	retn
  3116                              <1> 
  3117                              <1> csftdf_parse_sf_path_failed:	
  3118 0000C1E9 5F                  <1> 	pop	edi ; *
  3119 0000C1EA EBFC                <1> 	jmp	short csftdf_sf_error_retn
  3120                              <1> 
  3121                              <1> csftdf_sf_file_not_found_error:
  3122 0000C1EC B802000000          <1> 	mov	eax, 2 ; File not found 
  3123 0000C1F1 EBF5                <1> 	jmp	short csftdf_sf_error_retn
  3124                              <1> 
  3125                              <1> csftdf_check_sf_cdrv:
  3126 0000C1F3 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  3127                              <1> 
  3128 0000C1F9 883D[A7950100]      <1> 	mov	[csftdf_cdrv], bh ; 23/03/2016
  3129                              <1> 
  3130 0000C1FF 8A15[7C940100]      <1> 	mov	dl, [SourceFile_Drv]
  3131 0000C205 38FA                <1> 	cmp	dl, bh ; byte [Current_Drv]
  3132 0000C207 7407                <1> 	je	short csftdf_sf_check_directory
  3133                              <1> 
  3134 0000C209 E8D0BEFFFF          <1> 	call	change_current_drive
  3135 0000C20E 72D8                <1> 	jc	short csftdf_sf_error_retn
  3136                              <1> 
  3137                              <1> csftdf_sf_check_directory:
  3138 0000C210 BE[7D940100]        <1> 	mov	esi, SourceFile_Directory
  3139 0000C215 803E20              <1> 	cmp	byte [esi], 20h
  3140 0000C218 760F                <1> 	jna	short csftdf_find_sf
  3141                              <1> 
  3142                              <1> csftdf_sf_change_directory:
  3143 0000C21A FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  3144 0000C220 30E4                <1> 	xor	ah, ah ; CD_COMMAND sign -> 0 
  3145 0000C222 E815EEFFFF          <1> 	call	change_current_directory
  3146 0000C227 72BF                <1> 	jc	short csftdf_sf_error_retn
  3147                              <1> 
  3148                              <1> ;csftdf_sf_change_prompt_dir_string:
  3149                              <1> ;	call	change_prompt_dir_string
  3150                              <1> 
  3151                              <1> csftdf_find_sf:
  3152 0000C229 BE[BE940100]        <1> 	mov	esi, SourceFile_Name
  3153 0000C22E 66B80018            <1> 	mov	ax, 1800h ; Except volume label and dirs
  3154 0000C232 E84AD2FFFF          <1> 	call	find_first_file
  3155 0000C237 72AF                <1> 	jc	short csftdf_sf_error_retn
  3156                              <1> 
  3157                              <1> csftdf_sf_ambgfn_check:
  3158 0000C239 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3159 0000C23C 7407                <1> 	jz	short csftdf_sf_found
  3160                              <1> 
  3161                              <1> csftdf_ambiguous_file_name_error:
  3162 0000C23E B802000000          <1> 	mov	eax, 2 ; File not found error
  3163 0000C243 F9                  <1> 	stc
  3164 0000C244 C3                  <1> 	retn
  3165                              <1> 
  3166                              <1> csftdf_sf_found:
  3167 0000C245 A3[A8950100]        <1> 	mov	[csftdf_filesize], eax
  3168                              <1> 
  3169 0000C24A 09C0                <1> 	or	eax, eax
  3170 0000C24C 7507                <1> 	jnz	short csftdf_set_source_file_direntry
  3171                              <1> 
  3172                              <1> csftdf_sf_file_size_zero:
  3173 0000C24E B814000000          <1> 	mov	eax, 20 ; TRDOS zero length (file size) error
  3174 0000C253 F9                  <1> 	stc
  3175 0000C254 C3                  <1> 	retn
  3176                              <1> 
  3177                              <1> csftdf_set_source_file_direntry:
  3178 0000C255 BE[88930100]        <1> 	mov	esi, FindFile_DirEntry
  3179 0000C25A BF[CE940100]        <1> 	mov	edi, SourceFile_DirEntry
  3180 0000C25F B908000000          <1> 	mov	ecx, 8
  3181 0000C264 F3A5                <1> 	rep	movsd
  3182                              <1> 
  3183                              <1> csftdf_sf_restore_cdrv:
  3184                              <1> 	; 22/03/2016
  3185 0000C266 8A15[A7950100]      <1> 	mov	dl, [csftdf_cdrv]
  3186 0000C26C 3A15[968A0100]      <1> 	cmp	dl, [Current_Drv]
  3187 0000C272 7407                <1> 	je	short csftdf_sf_restore_cdir
  3188 0000C274 E865BEFFFF          <1> 	call	change_current_drive 
  3189 0000C279 724F                <1> 	jc	short csftdf_df_error_retn ; 30/03/2016
  3190                              <1> 
  3191                              <1> csftdf_sf_restore_cdir:
  3192 0000C27B 803D[63400100]00    <1> 	cmp	byte [Restore_CDIR], 0
  3193 0000C282 7612                <1> 	jna	short csftdf_df_check_filename_exists
  3194 0000C284 29C0                <1> 	sub	eax, eax
  3195 0000C286 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3196 0000C28B 88D4                <1> 	mov	ah, dl ; byte [csftdf_cdrv]
  3197 0000C28D 01C6                <1> 	add	esi, eax
  3198 0000C28F E801BFFFFF          <1> 	call	restore_current_directory
  3199 0000C294 7234                <1> 	jc	short csftdf_df_error_retn
  3200                              <1>   
  3201                              <1> csftdf_df_check_filename_exists:
  3202 0000C296 803D[3E950100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
  3203 0000C29D 7716                <1> 	ja	short csftdf_check_df_cdrv
  3204                              <1> 
  3205                              <1> csftdf_copy_sf_name:
  3206 0000C29F BF[3E950100]        <1> 	mov	edi, DestinationFile_Name
  3207 0000C2A4 BE[BE940100]        <1> 	mov	esi, SourceFile_Name
  3208 0000C2A9 B10C                <1> 	mov	cl, 12
  3209                              <1> 
  3210                              <1> csftdf_df_copy_sf_name_loop:
  3211 0000C2AB AC                  <1> 	lodsb
  3212 0000C2AC AA                  <1> 	stosb
  3213 0000C2AD 08C0                <1> 	or	al, al
  3214 0000C2AF 7404                <1> 	jz	short csftdf_check_df_cdrv             
  3215 0000C2B1 FEC9                <1> 	dec	cl
  3216 0000C2B3 75F6                <1> 	jnz	csftdf_df_copy_sf_name_loop
  3217                              <1> 
  3218                              <1> csftdf_check_df_cdrv:
  3219 0000C2B5 8A15[FC940100]      <1> 	mov	dl, [DestinationFile_Drv]
  3220 0000C2BB 3A15[968A0100]      <1> 	cmp	dl, [Current_Drv]
  3221 0000C2C1 7408                <1> 	je	short csftdf_df_check_directory
  3222                              <1> 
  3223 0000C2C3 E816BEFFFF          <1> 	call	change_current_drive
  3224 0000C2C8 7301                <1> 	jnc	short csftdf_df_check_directory
  3225                              <1> 
  3226                              <1> csftdf_df_error_retn:
  3227 0000C2CA C3                  <1> 	retn
  3228                              <1> 
  3229                              <1> csftdf_df_check_directory:
  3230 0000C2CB BE[FD940100]        <1> 	mov	esi, DestinationFile_Directory
  3231 0000C2D0 803E20              <1>         cmp     byte [esi], 20h
  3232 0000C2D3 760F                <1> 	jna	short csftdf_find_df
  3233                              <1> 
  3234                              <1> csftdf_df_change_directory:
  3235 0000C2D5 FE05[63400100]      <1> 	inc	byte [Restore_CDIR]
  3236 0000C2DB 28E4                <1> 	sub	ah, ah ; CD_COMMAND sign -> 0 
  3237 0000C2DD E85AEDFFFF          <1> 	call	change_current_directory
  3238 0000C2E2 72E6                <1> 	jc	short csftdf_df_error_retn
  3239                              <1> 
  3240                              <1> ;csftdf_df_change_prompt_dir_string:
  3241                              <1> ;	call	change_prompt_dir_string
  3242                              <1> 
  3243                              <1> csftdf_find_df:
  3244                              <1> 	; 23/03/2016
  3245 0000C2E4 29DB                <1> 	sub	ebx, ebx
  3246 0000C2E6 8A3D[FC940100]      <1> 	mov	bh,  [DestinationFile_Drv]
  3247 0000C2EC 81C300010900        <1> 	add	ebx, Logical_DOSDisks
  3248 0000C2F2 891D[D4950100]      <1> 	mov	[csftdf_df_drv_dt], ebx
  3249                              <1> 
  3250 0000C2F8 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
  3251 0000C2FD 6631C0              <1> 	xor	ax, ax 
  3252                              <1> 		; DestinationFile_AttributesMask -> any/zero
  3253 0000C300 E87CD1FFFF          <1> 	call	find_first_file
  3254 0000C305 7218                <1> 	jc	short csftdf_df_check_error_code
  3255                              <1> 
  3256                              <1> csftdf_df_ambgfn_check:
  3257 0000C307 6609D2              <1> 	or	dx, dx ; Ambiguous filename chars used sign (DX>0)
  3258 0000C30A 752A                <1> 	jnz	short csftdf_df_error_inv_fname
  3259                              <1> 	
  3260                              <1> csftdf_df_found:
  3261 0000C30C C605[A6950100]01    <1> 	mov	byte [DestinationFileFound], 1
  3262                              <1> 	; 17/10/2016 (cl -> bl)
  3263 0000C313 80E31F              <1> 	and	bl, 1Fh ; Attributes, D-V-S-H-R
  3264 0000C316 745F                <1> 	jz	short csftdf_df_save_first_cluster
  3265                              <1> 
  3266                              <1> csftdf_df_permission_denied_retn:	 
  3267 0000C318 B805000000          <1> 	mov	eax, 05h ; Access/Permission denied.
  3268                              <1> csftdf_df_error_stc_retn:
  3269 0000C31D F9                  <1> 	stc
  3270 0000C31E C3                  <1> 	retn
  3271                              <1> 
  3272                              <1> csftdf_df_check_error_code:
  3273                              <1> 	;cmp	eax, 2
  3274 0000C31F 3C02                <1> 	cmp	al, 2
  3275 0000C321 75FA                <1> 	jne	short csftdf_df_error_stc_retn
  3276                              <1> 
  3277 0000C323 C605[A6950100]00    <1> 	mov	byte [DestinationFileFound], 0
  3278                              <1> 
  3279                              <1> 	; 15/10/2016
  3280 0000C32A BE[78930100]        <1> 	mov	esi, FindFile_Name ; *
  3281 0000C32F E80BD5FFFF          <1> 	call	check_filename
  3282 0000C334 7307                <1> 	jnc	short csftdf_df_valid_fname
  3283                              <1> csftdf_df_error_inv_fname: ; 'invalid file name !'
  3284 0000C336 B81A000000          <1> 	mov 	eax, ERR_INV_FILE_NAME  ; 26
  3285 0000C33B F9                  <1> 	stc	
  3286 0000C33C C3                  <1> 	retn
  3287                              <1> 
  3288                              <1> csftdf_df_valid_fname:	
  3289                              <1> 	; 21/03/2016
  3290                              <1> 	; (Capitalized file name)
  3291                              <1> 	;mov	esi, FindFile_Name ; * ; 15/10/2016
  3292 0000C33D BF[3E950100]        <1> 	mov	edi, DestinationFile_Name
  3293 0000C342 A5                  <1> 	movsd
  3294 0000C343 A5                  <1> 	movsd	
  3295 0000C344 A5                  <1> 	movsd
  3296                              <1> 	;movsb
  3297                              <1> 
  3298                              <1> csftdf_check_disk_free_size_0:
  3299 0000C345 A1[EA940100]        <1> 	mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  3300                              <1> 
  3301                              <1> csftdf_check_disk_free_size_1:
  3302                              <1> 	;sub	ebx, ebx
  3303                              <1> 	;mov 	esi, Logical_DOSDisks
  3304                              <1> 	;mov	bh,  [DestinationFile_Drv]
  3305                              <1> 	;add	esi, ebx
  3306                              <1> 	
  3307 0000C34A 8B35[D4950100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  3308                              <1> 
  3309 0000C350 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  3310 0000C354 01C8                <1> 	add	eax, ecx
  3311 0000C356 48                  <1> 	dec	eax  ; file size (additional bytes) + 511 (round up)
  3312                              <1> csftdf_check_disk_free_size_3: ; 16/03/2016
  3313 0000C357 29D2                <1> 	sub	edx, edx
  3314 0000C359 F7F1                <1> 	div	ecx ; bytes per sector
  3315                              <1> 
  3316                              <1> csftdf_check_disk_free_size:
  3317 0000C35B 3B4674              <1> 	cmp	eax, [esi+LD_FreeSectors]
  3318 0000C35E 0F8294000000        <1>         jb      csftdf_check_disk_free_size_ok
  3319 0000C364 770A                <1> 	ja	short csftdf_df_insufficient_disk_space
  3320                              <1> 
  3321 0000C366 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0 ; FS needs FDT sector also.
  3322 0000C36A 0F8788000000        <1>         ja      csftdf_check_disk_free_size_ok 
  3323                              <1> 
  3324                              <1> csftdf_df_insufficient_disk_space:
  3325 0000C370 B827000000          <1> 	mov	eax, 27h ; insufficient disk space
  3326 0000C375 EBA6                <1> 	jmp	short csftdf_df_error_stc_retn
  3327                              <1> 
  3328                              <1> csftdf_df_save_first_cluster:
  3329                              <1> 	; ESI = FindFile_DirEntry (for the old destination file)
  3330                              <1> 	; EAX = Old destination file size
  3331                              <1> 	; 24/03/2016
  3332                              <1> 	; EDI = Directory entry address (within Dir Buffer boundaries)
  3333 0000C377 81EF00000800        <1> 	sub	edi, Directory_Buffer  ; (<65536)
  3334 0000C37D 66C1EF05            <1> 	shr	di, 5 ; Convert entry offset to entry index/number
  3335 0000C381 66893D[76950100]    <1> 	mov	[DestinationFile_DirEntryNumber], di ; (<2048)
  3336                              <1> 
  3337                              <1> csftdf_df_check_sf_df_fcluster:
  3338 0000C388 668B5614            <1> 	mov	dx, [esi+DirEntry_FstClusHI]
  3339 0000C38C C1E210              <1> 	shl	edx, 16
  3340 0000C38F 668B561A            <1> 	mov	dx, [esi+DirEntry_FstClusLO]
  3341 0000C393 8915[B8950100]      <1> 	mov	[csftdf_df_cluster], edx
  3342                              <1> csftdf_df_check_sf_df_fcluster_1:
  3343 0000C399 668B15[E2940100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  3344 0000C3A0 C1E210              <1> 	shl	edx, 16
  3345 0000C3A3 668B15[E8940100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  3346 0000C3AA 3B15[B8950100]      <1> 	cmp	edx, [csftdf_df_cluster]
  3347 0000C3B0 7512                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  3348                              <1> csftdf_df_check_sf_df_drv:
  3349 0000C3B2 8A15[7C940100]      <1> 	mov	dl, [SourceFile_Drv]
  3350 0000C3B8 3A15[FC940100]      <1> 	cmp	dl, [DestinationFile_Drv]
  3351 0000C3BE 7504                <1> 	jne	short csftdf_df_check_sf_df_fcluster_ok
  3352                              <1> 
  3353                              <1> 	; source and destination files are same !
  3354                              <1> 	; (they have same first cluster value on same logical disk)
  3355                              <1> 
  3356 0000C3C0 31C0                <1> 	xor	eax, eax ; mov eax, 0 -> Bad command or file name !
  3357 0000C3C2 F9                  <1> 	stc
  3358 0000C3C3 C3                  <1> 	retn 
  3359                              <1>    
  3360                              <1> csftdf_df_check_sf_df_fcluster_ok:
  3361                              <1> csftdf_df_move_findfile_struct:
  3362                              <1> 	; mov	esi, FindFile_DirEntry
  3363 0000C3C4 BF[4E950100]        <1> 	mov	edi, DestinationFile_DirEntry
  3364 0000C3C9 B908000000          <1> 	mov	ecx, 8
  3365 0000C3CE F3A5                <1> 	rep	movsd
  3366                              <1> 	
  3367                              <1> csftdf_check_disk_free_size_2:
  3368 0000C3D0 89C2                <1> 	mov	edx, eax ; Old destination file size
  3369                              <1> 
  3370                              <1> 	;mov	eax, [SourceFile_DirEntry+DirEntry_FileSize]
  3371 0000C3D2 A1[A8950100]        <1> 	mov	eax, [csftdf_filesize] ; 23/03/2016
  3372                              <1> 
  3373                              <1> 	;;sub	ecx, ecx ; 0
  3374                              <1> 	;mov 	esi, Logical_DOSDisks
  3375                              <1> 	;mov	ch,  [DestinationFile_Drv]
  3376                              <1> 	;add	esi, ecx
  3377                              <1> 	;
  3378                              <1> 	;mov	[csftdf_df_drv_dt], esi
  3379                              <1> 
  3380 0000C3D7 8B35[D4950100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 23/03/2016
  3381                              <1> 
  3382 0000C3DD 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec] ; 17, LD_BPB + 0Bh
  3383 0000C3E1 01CA                <1> 	add	edx, ecx ; + 512
  3384 0000C3E3 01C8                <1> 	add	eax, ecx ; + 512
  3385 0000C3E5 4A                  <1> 	dec	edx ; old file size + 511 (round up)
  3386 0000C3E6 48                  <1> 	dec	eax ; new file size + 511 (round up)
  3387 0000C3E7 F7D9                <1> 	neg	ecx ; -512 ; 0FFFFFE00h
  3388 0000C3E9 21CA                <1> 	and	edx, ecx ; = old sector count * 512 
  3389 0000C3EB 21C8                <1> 	and	eax, ecx ; = new sector count * 512 
  3390                              <1> 
  3391 0000C3ED 29D0                <1> 	sub	eax, edx ; new file size - old file size (on disk)
  3392 0000C3EF 7607                <1> 	jna	short csftdf_check_disk_free_size_ok
  3393                              <1> 
  3394 0000C3F1 F7D9                <1> 	neg	ecx ; 512 (bytes per sector) ; 200h
  3395                              <1> 	; check free space for additional sectors
  3396                              <1> 	; eax = number of additional sectors * bytes per sector
  3397                              <1> 	; esi = Logical DOS drive number (of destination disk)
  3398 0000C3F3 E95FFFFFFF          <1>         jmp     csftdf_check_disk_free_size_3
  3399                              <1>  
  3400                              <1> csftdf_check_disk_free_size_ok:
  3401                              <1> 	; 18/03/2016
  3402                              <1> csftdf_df_check_copy_cmd_phase:
  3403 0000C3F8 A0[A4950100]        <1> 	mov	al, [copy_cmd_phase]
  3404 0000C3FD 3C01                <1> 	cmp	al, 1
  3405 0000C3FF 7514                <1> 	jne	short csftdf2_check_cdrv
  3406                              <1> 	
  3407 0000C401 31C0                <1> 	xor	eax, eax
  3408 0000C403 A2[A4950100]        <1> 	mov	[copy_cmd_phase], al ; 0
  3409                              <1> 
  3410 0000C408 8A15[A6950100]      <1> 	mov	dl, [DestinationFileFound]            
  3411 0000C40E 8A35[D9940100]      <1> 	mov	dh, [SourceFile_DirEntry+11] ; Attributes
  3412                              <1>  
  3413                              <1> csftdf_return:	
  3414 0000C414 C3                  <1> 	retn
  3415                              <1> 
  3416                              <1> ; Phase 2
  3417                              <1> 
  3418                              <1> csftdf2_check_cdrv:
  3419                              <1> 	; 18/03/2016
  3420                              <1> 	; Here, destination drive and directory are ready !
  3421                              <1> 	; (checking/restoring is not needed)
  3422                              <1> 	; (Since at the end of the phase 1)
  3423                              <1> 
  3424                              <1> ;	mov	dl, [DestinationFile_Drv]
  3425                              <1> ;	cmp	dl, [Current_Drv]
  3426                              <1> ;	je	short csftdf2_df_check_directory
  3427                              <1> ;
  3428                              <1> ;	call	change_current_drive
  3429                              <1> ;	jc	short csftdf2_read_error
  3430                              <1> ;
  3431                              <1> ;csftdf2_df_check_directory:
  3432                              <1> ;	mov	esi, DestinationFile_Directory  
  3433                              <1> ;	cmp	byte [esi], 20h
  3434                              <1> ;	jna	short csftdf2_df_check_found_or_not
  3435                              <1> ;
  3436                              <1> ;csftdf2_df_change_directory:
  3437                              <1> ;	inc	byte [Restore_CDIR]
  3438                              <1> ;	xor	ah, ah ; CD_COMMAND sign -> 0 
  3439                              <1> ;	call	change_current_directory
  3440                              <1> ;	jc	short csftdf2_stc_return
  3441                              <1> ;
  3442                              <1> ;;csftdf2_df_change_prompt_dir_string:
  3443                              <1> ;;	call	change_prompt_dir_string
  3444                              <1> 
  3445                              <1> csftdf2_df_check_found_or_not:
  3446                              <1> 	; 21/03/2016
  3447 0000C415 803D[A6950100]00    <1> 	cmp	byte [DestinationFileFound], 0 
  3448 0000C41C 7739                <1> 	ja	short csftdf2_set_sf_percentage
  3449                              <1> 
  3450                              <1> csftdf2_create_file:
  3451 0000C41E BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
  3452 0000C423 A1[A8950100]        <1> 	mov	eax, [csftdf_filesize]
  3453 0000C428 30C9                <1> 	xor	cl, cl ; 0
  3454                              <1> 
  3455 0000C42A 31DB                <1> 	xor	ebx, ebx ; 0
  3456 0000C42C 4B                  <1> 	dec	ebx ; 0FFFFFFFFh 
  3457                              <1> 
  3458                              <1> 	; INPUT ->
  3459                              <1> 	; 	EAX -> File Size
  3460                              <1> 	; 	ESI = ASCIIZ File name
  3461                              <1> 	;	 CL = File attributes
  3462                              <1> 	;	EBX = FFFFFFFFh -> empty file sign for FAT fs
  3463                              <1> 	;	EBX <> FFFFFFFFh -> use file size for FAT fs 
  3464                              <1> 	;
  3465                              <1> 	; OUTPUT ->
  3466                              <1> 	;	EAX = New file's first cluster
  3467                              <1> 	;	ESI = Logical Dos Drv Descr. Table Addr.
  3468                              <1> 	;	EBX = CreateFile_Size address
  3469                              <1> 	;	ECX = Sectors per cluster (<256)
  3470                              <1> 	;	EDX = Directory Entry Index/Number (<65536)
  3471                              <1> 	;		
  3472                              <1> 	;	cf = 1 -> error code in AL (EAX)
  3473                              <1> 
  3474 0000C42D E8EC050000          <1> 	call	create_file
  3475                              <1> 	;pop	esi
  3476 0000C432 0F82A3050000        <1>         jc      csftdf2_rw_error
  3477                              <1> 
  3478                              <1> csftdf2_create_file_OK:
  3479 0000C438 A3[B8950100]        <1> 	mov	[csftdf_df_cluster], eax
  3480                              <1> 	
  3481                              <1> 	; 24/03/2016
  3482 0000C43D 668915[76950100]    <1> 	mov	[DestinationFile_DirEntryNumber], dx 
  3483                              <1> 
  3484                              <1> 	; 21/03/2016
  3485 0000C444 BE00000800          <1> 	mov	esi, Directory_Buffer
  3486 0000C449 C1E205              <1> 	shl	edx, 5 ; 32 * index number
  3487 0000C44C 01D6                <1> 	add	esi, edx
  3488 0000C44E BF[4E950100]        <1> 	mov	edi, DestinationFile_DirEntry	
  3489 0000C453 B108                <1> 	mov	cl, 8 ; 32 bytes
  3490 0000C455 F3A5                <1> 	rep	movsd
  3491                              <1> 
  3492                              <1> csftdf2_set_sf_percentage:
  3493                              <1> 	; 17/03/2016
  3494 0000C457 31C0                <1> 	xor	eax, eax	
  3495 0000C459 A2[CC950100]        <1> 	mov 	[csftdf_percentage], al ; 0, reset
  3496                              <1> 
  3497 0000C45E A3[C4950100]        <1> 	mov	[csftdf_sf_rbytes], eax ; 0, reset
  3498 0000C463 A3[C8950100]        <1> 	mov	[csftdf_df_wbytes], eax ; 0, reset
  3499                              <1> 
  3500 0000C468 8A25[7C940100]      <1> 	mov	ah, [SourceFile_Drv]	
  3501 0000C46E BE00010900          <1> 	mov	esi, Logical_DOSDisks
  3502 0000C473 01C6                <1> 	add	esi, eax
  3503                              <1> 	
  3504 0000C475 8935[D0950100]      <1> 	mov	[csftdf_sf_drv_dt], esi ; 23/03/2016
  3505                              <1> 
  3506 0000C47B 668B15[E2940100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusHI]
  3507 0000C482 C1E210              <1> 	shl	edx, 16
  3508 0000C485 668B15[E8940100]    <1> 	mov	dx, [SourceFile_DirEntry+DirEntry_FstClusLO]
  3509 0000C48C 8915[B4950100]      <1> 	mov	[csftdf_sf_cluster], edx
  3510                              <1> 
  3511                              <1> 	; 16/03/2016
  3512                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  3513                              <1> 	;	related calculations) has same offset
  3514                              <1> 	;	values from LD_BPB as in FAT file system.
  3515                              <1> 	;	[esi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  3516                              <1> 	;	
  3517 0000C492 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  3518 0000C496 880D[FA940100]      <1> 	mov	[SourceFile_SecPerClust], cl
  3519                              <1> 
  3520                              <1> 	; 17/03/2016
  3521 0000C49C 386E03              <1> 	cmp	[esi+LD_FATType], ch ; 0
  3522 0000C49F 7707                <1> 	ja	short csftdf2_set_sf_percent_rsize1
  3523                              <1> 
  3524 0000C4A1 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  3525 0000C4A6 EB06                <1> 	jmp	short csftdf2_set_sf_percent_rsize2	
  3526                              <1>  
  3527                              <1> csftdf2_set_sf_percent_rsize1:
  3528 0000C4A8 668B4611            <1> 	mov	ax, [esi+LD_BPB+BytesPerSec]
  3529 0000C4AC F7E1                <1> 	mul	ecx
  3530                              <1> 	;sub	edx, edx
  3531                              <1> csftdf2_set_sf_percent_rsize2:
  3532 0000C4AE A3[BC950100]        <1> 	mov	[csftdf_r_size], eax
  3533                              <1> 
  3534                              <1> csftdf2_set_df_percentage:
  3535                              <1> 	;sub	eax, eax
  3536                              <1> 	;mov	ah, [DestinationFile_Drv]	
  3537                              <1> 	;mov	edi, Logical_DOSDisks
  3538                              <1> 	;add	edi, eax
  3539                              <1> 	;mov	[csftdf_df_drv_dt], edi ; 17/03/2016
  3540                              <1> 
  3541 0000C4B3 8B3D[D4950100]      <1> 	mov	edi, [csftdf_df_drv_dt] ; 23/03/2016
  3542                              <1> 
  3543                              <1> 	; 16/03/2016
  3544                              <1> 	; Note: Singlix FS boot sector parameters (for cluster
  3545                              <1> 	;	related calculations) has same offset
  3546                              <1> 	;	values from LD_BPB as in FAT file system.
  3547                              <1> 	;	[edi+LD_BPB+SecPerClust] is 1 for Singlix FS.
  3548                              <1> 	;	
  3549                              <1> 	;movzx	ecx, byte [edi+LD_BPB+SecPerClust]
  3550 0000C4B9 8A4F13              <1> 	mov	cl, [edi+LD_BPB+SecPerClust]
  3551 0000C4BC 880D[7A950100]      <1> 	mov	[DestinationFile_SecPerClust], cl
  3552                              <1> 
  3553                              <1> 	; 17/03/2016
  3554 0000C4C2 386F03              <1> 	cmp	[edi+LD_FATType], ch ; 0
  3555 0000C4C5 7707                <1> 	ja	short csftdf2_set_df_percent_wsize1
  3556                              <1> 	
  3557 0000C4C7 B800000100          <1> 	mov	eax, 65536 ; read/write buffer size for Singlix FS
  3558 0000C4CC EB06                <1> 	jmp	short csftdf2_set_df_percent_wsize2	
  3559                              <1> 
  3560                              <1> csftdf2_set_df_percent_wsize1:
  3561 0000C4CE 0FB74711            <1> 	movzx	eax, word [edi+LD_BPB+BytesPerSec]
  3562 0000C4D2 F7E1                <1> 	mul	ecx
  3563                              <1> 	;sub	edx, edx
  3564                              <1> csftdf2_set_df_percent_wsize2:
  3565 0000C4D4 A3[C0950100]        <1> 	mov	[csftdf_w_size], eax
  3566                              <1> 
  3567 0000C4D9 A1[A8950100]        <1> 	mov	eax, [csftdf_filesize]
  3568                              <1> 
  3569 0000C4DE 3D00000100          <1> 	cmp	eax, 65536 ; 64KB	; small file
  3570 0000C4E3 721F                <1> 	jb	short csftdf2_load_file ; do not display percentage
  3571                              <1> 	
  3572                              <1> csftdf2_reset_wf_percent_ptr_chk_64k:
  3573 0000C4E5 B201                <1> 	mov	dl, 1 ; 25/03/2016
  3574                              <1> 
  3575 0000C4E7 3D00000400          <1> 	cmp	eax, 65536*4 ; 256KB
  3576 0000C4EC 7310                <1> 	jnb	short csftdf2_enable_percentage_display ; big file
  3577                              <1> 
  3578                              <1> 	; 64-128KB file size for floppy disks
  3579 0000C4EE 3815[7C940100]      <1> 	cmp	byte [SourceFile_Drv], dl ; 1 ; read from floppy disk ?
  3580 0000C4F4 7608                <1> 	jna	short csftdf2_enable_percentage_display
  3581                              <1> 
  3582 0000C4F6 3815[FC940100]      <1> 	cmp	byte [DestinationFile_Drv], dl ; 1 ; write to floppy disk ?
  3583 0000C4FC 7706                <1> 	ja	short csftdf2_load_file
  3584                              <1> 
  3585                              <1> csftdf2_enable_percentage_display:	
  3586 0000C4FE 8815[CC950100]      <1> 	mov	[csftdf_percentage], dl ; 1	
  3587                              <1> 	
  3588                              <1> csftdf2_load_file:
  3589                              <1> 	; 13/05/2016
  3590                              <1> 	; 19/03/2016
  3591                              <1> 	; 18/03/2016
  3592                              <1> 	; 17/03/2016
  3593 0000C504 B40F                <1> 	mov	ah, 0Fh
  3594 0000C506 E85E52FFFF          <1> 	call	_int10h
  3595                              <1> 	; 13/05/2016
  3596 0000C50B 883D[CD950100]      <1> 	mov	[csftdf_videopage], bh ; active video page
  3597 0000C511 B403                <1> 	mov	ah, 03h
  3598 0000C513 E85152FFFF          <1> 	call	_int10h
  3599 0000C518 668915[CE950100]    <1> 	mov	[csftdf_cursorpos], dx
  3600                              <1> 
  3601 0000C51F 29C0                <1> 	sub	eax, eax
  3602 0000C521 A2[A5950100]        <1> 	mov	[csftdf_rw_err], al ; 0 
  3603                              <1> 
  3604                              <1> ; ///
  3605                              <1> csftdf_sf_amb: ; 15/03/2016
  3606 0000C526 8B0D[A8950100]      <1> 	mov	ecx, [csftdf_filesize]	; 23/03/2016
  3607                              <1> 
  3608                              <1> 	; TRDOS 386 (TRDOS v2.0)
  3609                              <1> 	; Allocate contiguous memory block for loading the file
  3610                              <1> 	
  3611                              <1> 	;mov	ecx, [SourceFile_DirEntry+DirEntry_FileSize]
  3612                              <1> 	
  3613                              <1> 	;sub	eax, eax ; First free memory aperture
  3614                              <1> 	
  3615                              <1> 	; eax = 0 (Allocate memory from the beginning)
  3616                              <1> 	; ecx = File (Allocation) size in bytes
  3617                              <1> 	
  3618 0000C52C E84C9FFFFF          <1> 	call	allocate_memory_block
  3619 0000C531 7304                <1> 	jnc	short loc_check_sf_save_loading_parms
  3620                              <1> 
  3621 0000C533 29C0                <1> 	sub	eax, eax
  3622 0000C535 29C9                <1> 	sub	ecx, ecx
  3623                              <1> 	
  3624                              <1> loc_check_sf_save_loading_parms:
  3625 0000C537 A3[AC950100]        <1> 	mov	[csftdf_sf_mem_addr], eax ; loading address
  3626 0000C53C 890D[B0950100]      <1> 	mov	[csftdf_sf_mem_bsize], ecx ; block size
  3627                              <1> ; ///   
  3628                              <1> 	; 19/03/2016
  3629 0000C542 8B35[D0950100]      <1> 	mov	esi, [csftdf_sf_drv_dt] ; logical dos drv desc. tbl.
  3630                              <1> 
  3631                              <1> 	; 17/03/2016
  3632 0000C548 09C0                <1> 	or	eax, eax ; contiguous free memory block address 
  3633 0000C54A 0F845B010000        <1>         jz      csftdf2_read_sf_cluster
  3634                              <1> 
  3635                              <1> 	; 18/03/2016
  3636 0000C550 8B1D[AC950100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  3637                              <1> 
  3638 0000C556 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3639 0000C55A 0F8605020000        <1>         jna     csftdf2_load_fs_file
  3640                              <1> 
  3641                              <1> csftdf2_load_fat_file:
  3642 0000C560 53                  <1> 	push	ebx ; *
  3643                              <1> 
  3644                              <1> csftdf2_load_fat_file_next:
  3645 0000C561 BE[B3460100]        <1> 	mov	esi, msg_reading
  3646 0000C566 E8EAAFFFFF          <1> 	call	print_msg
  3647                              <1> 
  3648 0000C56B 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3649 0000C572 7605                <1> 	jna	short csftdf2_load_fat_file_1
  3650                              <1> 	
  3651 0000C574 E87C000000          <1> 	call	csftdf2_print_percentage ; 19/03/2016
  3652                              <1> 
  3653                              <1> csftdf2_load_fat_file_1:
  3654 0000C579 8B35[D0950100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  3655 0000C57F 5B                  <1> 	pop	ebx ; *
  3656                              <1> 
  3657                              <1> csftdf2_load_fat_file_2:
  3658 0000C580 E8B8000000          <1> 	call	csftdf2_read_fat_file_sectors ; 19/03/2016
  3659 0000C585 0F8250040000        <1>         jc      csftdf2_rw_error ; eocc! or disk error! 
  3660                              <1> 
  3661 0000C58B 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3662 0000C58D 7520                <1> 	jnz	short csftdf2_load_fat_file_ok
  3663                              <1> 
  3664 0000C58F 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3665 0000C596 76E8                <1> 	jna	short csftdf2_load_fat_file_2
  3666                              <1> 
  3667 0000C598 53                  <1> 	push	ebx ; *	
  3668                              <1> 
  3669                              <1> 	; Set cursor position
  3670                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  3671 0000C599 8A3D[CD950100]      <1> 	mov	bh, [csftdf_videopage]
  3672 0000C59F 668B15[CE950100]    <1> 	mov	dx, [csftdf_cursorpos]
  3673 0000C5A6 B402                <1> 	mov	ah, 2
  3674 0000C5A8 E8BC51FFFF          <1> 	call	_int10h
  3675 0000C5AD EBB2                <1> 	jmp	short csftdf2_load_fat_file_next
  3676                              <1> 	
  3677                              <1> csftdf2_load_fat_file_ok:
  3678 0000C5AF 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3679 0000C5B6 0F8651020000        <1>         jna     csftdf2_save_file ; 25/03/2016
  3680                              <1> 	
  3681                              <1> 	; "Reading... 100%"
  3682 0000C5BC BF[CB460100]        <1> 	mov	edi, percentagestr
  3683 0000C5C1 B031                <1> 	mov	al, '1'
  3684 0000C5C3 AA                  <1> 	stosb
  3685 0000C5C4 B030                <1> 	mov	al, '0'
  3686 0000C5C6 AA                  <1> 	stosb
  3687 0000C5C7 AA                  <1> 	stosb
  3688                              <1> 
  3689 0000C5C8 8A3D[CD950100]      <1> 	mov	bh, [csftdf_videopage]
  3690 0000C5CE 668B15[CE950100]    <1> 	mov	dx, [csftdf_cursorpos]
  3691 0000C5D5 B402                <1> 	mov	ah, 2
  3692 0000C5D7 E88D51FFFF          <1> 	call	_int10h
  3693                              <1> 
  3694 0000C5DC BE[B3460100]        <1> 	mov	esi, msg_reading
  3695 0000C5E1 E86FAFFFFF          <1> 	call	print_msg
  3696                              <1> 	
  3697 0000C5E6 BE[CB460100]        <1> 	mov	esi, percentagestr
  3698 0000C5EB E865AFFFFF          <1> 	call	print_msg
  3699                              <1> 
  3700 0000C5F0 E918020000          <1>         jmp     csftdf2_save_file ; 25/03/2016
  3701                              <1> 
  3702                              <1> csftdf2_print_percentage:
  3703                              <1> 	; 09/12/2017
  3704                              <1> 	; 19/03/2016
  3705                              <1> 	; 18/03/2016
  3706 0000C5F5 B020                <1> 	mov	al, 20h
  3707 0000C5F7 BF[CB460100]        <1> 	mov	edi, percentagestr
  3708 0000C5FC AA                  <1> 	stosb
  3709 0000C5FD AA                  <1> 	stosb
  3710 0000C5FE A1[C4950100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  3711 0000C603 BA64000000          <1> 	mov	edx, 100
  3712 0000C608 F7E2                <1> 	mul	edx
  3713 0000C60A 8B0D[A8950100]      <1> 	mov	ecx, [csftdf_filesize]	
  3714 0000C610 F7F1                <1> 	div	ecx
  3715 0000C612 B10A                <1> 	mov	cl, 10
  3716 0000C614 F6F1                <1> 	div	cl
  3717 0000C616 80C430              <1> 	add	ah, '0'
  3718 0000C619 8827                <1> 	mov	[edi], ah
  3719 0000C61B 20C0                <1> 	and	al, al
  3720 0000C61D 740A                <1> 	jz	short csftdf2_print_percent_1
  3721 0000C61F 4F                  <1> 	dec	edi
  3722                              <1> 	;cbw
  3723 0000C620 28E4                <1> 	sub	ah, ah ; 09/12/2017
  3724 0000C622 F6F1                <1> 	div	cl
  3725 0000C624 80C430              <1> 	add	ah, '0'
  3726 0000C627 8827                <1> 	mov	[edi], ah
  3727                              <1> 	;and	al, al
  3728                              <1> 	;jz	short csftdf2_print_percent_1
  3729                              <1> 	;dec	edi
  3730                              <1> 	;mov	[edi], '1' ; 100%		
  3731                              <1> 
  3732                              <1> csftdf2_print_percent_1:
  3733 0000C629 BE[CB460100]        <1> 	mov	esi, percentagestr
  3734                              <1> 	;call	print_msg
  3735                              <1> 	;retn
  3736 0000C62E E922AFFFFF          <1> 	jmp	print_msg
  3737                              <1> 
  3738                              <1> csftdf2_read_file_sectors:
  3739                              <1> 	; 19/03/2016
  3740 0000C633 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3741 0000C637 0F8627070000        <1>         jna     csftdf2_read_fs_file_sectors
  3742                              <1> 
  3743                              <1> csftdf2_read_fat_file_sectors:
  3744                              <1> 	; 19/03/2016
  3745                              <1> 	; 18/03/2016
  3746                              <1> 	; return:
  3747                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  3748                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  3749                              <1> 	;   CF = 1 -> read error (error code in AL)	
  3750                              <1> 
  3751                              <1> csftdf2_read_fat_file_secs_0:
  3752 0000C63D 8B15[A8950100]      <1> 	mov	edx, [csftdf_filesize]
  3753 0000C643 2B15[C4950100]      <1> 	sub	edx, [csftdf_sf_rbytes]
  3754 0000C649 3B15[BC950100]      <1> 	cmp	edx, [csftdf_r_size]	
  3755 0000C64F 7306                <1> 	jnb	short csftdf2_read_fat_file_secs_1
  3756 0000C651 8915[BC950100]      <1> 	mov	[csftdf_r_size], edx
  3757                              <1> 		
  3758                              <1> csftdf2_read_fat_file_secs_1:
  3759 0000C657 A1[BC950100]        <1> 	mov	eax, [csftdf_r_size]
  3760 0000C65C 29D2                <1> 	sub	edx, edx
  3761 0000C65E 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  3762 0000C662 01C8                <1> 	add	eax, ecx
  3763 0000C664 48                  <1> 	dec	eax
  3764 0000C665 F7F1                <1> 	div	ecx
  3765 0000C667 89C1                <1> 	mov	ecx, eax ; sector count
  3766 0000C669 A1[B4950100]        <1> 	mov	eax, [csftdf_sf_cluster]
  3767                              <1> 
  3768                              <1> 	; EBX = memory block address (current)
  3769                              <1> 	
  3770 0000C66E E821090000          <1> 	call	read_fat_file_sectors
  3771 0000C673 7235                <1> 	jc	short csftdf2_read_fat_file_secs_3
  3772                              <1> 
  3773                              <1> 	; EBX = next memory address
  3774                              <1> 
  3775 0000C675 A1[C4950100]        <1> 	mov	eax, [csftdf_sf_rbytes]
  3776 0000C67A 0305[BC950100]      <1> 	add	eax, [csftdf_r_size]
  3777 0000C680 8B15[A8950100]      <1> 	mov	edx, [csftdf_filesize]
  3778 0000C686 39D0                <1> 	cmp	eax, edx
  3779 0000C688 7320                <1> 	jnb	short csftdf2_read_fat_file_secs_3 ; edx > 0
  3780 0000C68A A3[C4950100]        <1> 	mov	[csftdf_sf_rbytes], eax
  3781                              <1> 
  3782 0000C68F 53                  <1> 	push	ebx ; *
  3783                              <1> 	; get next cluster (csftdf_r_size! bytes)
  3784 0000C690 A1[B4950100]        <1> 	mov	eax, [csftdf_sf_cluster]
  3785 0000C695 E8CC060000          <1> 	call	get_next_cluster
  3786 0000C69A 5B                  <1> 	pop	ebx ; *
  3787 0000C69B 7306                <1> 	jnc	short csftdf2_read_fat_file_secs_2
  3788                              <1> 
  3789                              <1> 	; 15/10/2016
  3790                              <1> 	;Disk read error instad of drv not ready err
  3791 0000C69D B811000000          <1> 	mov	eax, 17 ; Read error !
  3792 0000C6A2 C3                  <1> 	retn
  3793                              <1> 
  3794                              <1> csftdf2_read_fat_file_secs_2:
  3795 0000C6A3 29D2                <1> 	sub	edx, edx ; 0
  3796 0000C6A5 A3[B4950100]        <1> 	mov	[csftdf_sf_cluster], eax ; next cluster
  3797                              <1> 
  3798                              <1> csftdf2_read_fat_file_secs_3:
  3799 0000C6AA C3                  <1> 	retn
  3800                              <1> 
  3801                              <1> csftdf2_read_sf_cluster:
  3802                              <1> 	; 19/03/2016
  3803 0000C6AB BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  3804                              <1> 
  3805 0000C6B0 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3806 0000C6B7 760D                <1> 	jna	short csftdf2_read_sf_clust_2
  3807                              <1> 
  3808 0000C6B9 53                  <1> 	push	ebx ; *	
  3809                              <1> 
  3810                              <1> csftdf2_read_sf_clust_next:
  3811 0000C6BA E836FFFFFF          <1> 	call	csftdf2_print_percentage
  3812                              <1> 
  3813                              <1> csftdf2_read_sf_clust_0:
  3814 0000C6BF 8B35[D0950100]      <1> 	mov	esi, [csftdf_sf_drv_dt]	
  3815                              <1> csftdf2_read_sf_clust_1:
  3816 0000C6C5 5B                  <1> 	pop	ebx ; *
  3817                              <1> 
  3818                              <1> csftdf2_read_sf_clust_2:
  3819 0000C6C6 89DA                <1> 	mov	edx, ebx
  3820 0000C6C8 0315[BC950100]      <1> 	add	edx, [csftdf_r_size]
  3821 0000C6CE 81FA00000800        <1> 	cmp	edx, Cluster_Buffer + 65536
  3822 0000C6D4 772F                <1> 	ja	short csftdf2_write_df_cluster
  3823                              <1> 
  3824 0000C6D6 E858FFFFFF          <1> 	call	csftdf2_read_file_sectors ; 19/03/2016
  3825 0000C6DB 0F8280020000        <1>         jc      csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  3826                              <1> 
  3827 0000C6E1 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3828 0000C6E3 7520                <1> 	jnz	short csftdf2_write_df_cluster
  3829                              <1> 
  3830 0000C6E5 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3831 0000C6EC 76D8                <1> 	jna	short csftdf2_read_sf_clust_2
  3832                              <1> 
  3833 0000C6EE 53                  <1> 	push	ebx ; *	
  3834                              <1> 
  3835                              <1> 	; Set cursor position
  3836                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  3837 0000C6EF 8A3D[CD950100]      <1> 	mov	bh, [csftdf_videopage]
  3838 0000C6F5 668B15[CE950100]    <1> 	mov	dx, [csftdf_cursorpos]
  3839 0000C6FC B402                <1> 	mov	ah, 2
  3840 0000C6FE E86650FFFF          <1> 	call	_int10h
  3841 0000C703 EBB5                <1> 	jmp	short csftdf2_read_sf_clust_next
  3842                              <1> 
  3843                              <1> csftdf2_write_df_cluster:
  3844                              <1> 	; 19/03/2016
  3845 0000C705 8B35[D4950100]      <1> 	mov	esi, [csftdf_df_drv_dt]	
  3846 0000C70B BB00000700          <1> 	mov	ebx, Cluster_Buffer ; buffer address (64KB)
  3847                              <1> 
  3848                              <1> csftdf2_write_df_clust_next:
  3849 0000C710 E855000000          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016
  3850 0000C715 0F8246020000        <1>         jc      csftdf2_save_fat_file_err2 ; eocc! or disk error! 
  3851                              <1> 
  3852 0000C71B 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  3853 0000C71D 750A                <1> 	jnz	short csftdf2_rw_f_clust_ok
  3854                              <1> 
  3855 0000C71F 81FB00000800        <1> 	cmp	ebx, Cluster_Buffer + 65536
  3856 0000C725 72E9                <1> 	jb	short csftdf2_write_df_clust_next
  3857                              <1> 	
  3858 0000C727 EB82                <1> 	jmp	short csftdf2_read_sf_cluster
  3859                              <1>  
  3860                              <1> csftdf2_rw_f_clust_ok:
  3861 0000C729 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3862 0000C730 0F86B2010000        <1>         jna     csftdf2_save_fat_file_4 ; 25/03/2016
  3863                              <1> 
  3864                              <1> 	; "100%"
  3865 0000C736 BF[CB460100]        <1> 	mov	edi, percentagestr
  3866 0000C73B B031                <1> 	mov	al, '1'
  3867 0000C73D AA                  <1> 	stosb
  3868 0000C73E B030                <1> 	mov	al, '0'
  3869 0000C740 AA                  <1> 	stosb
  3870 0000C741 AA                  <1> 	stosb
  3871                              <1> 
  3872 0000C742 8A3D[CD950100]      <1> 	mov	bh, [csftdf_videopage]
  3873 0000C748 668B15[CE950100]    <1> 	mov	dx, [csftdf_cursorpos]
  3874 0000C74F B402                <1> 	mov	ah, 2
  3875 0000C751 E81350FFFF          <1> 	call	_int10h
  3876                              <1> 
  3877 0000C756 BE[CB460100]        <1> 	mov	esi, percentagestr
  3878 0000C75B E8F5ADFFFF          <1> 	call	print_msg
  3879                              <1> 
  3880 0000C760 E983010000          <1>         jmp     csftdf2_save_fat_file_4
  3881                              <1> 
  3882                              <1> csftdf2_load_fs_file:
  3883                              <1> 	; temporary - 18/03/2016
  3884 0000C765 E96F020000          <1>         jmp     csftdf2_read_error
  3885                              <1> 
  3886                              <1> csftdf2_write_file_sectors:
  3887                              <1> 	; 19/03/2016
  3888 0000C76A 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3889 0000C76E 0F86F1050000        <1>         jna     csftdf2_write_fs_file_sectors
  3890                              <1> 
  3891                              <1> csftdf2_write_fat_file_sectors:
  3892                              <1> 	; 19/03/2016
  3893                              <1> 	; 18/03/2016
  3894                              <1> 	; return:
  3895                              <1> 	;   CF = 0 & EDX > 0 -> END OF FILE
  3896                              <1> 	;   CF = 0 & EDX = 0 -> not EOF
  3897                              <1> 	;   CF = 1 -> write error (error code in AL)	
  3898                              <1> 
  3899                              <1> csftdf2_write_fat_file_secs_0:
  3900 0000C774 8B15[A8950100]      <1> 	mov	edx, [csftdf_filesize]
  3901 0000C77A 2B15[C8950100]      <1> 	sub	edx, [csftdf_df_wbytes]
  3902 0000C780 3B15[C0950100]      <1> 	cmp	edx, [csftdf_w_size]	
  3903 0000C786 7306                <1> 	jnb	short csftdf2_write_fat_file_secs_1
  3904 0000C788 8915[C0950100]      <1> 	mov	[csftdf_w_size], edx		
  3905                              <1> 
  3906                              <1> csftdf2_write_fat_file_secs_1:
  3907 0000C78E A1[C0950100]        <1> 	mov	eax, [csftdf_w_size]
  3908 0000C793 29D2                <1> 	sub	edx, edx
  3909 0000C795 0FB74E11            <1> 	movzx	ecx, word [esi+LD_BPB+BytesPerSec]
  3910 0000C799 01C8                <1> 	add	eax, ecx
  3911 0000C79B 48                  <1> 	dec	eax
  3912 0000C79C F7F1                <1> 	div	ecx
  3913 0000C79E 89C1                <1> 	mov	ecx, eax ; sector count
  3914 0000C7A0 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster]
  3915                              <1> 
  3916                              <1> 	; EBX = memory block address (current)	
  3917                              <1> 
  3918 0000C7A5 E8A20F0000          <1> 	call	write_fat_file_sectors
  3919 0000C7AA 7259                <1> 	jc	short csftdf2_write_fat_file_secs_4
  3920                              <1> 
  3921                              <1> 	; EBX = next memory address
  3922                              <1> 
  3923 0000C7AC A1[C8950100]        <1> 	mov	eax, [csftdf_df_wbytes]
  3924 0000C7B1 0305[C0950100]      <1> 	add	eax, [csftdf_w_size]
  3925 0000C7B7 8B15[A8950100]      <1> 	mov	edx, [csftdf_filesize]
  3926 0000C7BD 39D0                <1> 	cmp	eax, edx
  3927 0000C7BF 7344                <1> 	jnb	short csftdf2_write_fat_file_secs_4
  3928 0000C7C1 A3[C8950100]        <1> 	mov	[csftdf_df_wbytes], eax
  3929                              <1> 	;
  3930 0000C7C6 A3[6A950100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  3931                              <1> 
  3932 0000C7CB 53                  <1> 	push	ebx ; *
  3933                              <1> 
  3934 0000C7CC 803D[A6950100]01    <1> 	cmp	byte [DestinationFileFound], 1
  3935 0000C7D3 7210                <1> 	jb	short csftdf2_write_fat_file_secs_2
  3936                              <1> 
  3937                              <1> 	; get next cluster (csftdf_w_size! bytes)
  3938 0000C7D5 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster]
  3939 0000C7DA E887050000          <1> 	call	get_next_cluster
  3940 0000C7DF 731C                <1> 	jnc	short csftdf2_write_fat_file_secs_3
  3941                              <1> 
  3942 0000C7E1 21C0                <1> 	and	eax, eax ; end of cluster chain!?
  3943 0000C7E3 7521                <1> 	jnz	short csftdf2_write_fat_file_secs_5 ; disk error !
  3944                              <1> 
  3945                              <1> csftdf2_write_fat_file_secs_2:
  3946 0000C7E5 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  3947 0000C7EA E8800E0000          <1> 	call	add_new_cluster		
  3948 0000C7EF 7215                <1> 	jc	short csftdf2_write_fat_file_secs_5
  3949                              <1> 
  3950                              <1> 	; NOTE: Destination file size may be bigger than
  3951                              <1> 	; source file size when the last reading fails after here.
  3952                              <1> 	; (The last -empty- cluster of destination file must be 
  3953                              <1> 	; truncated and LMDT must be current date&time for partial
  3954                              <1> 	; copy result!) 
  3955 0000C7F1 8B15[C0950100]      <1> 	mov	edx, [csftdf_w_size] ; bytes per cluster
  3956 0000C7F7 0115[6A950100]      <1> 	add	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  3957                              <1> 
  3958                              <1> csftdf2_write_fat_file_secs_3:
  3959 0000C7FD 5B                  <1> 	pop	ebx ; *
  3960 0000C7FE 29D2                <1> 	sub	edx, edx ; 0
  3961 0000C800 A3[B8950100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  3962                              <1> 
  3963                              <1> csftdf2_write_fat_file_secs_4:
  3964 0000C805 C3                  <1> 	retn
  3965                              <1> 
  3966                              <1> csftdf2_write_fat_file_secs_5:
  3967 0000C806 5B                  <1> 	pop	ebx ; *
  3968                              <1> 	; 16/10/2016 (1Dh -> 18)
  3969 0000C807 B812000000          <1> 	mov	eax, 18 ; Write error !
  3970 0000C80C C3                  <1> 	retn
  3971                              <1> 
  3972                              <1> csftdf2_save_file:
  3973                              <1> 	; 09/12/2017
  3974                              <1> 	; 25/03/2016
  3975                              <1> 	; 19/03/2016
  3976                              <1> 	; 18/03/2016
  3977 0000C80D 8B35[D4950100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; logical dos drv desc. tbl.
  3978                              <1> 
  3979 0000C813 8B1D[AC950100]      <1> 	mov	ebx, [csftdf_sf_mem_addr] ; memory block address
  3980                              <1> 
  3981 0000C819 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  3982 0000C81D 0F86F4010000        <1>         jna     csftdf2_save_fs_file
  3983                              <1> 
  3984                              <1> csftdf2_save_fat_file:
  3985 0000C823 53                  <1> 	push	ebx; *
  3986                              <1> 
  3987 0000C824 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  3988 0000C82B 7724                <1> 	ja	short csftdf2_save_fat_file_0
  3989                              <1> 
  3990                              <1> 	; Set cursor position
  3991                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  3992 0000C82D 8A3D[CD950100]      <1> 	mov	bh, [csftdf_videopage]
  3993 0000C833 668B15[CE950100]    <1> 	mov	dx, [csftdf_cursorpos]
  3994 0000C83A B402                <1> 	mov	ah, 2
  3995 0000C83C E8284FFFFF          <1> 	call	_int10h
  3996                              <1> 	
  3997 0000C841 BE[BF460100]        <1> 	mov	esi, msg_writing
  3998 0000C846 E80AADFFFF          <1> 	call	print_msg
  3999                              <1> 
  4000                              <1> csftdf2_save_fat_file_next:
  4001 0000C84B 8B35[D4950100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 25/03/2016
  4002                              <1> 
  4003                              <1> csftdf2_save_fat_file_0:
  4004 0000C851 5B                  <1> 	pop	ebx ; *
  4005                              <1> 
  4006                              <1> csftdf2_save_fat_file_1:
  4007 0000C852 E813FFFFFF          <1> 	call	csftdf2_write_file_sectors ; 19/03/2016	
  4008 0000C857 0F827E010000        <1>         jc      csftdf2_rw_error ; eocc! or disk error! 
  4009                              <1> 
  4010 0000C85D 09D2                <1> 	or	edx, edx ; edx > 0 -> EOF
  4011 0000C85F 756D                <1>         jnz     short csftdf2_save_fat_file_3 ; 25/03/2016
  4012                              <1> 
  4013 0000C861 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4014 0000C868 76E8                <1> 	jna	short csftdf2_save_fat_file_1
  4015                              <1> 
  4016 0000C86A B020                <1> 	mov	al, 20h
  4017 0000C86C BF[CB460100]        <1> 	mov	edi, percentagestr
  4018 0000C871 AA                  <1> 	stosb
  4019 0000C872 AA                  <1> 	stosb
  4020 0000C873 A1[C8950100]        <1> 	mov	eax, [csftdf_df_wbytes]
  4021 0000C878 BA64000000          <1> 	mov	edx, 100
  4022 0000C87D F7E2                <1> 	mul	edx
  4023 0000C87F 8B0D[A8950100]      <1> 	mov	ecx, [csftdf_filesize]	
  4024 0000C885 F7F1                <1> 	div	ecx
  4025 0000C887 B10A                <1> 	mov	cl, 10
  4026 0000C889 F6F1                <1> 	div	cl
  4027 0000C88B 80C430              <1> 	add	ah, '0'
  4028 0000C88E 8827                <1> 	mov	[edi], ah
  4029 0000C890 20C0                <1> 	and	al, al
  4030 0000C892 740A                <1> 	jz	short csftdf2_save_fat_file_2
  4031 0000C894 4F                  <1> 	dec	edi
  4032                              <1> 	;cbw
  4033 0000C895 30E4                <1> 	xor	ah, ah ; 09/12/2017
  4034 0000C897 F6F1                <1> 	div	cl
  4035 0000C899 80C430              <1> 	add	ah, '0'
  4036 0000C89C 8827                <1> 	mov	[edi], ah
  4037                              <1> 	;and	al, al
  4038                              <1> 	;jz	short csftdf2_save_fat_file_2
  4039                              <1> 	;dec	edi
  4040                              <1> 	;mov	[edi], '1' ; 100%		
  4041                              <1> 
  4042                              <1> csftdf2_save_fat_file_2:
  4043 0000C89E 53                  <1> 	push	ebx ; *
  4044                              <1> 
  4045 0000C89F E802000000          <1> 	call	csftdf2_print_wr_percentage ; 25/03/2016
  4046                              <1> 
  4047 0000C8A4 EBA5                <1>         jmp     csftdf2_save_fat_file_next
  4048                              <1> 
  4049                              <1> csftdf2_print_wr_percentage:
  4050                              <1> 	; Set cursor position
  4051                              <1> 	; AH= 02h, BH= Page Number, DH= Row, DL= Column
  4052 0000C8A6 8A3D[CD950100]      <1> 	mov	bh, [csftdf_videopage]
  4053 0000C8AC 668B15[CE950100]    <1> 	mov	dx, [csftdf_cursorpos]
  4054 0000C8B3 B402                <1> 	mov	ah, 2
  4055 0000C8B5 E8AF4EFFFF          <1> 	call	_int10h
  4056                              <1> 
  4057 0000C8BA BE[BF460100]        <1> 	mov	esi, msg_writing
  4058 0000C8BF E891ACFFFF          <1> 	call	print_msg
  4059                              <1> 
  4060 0000C8C4 BE[CB460100]        <1> 	mov	esi, percentagestr
  4061                              <1> 	;call	print_msg
  4062                              <1> 	;retn
  4063 0000C8C9 E987ACFFFF          <1> 	jmp	print_msg
  4064                              <1> 
  4065                              <1> csftdf2_save_fat_file_3:
  4066 0000C8CE 803D[CC950100]00    <1> 	cmp	byte [csftdf_percentage], 0
  4067 0000C8D5 7611                <1>         jna     csftdf2_save_fat_file_4 ; 25/03/2016
  4068                              <1> 
  4069                              <1> 	; "100%"
  4070 0000C8D7 BF[CB460100]        <1> 	mov	edi, percentagestr
  4071 0000C8DC B031                <1> 	mov	al, '1'
  4072 0000C8DE AA                  <1> 	stosb
  4073 0000C8DF B030                <1> 	mov	al, '0'
  4074 0000C8E1 AA                  <1> 	stosb
  4075 0000C8E2 AA                  <1> 	stosb
  4076                              <1> 
  4077 0000C8E3 E8BEFFFFFF          <1> 	call	csftdf2_print_wr_percentage
  4078                              <1> 
  4079                              <1> csftdf2_save_fat_file_4:
  4080 0000C8E8 803D[A6950100]00    <1> 	cmp	byte [DestinationFileFound], 0
  4081 0000C8EF 7647                <1> 	jna	short csftdf2_save_fat_file_6
  4082                              <1> 
  4083 0000C8F1 8B35[D4950100]      <1> 	mov	esi, [csftdf_df_drv_dt] ; 31/03/2016	
  4084                              <1> 
  4085 0000C8F7 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4086 0000C8FC E865040000          <1> 	call	get_next_cluster
  4087 0000C901 7235                <1> 	jc	short csftdf2_save_fat_file_6 ; eocc! or disk error!
  4088                              <1> 
  4089 0000C903 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster] ; last cluster
  4090                              <1> 	;xor	ecx, ecx
  4091                              <1> 	;mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  4092                              <1> 	;dec	ecx ; 0FFFFFFFFh
  4093                              <1> 	;shr	ecx, 4 ; 28 bit ; 0FFFFFFFh
  4094 0000C908 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  4095 0000C90D E87E070000          <1> 	call	update_cluster
  4096 0000C912 7224                <1> 	jc	short csftdf2_save_fat_file_6 ; really last cluster!?
  4097                              <1> 
  4098 0000C914 A3[B8950100]        <1> 	mov	[csftdf_df_cluster], eax ; next cluster
  4099                              <1> 	
  4100                              <1> 	; byte [FAT_BuffValidData] = 2 
  4101 0000C919 E82F0A0000          <1> 	call	save_fat_buffer
  4102 0000C91E 730E                <1> 	jnc	short csftdf2_save_fat_file_5
  4103                              <1> 	
  4104 0000C920 8B15[A8950100]      <1> 	mov	edx, [csftdf_filesize]
  4105 0000C926 8915[6A950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4106 0000C92C EB58                <1> 	jmp	short csftdf2_save_fat_file_err3
  4107                              <1> 
  4108                              <1> csftdf2_save_fat_file_5:
  4109 0000C92E A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster]
  4110                              <1> 
  4111                              <1> 	; EAX = First cluster to be truncated/unlinked
  4112                              <1> 	; ESI = Logical dos drive description table address
  4113 0000C933 E8580C0000          <1> 	call	truncate_cluster_chain
  4114                              <1> 
  4115                              <1> csftdf2_save_fat_file_6:
  4116                              <1> 	; 28/03/2016
  4117 0000C938 BE[D9940100]        <1> 	mov	esi, SourceFile_DirEntry+DirEntry_Attr ; +11 to + 18
  4118 0000C93D BF[59950100]        <1> 	mov	edi, DestinationFile_DirEntry+DirEntry_Attr ; +11 to + 18
  4119 0000C942 A4                  <1> 	movsb ; +11
  4120 0000C943 A5                  <1> 	movsd ; +12 .. +15
  4121 0000C944 66A5                <1> 	movsw ; +16 .. +17
  4122                              <1> 		; + 18
  4123 0000C946 83C604              <1> 	add	esi, 4
  4124 0000C949 83C704              <1> 	add	edi, 4
  4125 0000C94C A5                  <1> 	movsd	; DirEntry_WrtTime ; +22 .. +25
  4126                              <1> 
  4127 0000C94D 8B15[A8950100]      <1> 	mov	edx, [csftdf_filesize]
  4128 0000C953 8915[6A950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], edx
  4129                              <1> 
  4130 0000C959 E8BAF0FFFF          <1> 	call	convert_current_date_time
  4131                              <1> 	; DX = Date in dos dir entry format
  4132                              <1> 	; AX = Time in dos dir entry format
  4133 0000C95E EB4D                <1> 	jmp	short csftdf2_save_fat_file_7
  4134                              <1> 
  4135                              <1> csftdf2_save_fat_file_err1:
  4136 0000C960 5B                  <1> 	pop	ebx ; *	
  4137                              <1> csftdf2_save_fat_file_err2:
  4138 0000C961 A1[C8950100]        <1> 	mov	eax, [csftdf_df_wbytes]
  4139 0000C966 8B15[6A950100]      <1> 	mov	edx, [DestinationFile_DirEntry+DirEntry_FileSize]
  4140 0000C96C 39C2                <1> 	cmp	edx, eax
  4141 0000C96E 7616                <1> 	jna	short csftdf2_save_fat_file_err3
  4142 0000C970 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster] ; last (empty) cluster
  4143                              <1> 	; ESI = Logical dos drive description table address
  4144 0000C975 E8160C0000          <1> 	call	truncate_cluster_chain
  4145 0000C97A 720A                <1> 	jc	short csftdf2_save_fat_file_err3
  4146 0000C97C A1[C8950100]        <1> 	mov	eax, [csftdf_df_wbytes]	
  4147 0000C981 A3[6A950100]        <1> 	mov	[DestinationFile_DirEntry+DirEntry_FileSize], eax
  4148                              <1> csftdf2_save_fat_file_err3:
  4149 0000C986 E88DF0FFFF          <1> 	call	convert_current_date_time
  4150                              <1> 	; DX = Date in dos dir entry format
  4151                              <1> 	; AX = Time in dos dir entry format
  4152 0000C98B C605[5B950100]00    <1> 	mov	byte [DestinationFile_DirEntry+DirEntry_CrtTimeTenth], 0
  4153 0000C992 66A3[5C950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtTime], ax
  4154 0000C998 668915[5E950100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_CrtDate], dx		
  4155 0000C99F 66A3[64950100]      <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtTime], ax
  4156 0000C9A5 668915[66950100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_WrtDate], dx
  4157 0000C9AC F9                  <1> 	stc
  4158                              <1> csftdf2_save_fat_file_7:
  4159 0000C9AD 9C                  <1> 	pushf
  4160 0000C9AE 668915[60950100]    <1> 	mov	[DestinationFile_DirEntry+DirEntry_LastAccDate], dx
  4161 0000C9B5 BE[4E950100]        <1> 	mov	esi, DestinationFile_DirEntry
  4162 0000C9BA BF00000800          <1> 	mov	edi, Directory_Buffer
  4163 0000C9BF 0FB70D[76950100]    <1> 	movzx	ecx, word [DestinationFile_DirEntryNumber] ; (<2048)
  4164 0000C9C6 66C1E105            <1> 	shl	cx, 5 ; 32 * directory entry number
  4165 0000C9CA 01CF                <1> 	add	edi, ecx
  4166                              <1> 	;mov	ecx, 8
  4167 0000C9CC 66B90800            <1> 	mov	cx, 8
  4168 0000C9D0 F3A5                <1> 	rep	movsd
  4169 0000C9D2 9D                  <1> 	popf
  4170 0000C9D3 730B                <1> 	jnc	short csftdf2_write_file_OK
  4171                              <1> 	 		
  4172                              <1> csftdf2_write_error:
  4173                              <1> 	; 18/03/2016
  4174 0000C9D5 B01D                <1> 	mov	al, 1Dh ; write error
  4175 0000C9D7 EB02                <1> 	jmp	short csftdf2_rw_error
  4176                              <1> 
  4177                              <1> 	; 16/03/2016
  4178                              <1> csftdf2_read_error:
  4179 0000C9D9 B011                <1> 	mov	al, 17 ; ; Drive not ready or read error!
  4180                              <1> csftdf2_rw_error:
  4181 0000C9DB A2[A5950100]        <1> 	mov	[csftdf_rw_err], al 
  4182                              <1> 
  4183                              <1> csftdf2_write_file_OK:
  4184                              <1> 	; 18/03/2016
  4185 0000C9E0 C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
  4186 0000C9E7 E8CAF0FFFF          <1> 	call	save_directory_buffer
  4187                              <1> 
  4188                              <1>  	; Update last modification date&time of destination
  4189                              <1> 	; file's (parent) directory
  4190 0000C9EC E860F1FFFF          <1> 	call	update_parent_dir_lmdt
  4191                              <1> 	;
  4192 0000C9F1 A1[AC950100]        <1> 	mov	eax, [csftdf_sf_mem_addr] ; start address
  4193                              <1> 
  4194 0000C9F6 21C0                <1> 	and	eax, eax
  4195 0000C9F8 750E                <1> 	jnz	short csftdf2_dealloc_mblock
  4196                              <1> 
  4197 0000C9FA 88C5                <1> 	mov	ch, al ; 0 (Cluster r/w, not full loading)
  4198                              <1> csftdf2_dealloc_retn:
  4199 0000C9FC 8A0D[A5950100]      <1> 	mov	cl, [csftdf_rw_err]
  4200 0000CA02 A1[B8950100]        <1> 	mov	eax, [csftdf_df_cluster]
  4201 0000CA07 C3                  <1> 	retn
  4202                              <1> 
  4203                              <1> csftdf2_dealloc_mblock:
  4204 0000CA08 8B0D[B0950100]      <1> 	mov	ecx, [csftdf_sf_mem_bsize] ; block size	
  4205 0000CA0E E8779CFFFF          <1> 	call	deallocate_memory_block
  4206 0000CA13 B5FF                <1>         mov     ch, 0FFh ; (File was full loaded at memory)
  4207 0000CA15 EBE5                <1> 	jmp	short csftdf2_dealloc_retn
  4208                              <1> 
  4209                              <1> csftdf2_save_fs_file:
  4210                              <1> 	; 16/10/2016 (1Dh -> 18)
  4211                              <1> 	; temporary - (21/03/2016)
  4212 0000CA17 B812000000          <1> 	mov	eax, 18 ; write error
  4213 0000CA1C F9                  <1> 	stc
  4214 0000CA1D C3                  <1> 	retn
  4215                              <1> 
  4216                              <1> create_file:
  4217                              <1> 	; 16/10/2016
  4218                              <1> 	; 24/03/2016, 31/03/2016
  4219                              <1> 	; 20/03/2016, 21/03/2016, 23/03/2016
  4220                              <1> 	; 19/03/2016 (TRDOS 396 = TRDOS v2.0)
  4221                              <1> 	; 03/09/2011 (FILE.ASM, 'proc_create_file')
  4222                              <1> 	; 09/08/2010
  4223                              <1> 	;
  4224                              <1> 	; INPUT ->
  4225                              <1> 	; 	EAX = File Size
  4226                              <1> 	; 	ESI = ASCIIZ File Name
  4227                              <1> 	; 	CL = File Attributes 
  4228                              <1> 	;	EBX = FFFFFFFFh -> create empty file 
  4229                              <1> 	;			 (only for FAT fs) 
  4230                              <1> 	; OUTPUT ->
  4231                              <1> 	;     CF = 0 ->
  4232                              <1> 	;	EAX = New file's first cluster
  4233                              <1> 	; 	ESI = Logical Dos Drv Descr. Table Addr.
  4234                              <1> 	; 	EBX = offset CreateFile_Size
  4235                              <1> 	; 	ECX = Sectors per cluster (<256) 
  4236                              <1> 	; 	EDX = Directory entry index/number (<65536)
  4237                              <1> 	;     CF = 1 -> error code in AL
  4238                              <1> 
  4239                              <1> ;	test	cl, 18h (directory or volume name)
  4240                              <1> ;	jnz	short loc_createfile_access_denied
  4241 0000CA1E 80E107              <1> 	and	cl, 07h ; S, H, R
  4242 0000CA21 880D[F4950100]      <1>         mov     [createfile_attrib], cl 
  4243                              <1> 
  4244 0000CA27 89D9                <1> 	mov	ecx, ebx
  4245 0000CA29 89F3                <1> 	mov	ebx, esi ; ASCIIZ File Name address
  4246 0000CA2B 29D2                <1> 	sub	edx, edx
  4247 0000CA2D 8A35[968A0100]      <1>         mov     dh, [Current_Drv]
  4248 0000CA33 BE00010900          <1>         mov     esi, Logical_DOSDisks
  4249 0000CA38 01D6                <1> 	add	esi, edx
  4250                              <1> 
  4251 0000CA3A 8815[FF950100]      <1> 	mov	[createfile_UpdatePDir], dl ; 0 ; 31/03/2016 
  4252                              <1> 
  4253                              <1> 	; LD_DiskType = 0 for write protection (read only) 
  4254 0000CA40 807E0101            <1> 	cmp	byte [esi+LD_DiskType], 1 ; 0 = Invalid
  4255 0000CA44 730A                <1> 	jnb	short loc_createfile_check_file_sytem
  4256                              <1> 	; 16/10/2016 (TRDOS Error code: 30, disk write protected) 
  4257 0000CA46 B81E000000          <1> 	mov	eax, 30 ; 13h, MSDOS err : Disk write-protected 
  4258 0000CA4B 66BA0000            <1> 	mov	dx, 0
  4259                              <1> 	; err retn: EDX = 0, EBX = File name offset
  4260                              <1> 	; ESI -> Dos drive description table address	
  4261 0000CA4F C3                  <1> 	retn
  4262                              <1> 
  4263                              <1> ;loc_createfile_access_denied:
  4264                              <1> ;	mov	eax, 05h ; access denied (invalid attributes input)
  4265                              <1> ;	stc
  4266                              <1> ;	retn
  4267                              <1> 
  4268                              <1> loc_createfile_check_file_sytem:
  4269 0000CA50 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  4270 0000CA54 730A                <1> 	jnb	short loc_createfile_chk_empty_FAT_file_sign1
  4271                              <1> 
  4272 0000CA56 A3[E0950100]        <1> 	mov	[createfile_size], eax
  4273                              <1> 	; ESI = Logical Dos Drive Description Table address
  4274                              <1> 	; EBX = ASCIIZ File Name address
  4275 0000CA5B E9FE020000          <1> 	jmp	create_fs_file
  4276                              <1> 
  4277                              <1> loc_createfile_chk_empty_FAT_file_sign1:
  4278                              <1> 	; ECX = FFFFFFFFh -> create empty file if drive has FAT fs
  4279 0000CA60 41                  <1> 	inc	ecx
  4280 0000CA61 7506                <1> 	jnz	short loc_createfile_chk_empty_FAT_file_sign2
  4281 0000CA63 890D[E0950100]      <1> 	mov	[createfile_size], ecx ; 0 ; empty file
  4282                              <1> 
  4283                              <1> loc_createfile_chk_empty_FAT_file_sign2:
  4284                              <1> 	; 23/03/2016
  4285 0000CA69 668B4E11            <1> 	mov	cx, [esi+LD_BPB+BytesPerSec]
  4286 0000CA6D 66890D[FC950100]    <1> 	mov	[createfile_BytesPerSec], cx
  4287                              <1> 	
  4288                              <1> 	; EBX = ASCIIZ File Name address
  4289 0000CA74 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
  4290 0000CA78 8815[F5950100]      <1> 	mov	[createfile_SecPerClust], dl
  4291 0000CA7E 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  4292 0000CA81 39D1                <1> 	cmp	ecx, edx ; byte [createfile_SecPerClust]
  4293 0000CA83 7306                <1> 	jnb	short loc_create_fat_file
  4294                              <1> 	  
  4295                              <1> loc_createfile_insufficient_disk_space:
  4296 0000CA85 B827000000          <1> 	mov	eax, 27h
  4297                              <1> loc_createfile_gffc_retn:
  4298 0000CA8A C3                  <1> 	retn
  4299                              <1> 
  4300                              <1> loc_create_fat_file:
  4301 0000CA8B 891D[D8950100]      <1> 	mov	[createfile_Name_Offset], ebx
  4302 0000CA91 890D[DC950100]      <1> 	mov	[createfile_FreeSectors], ecx
  4303                              <1> 
  4304                              <1> loc_createfile_gffc_1:
  4305 0000CA97 E821050000          <1> 	call	get_first_free_cluster
  4306 0000CA9C 72EC                <1> 	jc	short loc_createfile_gffc_retn
  4307                              <1> 
  4308 0000CA9E A3[E4950100]        <1> 	mov	[createfile_FFCluster], eax
  4309                              <1> 
  4310                              <1> loc_createfile_locate_ffe_on_directory:
  4311                              <1> 	; Current directory fcluster <> Directory buffer cluster
  4312                              <1> 	; Current directory will be reloaded by
  4313                              <1> 	; 'locate_current_dir_file' procedure
  4314                              <1> 	;
  4315                              <1> 	; ESI = Logical Dos Drv Desc. Table Adress
  4316 0000CAA3 56                  <1> 	push	esi ; *
  4317 0000CAA4 31C0                <1> 	xor	eax, eax
  4318                              <1> 
  4319 0000CAA6 A3[B2910100]        <1> 	mov	dword [FAT_ClusterCounter], eax ; 0
  4320                              <1> 	; 21/03/2016
  4321 0000CAAB A2[FE950100]        <1> 	mov	byte [createfile_wfc], al ; 0 
  4322                              <1> 
  4323 0000CAB0 89C1                <1>  	mov	ecx, eax
  4324 0000CAB2 6649                <1> 	dec	cx ; FFFFh  
  4325                              <1> 	; CX = FFFFh -> find first deleted or free entry
  4326                              <1> 	; ESI would be ASCIIZ filename address if the call
  4327                              <1> 	; would not be for first free or deleted dir entry  
  4328 0000CAB4 E8D7E7FFFF          <1> 	call	locate_current_dir_file
  4329 0000CAB9 0F83EE000000        <1> 	jnc	loc_createfile_set_ff_dir_entry
  4330 0000CABF 5E                  <1> 	pop	esi ; *
  4331                              <1> 	 ; ESI = Logical DOS Drv. Description Table Address 
  4332 0000CAC0 83F802              <1> 	cmp	eax, 2
  4333 0000CAC3 7402                <1> 	je	short loc_createfile_add_new_cluster
  4334                              <1> loc_createfile_locate_file_stc_retn:
  4335 0000CAC5 F9                  <1> 	stc
  4336 0000CAC6 C3                  <1> 	retn
  4337                              <1> 
  4338                              <1> loc_createfile_add_new_cluster:
  4339 0000CAC7 803D[958A0100]02    <1> 	cmp	byte [Current_FATType], 2
  4340                              <1> 	;cmp	byte [esi+LD_FATType], 2
  4341 0000CACE 770C                <1> 	ja	short loc_createfile_add_new_cluster_check_fsc
  4342 0000CAD0 803D[948A0100]01    <1> 	cmp	byte [Current_Dir_Level], 1
  4343                              <1> 	;cmp	byte [esi+LD_CDirLevel], 1
  4344 0000CAD7 7303                <1> 	jnb	short loc_createfile_add_new_cluster_check_fsc
  4345                              <1> 	
  4346                              <1> 	;mov	eax, 12
  4347 0000CAD9 B00C                <1> 	mov	al, 12 ; No more files 
  4348                              <1> 
  4349                              <1> loc_createfile_anc_retn:
  4350 0000CADB C3                  <1> 	retn
  4351                              <1> 
  4352                              <1> loc_createfile_add_new_cluster_check_fsc:
  4353 0000CADC 8B0D[DC950100]      <1> 	mov	ecx, [createfile_FreeSectors]
  4354 0000CAE2 0FB605[F5950100]    <1> 	movzx	eax, byte [createfile_SecPerClust]
  4355 0000CAE9 66D1E0              <1> 	shl	ax, 1 ; AX = 2 * AX
  4356 0000CAEC 39C1                <1> 	cmp	ecx, eax
  4357 0000CAEE 7295                <1>         jb	short loc_createfile_insufficient_disk_space
  4358                              <1> 
  4359                              <1> loc_createfile_add_new_subdir_cluster:
  4360 0000CAF0 8B15[C1910100]      <1> 	mov	edx, [DirBuff_Cluster]
  4361 0000CAF6 8915[E8950100]      <1> 	mov	[createfile_LastDirCluster], edx	
  4362                              <1> 
  4363 0000CAFC A1[E4950100]        <1> 	mov	eax, [createfile_FFCluster]
  4364 0000CB01 E846040000          <1> 	call	load_FAT_sub_directory 
  4365 0000CB06 72D3                <1> 	jc	short loc_createfile_anc_retn
  4366                              <1> 
  4367                              <1> pass_createfile_add_new_subdir_cluster:
  4368                              <1> 	;movzx	eax, word [esi+LD_BPB+BytesPerSec]
  4369 0000CB08 0FB705[FC950100]    <1> 	movzx	eax, word [createfile_BytesPerSec] ; 23/03/2016
  4370 0000CB0F F7E1                <1> 	mul	ecx ; ecx = directory buffer sector count
  4371 0000CB11 89C1                <1> 	mov	ecx, eax
  4372 0000CB13 C1E902              <1> 	shr	ecx, 2 ; dword count
  4373 0000CB16 29C0                <1> 	sub	eax, eax ; 0
  4374 0000CB18 F3AB                <1> 	rep	stosd 
  4375                              <1> 	;
  4376 0000CB1A C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  4377 0000CB21 E890EFFFFF          <1> 	call	save_directory_buffer
  4378 0000CB26 72B3                <1> 	jc	short loc_createfile_anc_retn
  4379                              <1> 
  4380                              <1> loc_createfile_save_added_subdir_cluster:
  4381 0000CB28 A1[E8950100]        <1> 	mov	eax, [createfile_LastDirCluster]
  4382 0000CB2D 8B0D[E4950100]      <1> 	mov	ecx, [createfile_FFCluster]
  4383 0000CB33 E858050000          <1> 	call	update_cluster
  4384 0000CB38 7304                <1> 	jnc	short loc_createfile_save_fat_buffer_0
  4385 0000CB3A 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4386 0000CB3C 751A                <1> 	jnz	short loc_createfile_save_fat_buffer_stc_retn
  4387                              <1> 
  4388                              <1> loc_createfile_save_fat_buffer_0:
  4389 0000CB3E A1[E4950100]        <1> 	mov	eax, [createfile_FFCluster]
  4390 0000CB43 A3[E8950100]        <1> 	mov	[createfile_LastDirCluster], eax
  4391 0000CB48 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh ; 28 bit
  4392 0000CB4D E83E050000          <1> 	call	update_cluster
  4393 0000CB52 7306                <1> 	jnc	short loc_createfile_save_fat_buffer_1
  4394 0000CB54 09C0                <1> 	or	eax, eax ; Was it free cluster
  4395 0000CB56 7402                <1> 	jz	short loc_createfile_save_fat_buffer_1
  4396                              <1> 
  4397                              <1> loc_createfile_save_fat_buffer_stc_retn:
  4398 0000CB58 F9                  <1> 	stc
  4399                              <1> loc_createfile_save_fat_buffer_retn:
  4400                              <1> loc_createfile_gffc_2_stc_retn:
  4401 0000CB59 C3                  <1> 	retn
  4402                              <1> 
  4403                              <1> loc_createfile_save_fat_buffer_1:
  4404                              <1> 	; byte [FAT_BuffValidData] = 2 
  4405 0000CB5A E8EE070000          <1> 	call	save_fat_buffer
  4406 0000CB5F 72F8                <1> 	jc	short loc_createfile_save_fat_buffer_retn
  4407                              <1> 
  4408 0000CB61 803D[B2910100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4409 0000CB68 7222                <1> 	jb	short loc_createfile_save_fat_buffer_2
  4410                              <1> 
  4411                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4412 0000CB6A A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4413                              <1> 
  4414 0000CB6F C605[B2910100]00    <1> 	mov	byte [FAT_ClusterCounter], 0 ; 21/03/2016
  4415                              <1> 
  4416 0000CB76 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4417 0000CB7A E863080000          <1> 	call	calculate_fat_freespace
  4418                              <1> 
  4419                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4420                              <1> 	;jnz	short loc_createfile_save_fat_buffer_2
  4421                              <1> 
  4422                              <1> 	; ecx > 0 -> Recalculation is needed
  4423 0000CB7F 09C9                <1> 	or	ecx, ecx 
  4424 0000CB81 7409                <1> 	jz	short loc_createfile_save_fat_buffer_2
  4425                              <1> 
  4426 0000CB83 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  4427 0000CB87 E856080000          <1> 	call	calculate_fat_freespace
  4428                              <1> 
  4429                              <1> loc_createfile_save_fat_buffer_2:
  4430                              <1> 	;call	update_parent_dir_lmdt
  4431                              <1> 
  4432                              <1> loc_createfile_gffc_2:
  4433 0000CB8C E82C040000          <1> 	call	get_first_free_cluster
  4434 0000CB91 72C6                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  4435                              <1> 
  4436 0000CB93 A3[E4950100]        <1> 	mov	[createfile_FFCluster], eax
  4437                              <1> 
  4438 0000CB98 A1[E8950100]        <1> 	mov	eax, [createfile_LastDirCluster]
  4439                              <1> 	
  4440 0000CB9D E8AA030000          <1> 	call	load_FAT_sub_directory 
  4441 0000CBA2 72B5                <1> 	jc	short loc_createfile_gffc_2_stc_retn
  4442                              <1> 
  4443 0000CBA4 BF00000800          <1> 	mov	edi, Directory_Buffer
  4444                              <1> 
  4445 0000CBA9 6629DB              <1> 	sub	bx, bx ; directory entry index/number = 0
  4446                              <1> 
  4447 0000CBAC 56                  <1> 	push	esi ; * ; 23/03/2016
  4448                              <1> 
  4449                              <1> loc_createfile_set_ff_dir_entry:
  4450 0000CBAD 66891D[F6950100]    <1> 	mov	[createfile_DirIndex], bx
  4451                              <1> 
  4452                              <1>         ; EDI = Directory entry address
  4453 0000CBB4 8B35[D8950100]      <1> 	mov	esi, [createfile_Name_Offset]
  4454 0000CBBA A1[E4950100]        <1> 	mov	eax, [createfile_FFCluster]
  4455 0000CBBF A3[EC950100]        <1> 	mov	[createfile_Cluster], eax ; 24/03/2016
  4456 0000CBC4 B5FF                <1> 	mov	ch, 0FFh
  4457 0000CBC6 8A0D[F4950100]      <1>         mov	cl, [createfile_attrib] ; file attributes
  4458                              <1> 	; CH > 0 -> File size is in [EBX]
  4459 0000CBCC BB[E0950100]        <1> 	mov	ebx, createfile_size
  4460                              <1>   
  4461 0000CBD1 E803EEFFFF          <1> 	call	make_directory_entry
  4462                              <1> 	
  4463 0000CBD6 5E                  <1> 	pop	esi ; * ; ESI = Logical Dos Drv Desc. Table address
  4464                              <1> 
  4465 0000CBD7 C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2 
  4466 0000CBDE E8D3EEFFFF          <1> 	call	save_directory_buffer
  4467 0000CBE3 7221                <1> 	jc	short loc_createfile_set_ff_dir_entry_retn
  4468                              <1> 
  4469 0000CBE5 C605[FF950100]01    <1> 	mov	byte [createfile_UpdatePDir], 1 ; 31/03/2016 
  4470                              <1> 
  4471                              <1> loc_createfile_get_set_write_file_cluster:
  4472 0000CBEC A1[E0950100]        <1> 	mov	eax, [createfile_size]
  4473 0000CBF1 09C0                <1> 	or	eax, eax
  4474 0000CBF3 7570                <1> 	jnz	short loc_createfile_get_set_wfc_cont
  4475 0000CBF5 40                  <1> 	inc	eax
  4476                              <1> 	; 23/03/2016
  4477 0000CBF6 0FB61D[F5950100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  4478                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512
  4479 0000CBFD 0FB70D[FC950100]    <1>         movzx   ecx, word [createfile_BytesPerSec] ; 512
  4480 0000CC04 EB7C                <1> 	jmp	loc_createfile_set_cluster_count 
  4481                              <1> 
  4482                              <1> loc_createfile_set_ff_dir_entry_retn:
  4483 0000CC06 C3                  <1> 	retn
  4484                              <1> 
  4485                              <1> loc_createfile_write_fcluster_to_disk:
  4486 0000CC07 034668              <1> 	add	eax, [esi+LD_DATABegin] ; convert to physical address
  4487 0000CC0A BB00000700          <1> 	mov	ebx, Cluster_Buffer
  4488                              <1> 	; ESI = Logical DOS Drv. Desc. Tbl. address
  4489                              <1> 	; EAX = Disk address
  4490                              <1> 	; EBX = Sector Buffer
  4491                              <1> 	; ECX = sectors per cluster
  4492 0000CC0F E83A5F0000          <1> 	call	disk_write
  4493 0000CC14 7211                <1> 	jc	short loc_createfile_dsk_wr_err
  4494                              <1> 
  4495                              <1> loc_createfile_update_fat_cluster:
  4496                              <1> 	; 21/03/2016	
  4497 0000CC16 803D[FE950100]00    <1> 	cmp	byte [createfile_wfc], 0 
  4498 0000CC1D 7712                <1> 	ja	short loc_createfile_update_fat_cluster_n1
  4499                              <1> 
  4500 0000CC1F FE05[FE950100]      <1> 	inc	byte [createfile_wfc] ; 1
  4501 0000CC25 EB24                <1> 	jmp	short loc_createfile_update_fat_cluster_n2
  4502                              <1> 
  4503                              <1> loc_createfile_dsk_wr_err:
  4504                              <1> 	; 16/10/2016 (1Dh -> 18)
  4505                              <1> 	; 23/03/2016
  4506 0000CC27 B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error !
  4507 0000CC2C E9BD000000          <1> 	jmp	loc_createfile_stc_retn
  4508                              <1> 
  4509                              <1> loc_createfile_update_fat_cluster_n1:
  4510 0000CC31 A1[F0950100]        <1> 	mov	eax, [createfile_PCluster]
  4511 0000CC36 8B0D[EC950100]      <1> 	mov	ecx, [createfile_Cluster]
  4512 0000CC3C E84F040000          <1> 	call	update_cluster
  4513 0000CC41 7308                <1> 	jnc	short loc_createfile_update_fat_cluster_n2
  4514 0000CC43 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4515 0000CC45 0F85A3000000        <1> 	jnz	loc_createfile_stc_retn
  4516                              <1> 
  4517                              <1> loc_createfile_update_fat_cluster_n2:
  4518 0000CC4B A1[EC950100]        <1>         mov	eax, [createfile_Cluster]
  4519 0000CC50 B9FFFFFF0F          <1> 	mov	ecx, 0FFFFFFFh
  4520 0000CC55 E836040000          <1> 	call	update_cluster
  4521 0000CC5A 734E                <1> 	jnc	short loc_createfile_save_fat_buffer_3
  4522 0000CC5C 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  4523 0000CC5E 744A                <1> 	jz	short loc_createfile_save_fat_buffer_3
  4524                              <1> 
  4525                              <1> loc_createfile_upd_fat_fcluster_stc_retn:
  4526 0000CC60 E989000000          <1> 	jmp	loc_createfile_stc_retn
  4527                              <1> 
  4528                              <1> loc_createfile_get_set_wfc_cont:
  4529                              <1> 	;movzx	ecx, word [esi+LD_BPB+BytesPerSec] ; 512	
  4530 0000CC65 0FB70D[FC950100]    <1> 	movzx	ecx, word [createfile_BytesPerSec] ; 512
  4531 0000CC6C 01C8                <1> 	add	eax, ecx
  4532 0000CC6E 48                  <1> 	dec	eax  ; add eax, 511
  4533 0000CC6F 29D2                <1> 	sub	edx, edx
  4534 0000CC71 F7F1                <1> 	div	ecx
  4535 0000CC73 0FB61D[F5950100]    <1> 	movzx	ebx, byte [createfile_SecPerClust]
  4536 0000CC7A 01D8                <1> 	add	eax, ebx
  4537 0000CC7C 48                  <1> 	dec	eax  ; add eax, SecPerClust - 1
  4538 0000CC7D 6631D2              <1> 	xor	dx, dx
  4539 0000CC80 F7F3                <1> 	div	ebx
  4540                              <1> 
  4541                              <1> loc_createfile_set_cluster_count:
  4542 0000CC82 A3[F8950100]        <1> 	mov 	[createfile_CCount], eax
  4543                              <1> 	
  4544 0000CC87 BF00000700          <1> 	mov	edi, Cluster_Buffer
  4545 0000CC8C 89C8                <1> 	mov	eax, ecx ; Bytes per Sector
  4546 0000CC8E F7E3                <1> 	mul	ebx ; Sectors per Cluster 
  4547                              <1> 	; EAX = Bytes per Cluster
  4548 0000CC90 89C1                <1> 	mov	ecx, eax
  4549 0000CC92 C1E902              <1> 	shr	ecx, 2 ; dword count
  4550 0000CC95 31C0                <1> 	xor	eax, eax
  4551 0000CC97 F3AB                <1> 	rep	stosd ; clear cluster buffer
  4552                              <1> 
  4553 0000CC99 A1[EC950100]        <1> 	mov	eax, [createfile_Cluster] ; 24/03/2016
  4554                              <1> 
  4555 0000CC9E 89D9                <1> 	mov	ecx, ebx
  4556                              <1> 
  4557                              <1> loc_createfile_get_set_wf_fclust_cont:
  4558 0000CCA0 83E802              <1> 	sub	eax, 2
  4559 0000CCA3 F7E1                <1> 	mul	ecx
  4560                              <1> 	; EAX = Logical DOS disk address (offset)
  4561 0000CCA5 E95DFFFFFF          <1>         jmp     loc_createfile_write_fcluster_to_disk
  4562                              <1> 
  4563                              <1> loc_createfile_save_fat_buffer_3:
  4564                              <1> 	; byte [FAT_BuffValidData] = 2
  4565 0000CCAA E89E060000          <1> 	call	save_fat_buffer
  4566 0000CCAF 723D                <1> 	jc	loc_createfile_stc_retn
  4567                              <1> 
  4568                              <1> 	; 21/03/2016
  4569 0000CCB1 803D[B2910100]01    <1> 	cmp	byte [FAT_ClusterCounter], 1
  4570 0000CCB8 721B                <1> 	jb	short loc_createfile_save_fat_buffer_4
  4571                              <1> 
  4572                              <1> 	; ESI = Logical DOS Drive Description Table address 
  4573 0000CCBA A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4574 0000CCBF 66BB01FF            <1> 	mov	bx, 0FF01h ; add free clusters 
  4575 0000CCC3 E81A070000          <1> 	call	calculate_fat_freespace
  4576                              <1> 
  4577                              <1> 	;inc	eax ; 0FFFFFFFFh -> 0 ; recalculation is needed!
  4578                              <1> 	;jnz	short loc_createfile_save_fat_buffer_4
  4579                              <1> 
  4580                              <1> 	; ecx > 0 -> Recalculation is needed
  4581 0000CCC8 09C9                <1> 	or	ecx, ecx 
  4582 0000CCCA 7409                <1> 	jz	short loc_createfile_save_fat_buffer_4
  4583                              <1> 
  4584 0000CCCC 66BB00FF            <1> 	mov	bx, 0FF00h ; ; recalculate free space
  4585 0000CCD0 E80D070000          <1> 	call	calculate_fat_freespace
  4586                              <1> 
  4587                              <1> loc_createfile_save_fat_buffer_4:
  4588 0000CCD5 FF0D[F8950100]      <1> 	dec	dword [createfile_CCount]
  4589                              <1> 	;jz	short loc_createfile_upd_dir_modif_date_time
  4590 0000CCDB 743F                <1> 	jz	short loc_createfile_stc_retn_cc ; 31/03/2016
  4591                              <1> 
  4592                              <1> loc_createfile_get_set_write_next_cluster:
  4593 0000CCDD E8DB020000          <1> 	call	get_first_free_cluster
  4594 0000CCE2 720A                <1> 	jc	short loc_createfile_stc_retn
  4595                              <1> 
  4596                              <1> loc_createfile_get_set_write_next_cluster_1:
  4597 0000CCE4 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh
  4598 0000CCE7 7213                <1> 	jb	short loc_createfile_get_set_write_next_cluster_2
  4599                              <1> 
  4600                              <1> loc_createfile_wnc_insufficient_disk_space:	
  4601 0000CCE9 B827000000          <1> 	mov	eax, 27h ; Insufficient disk space
  4602                              <1> 
  4603                              <1> loc_createfile_stc_retn:
  4604 0000CCEE 803D[FE950100]01    <1> 	cmp	byte [createfile_wfc], 1
  4605 0000CCF5 7324                <1> 	jnb	short loc_createfile_err_retn
  4606 0000CCF7 C3                  <1> 	retn
  4607                              <1> 
  4608                              <1> loc_createfile_wnc_inv_format_retn:
  4609                              <1> 	;mov	eax, 28
  4610 0000CCF8 B01C                <1> 	mov	al, 28 ; Invalid format
  4611 0000CCFA EBF2                <1> 	jmp	short loc_createfile_stc_retn
  4612                              <1> 	         
  4613                              <1> loc_createfile_get_set_write_next_cluster_2:
  4614 0000CCFC 83F802              <1> 	cmp	eax, 2
  4615 0000CCFF 72F7                <1> 	jb	short loc_createfile_wnc_inv_format_retn
  4616                              <1> 
  4617                              <1> loc_createfile_get_set_write_next_cluster_3:
  4618 0000CD01 8B0D[EC950100]      <1> 	mov	ecx, [createfile_Cluster]
  4619 0000CD07 A3[EC950100]        <1> 	mov	[createfile_Cluster], eax
  4620 0000CD0C 890D[F0950100]      <1> 	mov	[createfile_PCluster], ecx
  4621 0000CD12 0FB60D[F5950100]    <1> 	movzx	ecx, byte [createfile_SecPerClust]
  4622 0000CD19 EB85                <1> 	jmp	short loc_createfile_get_set_wf_fclust_cont
  4623                              <1> 
  4624                              <1> loc_createfile_err_retn:
  4625 0000CD1B F9                  <1> 	stc
  4626                              <1> 
  4627                              <1> ;loc_createfile_upd_dir_modif_date_time:
  4628                              <1> loc_createfile_stc_retn_cc: ; 31/03/2016
  4629 0000CD1C 9C                  <1> 	pushf	; cpu is here for an error return or completion 
  4630 0000CD1D 50                  <1> 	push	eax ; error code if cf = 1
  4631                              <1> 
  4632                              <1> 	;call	update_parent_dir_lmdt
  4633                              <1> 
  4634                              <1> ;loc_createfile_stc_retn_cc:
  4635 0000CD1E A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  4636 0000CD23 09C0                <1> 	or	eax, eax
  4637 0000CD25 741A                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  4638 0000CD27 8A3D[968A0100]      <1> 	mov	bh, [Current_Drv]
  4639 0000CD2D B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  4640                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  4641                              <1> 	; (If EAX value is negative, Free Cluster Count will be decreased)
  4642 0000CD2F E8AE060000          <1>   	call	calculate_fat_freespace
  4643                              <1>         ; ESI = Logical DOS Drive Description Table Address 
  4644                              <1>         ;jc	short loc_createfile_stc_retn_pop_eax_cf
  4645 0000CD34 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  4646 0000CD36 7409                <1> 	jz	short loc_createfile_stc_retn_pop_eax
  4647                              <1> 
  4648                              <1> loc_createfile_stc_retn_recalc_FAT_freespace:
  4649 0000CD38 66BB00FF            <1> 	mov	bx, 0FF00h ; bh = 0FFh -> 
  4650                              <1> 	; ESI = Logical DOS Drv DT Addr
  4651                              <1> 	; BL = 0 -> Recalculate 
  4652 0000CD3C E8A1060000          <1> 	call	calculate_fat_freespace
  4653                              <1> 
  4654                              <1> loc_createfile_stc_retn_pop_eax:
  4655 0000CD41 58                  <1> 	pop	eax
  4656 0000CD42 9D                  <1> 	popf
  4657 0000CD43 7218                <1> 	jc	short loc_createfile_retn
  4658                              <1> 
  4659                              <1> loc_createfile_retn_fcluster:
  4660 0000CD45 A1[E4950100]        <1> 	mov	eax, [createfile_FFCluster]
  4661 0000CD4A BB[E0950100]        <1> 	mov	ebx, createfile_size
  4662                              <1> 	;movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  4663 0000CD4F 0FB60D[F5950100]    <1> 	movzx	ecx, byte [createfile_SecPerClust] ; 23/03/2016
  4664 0000CD56 0FB715[F6950100]    <1> 	movzx	edx, word [createfile_DirIndex]
  4665                              <1> 
  4666                              <1> loc_createfile_retn:
  4667 0000CD5D C3                  <1> 	retn
  4668                              <1> 
  4669                              <1> create_fs_file:
  4670                              <1> 	; temporary (21/03/2016)
  4671 0000CD5E C3                  <1> 	retn
  4672                              <1> 
  4673                              <1> delete_fs_file:
  4674                              <1> 	; temporary (28/02/2016)
  4675 0000CD5F C3                  <1> 	retn
  4676                              <1> 
  4677                              <1> rename_fs_file_or_directory:
  4678 0000CD60 C3                  <1> 	retn
  4679                              <1> 
  4680                              <1> make_fs_directory:
  4681                              <1> 	; temporary (21/02/2016)
  4682 0000CD61 C3                  <1> 	retn
  4683                              <1> 
  4684                              <1> add_new_fs_section:
  4685                              <1> 	; temporary (11/03/2016)
  4686 0000CD62 C3                  <1> 	retn
  4687                              <1> 
  4688                              <1> delete_fs_directory_entry:
  4689                              <1> 	; temporary (11/03/2016)
  4690 0000CD63 C3                  <1> 	retn
  4691                              <1> 
  4692                              <1> csftdf2_read_fs_file_sectors:
  4693                              <1> 	; temporary (19/03/2016)
  4694 0000CD64 C3                  <1> 	retn
  4695                              <1> 
  4696                              <1> csftdf2_write_fs_file_sectors:
  4697                              <1> 	; temporary (19/03/2016)
  4698 0000CD65 C3                  <1> 	retn
  3083                                  %include 'trdosk5.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - File System Procedures : trdosk5s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 23/10/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; DRV_FAT.ASM (21/08/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DRV_FAT.ASM (c) 2005-2011 Erdogan TAN [ 07/07/2009 ] Last Update: 21/08/2011
    14                              <1> 
    15                              <1> get_next_cluster:
    16                              <1> 	; 15/10/2016
    17                              <1> 	; 23/03/2016
    18                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
    19                              <1> 	; 05/07/2011
    20                              <1> 	; 07/07/2009
    21                              <1> 	; 2005
    22                              <1> 	; INPUT ->
    23                              <1> 	;	EAX = Cluster Number (32 bit)
    24                              <1> 	;	ESI = Logical DOS Drive Parameters Table
    25                              <1> 	; OUTPUT ->
    26                              <1> 	;	cf = 0 -> No Error, EAX valid
    27                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
    28                              <1> 	;	cf = 1 & EAX > 0 -> Error
    29                              <1> 	;	ECX = Current/Previous cluster (if CF = 0)
    30                              <1> 	;	EAX = Next Cluster Number (32 bit)
    31                              <1> 	;
    32                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
    33                              <1> 
    34 0000CD66 A3[A6910100]        <1> 	mov	[FAT_CurrentCluster], eax
    35                              <1> check_next_cluster_fat_type:
    36 0000CD6B 29D2                <1> 	sub	edx, edx ; 0
    37 0000CD6D 807E0302            <1>         cmp     byte [esi+LD_FATType], 2
    38 0000CD71 7250                <1> 	jb	short get_FAT12_next_cluster
    39 0000CD73 0F87AF000000        <1>         ja      get_FAT32_next_cluster
    40                              <1> get_FAT16_next_cluster:
    41 0000CD79 BB00030000          <1> 	mov	ebx, 300h ;768
    42 0000CD7E F7F3                <1> 	div	ebx
    43                              <1> 	; EAX = Count of 3 FAT sectors
    44                              <1> 	; EDX = Cluster Offset (< 768)
    45 0000CD80 66D1E2              <1> 	shl	dx, 1 ; Multiply by 2
    46 0000CD83 89D3                <1> 	mov	ebx, edx ; Byte Offset
    47 0000CD85 81C3001C0900        <1> 	add	ebx, FAT_Buffer
    48 0000CD8B 66BA0300            <1> 	mov	dx, 3
    49 0000CD8F F7E2                <1> 	mul	edx  
    50                              <1> 	; EAX = FAT Sector (<= 256)
    51                              <1> 	; EDX = 0
    52 0000CD91 8A0E                <1> 	mov	cl, [esi+LD_Name]
    53 0000CD93 803D[AA910100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
    54 0000CD9A 0F86CC000000        <1>         jna     load_FAT_sectors0
    55 0000CDA0 3A0D[AB910100]      <1> 	cmp	cl, [FAT_BuffDrvName]
    56 0000CDA6 0F85C0000000        <1>         jne     load_FAT_sectors0
    57 0000CDAC 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
    58 0000CDB2 0F85BA000000        <1>         jne     load_FAT_sectors1
    59                              <1> 	;movzx	eax, word [ebx]
    60 0000CDB8 668B03              <1> 	mov	ax, [ebx]
    61                              <1> 	; 01/02/2016
    62                              <1> 	; DRV_FAT.ASM (21/08/2011) had a FATal bug here !
    63                              <1> 	; (cmp ah, 0Fh) ! (ax >= FF7h)
    64                              <1> 	; (how can i do a such mistake!?)
    65                              <1> 	;cmp	al, 0F7h
    66                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
    67                              <1> 	;cmp	ah, 0FFh
    68                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
    69 0000CDBB 6683F8F7            <1> 	cmp	ax, 0FFF7h
    70 0000CDBF 725A                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
    71                              <1> 	; ax >= FFF7h (cluster 0002h to FFF6h is valid, in use)
    72 0000CDC1 EB56                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
    73                              <1> 
    74                              <1> get_FAT12_next_cluster:
    75 0000CDC3 BB00040000          <1> 	mov	ebx, 400h ;1024
    76 0000CDC8 F7F3                <1> 	div	ebx
    77                              <1> 	; EAX = Count of 3 FAT sectors
    78                              <1> 	; EDX = Cluster Offset (< 1024)
    79 0000CDCA 6650                <1> 	push	ax
    80 0000CDCC 66B80300            <1> 	mov	ax, 3	
    81 0000CDD0 66F7E2              <1> 	mul	dx    	; Multiply by 3
    82 0000CDD3 66D1E8              <1> 	shr	ax, 1	; Divide by 2
    83 0000CDD6 6689C3              <1>         mov	bx, ax 	; Byte Offset
    84 0000CDD9 81C3001C0900        <1> 	add	ebx, FAT_Buffer
    85 0000CDDF 6658                <1> 	pop	ax
    86 0000CDE1 66BA0300            <1> 	mov	dx, 3
    87 0000CDE5 F7E2                <1> 	mul	edx 
    88                              <1> 	; EAX = FAT Sector (<= 12)
    89                              <1> 	; EDX = 0
    90 0000CDE7 8A0E                <1> 	mov	cl, [esi+LD_Name]
    91 0000CDE9 803D[AA910100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
    92 0000CDF0 767A                <1> 	jna	short load_FAT_sectors0
    93 0000CDF2 3A0D[AB910100]      <1> 	cmp	cl, [FAT_BuffDrvName]
    94 0000CDF8 7572                <1> 	jne	short load_FAT_sectors0
    95 0000CDFA 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
    96 0000CE00 7570                <1> 	jne	short load_FAT_sectors1
    97 0000CE02 A1[A6910100]        <1> 	mov	eax, [FAT_CurrentCluster]
    98 0000CE07 66D1E8              <1> 	shr	ax, 1
    99                              <1> 	;movzx	eax, word [ebx]
   100 0000CE0A 668B03              <1> 	mov	ax, [ebx]
   101 0000CE0D 7314                <1> 	jnc	short get_FAT12_nc_even
   102 0000CE0F 66C1E804            <1> 	shr	ax, 4
   103                              <1> loc_gnc_fat12_eoc_check:
   104                              <1> 	;cmp	al, 0F7h
   105                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
   106                              <1> 	;cmp	ah, 0Fh
   107                              <1> 	;jb	short loc_pass_gnc_FAT16_eoc_check
   108 0000CE13 663DF70F            <1> 	cmp	ax, 0FF7h
   109 0000CE17 7202                <1> 	jb	short loc_pass_gnc_FAT16_eoc_check
   110                              <1> 	; ax >= FF7h (cluster 0002h to FF6h is valid, in use)
   111                              <1> 
   112                              <1> loc_pass_gnc_FAT16_eoc_check_xor_eax:
   113 0000CE19 31C0                <1> 	xor	eax, eax ; 0
   114                              <1> loc_pass_gnc_FAT16_eoc_check:
   115                              <1> loc_pass_gnc_FAT32_eoc_check:
   116 0000CE1B 8B0D[A6910100]      <1> 	mov	ecx, [FAT_CurrentCluster]
   117 0000CE21 F5                  <1> 	cmc
   118 0000CE22 C3                  <1> 	retn
   119                              <1> 
   120                              <1> get_FAT12_nc_even:
   121 0000CE23 80E40F              <1> 	and	ah, 0Fh
   122 0000CE26 EBEB                <1> 	jmp	short loc_gnc_fat12_eoc_check
   123                              <1> 
   124                              <1> get_FAT32_next_cluster:
   125 0000CE28 BB80010000          <1> 	mov	ebx, 180h ;384
   126 0000CE2D F7F3                <1> 	div	ebx
   127                              <1> 	; EAX = Count of 3 FAT sectors
   128                              <1> 	; EDX = Cluster Offset (< 384)
   129 0000CE2F 66C1E202            <1> 	shl	dx, 2	; Multiply by 4
   130 0000CE33 89D3                <1> 	mov	ebx, edx ; Byte Offset
   131 0000CE35 81C3001C0900        <1> 	add	ebx, FAT_Buffer
   132 0000CE3B 66BA0300            <1> 	mov	dx, 3
   133 0000CE3F F7E2                <1> 	mul	edx	
   134                              <1>         ; EAX = FAT Sector (<= 2097152) ; (FFFFFF7h * 4) / 512
   135                              <1> 	; 	for 32KB cluster size:
   136                              <1> 	;	EAX <= 1024 = (4GB / 32KB) * 4) / 512 	
   137                              <1> 	; EDX = 0
   138 0000CE41 8A0E                <1> 	mov	cl, [esi+LD_Name]
   139 0000CE43 803D[AA910100]00    <1> 	cmp	byte [FAT_BuffValidData], 0
   140 0000CE4A 7620                <1> 	jna	short load_FAT_sectors0
   141 0000CE4C 3A0D[AB910100]      <1> 	cmp	cl, [FAT_BuffDrvName]
   142 0000CE52 7518                <1> 	jne	short load_FAT_sectors0
   143 0000CE54 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector] ; 0, 3, 6, 9 ...
   144 0000CE5A 7516                <1> 	jne	short load_FAT_sectors1
   145 0000CE5C 8B03                <1> 	mov	eax, [ebx]
   146 0000CE5E 25FFFFFF0F          <1>  	and	eax, 0FFFFFFFh ; 28 bit Cluster
   147 0000CE63 3DF7FFFF0F          <1> 	cmp	eax, 0FFFFFF7h
   148 0000CE68 72B1                <1> 	jb	short loc_pass_gnc_FAT32_eoc_check
   149                              <1> 	; eax >= FFFFFF7h (cluster 0002h to FFFFFF6h is valid)
   150 0000CE6A EBAD                <1> 	jmp	short loc_pass_gnc_FAT16_eoc_check_xor_eax
   151                              <1> 
   152                              <1> load_FAT_sectors0:
   153 0000CE6C 880D[AB910100]      <1> 	mov	[FAT_BuffDrvName], cl
   154                              <1> load_FAT_sectors1:
   155 0000CE72 A3[AE910100]        <1> 	mov	[FAT_BuffSector], eax
   156 0000CE77 89C3                <1> 	mov	ebx, eax
   157 0000CE79 034660              <1>         add     eax, [esi+LD_FATBegin]
   158 0000CE7C 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
   159 0000CE80 7706                <1>         ja      short load_FAT_sectors3
   160 0000CE82 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+BPB_FATSz16]
   161 0000CE86 EB03                <1> 	jmp	short load_FAT_sectors4
   162                              <1> load_FAT_sectors3:
   163 0000CE88 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+BPB_FATSz32]
   164                              <1> load_FAT_sectors4:
   165 0000CE8B 29D9                <1> 	sub	ecx, ebx ; [FAT_BuffSector]
   166 0000CE8D 83F903              <1>         cmp     ecx, 3
   167 0000CE90 7605                <1>         jna     short load_FAT_sectors5
   168 0000CE92 B903000000          <1> 	mov	ecx, 3
   169                              <1> load_FAT_sectors5:
   170 0000CE97 BB001C0900          <1> 	mov	ebx, FAT_Buffer
   171 0000CE9C E8BC5C0000          <1> 	call	disk_read
   172 0000CEA1 730D                <1> 	jnc	short load_FAT_sectors_ok
   173                              <1> 	; 15/10/2016 (15h -> 17)
   174                              <1> 	; 23/03/2016 (15h)
   175 0000CEA3 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
   176 0000CEA8 C605[AA910100]00    <1> 	mov	byte [FAT_BuffValidData], 0
   177 0000CEAF C3                  <1> 	retn
   178                              <1> load_FAT_sectors_ok:
   179 0000CEB0 C605[AA910100]01    <1> 	mov	byte [FAT_BuffValidData], 1
   180 0000CEB7 A1[A6910100]        <1> 	mov	eax, [FAT_CurrentCluster]
   181 0000CEBC E9AAFEFFFF          <1>         jmp     check_next_cluster_fat_type
   182                              <1> 
   183                              <1> load_FAT_root_directory:
   184                              <1> 	; 23/10/2016
   185                              <1> 	; 15/10/2016
   186                              <1> 	; 07/02/2016
   187                              <1> 	; 02/02/2016
   188                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
   189                              <1> 	; 21/05/2011
   190                              <1> 	; 22/08/2009
   191                              <1> 	;
   192                              <1> 	; INPUT ->
   193                              <1> 	;	ESI = Logical DOS Drive Description Table
   194                              <1> 	; OUTPUT ->
   195                              <1> 	;	cf = 1 -> Root directory could not be loaded
   196                              <1> 	;	    EAX > 0 -> Error number
   197                              <1> 	;	cf = 0 -> EAX = 0
   198                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   199                              <1> 	;	EBX = Directory buffer address
   200                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   201                              <1> 	;
   202                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   203                              <1> 
   204                              <1> 	; NOTE: Only for FAT12 and FAT16 file systems !
   205                              <1> 	; (FAT32 fs root dir must be loaded as sub directory)
   206                              <1> 
   207 0000CEC1 8A1E                <1> 	mov	bl, [esi+LD_Name]
   208 0000CEC3 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   209                              <1> 
   210                              <1> 	;mov	[DirBuff_DRV], bl
   211                              <1> 	;mov	[DirBuff_FATType], bh
   212 0000CEC6 66891D[BA910100]    <1> 	mov	[DirBuff_DRV], bx
   213                              <1> 	
   214                              <1> 	;cmp	bh, 2
   215                              <1> 	;ja	short load_FAT32_root_dir0 ; FAT32 root dir
   216                              <1> 
   217                              <1> load_FAT_root_dir0: ; 23/10/2016
   218 0000CECD 0FB75617            <1> 	movzx	edx, word [esi+LD_BPB+RootDirEnts]
   219                              <1> 
   220                              <1> 	;or	dx, dx ; 0 for FAT32 file systems
   221                              <1> 	;jz	short load_FAT32_root_dir0 ; FAT32 root dir
   222                              <1> 
   223 0000CED1 6681FA0002          <1> 	cmp	dx, 512 ; Number of Root Dir Entries
   224 0000CED6 7414                <1> 	je	short lrd_mov_ecx_32
   225 0000CED8 89D0                <1> 	mov	eax, edx
   226                              <1> 	; 23/10/2016
   227 0000CEDA 89C1                <1> 	mov	ecx, eax
   228 0000CEDC 6683C10F            <1> 	add	cx, 15 ; round up 
   229 0000CEE0 66C1E904            <1> 	shr	cx, 4  ; 16 entries per sector (512/32)
   230                              <1> 	; ecx = Root directory size in sectors
   231 0000CEE4 66C1E005            <1> 	shl	ax, 5 ; Root directory size in bytes
   232 0000CEE8 664A                <1> 	dec	dx    ; Last entry number of root dir
   233                              <1> 	; cx = Dir Buffer sector count             
   234 0000CEEA EB0B                <1> 	jmp	short lrd_check_dir_buffer
   235                              <1> 
   236                              <1> lrd_mov_ecx_32:
   237 0000CEEC B920000000          <1> 	mov	ecx, 32
   238 0000CEF1 664A                <1> 	dec	dx ; 511
   239 0000CEF3 66B80040            <1> 	mov	ax, 32*512 
   240                              <1>  
   241                              <1> lrd_check_dir_buffer:
   242 0000CEF7 29DB                <1> 	sub	ebx, ebx ; 0
   243 0000CEF9 881D[BC910100]      <1> 	mov	[DirBuff_ValidData], bl ; 0
   244 0000CEFF 668915[BF910100]    <1> 	mov	[DirBuff_LastEntry], dx
   245 0000CF06 891D[C1910100]      <1> 	mov	[DirBuff_Cluster], ebx ; 0
   246 0000CF0C 66A3[C5910100]      <1> 	mov	[DirBuffer_Size], ax
   247                              <1> 
   248 0000CF12 8B4664              <1> 	mov	eax, [esi+LD_ROOTBegin]
   249                              <1> read_directory:
   250 0000CF15 BB00000800          <1> 	mov	ebx, Directory_Buffer
   251 0000CF1A 51                  <1> 	push	ecx ; Directory buffer sector count
   252 0000CF1B 53                  <1> 	push	ebx
   253 0000CF1C E83C5C0000          <1> 	call	disk_read
   254 0000CF21 5B                  <1> 	pop	ebx
   255 0000CF22 720B                <1> 	jc	short load_DirBuff_error
   256                              <1> 
   257                              <1> validate_DirBuff_and_return:
   258 0000CF24 59                  <1> 	pop	ecx ; Number of loaded sectors
   259 0000CF25 C605[BC910100]01    <1> 	mov	byte [DirBuff_ValidData], 1
   260 0000CF2C 31C0                <1> 	xor	eax, eax ; 0 = no error
   261 0000CF2E C3                  <1> 	retn
   262                              <1> 
   263                              <1> load_DirBuff_error:
   264 0000CF2F 89C8                <1> 	mov	eax, ecx ; remaining sectors
   265 0000CF31 59                  <1> 	pop	ecx ; sector count
   266 0000CF32 29C1                <1> 	sub	ecx, eax ; Number of loaded sectors
   267                              <1> 	; 15/10/2016 (15h -> 17)
   268 0000CF34 B811000000          <1> 	mov	eax, 17 ; DRV NOT READY OR READ ERROR !
   269 0000CF39 F9                  <1> 	stc
   270 0000CF3A C3                  <1>         retn
   271                              <1> 
   272                              <1> load_FAT32_root_directory:
   273                              <1> 	; 02/02/2016 (TRDOS 386 =  TRDOS v2.0)
   274                              <1> 	;
   275                              <1> 	; INPUT ->
   276                              <1> 	;	ESI = Logical DOS Drive Description Table
   277                              <1> 	; OUTPUT ->
   278                              <1> 	;	cf = 1 -> Root directory could not be loaded
   279                              <1> 	;	    EAX > 0 -> Error number
   280                              <1> 	;	cf = 0 -> EAX = 0
   281                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   282                              <1> 	;	EBX = Directory buffer address
   283                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   284                              <1> 	;
   285                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   286                              <1> 
   287                              <1> 
   288 0000CF3B 8A1E                <1> 	mov	bl, [esi+LD_Name]
   289 0000CF3D 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   290                              <1> 
   291                              <1> 	;mov	[DirBuff_DRV], bl
   292                              <1> 	;mov	[DirBuff_FATType], bh
   293 0000CF40 66891D[BA910100]    <1> 	mov	[DirBuff_DRV], bx
   294                              <1> 
   295                              <1> load_FAT32_root_dir0:
   296 0000CF47 8B4632              <1> 	mov	eax, [esi+LD_BPB+FAT32_RootFClust]
   297 0000CF4A EB0C                <1> 	jmp	short load_FAT_sub_dir0
   298                              <1> 	
   299                              <1> load_FAT_sub_directory:
   300                              <1> 	; 01/02/2016 (TRDOS 386 =  TRDOS v2.0)
   301                              <1> 	; 05/07/2011
   302                              <1> 	; 23/08/2009
   303                              <1> 	;
   304                              <1> 	; INPUT ->
   305                              <1> 	;	ESI = Logical DOS Drive Description Table
   306                              <1> 	;	EAX = Cluster Number
   307                              <1> 	; OUTPUT ->
   308                              <1> 	;	cf = 1 -> Sub directory could not be loaded
   309                              <1> 	;	    EAX > 0 -> Error number
   310                              <1> 	;	cf = 0 -> EAX = 0
   311                              <1> 	;	ECX = Directory buffer size in sectors (CL)
   312                              <1> 	;	EBX = Directory buffer address
   313                              <1> 	;
   314                              <1> 	; 	NOTE: DirBuffer_Size is in bytes ! (word)
   315                              <1> 	;
   316                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   317                              <1> 
   318 0000CF4C 8A1E                <1> 	mov	bl, [esi+LD_Name]
   319 0000CF4E 8A7E03              <1> 	mov	bh, [esi+LD_FATType]
   320                              <1> 
   321                              <1> 	;mov	[DirBuff_DRV], bl
   322                              <1> 	;mov	[DirBuff_FATType], bh
   323 0000CF51 66891D[BA910100]    <1> 	mov	[DirBuff_DRV], bx
   324                              <1> 
   325                              <1> load_FAT_sub_dir0:
   326 0000CF58 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
   327                              <1> 
   328 0000CF5C 882D[BC910100]      <1> 	mov	[DirBuff_ValidData], ch ; 0
   329 0000CF62 A3[C1910100]        <1> 	mov	[DirBuff_Cluster], eax
   330                              <1> 
   331 0000CF67 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
   332 0000CF6B F7E1                <1> 	mul	ecx
   333 0000CF6D C1E805              <1> 	shr	eax, 5 ; directory entry count (dir size / 32)
   334 0000CF70 6648                <1> 	dec	ax ; last entry
   335 0000CF72 66A3[BF910100]      <1> 	mov	[DirBuff_LastEntry], ax
   336                              <1> 
   337 0000CF78 A1[C1910100]        <1> 	mov	eax, [DirBuff_Cluster]
   338 0000CF7D 83E802              <1> 	sub	eax, 2
   339 0000CF80 F7E1                <1> 	mul	ecx
   340 0000CF82 034668              <1> 	add	eax, [esi+LD_DATABegin]
   341                              <1> 	; ecx = sector per cluster (dir buffer size = 32 sectors)
   342 0000CF85 EB8E                <1> 	jmp	short read_directory
   343                              <1> 
   344                              <1> ; DRV_FS.ASM
   345                              <1> 
   346                              <1> load_current_FS_directory:
   347 0000CF87 C3                  <1> 	retn
   348                              <1> load_FS_root_directory:
   349 0000CF88 C3                  <1> 	retn
   350                              <1> load_FS_sub_directory:
   351 0000CF89 C3                  <1> 	retn
   352                              <1> 
   353                              <1> read_cluster:
   354                              <1> 	; 15/10/2016
   355                              <1> 	; 18/03/2016
   356                              <1> 	; 16/03/2016
   357                              <1> 	; 17/02/2016
   358                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
   359                              <1> 	;
   360                              <1> 	; INPUT ->
   361                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
   362                              <1> 	;	ESI = Logical DOS Drive Description Table address
   363                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
   364                              <1> 	;	Only for SINGLIX FS:
   365                              <1> 	;	EDX = File Number (The 1st FDT address) 
   366                              <1> 	; OUTPUT ->
   367                              <1> 	;	cf = 1 -> Cluster can not be loaded at the buffer
   368                              <1> 	;	    EAX > 0 -> Error number
   369                              <1> 	;	cf = 0 -> Cluster has been loaded at the buffer
   370                              <1> 	;
   371                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
   372                              <1> 	
   373 0000CF8A 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
   374                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
   375                              <1> 
   376                              <1> read_file_sectors: ; 16/03/2016
   377 0000CF8E 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
   378 0000CF92 761C                <1> 	jna	short read_fs_cluster
   379                              <1> 
   380                              <1> read_fat_file_sectors: ; 18/03/2016
   381 0000CF94 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
   382 0000CF97 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
   383 0000CF9B F7E2                <1> 	mul	edx
   384 0000CF9D 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
   385                              <1> 
   386                              <1> 	; EAX = Disk sector address
   387                              <1> 	; ECX = Sector count
   388                              <1> 	; EBX = Buffer address
   389                              <1> 	; (EDX = 0)
   390                              <1> 	; ESI = Logical DOS drive description table address	
   391                              <1> 
   392 0000CFA0 E8B85B0000          <1> 	call	disk_read
   393 0000CFA5 7306                <1> 	jnc	short rclust_retn
   394                              <1> 	
   395                              <1> 	; 15/10/2016 (15h -> 17)
   396 0000CFA7 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
   397 0000CFAC C3                  <1> 	retn
   398                              <1> 
   399                              <1> rclust_retn:
   400 0000CFAD 29C0                <1> 	sub	eax, eax ; 0
   401 0000CFAF C3                  <1> 	retn
   402                              <1> 
   403                              <1> read_fs_cluster:
   404                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
   405                              <1> 	; Singlix FS
   406                              <1> 	
   407                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
   408                              <1> 	
   409                              <1> 	; EDX = File number is the first File Descriptor Table address 
   410                              <1> 	;	of the file. (Absolute address of the FDT).
   411                              <1> 	
   412                              <1> 	; eax = sector index (0 for the first sector)
   413                              <1> 	; edx = FDT0 address
   414                              <1> 		; 64 KB buffer = 128 sectors (limit) 
   415 0000CFB0 B980000000          <1> 	mov	ecx, 128 ; maximum count of sectors (before eof) 
   416 0000CFB5 E801000000          <1> 	call	read_fs_sectors
   417 0000CFBA C3                  <1> 	retn
   418                              <1> 
   419                              <1> read_fs_sectors:
   420                              <1> 	; 15/02/2016 (TRDOS 386 =  TRDOS v2.0)
   421 0000CFBB F9                  <1> 	stc
   422 0000CFBC C3                  <1> 	retn
   423                              <1> 
   424                              <1> get_first_free_cluster:
   425                              <1> 	; 02/03/2016
   426                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
   427                              <1> 	; 26/10/2010 (DRV_FAT.ASM, 'proc_get_first_free_cluster')
   428                              <1> 	; 10/07/2010
   429                              <1> 	; INPUT ->
   430                              <1> 	;	ESI = Logical DOS Drive Description Table address
   431                              <1> 	; OUTPUT ->
   432                              <1> 	;	cf = 1 -> Error code in AL (EAX)
   433                              <1> 	;	cf = 0 -> 
   434                              <1> 	;	  EAX = Cluster number 
   435                              <1> 	;	  If EAX = FFFFFFFFh -> no free space
   436                              <1> 	;	If the drive has FAT32 fs:
   437                              <1> 	;	  EBX = FAT32 FSI sector buffer address (if > 0)
   438                              <1> 
   439 0000CFBD 8B4678              <1> 	mov	eax, [esi+LD_Clusters]
   440 0000CFC0 40                  <1> 	inc	eax ; add eax, 1
   441 0000CFC1 A3[44940100]        <1> 	mov	[gffc_last_free_cluster], eax
   442                              <1> 
   443 0000CFC6 31DB                <1> 	xor	ebx, ebx ; 0 ; 02/03/2016
   444                              <1> 
   445 0000CFC8 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
   446 0000CFCC 760E                <1> 	jna	short loc_gffc_get_first_fat_free_cluster0
   447                              <1> 
   448                              <1> loc_gffc_get_first_fat32_free_cluster:
   449                              <1> 	; 02/03/2016
   450 0000CFCE E844060000          <1> 	call	get_fat32_fsinfo_sector_parms
   451 0000CFD3 7207                <1> 	jc	short loc_gffc_get_first_fat_free_cluster0 
   452                              <1> 
   453                              <1> loc_gffc_check_fsinfo_parms:
   454                              <1> 	;;mov	ebx, DOSBootSectorBuff
   455                              <1> 	;cmp	dword [ebx], 41615252h
   456                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
   457                              <1> 	;cmp	dword [ebx+484], 61417272h
   458                              <1> 	;jne	short loc_gffc_fat32_fsinfo_err
   459                              <1> 	;mov	eax, [ebx+492] ; FSI_Next_Free
   460                              <1> 	;EAX = First free cluster 
   461                              <1> 	;(from FAT32 FSInfo sector)
   462 0000CFD5 89D0                <1> 	mov	eax, edx ; FSI_Next_Free (First Free Cluster)
   463 0000CFD7 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; invalid (unknown) !
   464 0000CFDA 7205                <1> 	jb	short loc_gffc_get_first_fat_free_cluster1
   465                              <1> 
   466                              <1> 	; Start from the 1st cluster of the FAT(32) file system
   467                              <1> loc_gffc_get_first_fat_free_cluster0:
   468 0000CFDC B802000000          <1> 	mov	eax, 2
   469                              <1> 	;xor	edx, edx
   470                              <1> 
   471                              <1> loc_gffc_get_first_fat_free_cluster1:
   472 0000CFE1 53                  <1> 	push	ebx ; 02/03/2016 
   473                              <1> 
   474                              <1> loc_gffc_get_first_fat_free_cluster2:   
   475 0000CFE2 A3[40940100]        <1> 	mov	[gffc_first_free_cluster], eax
   476 0000CFE7 A3[3C940100]        <1> 	mov	[gffc_next_free_cluster], eax
   477                              <1> 
   478                              <1> 	; EBX = FAT32 FSINFO sector buffer address
   479                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
   480                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
   481                              <1> 
   482                              <1> loc_gffc_get_first_fat_free_cluster3:
   483 0000CFEC E875FDFFFF          <1> 	call	get_next_cluster
   484 0000CFF1 7307                <1> 	jnc	short loc_gffc_get_first_fat_free_cluster4
   485 0000CFF3 09C0                <1> 	or	eax, eax
   486 0000CFF5 740B                <1> 	jz	short loc_gffc_first_free_fat_cluster_next
   487 0000CFF7 5B                  <1> 	pop	ebx ; 02/03/2016
   488 0000CFF8 F5                  <1> 	cmc 	; stc
   489 0000CFF9 C3                  <1> 	retn
   490                              <1> 
   491                              <1> loc_gffc_get_first_fat_free_cluster4:
   492 0000CFFA 21C0                <1> 	and	eax, eax ; next cluster value
   493 0000CFFC 7504                <1> 	jnz	short loc_gffc_first_free_fat_cluster_next
   494 0000CFFE 89C8                <1> 	mov	eax, ecx ; current (previous cluster) value
   495 0000D000 EB22                <1> 	jmp	short loc_gffc_check_for_set
   496                              <1>  
   497                              <1> loc_gffc_first_free_fat_cluster_next:
   498 0000D002 A1[3C940100]        <1> 	mov	eax, [gffc_next_free_cluster]
   499 0000D007 3B05[44940100]      <1> 	cmp	eax, [gffc_last_free_cluster]
   500 0000D00D 7308                <1> 	jnb	short retn_stc_from_get_first_free_cluster
   501                              <1> pass_gffc_last_cluster_eax_check:
   502 0000D00F 40                  <1> 	inc	eax ; add eax, 1
   503 0000D010 A3[3C940100]        <1> 	mov	[gffc_next_free_cluster], eax
   504 0000D015 EBD5                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster3
   505                              <1> 
   506                              <1> retn_stc_from_get_first_free_cluster:
   507 0000D017 A1[40940100]        <1> 	mov	eax, [gffc_first_free_cluster]
   508 0000D01C 83F802              <1> 	cmp	eax, 2
   509 0000D01F 7709                <1> 	ja	short loc_gffc_check_previous_clusters
   510 0000D021 29C0                <1> 	sub	eax, eax
   511 0000D023 48                  <1> 	dec	eax ; FFFFFFFFh
   512                              <1> 
   513                              <1> loc_gffc_check_for_set:
   514                              <1> 	; 02/03/2016
   515 0000D024 5B                  <1> 	pop	ebx
   516                              <1> 
   517                              <1> 	; EBX = FAT32 FSINFO sector buffer address
   518                              <1> 	; (EBX = 0, if the drive has not got FAT32 fs or
   519                              <1> 	; FAT32 FSINFO sector buffer is invalid.)
   520                              <1> 
   521 0000D025 09DB                <1> 	or	ebx, ebx
   522 0000D027 750E                <1> 	jnz	short loc_gffc_set_ffree_fat32_cluster
   523                              <1> 
   524                              <1> 	;cmp	byte [esi+LD_FATType], 3
   525                              <1> 	;jnb	short loc_gffc_set_ffree_fat32_cluster
   526                              <1> 
   527                              <1> 	;xor	ebx, ebx ; 0
   528                              <1> 
   529                              <1> loc_gffc_retn:
   530 0000D029 C3                  <1> 	retn
   531                              <1> 
   532                              <1> loc_gffc_check_previous_clusters:
   533 0000D02A 48                  <1> 	dec	eax ; sub eax, 1
   534 0000D02B A3[44940100]        <1> 	mov	[gffc_last_free_cluster], eax 
   535 0000D030 B802000000          <1> 	mov	eax, 2
   536                              <1> 	;xor	edx, edx
   537 0000D035 EBAB                <1> 	jmp	short loc_gffc_get_first_fat_free_cluster2
   538                              <1> 
   539                              <1> loc_gffc_set_ffree_fat32_cluster:
   540                              <1> 	;call	set_first_free_cluster
   541                              <1> 	;retn
   542                              <1> 	;jmp	short set_first_free_cluster	
   543                              <1> 
   544                              <1> set_first_free_cluster:
   545                              <1> 	; 15/10/2016
   546                              <1> 	; 23/03/2016
   547                              <1> 	; 02/03/2016
   548                              <1> 	; 29/02/2016
   549                              <1> 	; 26/02/2016
   550                              <1> 	; 21/02/2016 (TRDOS 386 =  TRDOS v2.0)
   551                              <1> 	; 21/08/2011 (DRV_FAT.ASM, 'proc_set_first_free_cluster')
   552                              <1> 	; 11/07/2010
   553                              <1> 	; INPUT -> 
   554                              <1> 	;	ESI = Logical DOS Drive Description Table address
   555                              <1> 	;	EAX = First free cluster
   556                              <1> 	;	EBX = FSINFO sector buffer address
   557                              <1> 	;  	;;If EBX > 0, it is FSINFO sector buffer address
   558                              <1> 	;	;;EBX = 0, if FSINFO sector is not loaded
   559                              <1> 	; OUTPUT->
   560                              <1> 	;	ESI = Logical DOS Drive Description Table address
   561                              <1> 	;  	If EBX > 0, it is FSINFO sector buffer address
   562                              <1> 	;	EBX = 0, if FSINFO sector could not be loaded
   563                              <1> 	; 	CF = 1 -> Error code in AL (EAX)
   564                              <1> 	;	CF = 0 -> first free cluster is successfully updated 
   565                              <1> 
   566                              <1> 	;cmp	byte [esi+LD_FATType], 3
   567                              <1> 	;jb	short loc_sffc_invalid_drive
   568                              <1> 
   569                              <1> 	; Save First Free Cluster value for 'update_cluster'
   570 0000D037 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; First free Cluster	
   571                              <1> 
   572                              <1> 	;or	ebx, ebx
   573                              <1> 	;jnz	short loc_sffc_read_fsinfo_sector
   574                              <1> 
   575 0000D03A 813B52526141        <1> 	cmp     dword [ebx], 41615252h
   576 0000D040 7540                <1> 	jne	short loc_sffc_read_fsinfo_sector
   577 0000D042 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
   577 0000D04B 61                  <1>
   578 0000D04C 7534                <1> 	jne	short loc_sffc_read_fsinfo_sector
   579                              <1> 
   580 0000D04E 3B83EC010000        <1> 	cmp	eax, [ebx+492]  ; FSI_Next_Free
   581 0000D054 741F                <1> 	je	short loc_sffc_retn
   582                              <1> 
   583                              <1> loc_sffc_write_fsinfo_sector:
   584                              <1> 	; EBX = FSINFO sector buffer
   585                              <1> 	; [CFS_FAT32FSINFOSEC] is set in 'get_fat32_fsinfo_sector_parms'
   586 0000D056 8983EC010000        <1> 	mov	[ebx+492], eax
   587 0000D05C A1[54940100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC] 
   588 0000D061 B901000000          <1> 	mov	ecx, 1
   589 0000D066 53                  <1> 	push	ebx
   590 0000D067 E8E25A0000          <1> 	call	disk_write
   591 0000D06C 7208                <1> 	jc      short loc_sffc_read_fsinfo_sector_err1
   592 0000D06E 5B                  <1> 	pop	ebx
   593                              <1> 
   594 0000D06F 8B83EC010000        <1> 	mov	eax, [ebx+492] ; First (Next) Free Cluster
   595                              <1> 
   596                              <1> loc_sffc_retn:
   597 0000D075 C3                  <1> 	retn
   598                              <1> 
   599                              <1> ;loc_sffc_invalid_drive:
   600                              <1> ;	mov	eax, 0Fh ; MSDOS Error : Invalid drive
   601                              <1> ;	push	edx
   602                              <1> 
   603                              <1> loc_sffc_read_fsinfo_sector_err1:
   604 0000D076 BB00000000          <1> 	mov	ebx, 0
   605                              <1> 	; 15/10/2016 (1Dh -> 18)
   606                              <1> 	; 23/03/2016 (1Dh)
   607 0000D07B B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error
   608                              <1> 
   609                              <1> loc_sffc_read_fsinfo_sector_err2:
   610 0000D080 5A                  <1> 	pop	edx
   611 0000D081 C3                  <1> 	retn
   612                              <1> 	
   613                              <1> loc_sffc_read_fsinfo_sector:
   614 0000D082 50                  <1> 	push	eax
   615                              <1> 
   616 0000D083 E88F050000          <1> 	call	get_fat32_fsinfo_sector_parms
   617 0000D088 72F6                <1> 	jc	short loc_sffc_read_fsinfo_sector_err2
   618                              <1> 
   619 0000D08A 58                  <1> 	pop	eax
   620                              <1> 	; EDX = First (Next) Free Cluster value from FSINFO sector
   621                              <1> 	; EAX = First Free Cluster value from 'get_next_cluster'
   622                              <1> 	; (edx = old value)
   623 0000D08B 39D0                <1> 	cmp	eax, edx ; First free Cluster (eax = new value) 
   624 0000D08D 75C7                <1> 	jne	short loc_sffc_write_fsinfo_sector
   625                              <1> 
   626 0000D08F C3                  <1> 	retn	
   627                              <1> 
   628                              <1> update_cluster:
   629                              <1> 	; 23/10/2016
   630                              <1> 	; 23/03/2016
   631                              <1> 	; 02/03/2016
   632                              <1> 	; 01/03/2016
   633                              <1> 	; 29/02/2016
   634                              <1> 	; 27/02/2016
   635                              <1> 	; 26/02/2016
   636                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
   637                              <1> 	; 11/08/2011  
   638                              <1> 	; 09/02/2005
   639                              <1> 	; INPUT ->
   640                              <1> 	;	EAX = Cluster Number
   641                              <1> 	;	ECX = New Cluster Value
   642                              <1> 	;	ESI = Logical Dos Drive Parameters Table
   643                              <1> 	;
   644                              <1> 	;	/// dword [FAT_ClusterCounter] ///
   645                              <1> 	;
   646                              <1> 	; OUTPUT ->
   647                              <1> 	;	cf = 0 -> No Error, EAX is valid
   648                              <1> 	;	cf = 1 & EAX = 0 -> End Of Cluster Chain
   649                              <1> 	; 	cf = 1 & EAX > 0 -> Error
   650                              <1> 	;		(ECX -> any value)
   651                              <1> 	; 	EAX = Next Cluster
   652                              <1> 	;	ECX = New Cluster Value
   653                              <1> 	;
   654                              <1> 	;	/// [FAT_ClusterCounter] is updated,
   655                              <1> 	;	/// decreased when a free cluster is assigned,
   656                              <1> 	;	/// increased if an assigned cluster is freed.	
   657                              <1> 	;		
   658                              <1> 	;
   659                              <1> 	; (Modified registers: EAX, EBX, -ECX-, EDX)
   660                              <1> 	
   661 0000D090 A3[A6910100]        <1> 	mov	[FAT_CurrentCluster], eax
   662 0000D095 890D[48940100]      <1> 	mov	[ClusterValue], ecx
   663                              <1> 
   664                              <1> loc_update_cluster_check_fat_buffer:
   665 0000D09B 8A1E                <1> 	mov	bl, [esi+LD_Name]
   666 0000D09D 381D[AB910100]      <1> 	cmp	[FAT_BuffDrvName], bl
   667 0000D0A3 741A                <1> 	je	short loc_update_cluster_check_fat_type
   668 0000D0A5 803D[AA910100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
   669 0000D0AC 0F84C2000000        <1>         je      loc_uc_save_fat_buffer
   670                              <1> 
   671                              <1> loc_uc_reset_fat_buffer_validation:
   672 0000D0B2 C605[AA910100]00    <1> 	mov	byte [FAT_BuffValidData], 0
   673                              <1> 
   674                              <1> loc_uc_check_fat_type_reset_drvname:
   675 0000D0B9 881D[AB910100]      <1> 	mov	[FAT_BuffDrvName], bl
   676                              <1> 
   677                              <1> loc_update_cluster_check_fat_type:
   678 0000D0BF 29D2                <1> 	sub	edx, edx ; 26/02/2016
   679 0000D0C1 8A5E03              <1> 	mov	bl, [esi+LD_FATType]
   680 0000D0C4 83F802              <1> 	cmp	eax, 2
   681 0000D0C7 0F82BE000000        <1>         jb      update_cluster_inv_data
   682 0000D0CD 80FB02              <1> 	cmp	bl, 2 
   683 0000D0D0 0F877A010000        <1>         ja      update_fat32_cluster
   684                              <1> 	;cmp	bl, 1
   685                              <1> 	;jb	short update_cluster_inv_data
   686 0000D0D6 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
   687 0000D0D9 41                  <1> 	inc	ecx  
   688 0000D0DA 890D[B6910100]      <1> 	mov	[LastCluster], ecx
   689 0000D0E0 39C8                <1> 	cmp	eax, ecx ; dword [LastCluster]
   690 0000D0E2 0F87A6000000        <1>         ja      return_uc_fat_stc
   691                              <1> 	; TRDOS v1 has a FATal bug here ! 
   692                              <1> 		; or bl, bl ; cmp bl, 0
   693                              <1> 		; jz short update_fat12_cluster
   694                              <1> 	; !! It would destroy FAT12 floppy disk fs here !!
   695                              <1> 	; ('A:' disks of TRDOS v1 operating system project
   696                              <1> 	; had 'singlix fs', so, I could not differ this mistake
   697                              <1> 	; on a drive 'A:')
   698 0000D0E8 80FB01              <1> 	cmp	bl, 1 ; correct comparison is this !
   699 0000D0EB 0F86A2000000        <1>         jna     update_fat12_cluster 
   700                              <1> 
   701                              <1> update_fat16_cluster:
   702                              <1> pass_uc_fat16_errc:
   703                              <1> 	;sub	edx, edx
   704 0000D0F1 BB00030000          <1> 	mov	ebx, 300h ;768
   705 0000D0F6 F7F3                <1> 	div	ebx
   706                              <1> 	; EAX = Count of 3 FAT sectors
   707                              <1> 	; DX = Cluster offset in FAT buffer
   708 0000D0F8 6689D3              <1> 	mov	bx, dx  
   709 0000D0FB 66D1E3              <1> 	shl	bx, 1 ; Multiply by 2
   710 0000D0FE 66BA0300            <1> 	mov	dx, 3
   711 0000D102 F7E2                <1> 	mul	edx  
   712                              <1> 	; EAX = FAT Sector
   713                              <1> 	; EDX = 0
   714                              <1> 	; EBX = Byte offset in FAT buffer
   715 0000D104 8A0D[AA910100]      <1> 	mov	cl, [FAT_BuffValidData]
   716 0000D10A 80F902              <1> 	cmp	cl, 2
   717 0000D10D 750A                <1> 	jne	short loc_uc_check_fat16_buff_sector_load
   718                              <1> 
   719                              <1> loc_uc_check_fat16_buff_sector_save:
   720 0000D10F 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
   721 0000D115 755D                <1> 	jne	short loc_uc_save_fat_buffer
   722 0000D117 EB15                <1> 	jmp	short loc_update_fat16_cell
   723                              <1> 
   724                              <1> loc_uc_check_fat16_buff_sector_load:
   725 0000D119 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
   726 0000D11C 0F85FB010000        <1>         jne     loc_uc_load_fat_sectors
   727 0000D122 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
   728 0000D128 0F85EF010000        <1>         jne     loc_uc_load_fat_sectors
   729                              <1> 
   730                              <1> loc_update_fat16_cell:
   731                              <1> loc_update_fat16_buffer:
   732 0000D12E 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   733                              <1> 	;movzx	eax, word [ebx]
   734 0000D134 668B03              <1> 	mov	ax, [ebx]
   735                              <1> 	; 01/03/2016
   736 0000D137 89C2                <1> 	mov	edx, eax ; old value of the cluster
   737 0000D139 A3[A6910100]        <1> 	mov	[FAT_CurrentCluster], eax
   738 0000D13E 8B0D[48940100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   739 0000D144 66890B              <1> 	mov	[ebx], cx ; 16 bits !
   740                              <1> 
   741 0000D147 C605[AA910100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   742                              <1> 	
   743 0000D14E 6683F802            <1> 	cmp	ax, 2
   744 0000D152 723A                <1> 	jb	short return_uc_fat_stc
   745 0000D154 3B05[B6910100]      <1> 	cmp	eax, [LastCluster]
   746 0000D15A 7732                <1> 	ja	short return_uc_fat_stc
   747                              <1> 
   748                              <1> loc_fat_buffer_updated:
   749                              <1> 	; 01/03/2016
   750 0000D15C F8                  <1> 	clc
   751                              <1> loc_fat_buffer_stc_1:
   752 0000D15D 9C                  <1> 	pushf
   753 0000D15E 21C9                <1> 	and	ecx, ecx
   754 0000D160 7506                <1> 	jnz	short loc_fat_buffer_updated_1
   755                              <1> 
   756                              <1> 	; 01/03/2016 
   757                              <1> 	; new value of the cluster = 0 (free)
   758                              <1> 	; increase free(d) cluster count
   759 0000D162 FF05[B2910100]      <1> 	inc	dword [FAT_ClusterCounter]
   760                              <1> 
   761                              <1> loc_fat_buffer_updated_1: ; new value of the cluster > 0
   762 0000D168 09D2                <1> 	or	edx, edx ; 02/03/2016
   763 0000D16A 7506                <1> 	jnz	short loc_fat_buffer_updated_2
   764                              <1> 	; old value of the cluster = 0 (it was free cluster)
   765                              <1> 	; decrease free(d) cluster count
   766 0000D16C FF0D[B2910100]      <1> 	dec	dword [FAT_ClusterCounter] ; it may be negative number
   767                              <1> 
   768                              <1> loc_fat_buffer_updated_2:
   769 0000D172 9D                  <1> 	popf
   770 0000D173 C3                  <1> 	retn
   771                              <1> 
   772                              <1> loc_uc_save_fat_buffer:
   773                              <1> 	; byte [FAT_BuffValidData] = 2 
   774 0000D174 E8D4010000          <1> 	call	save_fat_buffer
   775 0000D179 0F8297010000        <1>         jc      loc_fat_sectors_rw_error2
   776                              <1> 	;mov	byte [FAT_BuffValidData], 1
   777 0000D17F A1[A6910100]        <1> 	mov	eax, [FAT_CurrentCluster]
   778                              <1> 	;mov	ecx, [ClusterValue]
   779                              <1> 	;jmp	short loc_update_cluster_check_fat_buffer
   780 0000D184 8A1E                <1> 	mov	bl, [esi+LD_Name] ; 01/03/2016
   781 0000D186 E927FFFFFF          <1>         jmp     loc_uc_reset_fat_buffer_validation
   782                              <1> 
   783                              <1> update_cluster_inv_data:
   784                              <1> 	;mov	eax, 0Dh
   785 0000D18B B00D                <1> 	mov	al, 0Dh  ; Invalid Data
   786 0000D18D C3                  <1> 	retn 
   787                              <1> 
   788                              <1> return_uc_fat_stc:
   789                              <1> 	; 01/03/2016
   790 0000D18E 31C0                <1> 	xor	eax, eax
   791 0000D190 F9                  <1> 	stc
   792 0000D191 EBCA                <1> 	jmp	short loc_fat_buffer_stc_1
   793                              <1> 
   794                              <1> update_fat12_cluster:
   795                              <1> pass_uc_fat12_errc:
   796                              <1> 	;sub	edx, edx
   797 0000D193 BB00040000          <1> 	mov	ebx, 400h ;1024
   798 0000D198 F7F3                <1> 	div	ebx
   799                              <1> 	; EAX = Count of 3 FAT sectors
   800                              <1> 	; DX = Cluster offset in FAT buffer
   801 0000D19A 66B90300            <1> 	mov	cx, 3
   802 0000D19E 6689C3              <1> 	mov	bx, ax
   803 0000D1A1 6689C8              <1> 	mov	ax, cx ; 3
   804 0000D1A4 66F7E2              <1> 	mul	dx     ; Multiply by 3
   805 0000D1A7 66D1E8              <1> 	shr	ax, 1  ; Divide by 2
   806 0000D1AA 6693                <1> 	xchg	bx, ax
   807                              <1> 	; EAX = Count of 3 FAT sectors
   808                              <1> 	; EBX = Byte Offset in FAT buffer   
   809 0000D1AC 66F7E1              <1> 	mul	cx  ; 3 * AX
   810                              <1> 	; EAX = FAT Beginning Sector
   811                              <1> 	; EDX = 0
   812 0000D1AF 8A0D[AA910100]      <1> 	mov	cl, [FAT_BuffValidData]
   813                              <1> 	; TRDOS v1 has a FATal bug here ! 
   814                              <1> 	; (it does not have 'cmp cl, 2' instruction here !
   815                              <1> 	;  while 'jne' is existing !)
   816 0000D1B5 80F902              <1> 	cmp	cl, 2 ; 2 = dirty buffer (must be written to disk)
   817 0000D1B8 750A                <1> 	jne	short loc_uc_check_fat12_buff_sector_load
   818                              <1> 
   819                              <1> loc_uc_check_fat12_buff_sector_save:
   820 0000D1BA 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
   821 0000D1C0 75B2                <1>         jne     short loc_uc_save_fat_buffer
   822 0000D1C2 EB15                <1> 	jmp	short loc_update_fat12_cell
   823                              <1> 
   824                              <1> loc_uc_check_fat12_buff_sector_load:
   825 0000D1C4 80F901              <1> 	cmp	cl, 1 ; byte ptr [FAT_BuffValidData]
   826 0000D1C7 0F8550010000        <1>         jne     loc_uc_load_fat_sectors
   827 0000D1CD 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
   828 0000D1D3 0F8544010000        <1>         jne     loc_uc_load_fat_sectors
   829                              <1> 
   830                              <1> loc_update_fat12_cell:
   831 0000D1D9 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   832 0000D1DF 668B0D[A6910100]    <1> 	mov	cx, [FAT_CurrentCluster]
   833 0000D1E6 66D1E9              <1> 	shr	cx, 1
   834 0000D1E9 668B03              <1> 	mov	ax, [ebx]
   835 0000D1EC 6689C2              <1> 	mov	dx, ax
   836 0000D1EF 7344                <1> 	jnc	short uc_fat12_nc_even
   837                              <1> 
   838 0000D1F1 6683E00F            <1> 	and	ax, 0Fh
   839 0000D1F5 8B0D[48940100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   840 0000D1FB 66C1E104            <1> 	shl	cx, 4
   841 0000D1FF 6609C1              <1> 	or	cx, ax
   842 0000D202 6689D0              <1> 	mov	ax, dx
   843 0000D205 66890B              <1> 	mov	[ebx], cx  ; 16 bits !
   844 0000D208 66C1E804            <1> 	shr	ax, 4 ; al(bit4..7)+ah(bit0..7)
   845                              <1> 
   846                              <1> update_fat12_buffer:
   847 0000D20C A3[A6910100]        <1> 	mov	[FAT_CurrentCluster], eax
   848 0000D211 89C2                <1> 	mov	edx, eax ; 01/03/2016
   849 0000D213 C605[AA910100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   850 0000D21A 6683F802            <1> 	cmp	ax, 2
   851 0000D21E 0F826AFFFFFF        <1>         jb      return_uc_fat_stc
   852 0000D224 3B05[B6910100]      <1> 	cmp	eax, [LastCluster]
   853 0000D22A 0F875EFFFFFF        <1>         ja      return_uc_fat_stc
   854 0000D230 E927FFFFFF          <1>         jmp     loc_fat_buffer_updated
   855                              <1> 
   856                              <1> uc_fat12_nc_even:
   857 0000D235 662500F0            <1> 	and	ax, 0F000h
   858 0000D239 8B0D[48940100]      <1> 	mov	ecx, [ClusterValue] ; 32 bits
   859 0000D23F 80E50F              <1> 	and	ch, 0Fh
   860 0000D242 6609C1              <1> 	or	cx, ax
   861 0000D245 6689D0              <1> 	mov	ax, dx
   862 0000D248 66890B              <1> 	mov	[ebx], cx ; 16 bits !
   863 0000D24B 80E40F              <1> 	and	ah, 0Fh ; al(bit0..7)+ah(bit0..3)
   864 0000D24E EBBC                <1> 	jmp	short update_fat12_buffer
   865                              <1> 
   866                              <1> update_fat32_cluster:
   867 0000D250 8B4E78              <1> 	mov	ecx, [esi+LD_Clusters]
   868 0000D253 41                  <1> 	inc	ecx
   869 0000D254 890D[B6910100]      <1> 	mov	[LastCluster], ecx
   870                              <1> 
   871 0000D25A 39C8                <1> 	cmp	eax, ecx
   872 0000D25C 0F872CFFFFFF        <1>         ja      return_uc_fat_stc
   873                              <1> 
   874                              <1> pass_uc_fat32_errc:
   875                              <1> 	;sub	edx, edx
   876 0000D262 BB80010000          <1> 	mov	ebx, 180h ;384
   877 0000D267 F7F3                <1> 	div	ebx
   878                              <1> 	; EAX = Count of 3 FAT sectors
   879                              <1> 	; DX = Cluster offset in FAT buffer
   880 0000D269 89D3                <1> 	mov	ebx, edx
   881 0000D26B C1E302              <1> 	shl	ebx, 2 ; Multiply by 4
   882 0000D26E BA03000000          <1> 	mov	edx, 3	
   883 0000D273 F7E2                <1> 	mul	edx
   884                              <1> 	; EBX = Cluster Offset in FAT buffer
   885                              <1> 	; EAX = FAT Sector
   886                              <1> 	; EDX = 0
   887 0000D275 8A0D[AA910100]      <1> 	mov	cl, [FAT_BuffValidData]
   888 0000D27B 80F902              <1> 	cmp	cl, 2
   889 0000D27E 750E                <1> 	jne	short loc_uc_check_fat32_buff_sector_load
   890                              <1> 
   891                              <1> loc_uc_check_fat32_buff_sector_save:
   892 0000D280 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
   893 0000D286 0F85E8FEFFFF        <1>         jne     loc_uc_save_fat_buffer
   894 0000D28C EB11                <1> 	jmp	short loc_update_fat32_cell
   895                              <1> 
   896                              <1> loc_uc_check_fat32_buff_sector_load:
   897 0000D28E 80F901              <1> 	cmp	cl, 1 ; byte [FAT_BuffValidData]
   898 0000D291 0F8586000000        <1>         jne     loc_uc_load_fat_sectors
   899 0000D297 3B05[AE910100]      <1> 	cmp	eax, [FAT_BuffSector]
   900 0000D29D 757E                <1>         jne     loc_uc_load_fat_sectors
   901                              <1> 
   902                              <1> loc_update_fat32_cell:
   903                              <1> loc_update_fat32_buffer:
   904 0000D29F 81C3001C0900        <1> 	add	ebx, FAT_Buffer ; 26/02/2016
   905 0000D2A5 8B03                <1> 	mov	eax, [ebx]
   906 0000D2A7 25FFFFFF0F          <1> 	and	eax, 0FFFFFFFh ; 28 bit cluster value
   907                              <1> 	
   908 0000D2AC 8B15[A6910100]      <1> 	mov	edx, [FAT_CurrentCluster] ; 01/03/2016
   909                              <1> 
   910 0000D2B2 A3[A6910100]        <1> 	mov 	[FAT_CurrentCluster], eax
   911 0000D2B7 8B0D[48940100]      <1> 	mov	ecx, [ClusterValue]
   912 0000D2BD 890B                <1> 	mov	[ebx], ecx ; 29/02/2016 
   913                              <1> 
   914 0000D2BF C605[AA910100]02    <1> 	mov	byte [FAT_BuffValidData], 2
   915                              <1> 
   916                              <1> 	; 01/03/2016
   917 0000D2C6 21C0                <1> 	and	eax, eax ; was it free cluster ?
   918 0000D2C8 7514                <1> 	jnz	short loc_upd_fat32_c0
   919                              <1> 
   920                              <1> 	;or	ecx, ecx ; it will be left free ?!
   921                              <1> 	;jz	short loc_upd_fat32_c3
   922                              <1> 
   923 0000D2CA 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
   924 0000D2CD 7520                <1> 	jne	short loc_upd_fat32_c3
   925                              <1> 
   926 0000D2CF 3B15[B6910100]      <1> 	cmp	edx, [LastCluster]
   927 0000D2D5 7207                <1> 	jb	short loc_upd_fat32_c0
   928                              <1> 
   929 0000D2D7 BA02000000          <1> 	mov	edx, 2 ; rewind !
   930 0000D2DC EB0E                <1> 	jmp	short loc_upd_fat32_c2
   931                              <1> 
   932                              <1> loc_upd_fat32_c0:
   933 0000D2DE FF463E              <1> 	inc	dword [esi+LD_BPB+BPB_Reserved+4] ; set it to next cluster		
   934 0000D2E1 EB0C                <1> 	jmp	short loc_upd_fat32_c3
   935                              <1> 
   936                              <1> loc_upd_fat32_c1:
   937 0000D2E3 09C9                <1> 	or	ecx, ecx ; will it be free cluster ?
   938 0000D2E5 7508                <1> 	jnz	short loc_upd_fat32_c3
   939                              <1> 
   940 0000D2E7 3B563E              <1> 	cmp	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free cluster
   941 0000D2EA 7303                <1> 	jnb	short loc_upd_fat32_c3
   942                              <1> 
   943                              <1> loc_upd_fat32_c2:	
   944 0000D2EC 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx			
   945                              <1> 
   946                              <1> loc_upd_fat32_c3:
   947 0000D2EF 89C2                <1> 	mov	edx, eax
   948                              <1> 
   949                              <1> loc_upd_fat32_c4:
   950 0000D2F1 83F802              <1> 	cmp	eax, 2
   951 0000D2F4 0F8294FEFFFF        <1>         jb      return_uc_fat_stc
   952                              <1> 
   953                              <1> pass_uc_fat32_c_zero_check_2:
   954 0000D2FA 3B05[B6910100]      <1> 	cmp	eax, [LastCluster]
   955 0000D300 0F8788FEFFFF        <1>         ja      return_uc_fat_stc
   956                              <1> 	
   957 0000D306 E951FEFFFF          <1> 	jmp     loc_fat_buffer_updated
   958                              <1> 
   959                              <1> loc_fat_sectors_rw_error1:
   960                              <1> 	;mov	byte [FAT_BuffValidData], 0
   961                              <1> 	; 23/10/2016 (15h -> 17)
   962                              <1> 	; 23/03/2016
   963 0000D30B B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
   964 0000D310 8825[AA910100]      <1> 	mov	[FAT_BuffValidData], ah ; 0
   965                              <1> 
   966                              <1> loc_fat_sectors_rw_error2:
   967                              <1> 	;mov	eax, error code
   968                              <1> 	;mov	edx, 0
   969 0000D316 8B0D[48940100]      <1> 	mov	ecx, [ClusterValue]
   970 0000D31C C3                  <1> 	retn
   971                              <1> 
   972                              <1> loc_uc_load_fat_sectors:
   973 0000D31D A3[AE910100]        <1> 	mov	[FAT_BuffSector], eax
   974                              <1> 
   975                              <1> load_uc_fat_sectors_zero:
   976 0000D322 034660              <1> 	add	eax, [esi+LD_FATBegin]
   977 0000D325 BB001C0900          <1> 	mov	ebx, FAT_Buffer
   978 0000D32A B903000000          <1> 	mov	ecx, 3
   979 0000D32F E829580000          <1> 	call	disk_read
   980 0000D334 72D5                <1> 	jc	short loc_fat_sectors_rw_error1
   981                              <1> 
   982 0000D336 C605[AA910100]01    <1>         mov     byte [FAT_BuffValidData], 1
   983 0000D33D A1[A6910100]        <1> 	mov 	eax, [FAT_CurrentCluster]
   984 0000D342 8B0D[48940100]      <1> 	mov	ecx, [ClusterValue]
   985 0000D348 E972FDFFFF          <1>         jmp     loc_update_cluster_check_fat_type
   986                              <1> 
   987                              <1> save_fat_buffer:
   988                              <1> 	; 15/10/2016
   989                              <1> 	; 01/03/2016
   990                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
   991                              <1> 	; 11/08/2011
   992                              <1> 	; 09/02/2005 
   993                              <1> 	; INPUT ->
   994                              <1> 	;	None
   995                              <1> 	; OUTPUT ->
   996                              <1> 	;	cf = 0 -> OK.
   997                              <1> 	;	cf = 1 -> error code in AL (EAX)
   998                              <1> 	;
   999                              <1> 	;	EBX = FAT_Buffer address
  1000                              <1> 	;
  1001                              <1> 	; (EAX, EDX, ECX will be modified)
  1002                              <1> 
  1003                              <1> 	;cmp	byte [FAT_BuffValidData], 2 
  1004                              <1> 	;je	short loc_save_fat_buff
  1005                              <1> 
  1006                              <1> ;loc_save_fat_buffer_retn:
  1007                              <1> ;	xor	eax, eax
  1008                              <1> ;	retn
  1009                              <1> 
  1010                              <1> loc_save_fat_buff:
  1011 0000D34D 31D2                <1> 	xor	edx, edx
  1012 0000D34F 8A35[AB910100]      <1> 	mov	dh, [FAT_BuffDrvName]
  1013 0000D355 80FE41              <1> 	cmp	dh, 'A'
  1014 0000D358 722E                <1> 	jb	short loc_save_fat_buffer_inv_data_retn
  1015 0000D35A 80EE41              <1> 	sub	dh, 'A'
  1016 0000D35D 56                  <1> 	push	esi ; *
  1017 0000D35E BE00010900          <1>         mov     esi, Logical_DOSDisks
  1018 0000D363 01D6                <1> 	add	esi, edx
  1019                              <1> 	
  1020 0000D365 8A5603              <1> 	mov	dl, [esi+LD_FATType]
  1021 0000D368 20D2                <1> 	and	dl, dl
  1022 0000D36A 741B                <1> 	jz	short loc_save_fat_buffer_inv_data_pop_retn 
  1023                              <1> 
  1024 0000D36C A1[AE910100]        <1> 	mov	eax, [FAT_BuffSector]
  1025 0000D371 80FA02              <1> 	cmp	dl, 2
  1026 0000D374 770A                <1> 	ja	short loc_save_fat32_buff
  1027                              <1> 
  1028                              <1> loc_save_fat_12_16_buff:
  1029                              <1> 	; 01/03/2016
  1030                              <1> 	; TRDOS v1 has a FATal bug here!
  1031                              <1> 	; Correct code: mov dx, word ptr [FAT_BuffSector]+2
  1032                              <1> 	; (DX:AX in TRDOS v1 -> EAX in TRDOS v2)
  1033                              <1> 	;
  1034 0000D376 0FB74E1C            <1> 	movzx	ecx, word [esi+LD_BPB+FATSecs] 
  1035 0000D37A 29C1                <1> 	sub	ecx, eax
  1036                              <1> 	; TRDOS v1 has a bug here... ('pop esi' was forgotten!)
  1037                              <1> 	;jna	short loc_save_fat_buffer_inv_data_retn ; wrong addr!
  1038 0000D37C 7609                <1> 	jna	short loc_save_fat_buffer_inv_data_pop_retn ; correct addr.
  1039 0000D37E EB15                <1> 	jmp	short loc_save_fat_buffer_check_rs3
  1040                              <1> 
  1041                              <1> loc_save_fat32_buff:
  1042 0000D380 8B4E2A              <1> 	mov	ecx, [esi+LD_BPB+FAT32_FAT_Size]
  1043 0000D383 29C1                <1> 	sub	ecx, eax
  1044 0000D385 770E                <1> 	ja	short loc_save_fat_buffer_check_rs3
  1045                              <1> 
  1046                              <1> loc_save_fat_buffer_inv_data_pop_retn:
  1047 0000D387 5E                  <1> 	pop	esi ; *
  1048                              <1> loc_save_fat_buffer_inv_data_retn:
  1049 0000D388 B80D000000          <1> 	mov	eax, 0Dh ; Invalid DATA
  1050 0000D38D C3                  <1> 	retn
  1051                              <1> 
  1052                              <1> loc_save_fat_buff_remain_sectors_3:
  1053 0000D38E B903000000          <1> 	mov	ecx, 3
  1054 0000D393 EB05                <1> 	jmp	short loc_save_fat_buff_continue
  1055                              <1> 
  1056                              <1> loc_save_fat_buffer_check_rs3:
  1057 0000D395 83F903              <1> 	cmp	ecx, 3
  1058 0000D398 77F4                <1> 	ja	short loc_save_fat_buff_remain_sectors_3
  1059                              <1> 
  1060                              <1> loc_save_fat_buff_continue:
  1061 0000D39A BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1062 0000D39F 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1063 0000D3A2 51                  <1> 	push	ecx
  1064 0000D3A3 E8A6570000          <1> 	call	disk_write
  1065 0000D3A8 59                  <1> 	pop	ecx
  1066 0000D3A9 722B                <1> 	jc	short loc_save_FAT_buff_write_err
  1067                              <1> 	
  1068 0000D3AB 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1069 0000D3AF 7605                <1> 	jna	short loc_calc_2nd_fat12_16_addr
  1070                              <1> 
  1071                              <1> loc_calc_2nd_fat32_addr:
  1072 0000D3B1 8B462A              <1> 	mov	eax, [esi+LD_BPB+FAT32_FAT_Size]
  1073 0000D3B4 EB04                <1> 	jmp	short loc_calc_2nd_fat_addr
  1074                              <1> 
  1075                              <1> loc_calc_2nd_fat12_16_addr:
  1076 0000D3B6 0FB7461C            <1> 	movzx	eax, word [esi+LD_BPB+FATSecs]
  1077                              <1> 
  1078                              <1> loc_calc_2nd_fat_addr:
  1079 0000D3BA 034660              <1> 	add	eax, [esi+LD_FATBegin]
  1080 0000D3BD 0305[AE910100]      <1> 	add	eax, [FAT_BuffSector]
  1081 0000D3C3 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1082                              <1> 	; ecx = 1 to 3
  1083 0000D3C8 E881570000          <1> 	call	disk_write
  1084 0000D3CD 7207                <1> 	jc	short loc_save_FAT_buff_write_err
  1085                              <1>  	; Valid  buffer (1 = valid but do not save)
  1086 0000D3CF C605[AA910100]01    <1> 	mov	byte [FAT_BuffValidData], 1
  1087                              <1> 
  1088                              <1> loc_save_FAT_buff_write_err:
  1089 0000D3D6 5E                  <1> 	pop	esi ; *
  1090 0000D3D7 BB001C0900          <1> 	mov	ebx, FAT_Buffer
  1091                              <1> 	; 15/10/2016 (1Dh -> 18)
  1092                              <1> 	; 23/03/2016 (1Dh)
  1093 0000D3DC B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error
  1094 0000D3E1 C3                  <1> 	retn
  1095                              <1> 
  1096                              <1> calculate_fat_freespace:
  1097                              <1> 	; 23/03/2016
  1098                              <1> 	; 02/03/2016
  1099                              <1> 	; 01/03/2016
  1100                              <1> 	; 29/02/2016
  1101                              <1> 	; 22/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1102                              <1> 	; 30/04/2011
  1103                              <1> 	; 03/04/2010
  1104                              <1> 	; 2005
  1105                              <1> 	; INPUT ->
  1106                              <1> 	;	EAX = Cluster count to be added or subtracted
  1107                              <1> 	; 	If BH = FFh, ESI = TR-DOS Logical Drive Description Table
  1108                              <1> 	; 	If BH < FFh, BH = TR-DOS Logical Drive Number
  1109                              <1> 	; 	BL: 
  1110                              <1> 	;	0 = Calculate, 1 = Add, 2 = Subtract, 3 = Get (Not Set/Calc)
  1111                              <1> 	; OUTPUT ->
  1112                              <1> 	;	EAX = Free Space in sectors
  1113                              <1> 	;	ESI = Logical Dos Drive Description Table address
  1114                              <1> 	;	BH = Logical Dos Drive Number (same with input value of BH)
  1115                              <1> 	;	BL = Type of operation (same with input value of BL)
  1116                              <1> 	;	ECX = 0 -> valid
  1117                              <1> 	;	ECX > 0 -> error or invalid
  1118                              <1> 	;	If EAX = FFFFFFFFh, it is 're-calculation needed'
  1119                              <1> 	;			          sign due to r/w error   
  1120                              <1> 
  1121 0000D3E2 66891D[4E940100]    <1> 	mov	[CFS_OPType], bx
  1122 0000D3E9 A3[50940100]        <1> 	mov	[CFS_CC], eax
  1123                              <1> 	
  1124 0000D3EE 80FFFF              <1> 	cmp	bh, 0FFh
  1125 0000D3F1 740B                <1> 	je	short pass_calculate_freespace_get_drive_dt_offset
  1126                              <1> 
  1127                              <1> loc_calculate_freespace_get_drive_dt_offset:     
  1128 0000D3F3 31C0                <1> 	xor	eax, eax
  1129 0000D3F5 88FC                <1>         mov     ah, bh
  1130 0000D3F7 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1131 0000D3FC 01C6                <1>         add     esi, eax
  1132                              <1> 
  1133                              <1> pass_calculate_freespace_get_drive_dt_offset:
  1134 0000D3FE 08DB                <1> 	or	bl, bl
  1135 0000D400 7435                <1> 	jz	short loc_reset_fcc
  1136                              <1> 	
  1137                              <1> loc_get_free_sectors:
  1138 0000D402 8B4674              <1> 	mov	eax, [esi+LD_FreeSectors]
  1139                              <1> 
  1140                              <1> 	;xor	ecx, ecx
  1141                              <1> 	;dec	ecx ; 0FFFFFFFFh
  1142                              <1> 	;cmp	eax, ecx ; 29/02/2016
  1143                              <1> 	;je	short loc_get_free_sectors_retn ; recalculation is needed!
  1144                              <1> 	
  1145                              <1> 	; 23/03/2016
  1146 0000D405 8B4E70              <1> 	mov	ecx, [esi+LD_TotalSectors]
  1147 0000D408 39C1                <1> 	cmp	ecx, eax ; Total sectors must be greater than Free sectors !
  1148 0000D40A 7707                <1> 	ja	short loc_get_free_sectors_check_optype
  1149                              <1> 	
  1150 0000D40C 31C0                <1> 	xor	eax, eax
  1151 0000D40E 48                  <1> 	dec	eax ; 0FFFFFFFFh  ; recalculation is needed!
  1152 0000D40F 894674              <1> 	mov	[esi+LD_FreeSectors], eax ; reset (for recalculation)
  1153                              <1> 		
  1154                              <1> loc_get_free_sectors_retn:
  1155 0000D412 C3                  <1> 	retn
  1156                              <1> 	
  1157                              <1> loc_get_free_sectors_check_optype:
  1158 0000D413 80FB03              <1> 	cmp	bl, 3
  1159 0000D416 7203                <1> 	jb	short loc_set_fcc
  1160                              <1> 
  1161 0000D418 29C9                <1> 	sub	ecx, ecx ; 0
  1162                              <1> 
  1163 0000D41A C3                  <1> 	retn	
  1164                              <1> 
  1165                              <1> loc_set_fcc:
  1166 0000D41B 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1167 0000D41F 0F87DF000000        <1>         ja      loc_update_FAT32_fs_info_fcc
  1168                              <1> 
  1169                              <1> 	;mov	eax, [esi+LD_FreeSectors]
  1170 0000D425 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+SecPerClust]
  1171 0000D429 29D2                <1> 	sub	edx, edx
  1172 0000D42B F7F1                <1> 	div	ecx
  1173                              <1> 	;or	dx, dx 
  1174                              <1> 	;	; DX -> Remain sectors < SecPerClust
  1175                              <1> 	;	; DX > 0 -> invalid free sector count
  1176                              <1> 	;jnz	short loc_reset_fcc 
  1177                              <1> 
  1178                              <1> ;pass_set_fcc_div32:
  1179 0000D42D A3[C7910100]        <1> 	mov	[FreeClusterCount], eax
  1180 0000D432 E988000000          <1>         jmp     loc_set_free_sectors_FAT12_FAT16
  1181                              <1> 
  1182                              <1> loc_reset_fcc:
  1183 0000D437 31C0                <1> 	xor	eax, eax
  1184 0000D439 A3[C7910100]        <1> 	mov	[FreeClusterCount], eax ; 0
  1185 0000D43E 8B5678              <1> 	mov	edx, [esi+LD_Clusters]
  1186 0000D441 42                  <1> 	inc	edx
  1187 0000D442 8915[B6910100]      <1> 	mov	[LastCluster], edx
  1188                              <1> 
  1189 0000D448 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1190 0000D44C 7647                <1> 	jna	short loc_count_free_fat_clusters_0  
  1191                              <1> 
  1192 0000D44E 48                  <1> 	dec	eax ; FFFFFFFFh
  1193 0000D44F A3[58940100]        <1> 	mov	[CFS_FAT32FC], eax
  1194                              <1> 
  1195                              <1> 	; 29/02/2016
  1196 0000D454 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; reset
  1197 0000D457 89463E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], eax ; reset
  1198                              <1> 	
  1199 0000D45A B802000000          <1> 	mov 	eax, 2
  1200                              <1> 
  1201                              <1> loc_count_fc_next_cluster_0:
  1202 0000D45F 50                  <1> 	push	eax
  1203 0000D460 E801F9FFFF          <1> 	call	get_next_cluster
  1204 0000D465 7310                <1> 	jnc	short loc_check_fat32_ff_cluster
  1205 0000D467 09C0                <1> 	or	eax, eax
  1206 0000D469 741E                <1> 	jz	short pass_inc_cfs_fcc_0
  1207                              <1> 
  1208                              <1> loc_put_fcc_unknown_sign:
  1209 0000D46B 58                  <1> 	pop	eax
  1210                              <1> 	; "Free count is Unknown" sign
  1211                              <1> 	;mov	dword [FreeClusterCount], 0FFFFFFFFh
  1212                              <1> 
  1213                              <1> 	; 29/02/2016
  1214                              <1> 	; Save Free Cluster Count value in FAT32 'BPB_Reserved' area
  1215                              <1> 	;mov	[esi+LD_BPB+BPB_Reserved], 0FFFFFFFFh ; unknown!
  1216 0000D46C 8B15[58940100]      <1> 	mov	edx, [CFS_FAT32FC] ; First Free Cluster
  1217                              <1> 	; Save First Free Cluster value in FAT32 'BPB_Reserved+4' area
  1218 0000D472 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx
  1219                              <1> 	
  1220 0000D475 EB7D                <1>         jmp     loc_put_fcc_invalid_sign
  1221                              <1> 
  1222                              <1> loc_check_fat32_ff_cluster:
  1223 0000D477 09C0                <1> 	or	eax, eax
  1224 0000D479 750E                <1> 	jnz	short pass_inc_cfs_fcc_0
  1225 0000D47B 58                  <1> 	pop	eax
  1226 0000D47C A3[58940100]        <1> 	mov	[CFS_FAT32FC], eax
  1227                              <1> 	;mov	dword [FreeClusterCount], 1
  1228 0000D481 FF05[C7910100]      <1> 	inc	dword [FreeClusterCount]
  1229 0000D487 EB27                <1> 	jmp	short pass_inc_cfs_fcc_1
  1230                              <1> 
  1231                              <1> pass_inc_cfs_fcc_0:
  1232 0000D489 58                  <1> 	pop	eax
  1233                              <1> 
  1234                              <1> pass_inc_cfs_fcc_0c:
  1235 0000D48A 40                  <1> 	inc	eax ; add eax, 1
  1236 0000D48B 3B05[B6910100]      <1> 	cmp	eax, [LastCluster]
  1237 0000D491 76CC                <1> 	jna 	short loc_count_fc_next_cluster_0
  1238 0000D493 EB6F                <1> 	jmp	short loc_update_FAT32_fs_info_fcc
  1239                              <1> 
  1240                              <1> loc_count_free_fat_clusters_0:
  1241                              <1> 	;mov	eax, 2
  1242 0000D495 B002                <1> 	mov	al, 2
  1243                              <1> 
  1244                              <1> loc_count_fc_next_cluster:
  1245 0000D497 50                  <1> 	push	eax
  1246 0000D498 E8C9F8FFFF          <1> 	call	get_next_cluster
  1247 0000D49D 720C                <1> 	jc	short loc_count_fcc_stc
  1248                              <1> 
  1249                              <1> loc_count_free_clusters_1:
  1250 0000D49F 21C0                <1> 	and	eax, eax
  1251 0000D4A1 750C                <1> 	jnz	short pass_inc_cfs_fcc
  1252                              <1> 
  1253 0000D4A3 FF05[C7910100]      <1> 	inc	dword [FreeClusterCount]
  1254 0000D4A9 EB04                <1> 	jmp	short pass_inc_cfs_fcc
  1255                              <1> 
  1256                              <1> loc_count_fcc_stc:
  1257 0000D4AB 09C0                <1> 	or	eax, eax
  1258 0000D4AD 75BC                <1> 	jnz	short loc_put_fcc_unknown_sign ; 29/02/2016
  1259                              <1> 
  1260                              <1> pass_inc_cfs_fcc:
  1261 0000D4AF 58                  <1> 	pop	eax
  1262                              <1> 
  1263                              <1> pass_inc_cfs_fcc_1:
  1264 0000D4B0 40                  <1> 	inc	eax ; add eax, 1
  1265 0000D4B1 3B05[B6910100]      <1> 	cmp	eax, [LastCluster]
  1266 0000D4B7 76DE                <1> 	jna	short loc_count_fc_next_cluster
  1267                              <1> 
  1268                              <1> loc_set_free_sectors:
  1269 0000D4B9 807E0302            <1> 	cmp	byte [esi+LD_FATType], 2
  1270 0000D4BD 7745                <1> 	ja	short loc_update_FAT32_fs_info_fcc
  1271                              <1> 
  1272                              <1> loc_set_free_sectors_FAT12_FAT16:
  1273 0000D4BF 803D[4E940100]00    <1> 	cmp	byte [CFS_OPType], 0
  1274 0000D4C6 761C                <1> 	jna	short pass_FAT_add_sub_fcc
  1275 0000D4C8 A1[50940100]        <1> 	mov	eax, [CFS_CC]
  1276 0000D4CD 803D[4E940100]01    <1> 	cmp	byte [CFS_OPType], 1
  1277 0000D4D4 7708                <1> 	ja	short pass_FAT_add_fcc
  1278 0000D4D6 0105[C7910100]      <1> 	add 	[FreeClusterCount], eax
  1279 0000D4DC EB06                <1> 	jmp	short pass_FAT_add_sub_fcc
  1280                              <1> 
  1281                              <1> pass_FAT_add_fcc:
  1282 0000D4DE 2905[C7910100]      <1> 	sub	[FreeClusterCount], eax
  1283                              <1> 
  1284                              <1> pass_FAT_add_sub_fcc:
  1285 0000D4E4 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  1286 0000D4E8 8B15[C7910100]      <1> 	mov	edx, [FreeClusterCount]
  1287 0000D4EE F7E2                <1> 	mul	edx
  1288                              <1> 
  1289 0000D4F0 31C9                <1> 	xor	ecx, ecx 
  1290 0000D4F2 EB05                <1> 	jmp	short loc_cfs_retn_params
  1291                              <1> 
  1292                              <1> loc_put_fcc_invalid_sign:
  1293 0000D4F4 29C0                <1>        	sub	eax, eax ; 0
  1294 0000D4F6 48                  <1> 	dec	eax ; FFFFFFFFh
  1295                              <1> loc_fat32_ffc_recalc_needed:
  1296 0000D4F7 89C1                <1> 	mov	ecx, eax
  1297                              <1> 
  1298                              <1> loc_cfs_retn_params:
  1299 0000D4F9 894674              <1> 	mov 	[esi+LD_FreeSectors], eax
  1300 0000D4FC 0FB71D[4E940100]    <1> 	movzx	ebx, word [CFS_OPType]
  1301 0000D503 C3                  <1> 	retn
  1302                              <1> 
  1303                              <1> loc_update_FAT32_fs_info_fcc:
  1304                              <1> loc_check_fcc_FSINFO_op:
  1305                              <1> 	; 29/02/2016
  1306                              <1> 	; EAX = Free cluster count (before this update) ; value from disk
  1307                              <1> 	; EDX = First Free Cluster (before this update) ; value from disk
  1308 0000D504 803D[4E940100]01    <1> 	cmp	byte [CFS_OPType], 1
  1309 0000D50B 7221                <1> 	jb	short loc_cfs_FAT32_get_rcalc_parms ; 0 = recalculated
  1310 0000D50D 7406                <1> 	je	short loc_check_fcc_FSINFO_op1 ; 1 = add
  1311                              <1> loc_check_fcc_FSINFO_op2: ; subtract
  1312 0000D50F F71D[50940100]      <1> 	neg	dword [CFS_CC] ; prepare to subtract ; 2 = sub (add negative)
  1313                              <1> loc_check_fcc_FSINFO_op1:
  1314                              <1> 	; 01/03/2016
  1315 0000D515 31D2                <1> 	xor	edx, edx ; 0
  1316 0000D517 4A                  <1> 	dec	edx ; 0FFFFFFFFh
  1317 0000D518 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved]
  1318 0000D51B 39D0                <1> 	cmp	eax, edx
  1319 0000D51D 73D5                <1> 	jnb	short loc_put_fcc_invalid_sign
  1320 0000D51F 0305[50940100]      <1>         add     eax, [CFS_CC] ; free cluster count on disk + current count
  1321 0000D525 72CD                <1> 	jc	short loc_put_fcc_invalid_sign
  1322                              <1> 	
  1323 0000D527 A3[C7910100]        <1> 	mov	[FreeClusterCount], eax
  1324 0000D52C EB0E                <1> 	jmp	short loc_cfs_write_FSINFO_sector
  1325                              <1> 
  1326                              <1> loc_cfs_FAT32_get_rcalc_parms:
  1327 0000D52E 8B15[58940100]      <1> 	mov	edx, [CFS_FAT32FC]
  1328 0000D534 A1[C7910100]        <1> 	mov	eax, [FreeClusterCount]
  1329 0000D539 89563E              <1> 	mov	[esi+LD_BPB+BPB_Reserved+4], edx ; First Free Cluster
  1330                              <1> loc_cfs_write_FSINFO_sector:
  1331 0000D53C 89463A              <1> 	mov	[esi+LD_BPB+BPB_Reserved], eax ; Free cluster count
  1332                              <1> 	; 01/03/2016
  1333 0000D53F E8AA000000          <1> 	call	set_fat32_fsinfo_sector_parms
  1334 0000D544 72AE                <1>         jc      short loc_put_fcc_invalid_sign
  1335                              <1> 
  1336                              <1> loc_set_FAT32_free_sectors:
  1337                              <1> 	; 29/02/2016
  1338                              <1> 	;mov	eax, [FreeClusterCount]
  1339                              <1> 	;mov	ecx, eax
  1340                              <1> 	;cmp	eax, 0FFFFFFFFh ; Invalid !
  1341                              <1> 	;je	short loc_cfs_retn_params
  1342                              <1> 	;
  1343 0000D546 8B0D[C7910100]      <1> 	mov	ecx, [FreeClusterCount]
  1344 0000D54C 0FB64613            <1> 	movzx	eax, byte [esi+LD_BPB+SecPerClust]
  1345 0000D550 F7E1                <1> 	mul	ecx
  1346                              <1> 	; 29/02/2016
  1347 0000D552 31C9                <1> 	xor	ecx, ecx ; 0
  1348 0000D554 09D2                <1> 	or	edx, edx ; 0 ?
  1349 0000D556 759C                <1>         jnz     loc_put_fcc_invalid_sign
  1350 0000D558 394670              <1> 	cmp	[esi+LD_TotalSectors], eax ; Volume size in sectors
  1351 0000D55B 7697                <1>         jna     short loc_put_fcc_invalid_sign
  1352                              <1> 	;
  1353                              <1> loc_set_FAT32_free_sectors_ok:
  1354 0000D55D 31D2                <1> 	xor	edx, edx ; 0
  1355 0000D55F EB98                <1>         jmp     short loc_cfs_retn_params 
  1356                              <1> 	;
  1357                              <1> 
  1358                              <1> get_last_cluster:
  1359                              <1> 	; 22/10/2016
  1360                              <1> 	; 27/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1361                              <1> 	; 12/06/2010 (DRV_FAT.ASM, 'proc_get_last_custer')
  1362                              <1> 	; 06/06/2010
  1363                              <1> 	; INPUT ->
  1364                              <1> 	;	EAX = First Cluster Number
  1365                              <1> 	; 	ESI = Logical Dos Drive Parameters Table
  1366                              <1> 	; OUTPUT ->
  1367                              <1> 	;	cf = 0 -> No Error, EAX is valid
  1368                              <1> 	;	cf = 1 -> EAX > 0 -> Error
  1369                              <1> 	;	EAX = Last Cluster Number
  1370                              <1> 	;       ECX = Previous Cluster -just before the last cluster-
  1371                              <1> 	;       ; 22/10/2016
  1372                              <1> 	;	[glc_index] = cluster index number of the last cluster	
  1373                              <1> 	;
  1374                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  1375                              <1> 
  1376 0000D561 89C1                <1> 	mov	ecx, eax
  1377                              <1> 
  1378 0000D563 C705[60940100]FFFF- <1> 	mov	dword [glc_index], 0FFFFFFFFh ; 22/10/2016	
  1378 0000D56B FFFF                <1>
  1379                              <1> 
  1380                              <1> loc_glc_get_next_cluster_1:
  1381 0000D56D 890D[5C940100]      <1> 	mov	[glc_prevcluster], ecx
  1382                              <1>  	; 22/10/2016
  1383 0000D573 FF05[60940100]      <1> 	inc	dword [glc_index]
  1384                              <1> 
  1385                              <1> loc_glc_get_next_cluster_2:
  1386 0000D579 E8E8F7FFFF          <1> 	call	get_next_cluster
  1387                              <1> 	; ecx = current/previous cluster 
  1388                              <1> 	; eax = next/last cluster
  1389 0000D57E 73ED                <1> 	jnc	short loc_glc_get_next_cluster_1
  1390                              <1> 
  1391 0000D580 09C0                <1> 	or	eax, eax
  1392 0000D582 7509                <1> 	jnz	short loc_glc_stc_retn
  1393                              <1> 
  1394                              <1> 	; ecx = previous cluster
  1395 0000D584 89C8                <1>         mov	eax, ecx
  1396                              <1> 
  1397                              <1> 	; previous cluster becomes last cluster (ecx -> eax)
  1398                              <1> 	; previous of previous cluster becomes previous cluster (ecx)
  1399                              <1> 
  1400                              <1> loc_glc_prev_cluster_retn:
  1401 0000D586 8B0D[5C940100]      <1> 	mov	ecx, [glc_prevcluster] 
  1402 0000D58C C3                  <1> 	retn
  1403                              <1> 
  1404                              <1> loc_glc_stc_retn:
  1405 0000D58D F5                  <1> 	cmc	;stc
  1406 0000D58E EBF6                <1>         jmp	short loc_glc_prev_cluster_retn
  1407                              <1> 
  1408                              <1> truncate_cluster_chain:
  1409                              <1> 	; 01/03/2016
  1410                              <1> 	; 28/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1411                              <1> 	; 22/01/2011 (DRV_FAT.ASM, 'proc_truncate_cluster_chain')
  1412                              <1> 	; 11/09/2010
  1413                              <1> 	; INPUT ->
  1414                              <1> 	;	ESI = Logical dos drive description table address
  1415                              <1> 	;	EAX = First cluster to be truncated/unlinked 
  1416                              <1> 	; OUTPUT ->
  1417                              <1> 	;	ESI = Logical dos drive description table address
  1418                              <1> 	; 	ECX = Count of truncated/removed clusters
  1419                              <1> 	; 	CF = 0 -> EAX = Free sectors
  1420                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  1421                              <1> 
  1422                              <1> 	; NOTE: This procedure does not update lm date&time ! 
  1423                              <1> 
  1424                              <1> loc_truncate_cc:	
  1425 0000D590 31C9                <1> 	xor	ecx, ecx ; mov ecx, 0
  1426                              <1> 	;mov	byte [FAT_BuffValidData], 0
  1427 0000D592 890D[B2910100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  1428                              <1> 
  1429                              <1> loc_tcc_unlink_clusters:
  1430 0000D598 E8F3FAFFFF          <1> 	call	update_cluster
  1431                              <1> 	; EAX = Next Cluster
  1432                              <1> 	; ECX = Cluster Value
  1433                              <1> 	; Note:
  1434                              <1> 	; Returns count of unlinked clusters in
  1435                              <1> 	; dword ptr FAT_ClusterCounter
  1436 0000D59D 73F9                <1> 	jnc short loc_tcc_unlink_clusters
  1437                              <1> 
  1438                              <1> pass_tcc_unlink_clusters:
  1439 0000D59F A2[67940100]        <1> 	mov	byte [TCC_FATErr], al
  1440 0000D5A4 803D[AA910100]02    <1> 	cmp	byte [FAT_BuffValidData], 2
  1441 0000D5AB 750E                <1> 	jne	short loc_tcc_calculate_FAT_freespace
  1442 0000D5AD E89BFDFFFF          <1> 	call	save_fat_buffer
  1443 0000D5B2 7307                <1> 	jnc	short loc_tcc_calculate_FAT_freespace
  1444 0000D5B4 A2[67940100]        <1> 	mov	byte [TCC_FATErr], al ; Error
  1445                              <1> 	;mov	byte [FAT_BuffValidData], 0
  1446                              <1> 
  1447                              <1> 	; 01/03/2016
  1448 0000D5B9 EB12                <1> 	jmp	short loc_tcc_recalculate_FAT_freespace
  1449                              <1> 
  1450                              <1> loc_tcc_calculate_FAT_freespace:
  1451 0000D5BB A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter] ; signed (+-) number
  1452 0000D5C0 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI = Dos drv desc. table
  1453                              <1> 			   ; BL = 1 -> add cluster
  1454 0000D5C4 E819FEFFFF          <1> 	call	calculate_fat_freespace
  1455 0000D5C9 21C9                <1> 	and	ecx, ecx ; cx = 0 -> valid free sector count
  1456 0000D5CB 7409                <1> 	jz	short pass_truncate_cc_recalc_FAT_freespace
  1457                              <1> 
  1458                              <1> loc_tcc_recalculate_FAT_freespace:
  1459 0000D5CD 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate !
  1460 0000D5D1 E80CFEFFFF          <1> 	call	calculate_fat_freespace
  1461                              <1>               
  1462                              <1> loc_tcc_calculate_FAT_freespace_err:
  1463                              <1> pass_truncate_cc_recalc_FAT_freespace:
  1464 0000D5D6 8B0D[B2910100]      <1> 	mov	ecx, [FAT_ClusterCounter]
  1465                              <1> 
  1466 0000D5DC 803D[67940100]00    <1> 	cmp	byte [TCC_FATErr], 0
  1467 0000D5E3 7608                <1> 	jna	short loc_tcc_unlink_clusters_retn
  1468                              <1> 
  1469                              <1> loc_tcc_unlink_clusters_error:
  1470 0000D5E5 0FB605[67940100]    <1> 	movzx	eax, byte [TCC_FATErr]
  1471 0000D5EC F9                  <1> 	stc
  1472                              <1> loc_tcc_unlink_clusters_retn:
  1473 0000D5ED C3                  <1> 	retn
  1474                              <1> 
  1475                              <1> set_fat32_fsinfo_sector_parms:
  1476                              <1> 	; 15/10/2016
  1477                              <1> 	; 23/03/2016
  1478                              <1> 	; 29/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1479                              <1> 	; INPUT ->
  1480                              <1> 	;	ESI = Logical dos drive description table address
  1481                              <1> 	;	[esi+LD_BPB+BPB_Reserved] = Free Cluster Count
  1482                              <1> 	;	[esi+LD_BPB+BPB_Reserved+4] = First Free Cluster 
  1483                              <1> 	; OUTPUT ->
  1484                              <1> 	;	ESI = Logical dos drive description table address
  1485                              <1> 	; 	CF = 0 -> OK..
  1486                              <1> 	; 	CF = 1 -> Error code in EAX (AL)
  1487                              <1> 	;
  1488                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  1489                              <1> 
  1490 0000D5EE E824000000          <1> 	call	get_fat32_fsinfo_sector_parms
  1491 0000D5F3 7221                <1> 	jc	short update_fat32_fsinfo_sector_retn
  1492                              <1> 
  1493 0000D5F5 8B463A              <1> 	mov	eax, [esi+LD_BPB+BPB_Reserved] ; Free Cluster Count
  1494 0000D5F8 8B563E              <1> 	mov	edx, [esi+LD_BPB+BPB_Reserved+4] ; First free Cluster	
  1495                              <1> 
  1496                              <1>         ;mov	ebx, DOSBootSectorBuff
  1497 0000D5FB 8983E8010000        <1> 	mov	[ebx+488], eax
  1498 0000D601 8993EC010000        <1> 	mov	[ebx+492], edx	
  1499                              <1> 
  1500 0000D607 A1[54940100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  1501 0000D60C B901000000          <1> 	mov	ecx, 1
  1502 0000D611 E838550000          <1> 	call	disk_write
  1503                              <1> 	;jnc     short update_fat32_fsinfo_sector_retn
  1504                              <1> 
  1505                              <1> 	; 15/10/2016 (1Dh -> 18)
  1506                              <1> 	; 23/03/2016 (1Dh)
  1507                              <1> 	;mov	eax, 18 ; Drive not ready or write error
  1508                              <1> 
  1509                              <1> update_fat32_fsinfo_sector_retn:
  1510 0000D616 C3                  <1> 	retn
  1511                              <1> 
  1512                              <1> get_fat32_fsinfo_sector_parms:
  1513                              <1> 	; 15/10/2016
  1514                              <1> 	; 23/03/2016
  1515                              <1> 	; 01/03/2016
  1516                              <1> 	; 29/02/2016 (TRDOS 386 =  TRDOS v2.0)
  1517                              <1> 	; INPUT ->
  1518                              <1> 	;	ESI = Logical dos drive description table address
  1519                              <1> 	; OUTPUT ->
  1520                              <1> 	;	ESI = Logical dos drive description table address
  1521                              <1> 	;	EBX = FSINFO sector buffer address (DOSBootSectorBuff)	
  1522                              <1> 	;	CF = 0 -> OK..
  1523                              <1> 	;	   EAX = FsInfo sector address
  1524                              <1> 	;	   ECX = Free cluster count
  1525                              <1> 	;	   EDX = First free cluster 	
  1526                              <1> 	;	CF = 1 -> Error code in AL (EAX)
  1527                              <1> 	;	   EBX = 0
  1528                              <1> 	;	
  1529                              <1> 	;	[CFS_FAT32FSINFOSEC] = FAT32 FSINFO sector address
  1530                              <1>         ;
  1531                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
  1532                              <1> 
  1533 0000D617 0FB74636            <1> 	movzx	eax, word [esi+LD_BPB+FAT32_FSInfoSec]
  1534 0000D61B 03466C              <1> 	add	eax, [esi+LD_StartSector]
  1535 0000D61E A3[54940100]        <1> 	mov	[CFS_FAT32FSINFOSEC], eax
  1536                              <1> 	
  1537 0000D623 BB[A68F0100]        <1>         mov     ebx, DOSBootSectorBuff
  1538 0000D628 B901000000          <1> 	mov	ecx, 1
  1539 0000D62D E82B550000          <1> 	call	disk_read
  1540 0000D632 7232                <1> 	jc	short loc_read_FAT32_fsinfo_sec_err
  1541                              <1> 
  1542 0000D634 BB[A68F0100]        <1> 	mov	ebx, DOSBootSectorBuff
  1543                              <1> 
  1544 0000D639 813B52526141        <1> 	cmp	dword [ebx], 41615252h
  1545 0000D63F 751E                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  1546                              <1> 
  1547 0000D641 81BBE4010000727241- <1> 	cmp	dword [ebx+484], 61417272h
  1547 0000D64A 61                  <1>
  1548 0000D64B 7512                <1> 	jne	short loc_read_FAT32_fsinfo_sec_stc
  1549                              <1> 
  1550 0000D64D A1[54940100]        <1> 	mov	eax, [CFS_FAT32FSINFOSEC]
  1551 0000D652 8B8BE8010000        <1> 	mov	ecx, [ebx+488] ; free cluster count
  1552 0000D658 8B93EC010000        <1> 	mov	edx, [ebx+492] ; first (next) free cluster	
  1553                              <1> 
  1554 0000D65E C3                  <1> 	retn
  1555                              <1> 
  1556                              <1> loc_read_FAT32_fsinfo_sec_stc: 
  1557                              <1> 	; 15/10/2016 (0Bh -> 28)
  1558 0000D65F B81C000000          <1> 	mov	eax, 28 ; Invalid format!
  1559 0000D664 EB05                <1> 	jmp	short loc_read_FAT32_fsinfo_sec_stc_retn
  1560                              <1> 
  1561                              <1> loc_read_FAT32_fsinfo_sec_err:
  1562                              <1> 	; 15/10/2016 (15h -> 17)
  1563                              <1> 	; 23/03/2016 (15h)
  1564 0000D666 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error
  1565                              <1> 
  1566                              <1> loc_read_FAT32_fsinfo_sec_stc_retn:
  1567 0000D66B 29DB                <1> 	sub	ebx, ebx ; 0
  1568 0000D66D F9                  <1> 	stc
  1569 0000D66E C3                  <1> 	retn
  1570                              <1> 
  1571                              <1> add_new_cluster:
  1572                              <1> 	; 15/10/2016
  1573                              <1> 	; 16/05/2016
  1574                              <1> 	; 18/03/2016, 24/03/2016
  1575                              <1> 	; 11/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1576                              <1> 	; 30/07/2011 (DRV_FAT.ASM)
  1577                              <1> 	; 11/09/2010
  1578                              <1> 	; INPUT ->
  1579                              <1> 	;	ESI = Logical dos drv desc. table address
  1580                              <1> 	;	EAX = Last cluster
  1581                              <1> 	; OUTPUT ->
  1582                              <1> 	;	ESI = Logical dos drv desc. table address
  1583                              <1> 	;	EAX = New Last cluster (next cluster)
  1584                              <1> 	;	cf = 1 -> error code in EAX (AL)
  1585                              <1> 	;	cf = 1 -> DX = sectors per cluster
  1586                              <1> 	;	ECX = Free sectors
  1587                              <1> 	; NOTE:
  1588                              <1> 	; This procedure does not update lm date&time !
  1589                              <1> 	;
  1590                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, EDI)
  1591                              <1> 	;
  1592                              <1> 
  1593 0000D66F A3[84950100]        <1> 	mov	[FAT_anc_LCluster], eax
  1594                              <1> 	
  1595 0000D674 E844F9FFFF          <1> 	call	get_first_free_cluster
  1596 0000D679 720B                <1> 	jc	short loc_add_new_cluster_retn
  1597                              <1> 	; EAX >= 2 and EAX < FFFFFFFFh is valid
  1598                              <1> 
  1599 0000D67B 89C2                <1> 	mov	edx, eax
  1600                              <1> 
  1601 0000D67D 42                  <1> 	inc	edx
  1602                              <1> 	;jnz	short loc_add_new_cluster_check_ffc_eax
  1603 0000D67E 7516                <1> 	jnz	short loc_add_new_cluster_save_fcc
  1604                              <1> 
  1605                              <1> loc_add_new_cluster_no_disk_space_retn:
  1606 0000D680 B827000000          <1> 	mov	eax, 27h ; MSDOS err => insufficient disk space
  1607                              <1> loc_add_new_cluster_stc_retn:
  1608 0000D685 F9                  <1> 	stc
  1609                              <1> loc_add_new_cluster_retn:
  1610 0000D686 0FB65E13            <1> 	movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  1611 0000D68A 8B4E74              <1> 	mov	ecx, [esi+LD_FreeSectors]
  1612                              <1> 	;xor	edx, edx
  1613                              <1> 	;stc
  1614 0000D68D C3                  <1> 	retn
  1615                              <1> 
  1616                              <1> loc_anc_invalid_format_stc_retn:
  1617 0000D68E F9                  <1> 	stc
  1618                              <1> loc_add_new_cluster_invalid_format_retn:
  1619                              <1> 	; 15/10/2016 (0Bh -> 28)
  1620 0000D68F B81C000000          <1> 	mov	eax, 28 ; Invalid format
  1621 0000D694 EBF0                <1> 	jmp	short loc_add_new_cluster_retn 
  1622                              <1> 
  1623                              <1> ;loc_add_new_cluster_check_ffc_eax:
  1624                              <1> ;	cmp	eax, 2
  1625                              <1> ;	jb	short loc_add_new_cluster_invalid_format_retn
  1626                              <1> 
  1627                              <1> loc_add_new_cluster_save_fcc:  
  1628 0000D696 A3[88950100]        <1> 	mov	[FAT_anc_FFCluster], eax
  1629                              <1> 
  1630 0000D69B 83E802              <1> 	sub	eax, 2
  1631 0000D69E 0FB65E13            <1>         movzx   ebx, byte [esi+LD_BPB+SecPerClust]
  1632 0000D6A2 F7E3                <1> 	mul	ebx
  1633 0000D6A4 09D2                <1> 	or	edx, edx
  1634 0000D6A6 75E6                <1> 	jnz	short loc_anc_invalid_format_stc_retn
  1635                              <1> 
  1636                              <1> loc_add_new_cluster_allocate_cluster:
  1637                              <1> 	; 18/03/2016
  1638 0000D6A8 92                  <1> 	xchg	edx, eax ; eax = 0
  1639                              <1> 	; 16/05/2016
  1640                              <1> 	;cmp	[ClusterBuffer_Valid], al ; 0
  1641                              <1> 	;jna	short loc_anc_clear_cluster_buffer
  1642                              <1> 	;; 'copy' command, 
  1643                              <1> 	;; writing destination file clust after reading source file clust
  1644                              <1> 	;mov	[ClusterBuffer_Valid], al ; 0 ; reset
  1645                              <1> 	;jmp	short loc_add_new_cluster_write_nc_to_disk
  1646                              <1> 
  1647                              <1> loc_anc_clear_cluster_buffer:
  1648                              <1> 	; 11/03/2016
  1649                              <1> 	; Clear buffer
  1650 0000D6A9 BF00000700          <1> 	mov	edi, Cluster_Buffer ; 70000h (for current TRDOS 386 version)
  1651 0000D6AE 89D9                <1> 	mov	ecx, ebx ; sector count
  1652 0000D6B0 C1E107              <1> 	shl	ecx, 7 ; 1 sector = 512 bytes -> 128 double words
  1653                              <1> 	;xor	eax, eax ; 0
  1654 0000D6B3 F3AB                <1> 	rep	stosd
  1655                              <1> 
  1656                              <1> loc_add_new_cluster_write_nc_to_disk:
  1657                              <1> 	; 11/03/2016
  1658                              <1> 	;xchg	eax, edx ; edx = 0, eax = sector offset
  1659 0000D6B5 89D0                <1> 	mov	eax, edx
  1660 0000D6B7 034668              <1>         add     eax, [esi+LD_DATABegin]
  1661 0000D6BA 72D3                <1> 	jc	short loc_add_new_cluster_invalid_format_retn 
  1662                              <1> 		
  1663 0000D6BC 89D9                <1> 	mov	ecx, ebx ; ECX = sectors per cluster (<256)
  1664 0000D6BE BB00000700          <1> 	mov	ebx, Cluster_Buffer
  1665 0000D6C3 E886540000          <1> 	call	disk_write
  1666 0000D6C8 7307                <1> 	jnc	short loc_add_new_cluster_update_fat_nlc
  1667                              <1> 	
  1668                              <1> 	; 15/10/2016 (1Dh -> 18)
  1669 0000D6CA B812000000          <1> 	mov	eax, 18 ; Write Error
  1670 0000D6CF EBB4                <1> 	jmp	short loc_add_new_cluster_stc_retn
  1671                              <1> 
  1672                              <1> loc_add_new_cluster_update_fat_nlc:
  1673 0000D6D1 A1[88950100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  1674 0000D6D6 31C9                <1> 	xor	ecx, ecx
  1675 0000D6D8 890D[B2910100]      <1> 	mov	[FAT_ClusterCounter], ecx ; 0 ; reset
  1676 0000D6DE 49                  <1> 	dec	ecx ; 0FFFFFFFFh
  1677 0000D6DF E8ACF9FFFF          <1> 	call	update_cluster
  1678 0000D6E4 7304                <1> 	jnc	short loc_add_new_cluster_update_fat_plc
  1679 0000D6E6 09C0                <1> 	or	eax, eax ;EAX = 0 -> cluster value is 0 or eocc
  1680 0000D6E8 759B                <1> 	jnz	short loc_add_new_cluster_stc_retn
  1681                              <1> 
  1682                              <1> loc_add_new_cluster_update_fat_plc:
  1683 0000D6EA A1[84950100]        <1> 	mov	eax, [FAT_anc_LCluster]
  1684 0000D6EF 8B0D[88950100]      <1> 	mov	ecx, [FAT_anc_FFCluster]
  1685 0000D6F5 E896F9FFFF          <1> 	call	update_cluster
  1686 0000D6FA 7314                <1> 	jnc	short loc_add_new_cluster_save_fat_buffer
  1687 0000D6FC 09C0                <1> 	or	eax, eax ; EAX = 0 -> cluster value is 0 or eocc
  1688 0000D6FE 7410                <1> 	jz	short loc_add_new_cluster_save_fat_buffer
  1689                              <1> 
  1690                              <1> loc_anc_save_fat_buffer_err_retn:
  1691                              <1> 	;cmp	byte [FAT_ClusterCounter], 1
  1692                              <1> 	;jb	short loc_add_new_cluster_retn
  1693                              <1> 
  1694 0000D700 66BB00FF            <1> 	mov	bx, 0FF00h ; recalculate free space (BL = 0)
  1695                              <1> 			   ; (BH = FFh -> Use ESI as Drv Param. Tbl.)
  1696 0000D704 50                  <1> 	push	eax
  1697 0000D705 E8D8FCFFFF          <1> 	call	calculate_fat_freespace
  1698 0000D70A 58                  <1> 	pop	eax
  1699 0000D70B E975FFFFFF          <1>         jmp     loc_add_new_cluster_stc_retn
  1700                              <1> 
  1701                              <1> loc_add_new_cluster_save_fat_buffer:
  1702                              <1> 	;cmp	byte [FAT_BuffValidData], 2
  1703                              <1> 	;jne	short loc_add_new_cluster_calc_FAT_freespace 
  1704                              <1> 	;Byte [FAT_BuffValidData] =  2 
  1705 0000D710 E838FCFFFF          <1> 	call	save_fat_buffer
  1706 0000D715 72E9                <1> 	jc	short loc_anc_save_fat_buffer_err_retn
  1707                              <1> 
  1708                              <1> loc_add_new_cluster_calc_FAT_freespace:
  1709                              <1> 	;mov	eax, 1 ; Only one Cluster
  1710 0000D717 A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
  1711 0000D71C 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> ESI -> Dos drv desc. table
  1712                              <1> 		; BL = 1 -> add cluster
  1713 0000D720 B301                <1> 	mov	bl, 01h ; BL = 1 -> add clusters
  1714                              <1> 	; NOTE: EAX value will be added to Free Cluster Count
  1715                              <1> 	; (Free Cluster Count is decreased when EAX value is negative)
  1716 0000D722 E8BBFCFFFF          <1>         call    calculate_fat_freespace
  1717                              <1> 	;ECX = 0 -> no error, ECX > 0 -> error or invalid return
  1718 0000D727 21C9                <1> 	and	ecx, ecx ; ECX = 0 -> valid free sector count
  1719 0000D729 7409                <1> 	jz	short loc_add_new_cluster_return_cluster_number
  1720                              <1> 
  1721                              <1> loc_add_new_cluster_recalc_FAT_freespace:
  1722 0000D72B 66BB00FF            <1> 	mov	bx, 0FF00h  ; recalculate free space
  1723 0000D72F E8AEFCFFFF          <1>         call    calculate_fat_freespace
  1724                              <1> 	; cf = 0
  1725                              <1> loc_add_new_cluster_return_cluster_number:
  1726 0000D734 89C1                <1> 	mov	ecx, eax ; Free sector count
  1727 0000D736 A1[88950100]        <1> 	mov	eax, [FAT_anc_FFCluster]
  1728 0000D73B 0FB65E13            <1> 	movzx	ebx, byte [esi+LD_BPB+SecPerClust]
  1729                              <1> 	;mov	edi, Cluster_Buffer
  1730 0000D73F 31D2                <1> 	xor	edx, edx
  1731 0000D741 C3                  <1>         retn
  1732                              <1> 
  1733                              <1> write_cluster:
  1734                              <1> 	; 15/10/2016
  1735                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1736                              <1> 	;
  1737                              <1> 	; INPUT ->
  1738                              <1> 	;	EAX = Cluster Number (Sector index for SINGLIX FS)
  1739                              <1> 	;	ESI = Logical DOS Drive Description Table address
  1740                              <1> 	;	EBX = Cluster (File R/W) Buffer address (max. 64KB)
  1741                              <1> 	;	Only for SINGLIX FS:
  1742                              <1> 	;	EDX = File Number (The 1st FDT address) 
  1743                              <1> 	; OUTPUT ->
  1744                              <1> 	;	cf = 1 -> Cluster can not be written onto disk
  1745                              <1> 	;	    EAX > 0 -> Error number
  1746                              <1> 	;	cf = 0 -> Cluster has been written successfully
  1747                              <1> 	;
  1748                              <1> 	; (Modified registers: EAX, ECX, EBX, EDX)
  1749                              <1> 	
  1750 0000D742 0FB64E13            <1> 	movzx	ecx, byte [esi+LD_BPB+BPB_SecPerClust] 
  1751                              <1> 	; CL = 1 = [esi+LD_FS_Reserved2] ; SectPerClust for Singlix FS
  1752                              <1> 
  1753                              <1> write_file_sectors: ; 16/03/2016
  1754 0000D746 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
  1755 0000D74A 761C                <1> 	jna	short write_fs_cluster
  1756                              <1> 
  1757                              <1> write_fat_file_sectors: 
  1758 0000D74C 83E802              <1> 	sub	eax, 2 ; Beginning cluster number is always 2
  1759 0000D74F 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+BPB_SecPerClust] ; 18/03/2016 
  1760 0000D753 F7E2                <1> 	mul	edx
  1761 0000D755 034668              <1> 	add	eax, [esi+LD_DATABegin] ; absolute address of the cluster
  1762                              <1> 
  1763                              <1> 	; EAX = Disk sector address
  1764                              <1> 	; ECX = Sector count
  1765                              <1> 	; EBX = Buffer address
  1766                              <1> 	; (EDX = 0)
  1767                              <1> 	; ESI = Logical DOS drive description table address	
  1768                              <1> 
  1769 0000D758 E8F1530000          <1> 	call	disk_write
  1770 0000D75D 7306                <1> 	jnc	short wclust_retn
  1771                              <1> 	
  1772                              <1> 	; 15/10/2016 (1Dh -> 18)
  1773 0000D75F B812000000          <1> 	mov	eax, 18 ; Drive not ready or write error !
  1774 0000D764 C3                  <1> 	retn
  1775                              <1> 
  1776                              <1> wclust_retn:
  1777 0000D765 29C0                <1> 	sub	eax, eax ; 0
  1778 0000D767 C3                  <1> 	retn
  1779                              <1> 
  1780                              <1> write_fs_cluster:
  1781                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1782                              <1> 	; Singlix FS
  1783                              <1> 	
  1784                              <1> 	; EAX = Cluster number is sector index number of the file (eax)
  1785                              <1> 	
  1786                              <1> 	; EDX = File number is the first File Descriptor Table address 
  1787                              <1> 	;	of the file. (Absolute address of the FDT).
  1788                              <1> 	
  1789                              <1> 	; eax = sector index (0 for the first sector)
  1790                              <1> 	; edx = FDT0 address
  1791                              <1> 		; 64 KB buffer = 128 sectors (limit) 
  1792 0000D768 B980000000          <1> 	mov	ecx, 128 ; maximum count of sectors (before eof) 
  1793 0000D76D E801000000          <1> 	call	write_fs_sectors
  1794 0000D772 C3                  <1> 	retn
  1795                              <1> 
  1796                              <1> write_fs_sectors:
  1797                              <1> 	; 21/03/2016 (TRDOS 386 =  TRDOS v2.0)
  1798 0000D773 F9                  <1> 	stc
  1799 0000D774 C3                  <1> 	retn
  1800                              <1> 
  1801                              <1> get_cluster_by_index:
  1802                              <1> 	; 29/04/2016 (TRDOS 386 =  TRDOS v2.0)
  1803                              <1> 	; INPUT ->
  1804                              <1> 	; 	EAX = Beginning cluster
  1805                              <1> 	; 	EDX = Sector index in disk/file section
  1806                              <1> 	;	      (Only for SINGLIX file system!)
  1807                              <1> 	; 	ECX = Cluster sequence number after the beginning cluster
  1808                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  1809                              <1> 	; OUTPUT ->
  1810                              <1> 	;	EAX = Cluster number 
  1811                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  1812                              <1> 	;
  1813                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  1814                              <1> 	;	
  1815 0000D775 807E0301            <1> 	cmp	byte [esi+LD_FATType], 1
  1816 0000D779 721E                <1>         jb      short get_fs_section_by_index 
  1817                              <1> 
  1818 0000D77B 3B4E78              <1> 	cmp	ecx, [esi+LD_Clusters]
  1819 0000D77E 7207                <1> 	jb	short gcbi_1
  1820                              <1> gcbi_0:
  1821 0000D780 F9                  <1> 	stc
  1822 0000D781 B823000000          <1> 	mov	eax, 23h ; Cluster not available ! 
  1823                              <1> 			 ; MSDOS error code: FCB unavailable
  1824 0000D786 C3                  <1> 	retn
  1825                              <1> gcbi_1:
  1826 0000D787 51                  <1> 	push	ecx
  1827 0000D788 E8D9F5FFFF          <1> 	call	get_next_cluster
  1828 0000D78D 59                  <1> 	pop	ecx
  1829 0000D78E 7203                <1> 	jc	short gcbi_3
  1830 0000D790 E2F5                <1> 	loop	gcbi_1
  1831                              <1> gcbi_2:
  1832 0000D792 C3                  <1> 	retn
  1833                              <1> gcbi_3:
  1834 0000D793 09C0                <1> 	or	eax, eax
  1835 0000D795 74E9                <1> 	jz	short gcbi_0
  1836 0000D797 F5                  <1> 	cmc 	; stc
  1837 0000D798 C3                  <1> 	retn
  1838                              <1> 
  1839                              <1> get_fs_section_by_index:
  1840                              <1> 	; 29/04/2016 (TRDOS 386 =  TRDOS v2.0)
  1841                              <1> 	; INPUT ->
  1842                              <1> 	; 	EAX = Beginning FDT number/address
  1843                              <1> 	; 	EDX = Sector index in disk/file section
  1844                              <1> 	; 	ECX = Sector sequence number after the beginning FDT
  1845                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  1846                              <1> 	; OUTPUT ->
  1847                              <1> 	; 	EAX = FDT number/address
  1848                              <1> 	; 	EDX = Sector index of the section (0,1,2,3,4...)
  1849                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  1850                              <1> 	;
  1851                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  1852                              <1> 	;
  1853 0000D799 B8FFFFFFFF          <1> 	mov	eax, 0FFFFFFFFh
  1854 0000D79E C3                  <1> 	retn
  1855                              <1> 
  1856                              <1> get_last_section:
  1857                              <1> 	; 22/10/2016 (TRDOS 386 =  TRDOS v2.0)	
  1858                              <1> 	; INPUT ->
  1859                              <1> 	; 	EAX = (The 1st) FDT number/address
  1860                              <1> 	; 	ESI = Logical DOS Drive Description Table address
  1861                              <1> 	; OUTPUT ->
  1862                              <1> 	; 	EAX = FDT number/address of the last section
  1863                              <1> 	; 	EDX = Last sector of the section (0,1,2,3,4...)
  1864                              <1> 	;	[glc_index] = sector index number of the last sector
  1865                              <1> 	;		      (for file, not for the last section)  	
  1866                              <1> 	;		   	
  1867                              <1> 	;	cf = 1 -> Error code in AL (EAX)
  1868                              <1> 	;
  1869                              <1> 	;(Modified registers: EAX, ECX, EBX, EDX)
  1870                              <1> 	;
  1871 0000D79F B800000000          <1> 	mov	eax, 0
  1872 0000D7A4 BA00000000          <1> 	mov	edx, 0
  1873 0000D7A9 C3                  <1> 	retn
  3084                                  %include 'trdosk6.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.3) - MAIN PROGRAM : trdosk6.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 27/02/2021
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 t(trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; u1.s (27/17/2015), u2.s (03/01/2016)
    12                              <1> ; ****************************************************************************
    13                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    14                              <1> ; TRDOS2.ASM (09/11/2011)
    15                              <1> ; ----------------------------------------------------------------------------
    16                              <1> ; INT_21H.ASM (c) 2009-2011 Erdogan TAN  [14/11/2009] Last Update: 08/11/2011
    17                              <1> 
    18                              <1> sysent: ; < enter to system call >
    19                              <1> 	; 17/03/2017
    20                              <1> 	; 03/03/2017
    21                              <1> 	; 19/02/2017
    22                              <1> 	; 13/01/2017
    23                              <1> 	; 06/06/2016
    24                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
    25                              <1> 	; 16/04/2015 - 19/10/2015 (Retro UNIX 386 v1)
    26                              <1> 	; 10/04/2013 - 18/01/2014 (Retro UNIX 8086 v1)
    27                              <1> 	;
    28                              <1> 	; 'unkni' or 'sysent' is sytem entry from various traps. 
    29                              <1> 	; The trap type is determined and an indirect jump is made to 
    30                              <1> 	; the appropriate system call handler. If there is a trap inside
    31                              <1> 	; the system a jump to panic is made. All user registers are saved 
    32                              <1> 	; and u.sp points to the end of the users stack. The sys (trap)
    33                              <1> 	; instructor is decoded to get the the system code part (see
    34                              <1> 	; trap instruction in the PDP-11 handbook) and from this 
    35                              <1> 	; the indirect jump address is calculated. If a bad system call is
    36                              <1> 	; made, i.e., the limits of the jump table are exceeded, 'badsys'
    37                              <1> 	; is called. If the call is legitimate control passes to the
    38                              <1> 	; appropriate system routine.
    39                              <1> 	;
    40                              <1> 	; Calling sequence:
    41                              <1> 	;	Through a trap caused by any sys call outside the system.
    42                              <1> 	; Arguments:
    43                              <1> 	;	Arguments of particular system call.	
    44                              <1> 	; ...............................................................
    45                              <1> 	;	
    46                              <1> 	; Retro UNIX 8086 v1 modification: 
    47                              <1> 	;       System call number is in EAX register.
    48                              <1> 	;
    49                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
    50                              <1> 	;	registers depending of function details.
    51                              <1>   	;
    52                              <1> 	; 16/04/2015
    53 0000D7AA 368925[5C030300]    <1>         mov     [ss:u.sp], esp ; Kernel stack points to return address
    54                              <1> 
    55                              <1> 	; save user registers
    56 0000D7B1 1E                  <1> 	push	ds
    57 0000D7B2 06                  <1> 	push	es
    58 0000D7B3 0FA0                <1> 	push	fs
    59 0000D7B5 0FA8                <1> 	push	gs
    60 0000D7B7 60                  <1> 	pushad  ; eax, ecx, edx, ebx, esp -before pushad-, ebp, esi, edi
    61                              <1> 	;
    62                              <1> 	; ESPACE = [ss:u.sp] - esp ; 4*12 = 48 ; 17/09/2015 ; 06/06/2016
    63                              <1> 	; 	(ESPACE is size of space in kernel stack 
    64                              <1> 	;	for saving/restoring user registers.)
    65                              <1> 	;
    66 0000D7B8 50                  <1> 	push	eax ; 01/07/2015
    67 0000D7B9 66B81000            <1> 	mov     ax, KDATA
    68 0000D7BD 8ED8                <1>         mov     ds, ax
    69 0000D7BF 8EC0                <1>         mov     es, ax
    70 0000D7C1 8EE0                <1>         mov     fs, ax
    71 0000D7C3 8EE8                <1>         mov     gs, ax
    72 0000D7C5 A1[D0890100]        <1> 	mov	eax, [k_page_dir]
    73 0000D7CA 0F22D8              <1> 	mov	cr3, eax
    74 0000D7CD 58                  <1> 	pop	eax ; 01/07/2015
    75                              <1> 	; 19/10/2015
    76 0000D7CE FC                  <1> 	cld
    77                              <1> 	;
    78 0000D7CF FE05[5B030300]      <1> 	inc	byte [sysflg]
    79                              <1> 		; incb sysflg / indicate a system routine is in progress
    80 0000D7D5 FB                  <1>         sti 	; 18/01/2014
    81 0000D7D6 0F85DF9DFFFF        <1> 	jnz     panic ; 24/05/2013
    82                              <1> 		; beq 1f
    83                              <1> 		; jmp panic ; / called if trap inside system
    84                              <1> ;1:
    85                              <1> 	; 17/03/2017
    86 0000D7DC 80642438FE          <1> 	and	byte [esp+ESPACE+8], ~1 ; clear carry flag
    87                              <1> 
    88                              <1> 	; 16/04/2015
    89 0000D7E1 A3[64030300]        <1> 	mov	[u.r0], eax
    90 0000D7E6 8925[60030300]      <1> 	mov	[u.usp], esp ; kernel stack points to user's registers
    91                              <1> 
    92                              <1> 	; 13/01/2017 (TRDOS 386 Feaure only !)
    93 0000D7EC 803D[D4030300]00    <1> 	cmp	byte [u.t_lock], 0 ; timer interrupt lock ?
    94 0000D7F3 0F879D010000        <1> 	ja	sysrele		   ; yes, sys release only !!!
    95                              <1> 
    96                              <1> 		; mov $s.syst+2,clockp
    97                              <1> 		; mov r0,-(sp) / save user registers 
    98                              <1> 		; mov sp,u.r0 / pointer to bottom of users stack 
    99                              <1> 			   ; / in u.r0
   100                              <1> 		; mov r1,-(sp)
   101                              <1> 		; mov r2,-(sp)
   102                              <1> 		; mov r3,-(sp)
   103                              <1> 		; mov r4,-(sp)
   104                              <1> 		; mov r5,-(sp)
   105                              <1> 		; mov ac,-(sp) / "accumulator" register for extended
   106                              <1> 		             ; / arithmetic unit
   107                              <1> 		; mov mq,-(sp) / "multiplier quotient" register for the
   108                              <1> 		             ; / extended arithmetic unit
   109                              <1> 		; mov sc,-(sp) / "step count" register for the extended
   110                              <1> 		             ; / arithmetic unit
   111                              <1> 		; mov sp,u.sp / u.sp points to top of users stack
   112                              <1> 		; mov 18.(sp),r0 / store pc in r0
   113                              <1> 		; mov -(r0),r0 / sys inst in r0      10400xxx
   114                              <1> 		; sub $sys,r0 / get xxx code
   115 0000D7F9 C1E002              <1> 	shl	eax, 2
   116                              <1> 		; asl r0 / multiply by 2 to jump indirect in bytes
   117 0000D7FC 3DB8000000          <1> 	cmp	eax, end_of_syscalls - syscalls
   118                              <1> 		; cmp r0,$2f-1f / limit of table (35) exceeded
   119                              <1> 	;jnb	short badsys
   120                              <1> 		; bhis badsys / yes, bad system call
   121 0000D801 F5                  <1> 	cmc
   122 0000D802 9C                  <1> 	pushf	
   123 0000D803 50                  <1> 	push	eax
   124 0000D804 8B2D[5C030300]      <1>  	mov 	ebp, [u.sp] ; Kernel stack at the beginning of sys call
   125 0000D80A B0FE                <1> 	mov	al, 0FEh ; 11111110b
   126 0000D80C 1400                <1> 	adc	al, 0 ; al = al + cf
   127 0000D80E 204508              <1> 	and	[ebp+8], al ; flags (reset carry flag)
   128                              <1> 		; bic $341,20.(sp) / set users processor priority to 0 
   129                              <1> 				 ; / and clear carry bit
   130 0000D811 5D                  <1> 	pop	ebp ; eax
   131 0000D812 9D                  <1> 	popf
   132 0000D813 0F8208020000        <1>         jc      badsys
   133 0000D819 A1[64030300]        <1> 	mov	eax, [u.r0]
   134                              <1> 	; system call registers: EAX, EDX, ECX, EBX, ESI, EDI
   135 0000D81E FFA5[24D80000]      <1> 	jmp	dword [ebp+syscalls]
   136                              <1> 		; jmp *1f(r0) / jump indirect thru table of addresses
   137                              <1> 		            ; / to proper system routine.
   138                              <1> syscalls: ; 1:
   139                              <1> 	; 31/12/2017
   140                              <1> 	; 28/02/2017
   141                              <1> 	; 20/02/2017
   142                              <1> 	; 19/02/2017
   143                              <1> 	; 15/10/2016
   144                              <1> 	; 20/05/2016
   145                              <1> 	; 19/05/2016
   146                              <1> 	; 16/05/2016
   147                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   148                              <1> 	; 21/09/2015
   149                              <1> 	; 01/07/2015
   150                              <1> 	; 16/04/2015 (32 bit address modification) 
   151 0000D824 [481A0100]          <1> 	dd sysver	; 0 ; Get TRDOS 386 version number (v2.0)	
   152 0000D828 [83DA0000]          <1> 	dd sysexit 	; 1
   153 0000D82C [58DC0000]          <1> 	dd sysfork 	; 2
   154 0000D830 [8BE00000]          <1> 	dd sysread 	; 3
   155 0000D834 [AAE00000]          <1> 	dd syswrite 	; 4
   156 0000D838 [41DE0000]          <1> 	dd sysopen 	; 5
   157 0000D83C [62E00000]          <1> 	dd sysclose 	; 6
   158 0000D840 [DADB0000]          <1> 	dd syswait 	; 7
   159 0000D844 [70DD0000]          <1> 	dd syscreat 	; 8
   160 0000D848 [9C280100]          <1> 	dd sysrename	; 9  ; TRDOS 386, Rename File (31/12/2017)
   161 0000D84C [17240100]          <1> 	dd sysdelete	; 10 ; TRDOS 386, Delete File (29/12/2017)
   162 0000D850 [E50D0100]          <1> 	dd sysexec 	; 11
   163 0000D854 [41250100]          <1> 	dd syschdir 	; 12
   164 0000D858 [06270100]          <1> 	dd systime 	; 13 ; TRDOS 386, Get Sys Date&Time (30/12/2017)
   165 0000D85C [24E00000]          <1> 	dd sysmkdir 	; 14
   166 0000D860 [75250100]          <1> 	dd syschmod 	; 15 ; TRDOS 386, Change Attributes (30/12/2017) 
   167 0000D864 [7E240100]          <1> 	dd sysrmdir 	; 16 ; TRDOS 386, Remove Directory (29/12/2017)
   168 0000D868 [C0100100]          <1> 	dd sysbreak 	; 17
   169 0000D86C [5B260100]          <1> 	dd sysdrive 	; 18 ; TRDOS 386, Get/Set Current Drv (30/12/2017) 
   170 0000D870 [01110100]          <1> 	dd sysseek 	; 19
   171 0000D874 [13110100]          <1> 	dd systell 	; 20
   172 0000D878 [BD290100]          <1> 	dd sysmem 	; 21 ; TRDOS 386, Get Total&Free Mem (31/12/2017)
   173 0000D87C [F3290100]          <1> 	dd sysprompt 	; 22 ; TRDOS 386, Change Cmd Prompt (31/12/2017)
   174 0000D880 [352A0100]          <1> 	dd syspath 	; 23 ; TRDOS 386, Get/Set Run Path (31/12/2017)
   175 0000D884 [A22A0100]          <1> 	dd sysenv 	; 24 ; TRDOS 386, Get/Set Env Vars (31/12/2017)
   176 0000D888 [87270100]          <1> 	dd sysstime 	; 25 ; TRDOS 386, Set Sys Date&Time (30/12/2017)
   177 0000D88C [79110100]          <1> 	dd sysquit 	; 26
   178 0000D890 [6D110100]          <1> 	dd sysintr 	; 27
   179 0000D894 [AA260100]          <1> 	dd sysdir 	; 28 ; TRDOS 386, Get Curr Drive&Dir (30/12/2017) 
   180 0000D898 [41E10000]          <1> 	dd sysemt 	; 29
   181 0000D89C [E5260100]          <1> 	dd sysldrvt	; 30 ; TRDOS 386, Get Logical DOS DDT (30/12/2017)
   182 0000D8A0 [F2E20000]          <1> 	dd sysvideo 	; 31 ; TRDOS 386 Video Functions (16/05/2016)
   183 0000D8A4 [6C340100]          <1> 	dd sysaudio 	; 32 ; TRDOS 386 Audio Functions (16/05/2016)
   184 0000D8A8 [5AE10000]          <1> 	dd systimer 	; 33 ; TRDOS 386 Timer Functions (18/05/2016)
   185 0000D8AC [BA110100]          <1> 	dd syssleep 	; 34 ; Retro UNIX 8086 v1 feature only !
   186                              <1> 			     ; 11/06/2014
   187 0000D8B0 [E9110100]          <1> 	dd sysmsg	; 35 ; Retro UNIX 386 v1 feature only !
   188                              <1> 			     ; 01/07/2015
   189 0000D8B4 [06130100]          <1> 	dd sysgeterr	; 36 ; Retro UNIX 386 v1 feature only !
   190                              <1> 			     ; 21/09/2015 - get last error number
   191 0000D8B8 [EE230100]          <1> 	dd sysfpstat	; 37 ; TRDOS 386 FPU state option (28/02/2017)
   192 0000D8BC [571A0100]          <1> 	dd syspri 	; 38 ; change priority - TRDOS 386 (20/05/2016)
   193 0000D8C0 [96D90000]          <1> 	dd sysrele	; 39 ; TRDOS 386 (19/05/2016) (0 -> 39)
   194 0000D8C4 [8A1B0100]          <1> 	dd sysfff	; 40 ; Find First File - TRDOS 386 (15/10/2016)
   195 0000D8C8 [691C0100]          <1> 	dd sysfnf	; 41 ; Find Next File - TRDOS 386 (15/10/2016)
   196 0000D8CC [D9220100]          <1> 	dd sysalloc	; 42 ; Allocate contiguous memory block/pages
   197                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions		
   198 0000D8D0 [97230100]          <1> 	dd sysdalloc	; 43 ; Deallocate contiguous memory block/pages
   199                              <1> 			     ; TRDOS 386 (19/02/2017) DMA buff fuctions
   200 0000D8D4 [D2230100]          <1> 	dd syscalbac	; 44 ; IRQ Callback and Signal Response Byte
   201                              <1> 			     ; service setup - TRDOS 386 (20/02/2017)
   202                              <1> 			     ; 28/08/2017 (20/08/2017)	
   203 0000D8D8 [FD3C0100]          <1> 	dd sysdma	; 45 ; TRDOS 386 - (ISA) DMA service
   204                              <1> 	
   205                              <1> end_of_syscalls:
   206                              <1> 
   207                              <1> error:
   208                              <1> 	; 18/05/2016
   209                              <1> 	; 13/05/2016
   210                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   211                              <1> 	; 16/04/2015 - 17/09/2015 (Retro UNIX 386 v1)
   212                              <1> 	; 10/04/2013 - 07/08/2013 (Retro UNIX 8086 v1)
   213                              <1> 	;
   214                              <1> 	; 'error' merely sets the error bit off the processor status (c-bit)
   215                              <1> 	; then falls right into the 'sysret', 'sysrele' return sequence.
   216                              <1> 	;
   217                              <1> 	; INPUTS -> none
   218                              <1> 	; OUTPUTS ->
   219                              <1> 	;	processor status - carry (c) bit is set (means error)
   220                              <1> 	;
   221                              <1> 	; 26/05/2013 (Stack pointer must be reset here! 
   222                              <1> 	; 	      Because, jumps to error procedure
   223                              <1> 	;	      disrupts push-pop nesting balance)
   224                              <1> 	;
   225 0000D8DC 8B2D[5C030300]      <1> 	mov	ebp, [u.sp] ; interrupt (system call) return (iretd) address
   226 0000D8E2 804D0801            <1> 	or	byte [ebp+8], 1  ; set carry bit of flags register
   227                              <1> 				 ; (system call will return with cf = 1)
   228                              <1> 		; bis $1,20.(r1) / set c bit in processor status word below
   229                              <1> 		               ; / users stack
   230                              <1> 	; 17/09/2015
   231 0000D8E6 83ED30              <1> 	sub	ebp, ESPACE ; 48 ; total size of stack frame ('sysdefs.inc')
   232                              <1> 				 ; for saving/restoring user registers	
   233                              <1> 	;cmp	ebp, [u.usp]
   234                              <1> 	;je	short err0	
   235 0000D8E9 892D[60030300]      <1> 	mov	[u.usp], ebp
   236                              <1> ;err0:
   237                              <1> 	; 01/09/2015
   238 0000D8EF 8B25[60030300]      <1> 	mov	esp, [u.usp] 	    ; Retro Unix 8086 v1 modification!
   239                              <1> 				    ; 10/04/2013
   240                              <1> 				    ; (If an I/O error occurs during disk I/O,
   241                              <1> 				    ; related procedures will jump to 'error'
   242                              <1> 				    ; procedure directly without returning to 
   243                              <1> 				    ; the caller procedure. So, stack pointer
   244                              <1>                                     ; must be restored here.)
   245                              <1> 	; 13/05/2016
   246                              <1> 	; NOTE: (The last) error code is in 'u.error', it can be retrieved by
   247                              <1> 	;	'get last error' system call later. 	
   248                              <1> 
   249                              <1> 	; 03/09/2015 - 09/06/2015 - 07/08/2013
   250 0000D8F5 C605[C6030300]00    <1> 	mov 	byte [u.kcall], 0 ; namei_r, mkdir_w reset
   251                              <1> 
   252                              <1> sysret: ; < return from system call>
   253                              <1> 	; 01/03/2017
   254                              <1> 	; 28/02/2017
   255                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   256                              <1> 	; 16/04/2015 - 10/09/2015 (Retro UNIX 386 v1)
   257                              <1> 	; 10/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
   258                              <1> 	;
   259                              <1> 	; 'sysret' first checks to see if process is about to be 
   260                              <1> 	; terminated (u.bsys). If it is, 'sysexit' is called.
   261                              <1> 	; If not, following happens:	 
   262                              <1> 	; 	1) The user's stack pointer is restored.
   263                              <1> 	;	2) r1=0 and 'iget' is called to see if last mentioned
   264                              <1> 	;	   i-node has been modified. If it has, it is written out
   265                              <1> 	;	   via 'ppoke'.
   266                              <1> 	;	3) If the super block has been modified, it is written out
   267                              <1> 	;	   via 'ppoke'.				
   268                              <1> 	;	4) If the dismountable file system's super block has been
   269                              <1> 	;	   modified, it is written out to the specified device
   270                              <1> 	;	   via 'ppoke'.
   271                              <1> 	;	5) A check is made if user's time quantum (uquant) ran out
   272                              <1> 	;	   during his execution. If so, 'tswap' is called to give
   273                              <1> 	;	   another user a chance to run.
   274                              <1> 	;	6) 'sysret' now goes into 'sysrele'. 
   275                              <1> 	;	    (See 'sysrele' for conclusion.)		
   276                              <1> 	;
   277                              <1> 	; Calling sequence:
   278                              <1> 	;	jump table or 'br sysret'
   279                              <1> 	; Arguments: 
   280                              <1> 	;	-	
   281                              <1> 	; ...............................................................
   282                              <1> 	;	
   283                              <1> 	; ((AX=r1 for 'iget' input))
   284                              <1> 	;	
   285 0000D8FC 31C0                <1> 	xor	eax, eax ; 28/02/2017
   286                              <1> sysret0: ; 29/07/2015 (eax = 0, jump from sysexec)
   287 0000D8FE FEC0                <1> 	inc	al ; 04/05/2013
   288 0000D900 3805[B2030300]      <1> 	cmp	[u.bsys], al ; 1
   289                              <1> 		; tstb u.bsys / is a process about to be terminated because
   290 0000D906 0F8377010000        <1>         jnb     sysexit ; 04/05/2013
   291                              <1> 		; bne sysexit / of an error? yes, go to sysexit
   292                              <1> 	;mov	esp, [u.usp] ; 24/05/2013 (that is not needed here)
   293                              <1> 		; mov u.sp,sp / no point stack to users stack
   294 0000D90C FEC8                <1> 	dec 	al ; mov ax, 0
   295                              <1> 		; clr r1 / zero r1 to check last mentioned i-node
   296 0000D90E E83A520000          <1> 	call	iget
   297                              <1> 		; jsr r0,iget / if last mentioned i-node has been modified
   298                              <1> 		            ; / it is written out
   299                              <1> 	; 10/01/2017
   300                              <1> 	; 09/01/2017
   301                              <1> ;sysrele: ; < release >
   302                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   303                              <1> 	; 16/04/2015 - 14/10/2015 (Retro UNIX 386 v1)
   304                              <1> 	; 10/04/2013 - 07/03/2014 (Retro UNIX 8086 v1)
   305                              <1> 	;
   306                              <1> 	; 'sysrele' first calls 'tswap' if the time quantum for a user is
   307                              <1> 	;  zero (see 'sysret'). It then restores the user's registers and
   308                              <1> 	; turns off the system flag. It then checked to see if there is
   309                              <1> 	; an interrupt from the user by calling 'isintr'. If there is, 
   310                              <1> 	; the output gets flashed (see isintr) and interrupt action is
   311                              <1> 	; taken by a branch to 'intract'. If there is no interrupt from
   312                              <1> 	; the user, a rti is made.
   313                              <1> 	;
   314                              <1> 	; Calling sequence:
   315                              <1> 	;	Fall through a 'bne' in 'sysret' & ?
   316                              <1> 	; Arguments:
   317                              <1> 	;	-	
   318                              <1> 	; ...............................................................
   319                              <1> 	;	
   320                              <1> 	; 23/02/2014 (swapret)
   321                              <1> 	; 22/09/2013
   322                              <1> sysrel0: ;1:
   323 0000D913 803D[A8030300]00    <1> 	cmp	byte [u.quant], 0 ; 16/05/2013
   324                              <1> 		; tstb uquant / is the time quantum 0?
   325 0000D91A 7705                <1>         ja      short swapret
   326                              <1> 		; bne 1f / no, don't swap it out
   327                              <1> sysrelease: ; 07/12/2013 (jump from 'clock')
   328 0000D91C E8EF3F0000          <1> 	call	tswap
   329                              <1> 		; jsr r0,tswap / yes, swap it out
   330                              <1> 	
   331                              <1> ; Retro Unix 8086 v1 feature: return from 'swap' to 'swapret' address.
   332                              <1> swapret: ;1:
   333                              <1> 	; 10/09/2015
   334                              <1> 	; 01/09/2015
   335                              <1> 	; 14/05/2015
   336                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit, pm modifications)
   337                              <1> 	; 26/05/2013 (Retro UNIX 8086 v1)
   338                              <1> 	; cli
   339                              <1> 	; 24/07/2015
   340                              <1> 	;
   341                              <1> 	;; 'esp' must be already equal to '[u.usp]' here ! 
   342                              <1> 	;; mov	esp, [u.usp]
   343                              <1> 
   344                              <1> 	; 22/09/2013
   345 0000D921 E827520000          <1> 	call	isintr
   346                              <1> 	; 20/10/2013
   347 0000D926 7405                <1> 	jz	short sysrel1
   348 0000D928 E83F010000          <1> 	call	intract
   349                              <1> 		; jsr r0,isintr / is there an interrupt from the user
   350                              <1> 		;     br intract / yes, output gets flushed, take interrupt
   351                              <1> 		               ; / action
   352                              <1> sysrel1:
   353 0000D92D FA                  <1> 	cli	; 14/10/2015
   354                              <1> sysrel2:
   355                              <1> 	; 28/02/2017
   356                              <1> 	; Check if there is a (delayed) callback for current user/process
   357 0000D92E A0[D7030300]        <1> 	mov	al, [u.irqwait]
   358 0000D933 240F                <1> 	and	al, 0Fh ; is there a waiting IRQ callback service ?
   359 0000D935 7444                <1> 	jz	short sysrel8 ; no
   360                              <1> 
   361                              <1> 	; Set return to IRQ callback service and return from the service
   362 0000D937 0FB6D8              <1> 	movzx	ebx, al
   363 0000D93A 883D[D7030300]      <1> 	mov 	[u.irqwait], bh ; 0 ; reset
   364 0000D940 8A9B[98490100]      <1> 	mov	bl, [ebx+IRQenum] ; (available) IRQ index +1 (1 to 9)
   365                              <1> 	; 01/03/2017
   366 0000D946 FECB                <1> 	dec	bl ; IRQ index number, 0 to 8
   367 0000D948 7831                <1> 	js	short sysrel8 ; 0 -> FFh (not in use!?) 
   368                              <1> 	;
   369 0000D94A A0[B3030300]        <1> 	mov 	al, [u.uno] ; current process (user) number 
   370 0000D94F 3883[029C0100]      <1> 	cmp	[ebx+IRQ.owner], al
   371 0000D955 7524                <1> 	jne	short sysrel8 ; it is not the current user/process !?
   372 0000D957 F683[149C0100]01    <1> 	test	byte [ebx+IRQ.method], 1 ; callback ?
   373 0000D95E 741B                <1> 	jz	short sysrel8 ; not a callback method !?
   374                              <1> 
   375 0000D960 8B93[269C0100]      <1> 	mov	edx, [ebx+IRQ.addr] ; IRQ callback service address (virtual)
   376 0000D966 C605[D8030300]01    <1> 	mov	byte [u.r_lock], 1 ; IRQ callback service in progress flag
   377                              <1> 
   378 0000D96D E846400000          <1> 	call	wswap ; save user's registers & status 
   379                              <1> 		      ;	(for return from IRQ callback service)
   380                              <1> 
   381 0000D972 8B2D[5C030300]      <1> 	mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
   382 0000D978 895500              <1> 	mov	[ebp], edx ; IRQ call back service address
   383                              <1> sysrel8:
   384 0000D97B FE0D[5B030300]      <1> 	dec	byte [sysflg]
   385                              <1> 		; decb sysflg / turn system flag off
   386                              <1> 	
   387 0000D981 A1[B8030300]        <1> 	mov	eax, [u.pgdir]	
   388 0000D986 0F22D8              <1> 	mov	cr3, eax  ; 1st PDE points to Kernel Page Table 0 (1st 4 MB)
   389                              <1> 			  ; (others are different than kernel page tables) 
   390                              <1> 	; 10/09/2015
   391 0000D989 61                  <1> 	popad ; edi, esi, ebp, temp (icrement esp by 4), ebx, edx, ecx, eax
   392                              <1> 		; mov (sp)+,sc / restore user registers
   393                              <1> 		; mov (sp)+,mq
   394                              <1> 		; mov (sp)+,ac
   395                              <1> 		; mov (sp)+,r5
   396                              <1> 		; mov (sp)+,r4
   397                              <1> 		; mov (sp)+,r3
   398                              <1> 		; mov (sp)+,r2
   399                              <1> 	;
   400 0000D98A A1[64030300]        <1> 	mov	eax, [u.r0]  ; ((return value in EAX))
   401 0000D98F 0FA9                <1> 	pop	gs
   402 0000D991 0FA1                <1> 	pop	fs
   403 0000D993 07                  <1> 	pop	es
   404 0000D994 1F                  <1> 	pop	ds
   405                              <1> 	;or	word [esp+8], 200h ; 22/01/2017 ; force enabling interrupts
   406 0000D995 CF                  <1> 	iretd	
   407                              <1> 		; rti / no, return from interrupt
   408                              <1> 
   409                              <1> sysrele:
   410                              <1> 	; 24/03/2017
   411                              <1> 	; 28/02/2017
   412                              <1> 	; 27/02/2017
   413                              <1> 	; 29/01/2017
   414                              <1> 	; 14/01/2017
   415                              <1> 	; 13/01/2017
   416                              <1> 	; 09/01/2017, 10/01/2017, 12/01/2017
   417                              <1> 	; Major modification for TRDOS 386 (CallBack return)
   418                              <1> 	;
   419                              <1> 	; 'sysrele' system call restores previously saved
   420                              <1> 	; registers and addresses of the process
   421                              <1> 	; (Main purpose -in TRDOS 386- is to return from
   422                              <1> 	; timer callback service routine in ring 3 -user mode-.)
   423                              <1> 	;
   424                              <1> 	; check if the process is in timer callback phase
   425 0000D996 803D[D4030300]00    <1> 	cmp	byte [u.t_lock], 0 ; TIMER INT LOCK
   426                              <1> 	;je	short sysrel0 ; classic (Retro UNIX 386 type) sysrele
   427 0000D99D 7734                <1> 	ja	short sysrel3
   428                              <1> 	; 27/02/2017
   429 0000D99F 803D[D8030300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback lock	
   430 0000D9A6 0F8667FFFFFF        <1> 	jna	sysrel0 ; classic sysrele ; 24/03/2017
   431 0000D9AC E859000000          <1> 	call	sysrel7
   432 0000D9B1 803D[D8030300]00    <1> 	cmp	byte [u.r_lock], 0 ; IRQ callback service lock
   433 0000D9B8 7628                <1> 	jna	short sysrel4
   434 0000D9BA C605[D8030300]00    <1> 	mov	byte [u.r_lock], 0 ; reset
   435                              <1> 	;mov	byte [u.irqwait], 0 ; reset ; 28/02/2017
   436 0000D9C1 A0[D9030300]        <1> 	mov	al, [u.r_mode]
   437 0000D9C6 08C0                <1> 	or	al, al
   438 0000D9C8 7518                <1> 	jnz	short sysrel4
   439 0000D9CA FEC8                <1> 	dec	al
   440 0000D9CC A2[D9030300]        <1> 	mov	[u.r_mode], al ; 0FFh ; not necessary !?
   441 0000D9D1 EB32                <1> 	jmp	short sysrel6		
   442                              <1> sysrel3:
   443                              <1> 	; 27/02/2017
   444 0000D9D3 E832000000          <1> 	call	sysrel7
   445                              <1> 	; 14/01/2017
   446 0000D9D8 28C0                <1> 	sub	al, al
   447 0000D9DA 3805[D4030300]      <1> 	cmp	[u.t_lock], al ; 0 ; TIMER INT LOCK
   448 0000D9E0 770E                <1> 	ja	short sysrel5 ; yes
   449                              <1> sysrel4:
   450                              <1> 	; 29/01/2017
   451 0000D9E2 8B44241C            <1> 	mov	eax, [esp+28] ; eax
   452 0000D9E6 A3[64030300]        <1> 	mov	[u.r0], eax
   453 0000D9EB E93EFFFFFF          <1> 	jmp	sysrel2
   454                              <1> sysrel5:
   455 0000D9F0 A2[D4030300]        <1> 	mov	[u.t_lock], al ; 0 ; reset
   456 0000D9F5 A0[D5030300]        <1> 	mov	al, [u.t_mode]
   457 0000D9FA 20C0                <1> 	and	al, al
   458                              <1> 	;jnz	short sysrel2 ; 0FFh ; user mode
   459 0000D9FC 75E4                <1> 	jnz	short sysrel4 ; 29/01/2017
   460 0000D9FE FEC8                <1> 	dec	al
   461 0000DA00 A2[D5030300]        <1> 	mov	[u.t_mode], al ; 0FFh ; not necessary !?
   462                              <1> sysrel6:
   463                              <1> 	; cpu will continue from the interrupted sytem call addr
   464 0000DA05 61                  <1> 	popad		; edi, esi, ebp, esp, ebx, edx, ecx, eax
   465 0000DA06 83C410              <1> 	add	esp, 16	; pass segment segisters: ds, es, fs, gs		
   466 0000DA09 CF                  <1> 	iretd		; eip, cs, eflags
   467                              <1> 
   468                              <1> sysrel7:
   469 0000DA0A 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno] ; current process number
   470 0000DA11 66C1E302            <1> 	shl	bx, 2
   471                              <1> 	;cmp	[ebx+p.tcb-4], eax ; 0 ; is there callback address ?
   472                              <1> 	;jna	short sysrel0 
   473                              <1> 	; yes, reset callback address then restore process registers 
   474                              <1> 	;mov	[ebx+p.tcb-4], eax ; 0 ; reset
   475 0000DA15 8B83[BC000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address
   476 0000DA1B FA                  <1> 	cli	; disable interrupts till 'iretd'
   477 0000DA1C E9CF3F0000          <1> 	jmp	rswap ; restore process 'u' structure
   478                              <1>  
   479                              <1> badsys:
   480                              <1> 	; 25/12/2016
   481                              <1> 	; 18/04/2016 (TRDOS 386 = TRDOS v2.0)
   482                              <1> 	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
   483                              <1> 	; 03/02/2011 ('trdos_ifc_routine')
   484                              <1> 	;
   485                              <1> 	; 16/04/2015 (Retro UNIX 386 v1, 'badsys')
   486                              <1> 	; (EIP, EAX values will be shown on screen with error message)
   487                              <1> 	; (EIP = 'CD 40h' instruction address -INT 40h-)
   488                              <1> 	; (EAX = Function number)  
   489                              <1> 	;
   490 0000DA21 FE05[B2030300]      <1> 	inc	byte [u.bsys]
   491                              <1> 	;
   492 0000DA27 8B1D[5C030300]      <1> 	mov	ebx, [u.sp] ; esp at the beginning of 'sysent'
   493 0000DA2D 8B03                <1> 	mov	eax, [ebx] ; EIP (return address, not 'INT 30h' address)
   494 0000DA2F 83E802              <1> 	sub	eax, 2 ; CDh, ##h
   495 0000DA32 E8D668FFFF          <1> 	call	dwordtohex
   496 0000DA37 8915[71470100]      <1> 	mov	[eip_str], edx
   497 0000DA3D A3[75470100]        <1> 	mov	[eip_str+4], eax
   498 0000DA42 A1[64030300]        <1> 	mov	eax, [u.r0]
   499 0000DA47 E8C168FFFF          <1> 	call	dwordtohex
   500 0000DA4C 8915[60470100]      <1> 	mov	[eax_str], edx
   501 0000DA52 A3[64470100]        <1> 	mov	[eax_str+4], eax
   502                              <1> 
   503 0000DA57 66C705[55470100]34- <1> 	mov	word [int_num_str], SYSCALL_INT_NUM ; 25/12/2016
   503 0000DA5F 30                  <1>
   504                              <1> 
   505 0000DA60 BE[27470100]        <1> 	mov	esi, ifc_msg ; "invalid funtion call !" msg (trdosk9.s)
   506 0000DA65 E8EB9AFFFF          <1> 	call	print_msg
   507                              <1> 
   508 0000DA6A EB17                <1> 	jmp	sysexit
   509                              <1> 
   510                              <1> intract: ; / interrupt action
   511                              <1> 	; 14/10/2015
   512                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
   513                              <1> 	; 09/05/2013 - 07/12/2013 (Retro UNIX 8086 v1)
   514                              <1> 	;
   515                              <1> 	; Retro UNIX 8086 v1 modification !
   516                              <1> 	; (Process/task switching and quit routine by using
   517                              <1> 	; Retro UNIX 8086 v1 keyboard interrupt output.))
   518                              <1> 	;
   519                              <1> 	; input -> 'u.quit'  (also value of 'u.intr' > 0)
   520                              <1> 	; output -> If value of 'u.quit' = FFFFh ('ctrl+brk' sign)
   521                              <1> 	;		'intract' will jump to 'sysexit'.
   522                              <1> 	;	    Intract will return to the caller 
   523                              <1> 	;		if value of 'u.quit' <> FFFFh. 	 
   524                              <1> 	; 14/10/2015
   525 0000DA6C FB                  <1> 	sti
   526                              <1> 	; 07/12/2013	
   527 0000DA6D 66FF05[AC030300]    <1> 	inc 	word [u.quit]
   528 0000DA74 7408                <1> 	jz	short intrct0 ; FFFFh -> 0
   529 0000DA76 66FF0D[AC030300]    <1> 	dec	word [u.quit]
   530                              <1> 	; 16/04/2015
   531 0000DA7D C3                  <1> 	retn
   532                              <1> intrct0:	
   533 0000DA7E 58                  <1> 	pop	eax ; call intract -> retn
   534                              <1> 	;
   535 0000DA7F 31C0                <1> 	xor 	eax, eax
   536 0000DA81 FEC0                <1> 	inc	al  ; mov ax, 1
   537                              <1> ;;;
   538                              <1> 	; UNIX v1 original 'intract' routine... 
   539                              <1> 	; / interrupt action
   540                              <1> 		;cmp *(sp),$rti / are you in a clock interrupt?
   541                              <1> 		; bne 1f / no, 1f
   542                              <1> 		; cmp (sp)+,(sp)+ / pop clock pointer
   543                              <1> 	; 1: / now in user area
   544                              <1> 		; mov r1,-(sp) / save r1
   545                              <1> 		; mov u.ttyp,r1 
   546                              <1> 			; / pointer to tty buffer in control-to r1
   547                              <1> 		; cmpb 6(r1),$177
   548                              <1> 			; / is the interrupt char equal to "del"
   549                              <1> 		; beq 1f / yes, 1f
   550                              <1> 		; clrb 6(r1) 
   551                              <1> 		        ; / no, clear the byte 
   552                              <1> 			; / (must be a quit character)
   553                              <1> 		; mov (sp)+,r1 / restore r1
   554                              <1> 		; clr u.quit / clear quit flag
   555                              <1> 		; bis $20,2(sp) 
   556                              <1> 		    	; / set trace for quit (sets t bit of 
   557                              <1> 			; / ps-trace trap)
   558                              <1> 		; rti   ;  / return from interrupt
   559                              <1> 	; 1: / interrupt char = del
   560                              <1> 		; clrb 6(r1) / clear the interrupt byte 
   561                              <1> 			   ; / in the buffer
   562                              <1> 		; mov (sp)+,r1 / restore r1
   563                              <1> 		; cmp u.intr,$core / should control be 
   564                              <1> 				; / transferred to loc core?
   565                              <1> 		; blo 1f
   566                              <1> 		; jmp *u.intr / user to do rti yes, 
   567                              <1> 				; / transfer to loc core
   568                              <1> 	; 1:
   569                              <1> 		; sys 1 / exit
   570                              <1> 
   571                              <1> sysexit: ; <terminate process>
   572                              <1> 	; 14/11/2017
   573                              <1> 	; 27/05/2017
   574                              <1> 	; 10/04/2017
   575                              <1> 	; 26/02/2017, 28/02/2017
   576                              <1> 	; 02/01/2017, 23/01/2017
   577                              <1> 	; 06/06/2016, 10/06/2016
   578                              <1> 	; 19/05/2016, 23/05/2016
   579                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   580                              <1> 	; 16/04/2015 - 01/09/2015 (Retro UNIX 386 v1)
   581                              <1> 	; 19/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
   582                              <1> 	;
   583                              <1> 	; 'sysexit' terminates a process. First each file that
   584                              <1> 	; the process has opened is closed by 'flose'. The process
   585                              <1> 	; status is then set to unused. The 'p.pid' table is then
   586                              <1> 	; searched to find children of the dying process. If any of
   587                              <1> 	; children are zombies (died by not waited for), they are
   588                              <1> 	; set free. The 'p.pid' table is then searched to find the
   589                              <1> 	; dying process's parent. When the parent is found, it is
   590                              <1> 	; checked to see if it is free or it is a zombie. If it is
   591                              <1> 	; one of these, the dying process just dies. If it is waiting
   592                              <1> 	; for a child process to die, it notified that it doesn't 
   593                              <1> 	; have to wait anymore by setting it's status from 2 to 1
   594                              <1> 	; (waiting to active). It is awakened and put on runq by
   595                              <1> 	; 'putlu'. The dying process enters a zombie state in which
   596                              <1> 	; it will never be run again but stays around until a 'wait'
   597                              <1> 	; is completed by it's parent process. If the parent is not
   598                              <1> 	; found, process just dies. This means 'swap' is called with
   599                              <1> 	; 'u.uno=0'. What this does is the 'wswap' is not called
   600                              <1> 	; to write out the process and 'rswap' reads the new process
   601                              <1> 	; over the one that dies..i.e., the dying process is 
   602                              <1> 	; overwritten and destroyed.	
   603                              <1>  	;
   604                              <1> 	; Calling sequence:
   605                              <1> 	;	sysexit or conditional branch.
   606                              <1> 	; Arguments:
   607                              <1> 	;	-	
   608                              <1> 	; ...............................................................
   609                              <1> 	;	
   610                              <1> 	; Retro UNIX 8086 v1 modification: 
   611                              <1> 	;       System call number (=1) is in EAX register.
   612                              <1> 	;
   613                              <1> 	;       Other parameters are in EDX, EBX, ECX, ESI, EDI, EBP
   614                              <1> 	;       registers depending of function details.
   615                              <1> 	;
   616                              <1> 	; ('swap' procedure is mostly different than original UNIX v1.)
   617                              <1> 	;
   618                              <1> ; / terminate process
   619                              <1> 	; AX = 1
   620 0000DA83 6648                <1> 	dec 	ax ; 0
   621 0000DA85 66A3[AA030300]      <1> 	mov	[u.intr], ax ; 0
   622                              <1> 		; clr u.intr / clear interrupt control word
   623                              <1> 		; clr r1 / clear r1
   624                              <1> sysexit_0:
   625                              <1> 	; 23/01/2017
   626                              <1> 	; 02/01/2017
   627                              <1> 	; 10/06/2016
   628                              <1> 	; 06/06/2016
   629                              <1> 	; 23/05/2016
   630                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
   631                              <1> 	; Check and stop/clear timer event(s) of this (dying) process
   632                              <1> 	; if there is.
   633                              <1> 
   634                              <1> 	; 02/01/2017 
   635 0000DA8B FA                  <1> 	cli	; disable interrupts
   636                              <1> 	; 23/01/2017 - reset timer frequency (to 18.2Hz)
   637 0000DA8C B036                <1> 	mov	al, 00110110b ; 36h
   638 0000DA8E E643                <1>  	out	43h, al
   639 0000DA90 28C0                <1> 	sub	al, al ; 0
   640 0000DA92 E640                <1> 	out	40h, al ; LB
   641 0000DA94 E640                <1> 	out	40h, al ; HB
   642                              <1>  	; 
   643 0000DA96 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno]
   644                              <1> 	;mov	bl, [u.uno] ; process number of dying process
   645 0000DA9D 3883[FF000300]      <1> 	cmp	byte [ebx+p.timer-1], al ; 0
   646 0000DAA3 763A                <1> 	jna	short sysexit_12 ; no timer events for this process
   647 0000DAA5 8883[FF000300]      <1> 	mov	byte [ebx+p.timer-1], al ; 0 ; reset
   648                              <1> 	;mov	al, [timer_events]
   649                              <1> 	;or	al, al
   650                              <1>  	;jz	short sysexit_12 ; no timer events
   651                              <1> 	;mov	cl, al
   652 0000DAAB 8A0D[63960100]      <1> 	mov	cl, [timer_events] ; 14/11/2017
   653                              <1> 	;cli	; disable interrupts 
   654 0000DAB1 B410                <1> 	mov	ah, 16 ; number of available timer events
   655 0000DAB3 BE[60040300]        <1> 	mov	esi, timer_set ; beginning address of timer events
   656                              <1> sysexit_7:
   657 0000DAB8 8A06                <1> 	mov	al, [esi] ; process number (of timer event)
   658 0000DABA 38D8                <1> 	cmp	al, bl ; process number comparison
   659 0000DABC 7411                <1> 	je	short sysexit_10
   660 0000DABE 20C0                <1> 	and	al, al
   661 0000DAC0 7404                <1> 	jz	short sysexit_9
   662                              <1> sysexit_8:
   663 0000DAC2 FEC9                <1> 	dec	cl
   664 0000DAC4 7416                <1> 	jz	short sysexit_11
   665                              <1> sysexit_9:
   666 0000DAC6 FECC                <1> 	dec	ah
   667 0000DAC8 7415                <1> 	jz	short sysexit_12
   668 0000DACA 83C610              <1> 	add	esi, 16
   669 0000DACD EBE9                <1> 	jmp	short sysexit_7
   670                              <1> 
   671                              <1> sysexit_10:
   672                              <1> 	;mov	byte [esi], 0
   673 0000DACF 66C7060000          <1> 	mov	word [esi], 0
   674                              <1> 	;mov	dword [esi+12], 0
   675                              <1> 	;
   676 0000DAD4 FE0D[63960100]      <1> 	dec	byte [timer_events] ; 02/01/2017
   677                              <1> 	;
   678 0000DADA EBE6                <1> 	jmp	short sysexit_8
   679                              <1> 
   680                              <1> sysexit_11:
   681 0000DADC 6629C0              <1> 	sub	ax, ax ; 0 ; 26/02/2017
   682                              <1> sysexit_12:
   683                              <1> 	; 26/02/2017 (Unlink IRQ callbacks belong to the user)
   684 0000DADF 803D[D6030300]00    <1> 	cmp	byte [u.irqc], 0 ; Count of IRQ callbacks
   685 0000DAE6 7E2E                <1> 	jng	short sysexit_16 ; zero or invalid
   686                              <1> 	; 28/02/2017
   687                              <1> 	; clear IRQ callback flags (for 'sysrele' and 'sysret')
   688 0000DAE8 A2[D7030300]        <1> 	mov	[u.irqwait], al ; 0 ; force to clear waiting flag
   689 0000DAED A2[D8030300]        <1> 	mov	[u.r_lock], al ; 0 ; force to clear busy flag
   690 0000DAF2 BE[029C0100]        <1> 	mov	esi, IRQ.owner
   691                              <1> sysexit_13:	
   692 0000DAF7 AC                  <1> 	lodsb
   693 0000DAF8 3A05[B3030300]      <1> 	cmp	al, [u.uno] ; owner = current user ?
   694 0000DAFE 750C                <1> 	jne	short sysexit_14
   695 0000DB00 C646FF00            <1> 	mov	byte [esi-1], 0 ; owner = 0 : Free
   696 0000DB04 FE0D[D6030300]      <1> 	dec	byte [u.irqc]
   697 0000DB0A 7408                <1> 	jz	short sysexit_15
   698                              <1> sysexit_14:
   699 0000DB0C 81FE[0A9C0100]      <1> 	cmp	esi, IRQ.owner + 8 ; the last IRQ index number ?
   700 0000DB12 76E3                <1> 	jna	short sysexit_13 ; no
   701                              <1> sysexit_15:
   702 0000DB14 30C0                <1> 	xor	al, al ; 0
   703                              <1> sysexit_16: ; 2:
   704 0000DB16 FB                  <1> 	sti	; enable interrupts 
   705                              <1> 	;
   706                              <1> 	; AX = 0
   707                              <1> sysexit_1: ; 1:
   708                              <1> 	; AX = File descriptor
   709                              <1> 		; / r1 has file descriptor (index to u.fp list)
   710                              <1> 		; / Search the whole list
   711 0000DB17 E8C1340000          <1> 	call	fclose
   712                              <1> 		; jsr r0,fclose / close all files the process opened
   713                              <1> 	;; ignore error return
   714                              <1> 		; br .+2 / ignore error return
   715                              <1> 	;inc	ax
   716 0000DB1C FEC0                <1> 	inc	al
   717                              <1> 		; inc r1 / increment file descriptor
   718                              <1> 	;cmp	ax, 10
   719 0000DB1E 3C0A                <1> 	cmp	al, 10
   720                              <1> 		; cmp r1,$10. / end of u.fp list?
   721 0000DB20 72F5                <1> 	jb	short sysexit_1
   722                              <1> 		; blt 1b / no, go back
   723                              <1> 	;movzx	ebx, byte [u.uno]
   724 0000DB22 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; 02/01/2017
   725                              <1> 		; movb	u.uno,r1 / yes, move dying process's number to r1
   726 0000DB28 88A3[AF000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
   727                              <1> 		; clrb p.stat-1(r1) / free the process
   728                              <1> 	; 10/04/2017
   729 0000DB2E 381D[799C0100]      <1> 	cmp	[audio_user], bl
   730 0000DB34 7518                <1> 	jne	short sysexit_17
   731                              <1> 	; reset audio device (current) owner and 'initializated' flag
   732 0000DB36 883D[799C0100]      <1> 	mov	[audio_user], bh ; 0
   733                              <1> 	; 27/05/2017
   734 0000DB3C 8B0D[649C0100]      <1> 	mov	ecx,  [audio_buffer]
   735 0000DB42 09C9                <1> 	or	ecx, ecx
   736 0000DB44 7408                <1> 	jz	short sysexit_17
   737                              <1> 	; 'deallocate_user_pages' is not necessary in sysexit !!!
   738                              <1> 	;push	ebx
   739                              <1> 	;mov	ebx, ecx
   740                              <1> 	;mov	ecx, [audio_buff_size]
   741                              <1> 	;call	deallocate_user_pages
   742                              <1> 	;; (Modified Registers -> EAX, EDX, ESI, EDI, EBX, ECX, EBP)
   743 0000DB46 29C9                <1> 	sub	ecx, ecx
   744 0000DB48 890D[649C0100]      <1> 	mov	[audio_buffer], ecx ; 0
   745                              <1> 	;pop	ebx
   746                              <1> sysexit_17:
   747                              <1> 	;shl	bx, 1
   748 0000DB4E D0E3                <1> 	shl	bl, 1
   749                              <1> 		; asl r1 / use r1 for index into the below tables
   750 0000DB50 668B8B[1E000300]    <1> 	mov	cx, [ebx+p.pid-2]
   751                              <1> 		; mov p.pid-2(r1),r3 / move dying process's name to r3
   752 0000DB57 668B93[3E000300]    <1> 	mov	dx, [ebx+p.ppid-2]
   753                              <1> 		; mov p.ppid-2(r1),r4 / move its parents name to r4
   754                              <1> 	; xor 	bx, bx ; 0
   755 0000DB5E 30DB                <1> 	xor	bl, bl ; 0
   756                              <1> 		; clr r2
   757 0000DB60 31F6                <1> 	xor	esi, esi ; 0
   758                              <1> 		; clr r5 / initialize reg
   759                              <1> sysexit_2: ; 1:
   760                              <1> 	        ; / find children of this dying process, 
   761                              <1> 		; / if they are zombies, free them
   762                              <1> 	;add	bx, 2
   763 0000DB62 80C302              <1> 	add	bl, 2
   764                              <1> 		; add $2,r2 / search parent process table 
   765                              <1> 		          ; / for dying process's name
   766 0000DB65 66398B[3E000300]    <1> 	cmp	[ebx+p.ppid-2], cx
   767                              <1> 		; cmp p.ppid-2(r2),r3 / found it?
   768 0000DB6C 7513                <1> 	jne	short sysexit_4
   769                              <1> 		; bne 3f / no
   770                              <1> 	;shr	bx, 1
   771 0000DB6E D0EB                <1> 	shr	bl, 1
   772                              <1> 		; asr r2 / yes, it is a parent
   773 0000DB70 80BB[AF000300]03    <1> 	cmp	byte [ebx+p.stat-1], 3 ; SZOMB
   774                              <1> 		; cmpb p.stat-1(r2),$3 / is the child of this 
   775                              <1> 				     ; / dying process a zombie
   776 0000DB77 7506                <1> 	jne	short sysexit_3 
   777                              <1> 		; bne 2f / no
   778 0000DB79 88A3[AF000300]      <1> 	mov	[ebx+p.stat-1], ah ; 0, SFREE
   779                              <1> 		; clrb p.stat-1(r2) / yes, free the child process
   780                              <1> sysexit_3: ; 2:
   781                              <1> 	;shr	bx, 1
   782 0000DB7F D0E3                <1> 	shl	bl, 1
   783                              <1> 		; asl r2
   784                              <1> sysexit_4: ; 3:
   785                              <1> 		; / search the process name table 
   786                              <1> 		; / for the dying process's parent
   787 0000DB81 663993[1E000300]    <1> 	cmp	[ebx+p.pid-2], dx
   788                              <1> 		; cmp p.pid-2(r2),r4 / found it?
   789 0000DB88 7502                <1> 	jne	short sysexit_5
   790                              <1> 		; bne 3f / no
   791 0000DB8A 89DE                <1> 	mov	esi, ebx
   792                              <1> 		; mov r2,r5 / yes, put index to p.pid table (parents
   793                              <1> 		          ; / process # x2) in r5
   794                              <1> sysexit_5: ; 3:
   795                              <1> 	;cmp	bx, nproc + nproc
   796 0000DB8C 80FB20              <1> 	cmp	bl, nproc + nproc
   797                              <1> 		; cmp r2,$nproc+nproc / has whole table been searched?
   798 0000DB8F 72D1                <1> 	jb	short sysexit_2
   799                              <1> 		; blt 1b / no, go back
   800                              <1> 		; mov r5,r1 / yes, r1 now has parents process # x2
   801 0000DB91 21F6                <1> 	and	esi, esi ; r5=r1
   802 0000DB93 7436                <1> 	jz	short sysexit_6
   803                              <1> 		; beq 2f / no parent has been found. 
   804                              <1> 		       ; / The process just dies
   805 0000DB95 66D1EE              <1> 	shr	si, 1
   806                              <1> 		; asr r1 / set up index to p.stat
   807 0000DB98 8A86[AF000300]      <1> 	mov	al, [esi+p.stat-1]
   808                              <1> 		; movb p.stat-1(r1),r2 / move status of parent to r2
   809 0000DB9E 20C0                <1> 	and	al, al
   810 0000DBA0 7429                <1> 	jz	short sysexit_6
   811                              <1> 		; beq 2f / if its been freed, 2f
   812 0000DBA2 3C03                <1> 	cmp	al, 3
   813                              <1> 		; cmp r2,$3 / is parent a zombie?
   814 0000DBA4 7425                <1> 	je	short sysexit_6
   815                              <1> 		; beq 2f / yes, 2f
   816                              <1> 	; BH = 0
   817 0000DBA6 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
   818                              <1> 		; movb u.uno,r3 / move dying process's number to r3
   819 0000DBAC C683[AF000300]03    <1> 	mov	byte [ebx+p.stat-1], 3  ; SZOMB
   820                              <1> 		; movb $3,p.stat-1(r3) / make the process a zombie
   821 0000DBB3 3C01                <1> 	cmp	al, 1 ; SRUN
   822 0000DBB5 7414                <1> 	je	short sysexit_6
   823                              <1> 	;cmp	al, 2
   824                              <1> 		; cmp r2,$2 / is the parent waiting for 
   825                              <1> 			  ; / this child to die
   826                              <1> 	;jne	short sysexit_6	
   827                              <1> 		; bne 2f / yes, notify parent not to wait any more
   828                              <1> 	; p.stat = 2 --> waiting
   829                              <1> 	; p.stat = 4 --> sleeping
   830 0000DBB7 C686[AF000300]01    <1> 	mov	byte [esi+p.stat-1], 1 ; SRUN
   831                              <1> 	;dec	byte [esi+p.stat-1]
   832                              <1> 		; decb	p.stat-1(r1) / awaken it by putting it (parent)
   833 0000DBBE 6689F0              <1> 	mov	ax, si ; r1  (process number in AL)
   834                              <1> 	; 
   835                              <1> 	;mov	ebx, runq + 4
   836                              <1> 		; mov $runq+4,r2 / on the runq
   837 0000DBC1 BB[54030300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017
   838 0000DBC6 E85D3E0000          <1> 	call	putlu
   839                              <1> 		; jsr r0, putlu
   840                              <1> sysexit_6: 
   841                              <1> 		; / the process dies
   842 0000DBCB C605[B3030300]00    <1> 	mov	byte [u.uno], 0
   843                              <1> 		; clrb u.uno / put zero as the process number, 
   844                              <1> 	           ; / so "swap" will
   845 0000DBD2 E8533D0000          <1> 	call	swap
   846                              <1> 		; jsr r0,swap / overwrite process with another process
   847                              <1> hlt_sys:
   848                              <1> 	;sti
   849                              <1> hlts0:
   850 0000DBD7 F4                  <1> 	hlt
   851 0000DBD8 EBFD                <1> 	jmp	short hlts0
   852                              <1> 		; 0 / and thereby kill it; halt?
   853                              <1> 
   854                              <1> syswait: ; < wait for a processs to die >
   855                              <1> 	; 17/09/2015
   856                              <1> 	; 02/09/2015
   857                              <1> 	; 01/09/2015
   858                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - Beginning)
   859                              <1> 	; 24/05/2013 - 05/02/2014 (Retro UNIX 8086 v1)
   860                              <1> 	;
   861                              <1> 	; 'syswait' waits for a process die. 
   862                              <1> 	; It works in following way:
   863                              <1> 	;    1) From the parent process number, the parent's 
   864                              <1> 	; 	process name is found. The p.ppid table of parent
   865                              <1> 	;	names is then searched for this process name.
   866                              <1> 	;	If a match occurs, r2 contains child's process
   867                              <1> 	;	number. The child status is checked to see if it is
   868                              <1> 	;	a zombie, i.e; dead but not waited for (p.stat=3)
   869                              <1> 	;	If it is, the child process is freed and it's name
   870                              <1> 	;	is put in (u.r0). A return is then made via 'sysret'.
   871                              <1> 	;	If the child is not a zombie, nothing happens and
   872                              <1> 	;	the search goes on through the p.ppid table until
   873                              <1> 	;	all processes are checked or a zombie is found.
   874                              <1> 	;    2) If no zombies are found, a check is made to see if
   875                              <1> 	;	there are any children at all. If there are none,
   876                              <1> 	;	an error return is made. If there are, the parent's
   877                              <1> 	;	status is set to 2 (waiting for child to die),
   878                              <1> 	;	the parent is swapped out, and a branch to 'syswait'
   879                              <1> 	;	is made to wait on the next process.
   880                              <1> 	;
   881                              <1> 	; Calling sequence:
   882                              <1> 	;	?
   883                              <1> 	; Arguments:
   884                              <1> 	;	-
   885                              <1> 	; Inputs: - 
   886                              <1> 	; Outputs: if zombie found, it's name put in u.r0.	
   887                              <1> 	; ...............................................................
   888                              <1> 	;				
   889                              <1> 	
   890                              <1> ; / wait for a process to die
   891                              <1> 
   892                              <1> syswait_0:
   893 0000DBDA 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno] ; 01/09/2015
   894                              <1> 		; movb u.uno,r1 / put parents process number in r1
   895 0000DBE1 D0E3                <1> 	shl	bl, 1
   896                              <1> 	;shl	bx, 1
   897                              <1> 		; asl r1 / x2 to get index into p.pid table
   898 0000DBE3 668B83[1E000300]    <1> 	mov	ax, [ebx+p.pid-2]
   899                              <1> 		; mov p.pid-2(r1),r1 / get the name of this process
   900 0000DBEA 31F6                <1> 	xor	esi, esi
   901                              <1> 		; clr r2
   902 0000DBEC 31C9                <1> 	xor	ecx, ecx ; 30/10/2013
   903                              <1> 	;xor 	cl, cl
   904                              <1> 		; clr r3 / initialize reg 3
   905                              <1> syswait_1: ; 1:
   906 0000DBEE 6683C602            <1> 	add	si, 2
   907                              <1> 		; add $2,r2 / use r2 for index into p.ppid table
   908                              <1> 			  ; / search table of parent processes 
   909                              <1> 			  ; / for this process name
   910 0000DBF2 663B86[3E000300]    <1> 	cmp	ax, [esi+p.ppid-2]
   911                              <1> 		; cmp p.ppid-2(r2),r1 / r2 will contain the childs 
   912                              <1> 			            ; / process number
   913 0000DBF9 7535                <1> 	jne	short syswait_3
   914                              <1> 		;bne 3f / branch if no match of parent process name
   915                              <1> 	;inc	cx
   916 0000DBFB FEC1                <1> 	inc	cl
   917                              <1> 		;inc r3 / yes, a match, r3 indicates number of children
   918 0000DBFD 66D1EE              <1> 	shr	si, 1
   919                              <1> 		; asr r2 / r2/2 to get index to p.stat table
   920                              <1> 	; The possible states ('p.stat' values) of a process are:
   921                              <1> 	;	0 = free or unused
   922                              <1> 	;	1 = active
   923                              <1> 	;	2 = waiting for a child process to die
   924                              <1> 	;	3 = terminated, but not yet waited for (zombie).	
   925 0000DC00 80BE[AF000300]03    <1> 	cmp	byte [esi+p.stat-1], 3 ; SZOMB, 05/02/2014
   926                              <1> 		; cmpb p.stat-1(r2),$3 / is the child process a zombie?
   927 0000DC07 7524                <1> 	jne	short syswait_2
   928                              <1> 		; bne 2f / no, skip it
   929 0000DC09 88BE[AF000300]      <1> 	mov	[esi+p.stat-1], bh ; 0
   930                              <1> 		; clrb p.stat-1(r2) / yes, free it
   931 0000DC0F 66D1E6              <1> 	shl	si, 1
   932                              <1> 		; asl r2 / r2x2 to get index into p.pid table
   933 0000DC12 0FB786[1E000300]    <1> 	movzx	eax, word [esi+p.pid-2]
   934 0000DC19 A3[64030300]        <1> 	mov	[u.r0], eax
   935                              <1> 		; mov p.pid-2(r2),*u.r0 
   936                              <1> 			      ; / put childs process name in (u.r0)
   937                              <1> 	;
   938                              <1> 	; Retro UNIX 386 v1 modification ! (17/09/2015)
   939                              <1> 	;
   940                              <1> 	; Parent process ID -p.ppid- field (of the child process)
   941                              <1> 	; must be cleared in order to prevent infinitive 'syswait'
   942                              <1> 	; system call loop from the application/program if it calls
   943                              <1> 	; 'syswait' again (mistakenly) while there is not a zombie
   944                              <1> 	; or running child process to wait. ('forktest.s', 17/09/2015)
   945                              <1> 	;
   946                              <1> 	; Note: syswait will return with error if there is not a
   947                              <1> 	;       zombie or running process to wait.	
   948                              <1> 	;
   949 0000DC1E 6629C0              <1> 	sub	ax, ax
   950 0000DC21 668986[3E000300]    <1> 	mov 	[esi+p.ppid-2], ax ; 0 ; 17/09/2015
   951 0000DC28 E9D1FCFFFF          <1> 	jmp	sysret0 ; ax = 0
   952                              <1> 	;
   953                              <1> 	;jmp	sysret
   954                              <1> 		; br sysret1 / return cause child is dead
   955                              <1> syswait_2: ; 2:
   956 0000DC2D 66D1E6              <1> 	shl	si, 1
   957                              <1> 		; asl r2 / r2x2 to get index into p.ppid table
   958                              <1> syswait_3: ; 3:
   959 0000DC30 6683FE20            <1> 	cmp	si, nproc+nproc
   960                              <1> 		; cmp r2,$nproc+nproc / have all processes been checked?
   961 0000DC34 72B8                <1> 	jb	short syswait_1
   962                              <1> 		; blt 1b / no, continue search
   963                              <1> 	;and	cx, cx
   964 0000DC36 20C9                <1> 	and	cl, cl
   965                              <1> 		; tst r3 / one gets here if there are no children 
   966                              <1> 		       ; / or children that are still active
   967                              <1> 	; 30/10/2013
   968 0000DC38 750B                <1> 	jnz	short syswait_4
   969                              <1> 	;jz	error
   970                              <1> 		; beq error1 / there are no children, error
   971 0000DC3A 890D[64030300]      <1> 	mov	[u.r0], ecx ; 0
   972 0000DC40 E997FCFFFF          <1> 	jmp	error
   973                              <1> syswait_4:
   974 0000DC45 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
   975                              <1> 		; movb u.uno,r1 / there are children so put 
   976                              <1> 			      ; / parent process number in r1
   977 0000DC4B FE83[AF000300]      <1> 	inc	byte [ebx+p.stat-1] ; 2, SWAIT, 05/02/2014
   978                              <1> 		; incb p.stat-1(r1) / it is waiting for 
   979                              <1> 				  ; / other children to die
   980                              <1> 	; 04/11/2013
   981 0000DC51 E8D43C0000          <1> 	call	swap
   982                              <1> 		; jsr r0,swap / swap it out, because it's waiting
   983 0000DC56 EB82                <1> 	jmp	syswait_0
   984                              <1> 		; br syswait / wait on next process
   985                              <1> 
   986                              <1> sysfork: ; < create a new process >
   987                              <1> 	; 02/01/2017 (TRDOS 386 modification)
   988                              <1> 	; 04/09/2015, 18/05/2015
   989                              <1> 	; 28/08/2015, 01/09/2015, 02/09/2015
   990                              <1> 	; 09/05/2015, 10/05/2015, 14/05/2015
   991                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 - Beginning)
   992                              <1> 	; 24/05/2013 - 14/02/2014 (Retro UNIX 8086 v1)
   993                              <1> 	;
   994                              <1> 	; 'sysfork' creates a new process. This process is referred
   995                              <1> 	; to as the child process. This new process core image is
   996                              <1> 	; a copy of that of the caller of 'sysfork'. The only
   997                              <1> 	; distinction is the return location and the fact that (u.r0)
   998                              <1> 	; in the old process (parent) contains the process id (p.pid)
   999                              <1> 	; of the new process (child). This id is used by 'syswait'.
  1000                              <1> 	; 'sysfork' works in the following manner: 	
  1001                              <1> 	;    1) The process status table (p.stat) is searched to find
  1002                              <1> 	;	a process number that is unused. If none are found
  1003                              <1> 	;	an error occurs.
  1004                              <1> 	;    2) when one is found, it becomes the child process number
  1005                              <1> 	;	and it's status (p.stat) is set to active.
  1006                              <1> 	;    3) If the parent had a control tty, the interrupt 
  1007                              <1> 	;	character in that tty buffer is cleared.
  1008                              <1> 	;    4) The child process is put on the lowest priority run 
  1009                              <1> 	;	queue via 'putlu'.
  1010                              <1> 	;    5) A new process name is gotten from 'mpid' (actually 
  1011                              <1> 	;	it is a unique number) and is put in the child's unique
  1012                              <1> 	;	identifier; process id (p.pid).
  1013                              <1> 	;    6) The process name of the parent is then obtained and
  1014                              <1> 	;	placed in the unique identifier of the parent process
  1015                              <1> 	;	name is then put in 'u.r0'.	
  1016                              <1> 	;    7) The child process is then written out on disk by
  1017                              <1> 	;	'wswap',i.e., the parent process is copied onto disk
  1018                              <1> 	;	and the child is born. (The child process is written 
  1019                              <1> 	;	out on disk/drum with 'u.uno' being the child process
  1020                              <1> 	;	number.)
  1021                              <1> 	;    8) The parent process number is then restored to 'u.uno'.
  1022                              <1> 	;    9) The child process name is put in 'u.r0'.
  1023                              <1> 	;   10) The pc on the stack sp + 18 is incremented by 2 to
  1024                              <1> 	;	create the return address for the parent process.
  1025                              <1> 	;   11) The 'u.fp' list as then searched to see what files
  1026                              <1> 	;	the parent has opened. For each file the parent has
  1027                              <1> 	;	opened, the corresponding 'fsp' entry must be updated
  1028                              <1> 	;	to indicate that the child process also has opened
  1029                              <1> 	;	the file. A branch to 'sysret' is then made.	 			 				
  1030                              <1> 	;
  1031                              <1> 	; Calling sequence:
  1032                              <1> 	;	from shell ?
  1033                              <1> 	; Arguments:
  1034                              <1> 	;	-
  1035                              <1> 	; Inputs: -
  1036                              <1> 	; Outputs: *u.r0 - child process name
  1037                              <1> 	; ...............................................................
  1038                              <1> 	;	
  1039                              <1> 	; Retro UNIX 8086 v1 modification: 
  1040                              <1> 	;	AX = r0 = PID (>0) (at the return of 'sysfork')
  1041                              <1> 	;	= process id of child a parent process returns
  1042                              <1> 	;	= process id of parent when a child process returns
  1043                              <1> 	;
  1044                              <1> 	;       In original UNIX v1, sysfork is called and returns as
  1045                              <1> 	;	in following manner: (with an example: c library, fork)
  1046                              <1> 	;	
  1047                              <1> 	;	1:
  1048                              <1> 	;		sys	fork
  1049                              <1> 	;			br 1f  / child process returns here
  1050                              <1> 	;		bes	2f     / parent process returns here
  1051                              <1> 	;		/ pid of new process in r0
  1052                              <1> 	;		rts	pc
  1053                              <1> 	;	2: / parent process condionally branches here
  1054                              <1> 	;		mov	$-1,r0 / pid = -1 means error return
  1055                              <1> 	;		rts	pc
  1056                              <1> 	;
  1057                              <1> 	;	1: / child process brances here
  1058                              <1> 	;		clr	r0   / pid = 0 in child process
  1059                              <1> 	;		rts	pc
  1060                              <1> 	;
  1061                              <1> 	;	In UNIX v7x86 (386) by Robert Nordier (1999)
  1062                              <1> 	;		// pid = fork();
  1063                              <1> 	;		//
  1064                              <1> 	;		// pid == 0 in child process; 
  1065                              <1> 	;		// pid == -1 means error return
  1066                              <1> 	;		// in child, 
  1067                              <1> 	;		//	parents id is in par_uid if needed
  1068                              <1> 	;		
  1069                              <1> 	;		_fork:
  1070                              <1> 	;			mov	$.fork,eax
  1071                              <1> 	;			int	$0x30
  1072                              <1> 	;			jmp	1f
  1073                              <1> 	;			jnc	2f
  1074                              <1> 	;			jmp	cerror
  1075                              <1> 	;		1:
  1076                              <1> 	;			mov	eax,_par_uid
  1077                              <1> 	;			xor	eax,eax
  1078                              <1> 	;		2:
  1079                              <1> 	;			ret
  1080                              <1> 	;
  1081                              <1> 	;	In Retro UNIX 8086 v1,
  1082                              <1> 	;	'sysfork' returns in following manner:
  1083                              <1> 	;	
  1084                              <1> 	;		mov	ax, sys_fork
  1085                              <1> 	;		mov	bx, offset @f ; routine for child
  1086                              <1> 	;		int	20h
  1087                              <1> 	;		jc	error
  1088                              <1> 	;		
  1089                              <1> 	;	; Routine for parent process here (just after 'jc')
  1090                              <1> 	;		mov	word ptr [pid_of_child], ax
  1091                              <1> 	;		jmp	next_routine_for_parent	
  1092                              <1> 	;
  1093                              <1> 	;	@@: ; routine for child process here				
  1094                              <1> 	;		....	
  1095                              <1> 	;	NOTE: 'sysfork' returns to specified offset
  1096                              <1> 	;	       for child process by using BX input.
  1097                              <1> 	;	      (at first, parent process will return then 
  1098                              <1> 	;	      child process will return -after swapped in-
  1099                              <1> 	;	      'syswait' is needed in parent process
  1100                              <1> 	;	      if return from child process will be waited for.)
  1101                              <1> 	;	  				
  1102                              <1> 	
  1103                              <1> ; / create a new process
  1104                              <1> 	; EBX = return address for child process 
  1105                              <1> 	     ; (Retro UNIX 8086 v1 modification !)
  1106 0000DC58 31F6                <1> 	xor 	esi, esi
  1107                              <1> 		; clr r1
  1108                              <1> sysfork_1: ; 1: / search p.stat table for unused process number
  1109 0000DC5A 46                  <1> 	inc	esi
  1110                              <1> 		; inc r1
  1111 0000DC5B 80BE[AF000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE, 05/02/2014
  1112                              <1> 		; tstb p.stat-1(r1) / is process active, unused, dead
  1113 0000DC62 760B                <1> 	jna	short sysfork_2	
  1114                              <1> 		; beq 1f / it's unused so branch
  1115 0000DC64 6683FE10            <1> 	cmp	si, nproc
  1116                              <1> 		; cmp r1,$nproc / all processes checked
  1117 0000DC68 72F0                <1> 	jb	short sysfork_1
  1118                              <1> 		; blt 1b / no, branch back
  1119                              <1> 	;
  1120                              <1> 	; Retro UNIX 8086 v1. modification:
  1121                              <1> 	;	Parent process returns from 'sysfork' to address 
  1122                              <1> 	;	which is just after 'sysfork' system call in parent
  1123                              <1> 	;	process. Child process returns to address which is put
  1124                              <1> 	;	in BX register by parent process for 'sysfork'. 
  1125                              <1> 	;
  1126                              <1> 		;add $2,18.(sp) / add 2 to pc when trap occured, points
  1127                              <1> 		             ; / to old process return
  1128                              <1> 		; br error1 / no room for a new process
  1129 0000DC6A E96DFCFFFF          <1> 	jmp	error
  1130                              <1> sysfork_2: ; 1:
  1131 0000DC6F E85F7FFFFF          <1> 	call	allocate_page
  1132 0000DC74 0F8262FCFFFF        <1> 	jc	error
  1133 0000DC7A 50                  <1> 	push	eax   ; UPAGE (user structure page) address
  1134                              <1> 	; Retro UNIX 386 v1 modification!
  1135 0000DC7B E86281FFFF          <1> 	call	duplicate_page_dir
  1136                              <1> 		; EAX = New page directory 
  1137 0000DC80 730B                <1> 	jnc	short sysfork_3
  1138 0000DC82 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  1139 0000DC83 E82981FFFF          <1> 	call 	deallocate_page
  1140 0000DC88 E94FFCFFFF          <1> 	jmp	error
  1141                              <1> sysfork_3:
  1142                              <1> 	; Retro UNIX 386 v1 modification !
  1143 0000DC8D 56                  <1> 	push	esi
  1144 0000DC8E E8253D0000          <1> 	call	wswap ; save current user (u) structure, user registers
  1145                              <1> 		      ; and interrupt return components (for IRET)
  1146 0000DC93 8705[B8030300]      <1> 	xchg	eax, [u.pgdir] ; page directory of the child process
  1147 0000DC99 A3[BC030300]        <1> 	mov	[u.ppgdir], eax ; page directory of the parent process
  1148 0000DC9E 5E                  <1> 	pop	esi
  1149 0000DC9F 58                  <1> 	pop	eax   ; UPAGE (user structure page) address
  1150                              <1> 		; [u.usp] = esp
  1151 0000DCA0 89F7                <1> 	mov	edi, esi
  1152 0000DCA2 66C1E702            <1> 	shl	di, 2
  1153 0000DCA6 8987[BC000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
  1154 0000DCAC A3[B4030300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
  1155                              <1> 	; 28/08/2015
  1156 0000DCB1 0FB605[B3030300]    <1> 	movzx	eax, byte [u.uno] ; parent process number
  1157                              <1> 		; movb u.uno,-(sp) / save parent process number
  1158 0000DCB8 89C7                <1> 	mov	edi, eax
  1159 0000DCBA 50                  <1>         push	eax ; ** 
  1160 0000DCBB 8A87[7F000300]      <1> 	mov     al, [edi+p.ttyc-1] ; console tty (parent)
  1161                              <1> 	; 18/09/2015
  1162                              <1> 	;mov     [esi+p.ttyc-1], al ; set child's console tty
  1163                              <1> 	;mov     [esi+p.waitc-1], ah ; 0 ; reset child's wait channel
  1164 0000DCC1 668986[7F000300]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
  1165                              <1> 				   ; ah - reset child's wait channel	
  1166 0000DCC8 89F0                <1> 	mov	eax, esi
  1167 0000DCCA A2[B3030300]        <1> 	mov	[u.uno], al ; child process number
  1168                              <1> 		;movb r1,u.uno / set child process number to r1
  1169 0000DCCF FE86[AF000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN, 05/02/2014
  1170                              <1> 		; incb p.stat-1(r1) / set p.stat entry for child 
  1171                              <1> 				; / process to active status
  1172                              <1> 		; mov u.ttyp,r2 / put pointer to parent process' 
  1173                              <1> 			      ; / control tty buffer in r2
  1174                              <1>                 ; beq 2f / branch, if no such tty assigned
  1175                              <1> 		; clrb 6(r2) / clear interrupt character in tty buffer
  1176                              <1> 	; 2:
  1177 0000DCD5 53                  <1> 	push	ebx  ; * return address for the child process
  1178                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  1179                              <1> 	; (Retro UNIX 8086 v1 modification!)
  1180                              <1> 		; mov $runq+4,r2
  1181 0000DCD6 BB[54030300]        <1> 	mov	ebx, runq+2 ; normal run queue ; 02/01/2017  
  1182 0000DCDB E8483D0000          <1> 	call	putlu
  1183                              <1>  		; jsr r0,putlu / put child process on lowest priority 
  1184                              <1> 			   ; / run queue
  1185 0000DCE0 66D1E6              <1> 	shl	si, 1
  1186                              <1> 		; asl r1 / multiply r1 by 2 to get index 
  1187                              <1> 		       ; / into p.pid table
  1188 0000DCE3 66FF05[4E030300]    <1> 	inc	word [mpid]
  1189                              <1> 		; inc mpid / increment m.pid; get a new process name
  1190 0000DCEA 66A1[4E030300]      <1> 	mov	ax, [mpid]
  1191 0000DCF0 668986[1E000300]    <1> 	mov	[esi+p.pid-2], ax
  1192                              <1> 		;mov mpid,p.pid-2(r1) / put new process name 
  1193                              <1> 				    ; / in child process' name slot
  1194 0000DCF7 5A                  <1> 	pop	edx  ; * return address for the child process
  1195                              <1> 		     ; * Retro UNIX 8086 v1 feature only !	
  1196 0000DCF8 5B                  <1>   	pop	ebx  ; **
  1197                              <1> 	;mov	ebx, [esp] ; ** parent process number
  1198                              <1> 		; movb (sp),r2 / put parent process number in r2
  1199 0000DCF9 66D1E3              <1> 	shl 	bx, 1
  1200                              <1> 		;asl r2 / multiply by 2 to get index into below tables
  1201                              <1> 	;movzx eax, word [ebx+p.pid-2]
  1202 0000DCFC 668B83[1E000300]    <1> 	mov	ax, [ebx+p.pid-2]
  1203                              <1> 		; mov p.pid-2(r2),r2 / get process name of parent
  1204                              <1> 				   ; / process
  1205 0000DD03 668986[3E000300]    <1> 	mov	[esi+p.ppid-2], ax
  1206                              <1> 		; mov r2,p.ppid-2(r1) / put parent process name 
  1207                              <1> 			  ; / in parent process slot for child
  1208 0000DD0A A3[64030300]        <1> 	mov	[u.r0], eax	
  1209                              <1> 		; mov r2,*u.r0 / put parent process name on stack 
  1210                              <1> 			     ; / at location where r0 was saved
  1211 0000DD0F 8B2D[5C030300]      <1> 	mov 	ebp, [u.sp] ; points to return address (EIP for IRET)
  1212 0000DD15 895500              <1> 	mov	[ebp], edx ; *, CS:EIP -> EIP
  1213                              <1> 			   ; * return address for the child process
  1214                              <1> 		; mov $sysret1,-(sp) /
  1215                              <1> 		; mov sp,u.usp / contents of sp at the time when 
  1216                              <1> 			      ; / user is swapped out
  1217                              <1> 		; mov $sstack,sp / point sp to swapping stack space
  1218                              <1> 	; 04/09/2015 - 01/09/2015
  1219                              <1> 	; [u.usp] = esp
  1220 0000DD18 68[FCD80000]        <1> 	push	sysret ; ***
  1221 0000DD1D 8925[60030300]      <1> 	mov	[u.usp], esp ; points to 'sysret' address (***)
  1222                              <1> 			     ; (for child process)	
  1223 0000DD23 31C0                <1> 	xor 	eax, eax
  1224 0000DD25 66A3[94030300]      <1> 	mov 	[u.ttyp], ax ; 0
  1225                              <1> 	;
  1226 0000DD2B E8883C0000          <1> 	call	wswap ; Retro UNIX 8086 v1 modification !
  1227                              <1> 		;jsr r0,wswap / put child process out on drum
  1228                              <1> 		;jsr r0,unpack / unpack user stack
  1229                              <1> 		;mov u.usp,sp / restore user stack pointer
  1230                              <1> 		; tst (sp)+ / bump stack pointer
  1231                              <1> 	; Retro UNIX 386 v1 modification !
  1232 0000DD30 58                  <1> 	pop	eax ; ***
  1233 0000DD31 66D1E3              <1> 	shl	bx, 1
  1234 0000DD34 8B83[BC000300]      <1> 	mov     eax, [ebx+p.upage-4] ; UPAGE address ; 14/05/2015
  1235 0000DD3A E8B13C0000          <1> 	call	rswap ; restore parent process 'u' structure, 
  1236                              <1> 		      ; registers and return address (for IRET)
  1237                              <1> 		;movb (sp)+,u.uno / put parent process number in u.uno
  1238 0000DD3F 0FB705[4E030300]    <1>         movzx   eax, word [mpid]
  1239 0000DD46 A3[64030300]        <1> 	mov	[u.r0], eax
  1240                              <1> 		; mov mpid,*u.r0 / put child process name on stack 
  1241                              <1> 			       ; / where r0 was saved
  1242                              <1> 		; add $2,18.(sp) / add 2 to pc on stack; gives parent
  1243                              <1> 			          ; / process return
  1244                              <1> 	;xor	ebx, ebx
  1245 0000DD4B 31F6                <1> 	xor     esi, esi
  1246                              <1> 		;clr r1
  1247                              <1> sysfork_4: ; 1: / search u.fp list to find the files 
  1248                              <1> 	      ; / opened by the parent process
  1249                              <1> 	; 01/09/2015
  1250                              <1> 	;xor	bh, bh
  1251                              <1> 	;mov 	bl, [esi+u.fp]
  1252 0000DD4D 8A86[6A030300]      <1> 	mov 	al, [esi+u.fp]
  1253                              <1> 		; movb u.fp(r1),r2 / get an open file for this process
  1254                              <1>         ;or      bl, bl
  1255 0000DD53 08C0                <1> 	or	al, al
  1256 0000DD55 740D                <1> 	jz	short sysfork_5	
  1257                              <1> 		; beq 2f / file has not been opened by parent, 
  1258                              <1> 		       ; / so branch
  1259 0000DD57 B40A                <1> 	mov	ah, 10 ; Retro UNIX 386 v1 fsp structure size = 10 bytes
  1260 0000DD59 F6E4                <1> 	mul	ah
  1261                              <1> 	;movzx	ebx, ax
  1262 0000DD5B 6689C3              <1> 	mov	bx, ax
  1263                              <1> 	;shl     bx, 3
  1264                              <1> 		; asl r2 / multiply by 8
  1265                              <1>        		; asl r2 / to get index into fsp table
  1266                              <1>        		; asl r2
  1267 0000DD5E FE83[4E010300]      <1>   	inc     byte [ebx+fsp-2]
  1268                              <1> 		; incb fsp-2(r2) / increment number of processes
  1269                              <1> 			     ; / using file, because child will now be
  1270                              <1> 			     ; / using this file
  1271                              <1> sysfork_5: ; 2:
  1272 0000DD64 46                  <1>         inc     esi
  1273                              <1> 		; inc r1 / get next open file
  1274 0000DD65 6683FE0A            <1>         cmp     si, 10
  1275                              <1> 		; cmp r1,$10. / 10. files is the maximum number which
  1276                              <1> 			  ; / can be opened
  1277 0000DD69 72E2                <1> 	jb	short sysfork_4	
  1278                              <1> 		; blt 1b / check next entry
  1279 0000DD6B E98CFBFFFF          <1> 	jmp	sysret
  1280                              <1> 		; br sysret1
  1281                              <1> 
  1282                              <1> syscreat: ; < create file >
  1283                              <1> 	; 13/11/2017
  1284                              <1> 	; 27/10/2016
  1285                              <1> 	; 25/10/2016, 26/10/2016
  1286                              <1> 	; 15/10/2016, 16/10/2016, 17/10/2016
  1287                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
  1288                              <1> 	;	     -derived from INT_21H.ASM-
  1289                              <1> 	;            ("loc_INT21h_create_file")
  1290                              <1>         ; 	10/07/2011 (12/03/2011)
  1291                              <1>         ;	INT 21h Function AH = 3Ch
  1292                              <1>         ;	Create File
  1293                              <1>         ;	INPUT
  1294                              <1>         ;	   CX = Attributes
  1295                              <1>         ;          DS:DX= Address of zero terminaned path name
  1296                              <1>         ;
  1297                              <1> 	; 27/12/2015 (Retro UNIX 386 v1.1)
  1298                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1299                              <1> 	; 27/05/2013 (Retro UNIX 8086 v1)
  1300                              <1> 	;
  1301                              <1> 	; 'syscreat' called with two arguments; name and mode.
  1302                              <1> 	; u.namep points to name of the file and mode is put
  1303                              <1> 	; on the stack. 'namei' is called to get i-number of the file.		
  1304                              <1> 	; If the file aready exists, it's mode and owner remain 
  1305                              <1> 	; unchanged, but it is truncated to zero length. If the file
  1306                              <1> 	; did not exist, an i-node is created with the new mode via
  1307                              <1> 	; 'maknod' whether or not the file already existed, it is
  1308                              <1> 	; open for writing. The fsp table is then searched for a free
  1309                              <1> 	; entry. When a free entry is found, proper data is placed
  1310                              <1> 	; in it and the number of this entry is put in the u.fp list.
  1311                              <1> 	; The index to the u.fp (also know as the file descriptor)
  1312                              <1> 	; is put in the user's r0. 			
  1313                              <1> 	;
  1314                              <1> 	; Calling sequence:
  1315                              <1> 	;	syscreate; name; mode
  1316                              <1> 	; Arguments:
  1317                              <1> 	;	name - name of the file to be created
  1318                              <1> 	;	mode - mode of the file to be created
  1319                              <1> 	; Inputs: (arguments)
  1320                              <1> 	; Outputs: *u.r0 - index to u.fp list 
  1321                              <1> 	;		   (the file descriptor of new file)
  1322                              <1> 	; ...............................................................
  1323                              <1> 	;				
  1324                              <1> 	; Retro UNIX 8086 v1 modification: 
  1325                              <1> 	;       'syscreate' system call has two arguments; so,
  1326                              <1> 	;	* 1st argument, name is pointed to by BX register
  1327                              <1> 	;	* 2nd argument, mode is in CX register
  1328                              <1> 	;
  1329                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1330                              <1> 	;	to the user with the file descriptor/number 
  1331                              <1> 	;	(index to u.fp list).
  1332                              <1> 	;
  1333                              <1> 	;call	arg2
  1334                              <1> 	; * name - 'u.namep' points to address of file/path name
  1335                              <1> 	;          in the user's program segment ('u.segmnt')
  1336                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1337                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1338                              <1> 	;          which is on top of stack.
  1339                              <1> 	;
  1340                              <1> 	; TRDOS 386 (10/10/2016)
  1341                              <1> 	;	
  1342                              <1>         ; INPUT ->
  1343                              <1>         ;	   CL = File Attributes
  1344                              <1> 	;     	      bit 0 (1) - Read only file (R)
  1345                              <1> 	;             bit 1 (1) - Hidden file (H)
  1346                              <1>         ;             bit 2 (1) - System file (R)
  1347                              <1> 	;             bit 3 (1) - Volume label/name (V)
  1348                              <1>         ;             bit 4 (1) - Subdirectory (D)
  1349                              <1> 	;	      bit 5 (1) - File has been archived (A)	 	
  1350                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
  1351                              <1> 	;	
  1352                              <1> 	; OUTPUT ->
  1353                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
  1354                              <1> 	;          cf = 1 -> Error code in AL
  1355                              <1> 	;
  1356                              <1> 	; Modified Registers: EAX (at the return of system call)
  1357                              <1> 	;  
  1358                              <1> 	; Note: If the file is existing and it has not any one
  1359                              <1> 	;	of S,H,R,V,D attributes, it will be truncated 
  1360                              <1> 	;	to zero length; otherwise, access error will be 
  1361                              <1> 	;	returned. 
  1362                              <1> 
  1363                              <1> sysmkdir_0:
  1364 0000DD70 F6C108              <1> 	test	cl, 08h ; Volume name 
  1365 0000DD73 740A                <1> 	jz	short syscreat_0
  1366                              <1> 
  1367                              <1> 	; Volume name or long name creation
  1368                              <1> 	; is not permitted (in TRDOS 386)!
  1369 0000DD75 B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
  1370 0000DD7A E926020000          <1>         jmp	sysopen_dev_err
  1371                              <1> 
  1372                              <1> syscreat_0:
  1373                              <1>         ;mov	[u.namep], ebx
  1374 0000DD7F 51                  <1> 	push	ecx
  1375 0000DD80 89DE                <1> 	mov	esi, ebx
  1376                              <1> 	; file name is forced, change directory as temporary
  1377                              <1> 	;mov	ax, 1
  1378                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  1379                              <1> 	;call	set_working_path 
  1380 0000DD82 E8F9510000          <1> 	call	set_working_path_x ; 17/10/2016	
  1381 0000DD87 0F82D7000000        <1> 	jc	syscreat_err
  1382                              <1> 
  1383                              <1> 	; 16/10/2016
  1384 0000DD8D 803D[87960100]00    <1> 	cmp	byte [SWP_inv_fname], 0
  1385 0000DD94 776C                <1> 	ja	short  syscreat_inv_fname ; invalid file name !
  1386                              <1> 
  1387                              <1> 	; Here, we have a valid path and also a valid file name
  1388                              <1> 	; (Working dir has been changed if the path
  1389                              <1> 	;  -file name string- had contained a dir name.)
  1390                              <1> 
  1391 0000DD96 6631C0              <1> 	xor	ax, ax 
  1392                              <1> 	;mov	esi, FindFile_Name
  1393 0000DD99 E8E3B6FFFF          <1> 	call	find_first_file
  1394 0000DD9E 59                  <1> 	pop	ecx
  1395                              <1> 		; ESI = Directory Entry (FindFile_DirEntry) Location
  1396                              <1> 		; EDI = Directory Buffer Directory Entry Location
  1397                              <1> 		; EAX = File Size
  1398                              <1> 		;  BL = Attributes of The File/Directory
  1399                              <1> 		;  BH = Long Name Yes/No Status (>0 is YES)
  1400                              <1> 		;  DX > 0 : Ambiguous filename chars are used
  1401 0000DD9F 7269                <1> 	jc	short syscreat_1 ; file not found (the good!) 
  1402                              <1> 				 ; or another error (the bad') 
  1403                              <1> 
  1404                              <1> 	; (& the uggly!) truncate file to zero length before open
  1405                              <1> 
  1406                              <1> 	;'*' and '?' already checked at 'set_working_path' stage
  1407                              <1> 	;and	dx, dx
  1408                              <1> 	;jnz	short sysmkdir_err ; permission denied 
  1409                              <1> 				   ; invalid filename chars
  1410                              <1> 
  1411                              <1> 	;test	cl, 10h ; subdirectory ?
  1412                              <1> 	;jnz	short sysmkdir_err	
  1413                              <1> 
  1414                              <1> 	; BL = File Attributes:	
  1415                              <1> 	;     	      bit 0 (1) - Read only file (R)
  1416                              <1> 	;             bit 1 (1) - Hidden file (H)
  1417                              <1>         ;             bit 2 (1) - System file (R)
  1418                              <1> 	;             bit 3 (1) - Volume label/name (V)
  1419                              <1>         ;             bit 4 (1) - Subdirectory (D)
  1420                              <1> 	;	      bit 5 (1) - File has been archived	 	
  1421                              <1> 
  1422                              <1> 	; * existing directory must not be truncated
  1423                              <1> 	;   (we don't know it is empty or not, at this stage) 
  1424                              <1> 	; * existing volume name (or a long name) can not be
  1425                              <1> 	;   re-created or truncated by 'syscreat' 	
  1426                              <1> 	; * A file with S, H, R attributes must not be truncated
  1427                              <1> 	;   (change attributes to normal, if you need truncate it)
  1428                              <1> 
  1429 0000DDA1 F6C31F              <1> 	test	bl, 00011111b  ; check attributes of existing file
  1430 0000DDA4 754E                <1> 	jnz	short sysmkdir_err
  1431                              <1> 
  1432                              <1> 	;; normal file, OK to continue...
  1433                              <1> 
  1434                              <1> 	; ESI = FindFile_DirEntry
  1435 0000DDA6 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
  1436 0000DDAA C1E010              <1> 	shl	eax, 16 ; 13/11/2017
  1437 0000DDAD 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
  1438                              <1> 	; EAX = First cluster to be truncated/unlinked
  1439 0000DDB1 57                  <1> 	push	edi
  1440 0000DDB2 51                  <1> 	push	ecx
  1441 0000DDB3 BE00010900          <1> 	mov	esi, Logical_DOSDisks
  1442 0000DDB8 29C9                <1> 	sub	ecx, ecx
  1443 0000DDBA 8A2D[968A0100]      <1> 	mov	ch, [Current_Drv]
  1444 0000DDC0 01CE                <1> 	add	esi, ecx
  1445                              <1> 	; ESI = Logical dos drive description table address
  1446 0000DDC2 E8C9F7FFFF          <1> 	call	truncate_cluster_chain
  1447 0000DDC7 59                  <1> 	pop	ecx
  1448 0000DDC8 5F                  <1> 	pop	edi
  1449 0000DDC9 7230                <1> 	jc	short syscreate_truncate_err
  1450                              <1> 
  1451                              <1> 	; 26/10/2016
  1452                              <1> 	; EDI = Directory entry address in directory buffer
  1453                              <1> 	; Update directory entry
  1454 0000DDCB E848DCFFFF          <1> 	call	convert_current_date_time
  1455                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
  1456                              <1>         ; 	    AX = Time in dos dir entry format	
  1457 0000DDD0 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
  1458 0000DDD4 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
  1459 0000DDD8 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
  1460 0000DDDC 31C0                <1> 	xor	eax, eax ; file size = 0 
  1461 0000DDDE 89471C              <1> 	mov	[edi+DirEntry_FileSize], eax ; 0
  1462 0000DDE1 C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; data changed sign	
  1463 0000DDE8 BE[88930100]        <1> 	mov	esi, FindFile_DirEntry
  1464 0000DDED B201                <1> 	mov	dl, 1 ; open file for writing
  1465 0000DDEF E9AA000000          <1> 	jmp	sysopen_2
  1466                              <1> 
  1467                              <1> sysmkdir_err:
  1468                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
  1469 0000DDF4 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 ; 'permission denied !'
  1470 0000DDF9 EB73                <1>         jmp	short sysopen_err
  1471                              <1> 
  1472                              <1> syscreate_truncate_err:
  1473 0000DDFB B812000000          <1> 	mov	eax, ERR_DRV_WRITE ; 18 ; 'disk write error !'
  1474 0000DE00 EB6C                <1>         jmp	short sysopen_err
  1475                              <1> 
  1476                              <1> syscreat_inv_fname:  ; invalid file name chars 
  1477                              <1> 	; 16/10/2016
  1478 0000DE02 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME  ; 26 ; invalid file name chars 
  1479 0000DE07 59                  <1> 	pop	ecx
  1480 0000DE08 EB64                <1> 	jmp	sysopen_err
  1481                              <1> 
  1482                              <1> syscreat_1:
  1483                              <1> 	; Error code in EAX
  1484 0000DE0A 3C02                <1>         cmp	al, 02h ; 'File not found' error
  1485 0000DE0C 7560                <1>         jne	sysopen_err
  1486                              <1> 
  1487 0000DE0E F6C110              <1> 	test	cl, 10h ; Directory
  1488 0000DE11 0F852C020000        <1> 	jnz	sysmkdir_2
  1489                              <1> 
  1490                              <1> syscreat_2:
  1491 0000DE17 BE[78930100]        <1> 	mov	esi, FindFile_Name 
  1492                              <1>         ;xor	edx, edx
  1493 0000DE1C 31C0                <1>         xor	eax, eax ; File Size  = 0
  1494 0000DE1E 31DB                <1> 	xor	ebx, ebx
  1495 0000DE20 4B                  <1> 	dec 	ebx ; FFFFFFFFh -> create empty file 
  1496                              <1> 	            ;              (only for FAT fs) 
  1497                              <1> 	; CL = File Attributes
  1498 0000DE21 E8F8EBFFFF          <1> 	call	create_file
  1499 0000DE26 7246                <1> 	jc	sysopen_err
  1500                              <1> 		; EAX = New file's first cluster
  1501                              <1> 		; ESI = Logical Dos Drv Descr. Table Addr.
  1502                              <1> 		; EBX = offset CreateFile_Size
  1503                              <1> 		; ECX = Sectors per cluster (<256) 
  1504                              <1> 		; EDX = Directory entry index/number (<65536)
  1505                              <1> 	; 26/10/2016
  1506                              <1> 	;mov	esi, Directory_Buffer
  1507                              <1> 	;shl	dx, 5 ; *32
  1508                              <1> 	;add	esi, edx
  1509                              <1> 	;; esi = directory entry address in directory buffer
  1510                              <1> 
  1511                              <1> 	; Here, directory entry has been created but last
  1512                              <1> 	; modification date & time of the parent dir has not
  1513                              <1> 	; been updated, yet! 
  1514                              <1> 	; (Note: Directory and FAT buffers have been updated...)
  1515                              <1>  	
  1516 0000DE28 E824DDFFFF          <1> 	call	update_parent_dir_lmdt ; now, it is OK too!
  1517                              <1> 
  1518                              <1> 	; 25/10/2016
  1519 0000DE2D 66B80018            <1> 	mov	ax, 1800h
  1520 0000DE31 BE[78930100]        <1> 	mov	esi, FindFile_Name
  1521 0000DE36 E846B6FFFF          <1> 	call	find_first_file
  1522 0000DE3B 7231                <1> 	jc	short sysopen_err
  1523                              <1> 
  1524                              <1> 	; Only possible error after here is 
  1525                              <1> 	; "too many open files !" error.
  1526                              <1> 	;
  1527                              <1> 	; If "syscreat" will return with that error,
  1528                              <1> 	; (the file has been created but it could not be opened)
  1529                              <1> 	; the user must retry to open this file again
  1530                              <1> 	; or must close another file before using 
  1531                              <1> 	; "sysopen" system call.
  1532                              <1> 
  1533 0000DE3D B201                <1> 	mov	dl, 1 ; open file for writing
  1534                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
  1535                              <1> 	; EAX = File Size (= 0)
  1536 0000DE3F EB5D                <1> 	jmp	short sysopen_2
  1537                              <1> 
  1538                              <1> sysopen: ;<open file>
  1539                              <1> 	; 26/10/2016
  1540                              <1> 	; 24/10/2016
  1541                              <1> 	; 17/10/2016
  1542                              <1> 	; 15/10/2016
  1543                              <1> 	; 06/10/2016, 07/10/2016, 08/10/2016
  1544                              <1> 	; 05/10/2016 (TRDOS 386 = TRDOS v2.0) 
  1545                              <1> 	;	     -derived from INT_21H.ASM-
  1546                              <1> 	;            ("loc_INT21h_open_file")
  1547                              <1>         ; 	26/02/2011 
  1548                              <1>         ;	INT 21h Function AH = 3Dh
  1549                              <1>         ;	Open File
  1550                              <1>         ;	INPUT
  1551                              <1>         ;	   AL= File Access Value
  1552                              <1> 	;     	     0- Open for reading
  1553                              <1> 	;            1- Open for writing
  1554                              <1>         ;            2- Open for reading and writing
  1555                              <1>         ;          DS:DX= Pointer to filename (ASCIIZ)
  1556                              <1>         ;
  1557                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1558                              <1> 	; 22/05/2013 - 27/05/2013 (Retro UNIX 8086 v1)
  1559                              <1> 	;
  1560                              <1> 	; 'sysopen' opens a file in following manner:
  1561                              <1> 	;    1) The second argument in a sysopen says whether to
  1562                              <1> 	;	open the file ro read (0) or write (>0).
  1563                              <1> 	;    2) I-node of the particular file is obtained via 'namei'.
  1564                              <1> 	;    3) The file is opened by 'iopen'.
  1565                              <1> 	;    4) Next housekeeping is performed on the fsp table
  1566                              <1> 	;	and the user's open file list - u.fp.
  1567                              <1> 	;	a) u.fp and fsp are scanned for the next available slot.
  1568                              <1> 	;	b) An entry for the file is created in the fsp table.
  1569                              <1> 	;	c) The number of this entry is put on u.fp list.
  1570                              <1> 	;	d) The file descriptor index to u.fp list is pointed
  1571                              <1> 	;	   to by u.r0.
  1572                              <1> 	;
  1573                              <1> 	; Calling sequence:
  1574                              <1> 	;	sysopen; name; mode
  1575                              <1> 	; Arguments:
  1576                              <1> 	;	name - file name or path name
  1577                              <1> 	;	mode - 0 to open for reading
  1578                              <1> 	;	       1 to open for writing
  1579                              <1> 	; Inputs: (arguments)
  1580                              <1> 	; Outputs: *u.r0 - index to u.fp list (the file descriptor)
  1581                              <1> 	;		  is put into r0's location on the stack.	
  1582                              <1> 	; ...............................................................
  1583                              <1> 	;				
  1584                              <1> 	; Retro UNIX 8086 v1 modification: 
  1585                              <1> 	;       'sysopen' system call has two arguments; so,
  1586                              <1> 	;	* 1st argument, name is pointed to by BX register
  1587                              <1> 	;	* 2nd argument, mode is in CX register
  1588                              <1> 	;
  1589                              <1> 	;	AX register (will be restored via 'u.r0') will return
  1590                              <1> 	;	to the user with the file descriptor/number 
  1591                              <1> 	;	(index to u.fp list).
  1592                              <1> 	;
  1593                              <1> 	;call	arg2
  1594                              <1> 	; * name - 'u.namep' points to address of file/path name
  1595                              <1> 	;          in the user's program segment ('u.segmnt')
  1596                              <1> 	;          with offset in BX register (as sysopen argument 1).
  1597                              <1> 	; * mode - sysopen argument 2 is in CX register 
  1598                              <1> 	;          which is on top of stack.
  1599                              <1> 	;
  1600                              <1> 	; jsr r0,arg2 / get sys args into u.namep and on stack
  1601                              <1> 	;
  1602                              <1>        	; system call registers: ebx, ecx (through 'sysenter')
  1603                              <1> 	;
  1604                              <1> 	; TRDOS 386 (05/10/2016)
  1605                              <1> 	;	
  1606                              <1>         ; INPUT ->
  1607                              <1>         ;	   CL = File Access Value (Open Mode)
  1608                              <1> 	;     	      0 - Open file for reading
  1609                              <1> 	;             1 - Open file for writing
  1610                              <1>         ;             2 - Open device for reading
  1611                              <1> 	;	      3 - Open device for writing
  1612                              <1>         ;          EBX = Pointer to filename/devicename (ASCIIZ)
  1613                              <1> 	; OUTPUT ->
  1614                              <1> 	;          eax = File/Device Handle/Number (index) (AL)
  1615                              <1> 	;          cf = 1 -> Error code in AL
  1616                              <1> 	;
  1617                              <1> 	; Modified Registers: EAX (at the return of system call)
  1618                              <1> 	;  
  1619                              <1> 
  1620 0000DE41 80F901              <1> 	cmp	cl, 1 ; read file (0), write file (1)
  1621 0000DE44 7614                <1> 	jna	short sysopen_0
  1622                              <1> 
  1623 0000DE46 80F903              <1> 	cmp	cl, 3
  1624 0000DE49 0F8640010000        <1> 	jna	sysopen_device
  1625                              <1> 
  1626                              <1> 	; Invalid access code
  1627 0000DE4F B817000000          <1> 	mov	eax, ERR_INV_PARAMETER
  1628 0000DE54 0F874B010000        <1> 	ja	sysopen_dev_err
  1629                              <1> 
  1630                              <1> sysopen_0:
  1631                              <1> 	;mov	[u.namep], ebx
  1632 0000DE5A 51                  <1> 	push	ecx
  1633 0000DE5B 89DE                <1> 	mov	esi, ebx
  1634                              <1> 	; file name is forced, change directory as temporary
  1635                              <1> 	;mov	ax, 1
  1636                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
  1637                              <1> 	;call	set_working_path 
  1638 0000DE5D E81E510000          <1> 	call	set_working_path_x ; 17/10/2016	
  1639 0000DE62 731E                <1> 	jnc	short sysopen_1
  1640                              <1> 
  1641                              <1> syscreat_err: ; ecx = file attributes (for 'syscreat')
  1642 0000DE64 59                  <1> 	pop	ecx ; open mode  
  1643 0000DE65 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
  1644 0000DE67 7505                <1> 	jnz	short sysopen_err
  1645                              <1> 	; eax = 0
  1646 0000DE69 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
  1647                              <1> sysopen_err:
  1648 0000DE6E A3[64030300]        <1> 	mov	[u.r0], eax
  1649 0000DE73 A3[C8030300]        <1> 	mov	[u.error], eax
  1650 0000DE78 E8D8510000          <1> 	call 	reset_working_path
  1651 0000DE7D E95AFAFFFF          <1> 	jmp	error
  1652                              <1> 
  1653                              <1> sysopen_1:
  1654                              <1> 	;mov	esi, FindFile_Name
  1655 0000DE82 66B80018            <1>         mov	ax, 1800h ; Only files 
  1656 0000DE86 E8F6B5FFFF          <1> 	call	find_first_file
  1657 0000DE8B 5A                  <1> 	pop	edx
  1658 0000DE8C 72E0                <1> 	jc	short sysopen_err ; eax = 2 (File not found !)
  1659                              <1> 
  1660                              <1> 	; check_open_file_attr_access_code
  1661                              <1> 
  1662 0000DE8E F6C307              <1>         test	bl, 7  ; system, hidden, readonly 
  1663 0000DE91 740B                <1>         jz	short sysopen_2
  1664                              <1> 
  1665 0000DE93 20D2                <1> 	and	dl, dl ; 0 = read mode
  1666 0000DE95 7407                <1> 	jz	short sysopen_2
  1667                              <1> 
  1668                              <1> 	; 1 = write, 2 = read & write, >2 = invalid
  1669 0000DE97 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 = 'permission denied !'
  1670 0000DE9C EBD0                <1>         jmp	short sysopen_err
  1671                              <1> 
  1672                              <1> sysopen_2:
  1673                              <1> 	; esi = Directory Entry (FindFile_DirEntry) Location
  1674 0000DE9E 89F3                <1> 	mov	ebx, esi
  1675 0000DEA0 31F6                <1>         xor     esi, esi ; 0
  1676 0000DEA2 31FF                <1>         xor     edi, edi ; 0
  1677                              <1> sysopen_3: ; scan the list of entries in fsp table
  1678 0000DEA4 80BE[6A030300]00    <1>         cmp     byte [esi+u.fp], 0
  1679 0000DEAB 760F                <1>         jna     short sysopen_4 ; empty slot
  1680 0000DEAD 6646                <1>         inc     si
  1681 0000DEAF 6683FE0A            <1>         cmp     si, 10
  1682 0000DEB3 72EF                <1> 	jb	short sysopen_3
  1683                              <1> toomanyf:
  1684 0000DEB5 B80D000000          <1> 	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
  1685 0000DEBA EBB2                <1> 	jmp	short sysopen_err
  1686                              <1> 
  1687                              <1> sysopen_4: 
  1688 0000DEBC 80BF[F6990100]00    <1>         cmp     byte [edi+OF_MODE], 0 ; Scan open files table 
  1689 0000DEC3 760A                <1> 	jna     short sysopen_5
  1690 0000DEC5 6647                <1> 	inc	di
  1691 0000DEC7 6683FF0A            <1> 	cmp     di, OPENFILES ; max. number of open files (=10)
  1692 0000DECB 72EF                <1> 	jb	short sysopen_4
  1693 0000DECD EBE6                <1> 	jmp	short toomanyf
  1694                              <1> 
  1695                              <1> sysopen_5:
  1696 0000DECF FEC2                <1> 	inc	dl
  1697 0000DED1 8897[F6990100]      <1>         mov     [edi+OF_MODE], dl
  1698 0000DED7 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
  1699 0000DEDD 8897[EC990100]      <1>         mov     [edi+OF_DRIVE], dl ; Logical DOS drive number
  1700 0000DEE3 66C1E702            <1> 	shl	di, 2 ; *4 (dword offset)
  1701                              <1> 
  1702 0000DEE7 8987[3C9A0100]      <1> 	mov	[edi+OF_SIZE], eax ; File size in bytes
  1703                              <1> 
  1704 0000DEED 668B4314            <1>         mov 	ax, [ebx+DirEntry_FstClusHI]
  1705 0000DEF1 C1E010              <1> 	shl	eax, 16
  1706 0000DEF4 668B431A            <1> 	mov 	ax, [ebx+DirEntry_FstClusLO]
  1707 0000DEF8 8987[C4990100]      <1> 	mov     [edi+OF_FCLUSTER], eax ; First cluster
  1708 0000DEFE 8987[DC9A0100]      <1> 	mov     [edi+OF_CCLUSTER], eax ; Current cluster
  1709                              <1> 
  1710 0000DF04 31DB                <1>         xor	ebx, ebx
  1711 0000DF06 899F[149A0100]      <1>         mov     [edi+OF_POINTER], ebx ; offset pointer (0)
  1712 0000DF0C 899F[049B0100]      <1>         mov     [edi+OF_CCINDEX], ebx ; cluster index (0)
  1713                              <1> 
  1714 0000DF12 A1[A8930100]        <1> 	mov	eax, [FindFile_DirFirstCluster]
  1715 0000DF17 8987[649A0100]      <1> 	mov	[edi+OF_DIRFCLUSTER], eax
  1716                              <1> 
  1717 0000DF1D A1[AC930100]        <1> 	mov	eax, [FindFile_DirCluster]
  1718 0000DF22 8987[8C9A0100]      <1> 	mov	[edi+OF_DIRCLUSTER], eax
  1719                              <1> 
  1720                              <1> 	; Get (& Save) Volume ID 
  1721                              <1> 	; Important for files of removable drives
  1722                              <1> 	; (In order to check the drive has same volume/disk)
  1723 0000DF28 88D7                <1> 	mov	bh, dl
  1724 0000DF2A 81C300010900        <1>         add	ebx, Logical_DOSDisks
  1725 0000DF30 8A4303              <1>         mov	al, [ebx+LD_FATType]
  1726 0000DF33 3C01                <1>         cmp	al, 1
  1727 0000DF35 7209                <1>         jb	short sysopen_6_fs
  1728 0000DF37 3C02                <1>         cmp	al, 2
  1729 0000DF39 770A                <1>         ja	short sysopen_6_fat32
  1730                              <1> sysopen_6_fat:
  1731 0000DF3B 8B432D              <1>         mov	eax, [ebx+LD_BPB+VolumeID]
  1732 0000DF3E EB08                <1>         jmp	short sysopen_7
  1733                              <1> sysopen_6_fs:
  1734 0000DF40 8B4328              <1>         mov	eax, [ebx+LD_FS_VolumeSerial]
  1735 0000DF43 EB03                <1>         jmp	short sysopen_7
  1736                              <1> sysopen_6_fat32:
  1737 0000DF45 8B4349              <1>         mov	eax, [ebx+LD_BPB+FAT32_VolID]
  1738                              <1> sysopen_7:
  1739 0000DF48 A3[8C8A0100]        <1>         mov	[Current_VolSerial], eax
  1740                              <1> 
  1741 0000DF4D 8987[B49A0100]      <1> 	mov	[edi+OF_VOLUMEID], eax
  1742                              <1> 
  1743                              <1> 	; 24/10/2016
  1744 0000DF53 66D1EF              <1> 	shr	di, 1 ; 4/2, word offset
  1745 0000DF56 668B1D[B0930100]    <1> 	mov	bx, [FindFile_DirEntryNumber]
  1746 0000DF5D 66899F[2C9B0100]    <1> 	mov	[edi+OF_DIRENTRY], bx
  1747                              <1> 
  1748 0000DF64 31D2                <1> 	xor	edx, edx
  1749                              <1> 	;shr	di, 2 ; /4 (byte offset)
  1750 0000DF66 66D1EF              <1> 	shr	di, 1 ; 2/2, byte offset
  1751 0000DF69 8897[0A9A0100]      <1> 	mov	byte [edi+OF_OPENCOUNT], dl ; 0
  1752 0000DF6F 8897[009A0100]      <1> 	mov	byte [edi+OF_STATUS], dl ; 0
  1753                              <1> 
  1754 0000DF75 89FB                <1> 	mov	ebx, edi
  1755 0000DF77 FEC3                <1> 	inc	bl
  1756                              <1> 
  1757 0000DF79 889E[6A030300]      <1>         mov     [esi+u.fp], bl ; Open File Entry Number
  1758 0000DF7F 8935[64030300]      <1> 	mov     [u.r0], esi ; move index to u.fp list 
  1759                              <1> 			    ; into eax on stack
  1760                              <1> 
  1761 0000DF85 E8CB500000          <1>         call 	reset_working_path
  1762                              <1>         
  1763 0000DF8A E96DF9FFFF          <1> 	jmp	sysret
  1764                              <1> 
  1765                              <1> 	; (Retro UNIX 386 v1.0)
  1766                              <1> 	; 'fsp' table (10 bytes/entry)
  1767                              <1> 	; bit 15				   bit 0
  1768                              <1> 	; ---|-------------------------------------------
  1769                              <1> 	; r/w|		i-number of open file
  1770                              <1> 	; ---|-------------------------------------------
  1771                              <1> 	;		   device number
  1772                              <1> 	; -----------------------------------------------
  1773                              <1> 	; offset pointer, r/w pointer to file (bit 0-15)
  1774                              <1> 	; -----------------------------------------------
  1775                              <1> 	; offset pointer, r/w pointer to file (bit 16-31)
  1776                              <1> 	; ----------------------|------------------------
  1777                              <1> 	;  flag that says file 	| number of processes
  1778                              <1> 	;   has been deleted	| that have file open 
  1779                              <1> 	; ----------------------|------------------------
  1780                              <1> 
  1781                              <1> sysopen_device:
  1782                              <1> 	; 15/10/2016
  1783                              <1> 	; 08/10/2016
  1784                              <1> 	; 07/10/2016 (TRDOS 386 = TRDOS v2.0)
  1785 0000DF8F 51                  <1> 	push	ecx ; open mode
  1786 0000DF90 89E5                <1> 	mov	ebp, esp
  1787 0000DF92 B910000000          <1> 	mov	ecx, 16 ; transfer length = 16 bytes 
  1788 0000DF97 29CC                <1> 	sub	esp, ecx
  1789 0000DF99 89E7                <1> 	mov	edi, esp ; destination address 
  1790 0000DF9B 89DE                <1> 	mov 	esi, ebx ; dev name in user's memory space
  1791 0000DF9D E8AC3B0000          <1> 	call	transfer_from_user_buffer
  1792 0000DFA2 7310                <1> 	jnc	short sysopen_dev_0
  1793                              <1> 	; eax = ERR_OUT_OF_MEMORY = 4 = ERR_MINOR_IM
  1794 0000DFA4 59                  <1> 	pop	ecx
  1795                              <1> sysopen_dev_err:
  1796 0000DFA5 A3[64030300]        <1> 	mov	[u.r0], eax
  1797 0000DFAA A3[C8030300]        <1> 	mov	[u.error], eax
  1798 0000DFAF E928F9FFFF          <1> 	jmp	error
  1799                              <1> sysopen_dev_0:
  1800 0000DFB4 89FE                <1> 	mov	esi, edi ; Device name addr (max. 16 bytes, ASCIIZ) 
  1801                              <1> 			 ; for example: "tty, TTY, /dev/tty"
  1802 0000DFB6 E840530000          <1> 	call	get_device_number
  1803 0000DFBB 89EC                <1> 	mov	esp, ebp
  1804 0000DFBD 59                  <1> 	pop	ecx
  1805 0000DFBE 7307                <1> 	jnc	short sysopen_dev_1
  1806 0000DFC0 B818000000          <1> 	mov	eax, ERR_INV_DEV_NAME ; 24 ; 'invalid device name !'
  1807 0000DFC5 EBDE                <1> 	jmp	short sysopen_dev_err
  1808                              <1> sysopen_dev_1:
  1809                              <1> 	; eax = Device Number (AL)
  1810                              <1> 	;  cl = Open mode (2 = device read, 3 = device write)
  1811 0000DFC7 31DB                <1>         xor     ebx, ebx ; 0
  1812                              <1> sysopen_dev_2: ; scan the list of entries
  1813 0000DFC9 389B[6A030300]      <1>         cmp     [ebx+u.fp], bl ; 0
  1814 0000DFCF 760E                <1>         jna     short sysopen_dev_3 ; empty slot
  1815 0000DFD1 FEC3                <1>         inc     bl
  1816 0000DFD3 80FB0A              <1>         cmp     bl, 10
  1817 0000DFD6 72F1                <1> 	jb	short sysopen_dev_2
  1818                              <1> 	;
  1819 0000DFD8 B80D000000          <1> 	mov	eax, ERR_TOO_MANY_FILES ; too many open files !
  1820 0000DFDD EBC6                <1> 	jmp	short sysopen_dev_err
  1821                              <1> sysopen_dev_3:
  1822 0000DFDF 891D[64030300]      <1> 	mov 	[u.r0], ebx ; File/Device index/handle/descriptor
  1823                              <1> 	; eax = device number (entry offset)
  1824 0000DFE5 8AA8[88970100]      <1> 	mov	ch, [eax+DEV_ACCESS] ; bit 0 = accessable by users
  1825                              <1> 				     ; bit 1 = read access perm
  1826                              <1> 				     ; bit 2 = write access perm
  1827                              <1> 				     ; bit 3 = IOCTL permit to users
  1828                              <1> 				     ; bit 4 = block device if set
  1829                              <1> 				     ; bit 5 = 16 bit or 1024 byte
  1830                              <1> 				     ; bit 6 = 32 bit or 2048 byte
  1831                              <1> 				     ; bit 7 = installable device drv
  1832 0000DFEB F6C501              <1> 	test 	ch, 1 ; accessable by normal users (except root)
  1833 0000DFEE 7510                <1> 	jnz	short sysopen_dev_4 ; yes, permission has been given
  1834 0000DFF0 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0 ; root?
  1835 0000DFF7 7607                <1> 	jna	short sysopen_dev_4 ; superuser can open all devices
  1836                              <1> sysopen_dev_perm_err:
  1837 0000DFF9 B80B000000          <1> 	mov	eax, ERR_DEV_ACCESS  ; 11 = 'permission denied !'
  1838 0000DFFE EBA5                <1> 	jmp	short sysopen_dev_err
  1839                              <1> sysopen_dev_4:
  1840 0000E000 D0ED                <1> 	shr	ch, 1 ; result: 1 = read, 2 = write, 3 = r & w 
  1841 0000E002 FEC9                <1> 	dec	cl  ; result: 1 = read, 2 = write
  1842 0000E004 84E9                <1> 	test	cl, ch
  1843 0000E006 74F1                <1> 	jz	short sysopen_dev_perm_err 
  1844                              <1> 
  1845 0000E008 D0E5                <1> 	shl	ch, 1 ; bit 0 = 0
  1846                              <1> 	; eax = device number (entry offset)
  1847 0000E00A E808540000          <1> 	call	device_open
  1848 0000E00F 72E8                <1> 	jc	short sysopen_dev_perm_err 
  1849                              <1> 
  1850                              <1> 	; eax = device number (entry offset)
  1851 0000E011 0C80                <1> 	or	al, 80h ; set device bit (set bit 7 to 1)
  1852 0000E013 8B1D[64030300]      <1> 	mov	ebx, [u.r0]
  1853 0000E019 8883[6A030300]      <1> 	mov	[ebx+u.fp], al	; bit 7 (=1) points to device	
  1854                              <1> 	
  1855 0000E01F E9D8F8FFFF          <1> 	jmp	sysret
  1856                              <1> 
  1857                              <1> sysmkdir: ; < make directory >
  1858                              <1> 	; 15/10/2016
  1859                              <1> 	; 10/10/2016 (TRDOS 386 = TRDOS v2.0) 
  1860                              <1> 	;	     -derived from INT_21H.ASM-
  1861                              <1> 	;            ("loc_INT21h_create_file")
  1862                              <1>         ; 	10/07/2011 (12/03/2011)
  1863                              <1>         ;	INT 21h Function AH = 3Ch
  1864                              <1>         ;	Create File
  1865                              <1>         ;	INPUT
  1866                              <1>         ;	   CX = Attributes
  1867                              <1>         ;          DS:DX= Address of zero terminaned path name
  1868                              <1>         ;
  1869                              <1>         ;
  1870                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1871                              <1> 	; 27/05/2013 - 02/08/2013 (Retro UNIX 8086 v1)
  1872                              <1> 	;
  1873                              <1> 	; 'sysmkdir' creates an empty directory whose name is
  1874                              <1> 	; pointed to by arg 1. The mode of the directory is arg 2.	
  1875                              <1> 	; The special entries '.' and '..' are not present.
  1876                              <1> 	; Errors are indicated if the directory already exists or		
  1877                              <1> 	; user is not the super user. 
  1878                              <1> 	;
  1879                              <1> 	; Calling sequence:
  1880                              <1> 	;	sysmkdir; name; mode
  1881                              <1> 	; Arguments:
  1882                              <1> 	;	name - points to the name of the directory
  1883                              <1> 	;	mode - mode of the directory
  1884                              <1> 	; Inputs: (arguments)
  1885                              <1> 	; Outputs: -
  1886                              <1> 	;    (sets 'directory' flag to 1; 
  1887                              <1> 	;    'set user id on execution' and 'executable' flags to 0)
  1888                              <1> 	; ...............................................................
  1889                              <1> 	;				
  1890                              <1> 	; Retro UNIX 8086 v1 modification: 
  1891                              <1> 	;       'sysmkdir' system call has two arguments; so,
  1892                              <1> 	;	* 1st argument, name is pointed to by BX register
  1893                              <1> 	;	* 2nd argument, mode is in CX register
  1894                              <1> 	;
  1895                              <1> 	; TRDOS 386 (10/10/2016)
  1896                              <1> 	;	
  1897                              <1>         ; INPUT ->
  1898                              <1>         ;	   CL = Directory Attributes
  1899                              <1> 	;     	      bit 0 (1) - Read only file/dir (R)
  1900                              <1> 	;             bit 1 (1) - Hidden file/dir (H)
  1901                              <1>         ;             bit 2 (1) - System file/dir (R)
  1902                              <1> 	;             bit 3 (1) - Volume label/name (V)
  1903                              <1>         ;             bit 4 (1) - Subdirectory (D)
  1904                              <1> 	;	      bit 5 (1) - File/Dir has been archived (A)
  1905                              <1> 	;	   CX = 0 -> create normal directory	 	
  1906                              <1>         ;          EBX = Pointer to directory name (ASCIIZ) -path-
  1907                              <1> 	;	
  1908                              <1> 	; OUTPUT ->
  1909                              <1> 	;          eax = First cluster of the new directory
  1910                              <1> 	;          cf = 1 -> Error code in AL
  1911                              <1> 	;
  1912                              <1> 	; Modified Registers: EAX (at the return of system call)
  1913                              <1> 	;  
  1914                              <1> 	; Note: If the file or directory is existing
  1915                              <1> 	;	an access error will be returned. 
  1916                              <1> 
  1917 0000E024 6621C9              <1> 	and	cx, cx ; if cx = 0 -> create a normal subdir
  1918 0000E027 7413                <1> 	jz	short sysmkdir_1
  1919                              <1> 
  1920 0000E029 F6C110              <1> 	test	cl, 10h ; if dir flags set, also use other flags
  1921 0000E02C 0F853EFDFFFF        <1> 	jnz	sysmkdir_0 ; jump to head of 'syscreat'
  1922                              <1> 
  1923                              <1> 	; CX has wrong flags
  1924 0000E032 B817000000          <1> 	mov 	eax, ERR_INV_FLAGS
  1925 0000E037 E969FFFFFF          <1> 	jmp	sysopen_dev_err
  1926                              <1> 
  1927                              <1> sysmkdir_1:
  1928 0000E03C B110                <1> 	mov	cl, 10h ; set subdir flag and reset other flags
  1929 0000E03E E92DFDFFFF          <1> 	jmp	sysmkdir_0 ; jump to head of 'syscreat'
  1930                              <1> sysmkdir_2: 
  1931                              <1> 	; jump from 'syscreat' ; from 'syscreat_1'
  1932                              <1> 	;  CL = Directory attributes/flags  
  1933 0000E043 BE[78930100]        <1> 	mov	esi, FindFile_Name 
  1934 0000E048 E804D7FFFF          <1> 	call	make_sub_directory
  1935 0000E04D 0F821BFEFFFF        <1> 	jc	sysopen_err       ; NOTE: Old type (TRDOS 8086)
  1936                              <1> 				  ; error codes must be modified
  1937                              <1> 				  ; for next TRDOS 386 versions
  1938                              <1> 				  ; (10/10/2016)
  1939                              <1> 				  ; Old (MSDOS type)
  1940                              <1> 				  ; error codes (2011):
  1941                              <1> 				  ;  2 = file not found
  1942                              <1> 				  ;  3 = directory not found
  1943                              <1> 				  ;  5 = access denied
  1944                              <1> 				  ; 12 = no more files
  1945                              <1> 			          ; 19 = disk write protected   
  1946                              <1> 				  ; 39 = insufficient disk space
  1947                              <1> 				  ; 'sysdefs.s' ; 10/10/2016  	
  1948                              <1> 	
  1949 0000E053 A3[64030300]        <1> 	mov	[u.r0], eax ; New sub dir's first cluster
  1950                              <1> 
  1951 0000E058 E8F84F0000          <1>         call 	reset_working_path
  1952                              <1> 
  1953 0000E05D E99AF8FFFF          <1> 	jmp	sysret	
  1954                              <1> 
  1955                              <1> sysclose: ;<close file>
  1956                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0) 
  1957                              <1> 	;
  1958                              <1> 	; 14/05/2015 (Retro UNIX 386 v1 - Beginning)
  1959                              <1> 	; 22/05/2013 - 26/05/2013 (Retro UNIX 8086 v1)
  1960                              <1> 	;
  1961                              <1> 	; 'sysclose', given a file descriptor in 'u.r0', closes the
  1962                              <1> 	; associated file. The file descriptor (index to 'u.fp' list)
  1963                              <1> 	; is put in r1 and 'fclose' is called.
  1964                              <1> 	;
  1965                              <1> 	; Calling sequence:
  1966                              <1> 	;	sysclose
  1967                              <1> 	; Arguments:
  1968                              <1> 	;	-  
  1969                              <1> 	; Inputs: *u.r0 - file descriptor
  1970                              <1> 	; Outputs: -
  1971                              <1> 	; ...............................................................
  1972                              <1> 	;				
  1973                              <1> 	; Retro UNIX 8086 v1 modification:
  1974                              <1> 	;	 The user/application program puts file descriptor
  1975                              <1> 	;        in BX register as 'sysclose' system call argument.
  1976                              <1> 	; 	 (argument transfer method 1)
  1977                              <1> 
  1978                              <1> 	; TRDOS 386 (06/10/2016)
  1979                              <1> 	;	
  1980                              <1>         ; INPUT ->
  1981                              <1>         ;	   EBX = File Handle/Number (file index) (AL)
  1982                              <1> 	; OUTPUT ->
  1983                              <1> 	;          cf = 0 -> EAX = 0
  1984                              <1> 	;          cf = 1 -> Error code in EAX (ERR_FILE_NOT_OPEN)
  1985                              <1> 	;
  1986                              <1> 	; Modified Registers: EAX (at the return of system call)
  1987                              <1> 	;  
  1988                              <1> 
  1989 0000E062 89D8                <1> 	mov 	eax, ebx
  1990 0000E064 31DB                <1> 	xor	ebx, ebx	
  1991 0000E066 891D[64030300]      <1> 	mov	[u.r0], ebx ; 0  ; return value of EAX
  1992 0000E06C E86C2F0000          <1> 	call 	fclose
  1993 0000E071 0F8385F8FFFF        <1> 	jnc	sysret
  1994 0000E077 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
  1995 0000E07C A3[C8030300]        <1> 	mov	[u.error], eax ;
  1996 0000E081 A3[64030300]        <1> 	mov	[u.r0], eax ; ! invalid handle !
  1997 0000E086 E951F8FFFF          <1> 	jmp	error
  1998                              <1> 
  1999                              <1> sysread: ; < read from file >
  2000                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2001                              <1> 	;	     -derived from INT_21H.ASM-
  2002                              <1> 	;            ("loc_INT21h_read_file")
  2003                              <1>         ; 	13/03/2011 (05/03/2011)
  2004                              <1>         ;	INT 21h Function AH = 3Fh
  2005                              <1>         ;	Read from a File
  2006                              <1>         ;	INPUT
  2007                              <1> 	;	   BX = File Handle
  2008                              <1>         ;	   CX = Number of bytes to read
  2009                              <1>         ;          DS:DX= Buffer address
  2010                              <1>         ;
  2011                              <1> 	; Note: TRDOS 386 'sysread' has been derived from 
  2012                              <1> 	;	Retro UNIX 386 v1 'sysread', except a few 
  2013                              <1> 	;	code modifications.
  2014                              <1> 	;
  2015                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
  2016                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  2017                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  2018                              <1> 	;
  2019                              <1> 	; 'sysread' is given a buffer to read into and the number of
  2020                              <1> 	; characters to be read. If finds the file from the file
  2021                              <1> 	; descriptor located in *u.r0 (r0). This file descriptor
  2022                              <1> 	; is returned from a successful open call (sysopen).
  2023                              <1> 	; The i-number of file is obtained via 'rw1' and the data
  2024                              <1> 	; is read into core via 'readi'.
  2025                              <1> 	;
  2026                              <1> 	; Calling sequence:
  2027                              <1> 	;	sysread; buffer; nchars
  2028                              <1> 	; Arguments:
  2029                              <1> 	;	buffer - location of contiguous bytes where 
  2030                              <1> 	;		 input will be placed.
  2031                              <1> 	;	nchars - number of bytes or characters to be read.
  2032                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  2033                              <1> 	; Outputs: *u.r0 - number of bytes read.	
  2034                              <1> 	; ...............................................................
  2035                              <1> 	;				
  2036                              <1> 	; Retro UNIX 8086 v1 modification: 
  2037                              <1> 	;       'sysread' system call has three arguments; so,
  2038                              <1> 	;	* 1st argument, file descriptor is in BX register
  2039                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  2040                              <1> 	;	* 3rd argument, number of bytes is in DX register
  2041                              <1> 	;
  2042                              <1> 	;	AX register (will be restored via 'u.r0') will return
  2043                              <1> 	;	to the user with number of bytes read. 
  2044                              <1> 	;
  2045                              <1> 	; TRDOS 386 (05/10/2016)
  2046                              <1> 	;	
  2047                              <1>         ; INPUT ->
  2048                              <1>         ;	   EBX = File handle (descriptor/index)
  2049                              <1> 	;	   ECX = Buffer address		
  2050                              <1>         ;          EDX = Number of bytes
  2051                              <1> 	; OUTPUT ->
  2052                              <1> 	;          EAX = Number of bytes have been read
  2053                              <1> 	;          cf = 1 -> Error code in AL
  2054                              <1> 	;
  2055                              <1> 	; Modified Registers: EAX (at the return of system call)
  2056                              <1> 	; 
  2057                              <1> 
  2058                              <1> 	; EBX = File descriptor
  2059 0000E08B E89B2F0000          <1> 	call	getf1 
  2060 0000E090 7277                <1> 	jc	short device_read ; read data from device
  2061                              <1> 	; EAX = First cluster of the file
  2062                              <1> 
  2063 0000E092 E83F000000          <1> 	call	rw1
  2064 0000E097 730A                <1> 	jnc	short sysread_0
  2065                              <1> 
  2066 0000E099 A3[64030300]        <1> 	mov	[u.r0], eax ; error code
  2067 0000E09E E939F8FFFF          <1> 	jmp	error
  2068                              <1> 	 
  2069                              <1> sysread_0:
  2070 0000E0A3 E892350000          <1> 	call	readi
  2071 0000E0A8 EB1D                <1> 	jmp	short rw0
  2072                              <1> 
  2073                              <1> syswrite: ; < write to file >
  2074                              <1> 	; 23/10/2016
  2075                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2076                              <1> 	;	     -derived from INT_21H.ASM-
  2077                              <1> 	;            ("loc_INT21h_write_file")
  2078                              <1>         ; 	13/03/2011 (05/03/2011)
  2079                              <1>         ;	INT 21h Function AH = 40h
  2080                              <1>         ;	Write to a File
  2081                              <1>         ;	INPUT
  2082                              <1> 	;	   BX = File Handle
  2083                              <1>         ;	   CX = Number of bytes to write
  2084                              <1>         ;          DS:DX= Buffer address
  2085                              <1>         ;
  2086                              <1> 	; Note: TRDOS 386 'sysrwrite' has been derived from 
  2087                              <1> 	;	Retro UNIX 386 v1 'syswrite', except a few 
  2088                              <1> 	;	code modifications.
  2089                              <1> 	;
  2090                              <1> 
  2091                              <1> 	; 13/05/2015 (Retro UNIX 386 v1)
  2092                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  2093                              <1> 	; 23/05/2013 (Retro UNIX 8086 v1)
  2094                              <1> 	;
  2095                              <1> 	; 'syswrite' is given a buffer to write onto an output file
  2096                              <1> 	; and the number of characters to write. If finds the file
  2097                              <1> 	; from the file descriptor located in *u.r0 (r0). This file 
  2098                              <1> 	; descriptor is returned from a successful open or create call
  2099                              <1> 	; (sysopen or syscreat). The i-number of file is obtained via
  2100                              <1> 	; 'rw1' and buffer is written on the output file via 'write'.
  2101                              <1> 	;
  2102                              <1> 	; Calling sequence:
  2103                              <1> 	;	syswrite; buffer; nchars
  2104                              <1> 	; Arguments:
  2105                              <1> 	;	buffer - location of contiguous bytes to be writtten.
  2106                              <1> 	;	nchars - number of characters to be written.
  2107                              <1> 	; Inputs: *u.r0 - file descriptor (& arguments)
  2108                              <1> 	; Outputs: *u.r0 - number of bytes written.	
  2109                              <1> 	; ...............................................................
  2110                              <1> 	;				
  2111                              <1> 	; Retro UNIX 8086 v1 modification: 
  2112                              <1> 	;       'syswrite' system call has three arguments; so,
  2113                              <1> 	;	* 1st argument, file descriptor is in BX register
  2114                              <1> 	;	* 2nd argument, buffer address/offset in CX register
  2115                              <1> 	;	* 3rd argument, number of bytes is in DX register
  2116                              <1> 	;
  2117                              <1> 	;	AX register (will be restored via 'u.r0') will return
  2118                              <1> 	;	to the user with number of bytes written. 
  2119                              <1> 	;
  2120                              <1> 	; INPUT ->
  2121                              <1>         ;	   EBX = File handle (descriptor/index)
  2122                              <1> 	;	   ECX = Buffer address		
  2123                              <1>         ;          EDX = Number of bytes
  2124                              <1> 	; OUTPUT ->
  2125                              <1> 	;          EAX = Number of bytes have been written
  2126                              <1> 	;          cf = 1 -> Error code in AL
  2127                              <1> 	;
  2128                              <1> 	; Modified Registers: EAX (at the return of system call)
  2129                              <1> 	;  
  2130                              <1> 
  2131                              <1> 	; EBX = File descriptor
  2132 0000E0AA E87C2F0000          <1> 	call	getf1 
  2133 0000E0AF 7274                <1> 	jc	short device_write ; write data to device
  2134                              <1> 	; EAX = First cluster of the file
  2135                              <1> 	; EBX = File number  (Open file number) ; 23/10/2016
  2136                              <1> 
  2137 0000E0B1 E820000000          <1> 	call	rw1
  2138 0000E0B6 730A                <1> 	jnc	short syswrite_0
  2139 0000E0B8 A3[64030300]        <1> 	mov	[u.r0], eax ; error code
  2140 0000E0BD E91AF8FFFF          <1> 	jmp	error
  2141                              <1> 	 
  2142                              <1> syswrite_0:
  2143 0000E0C2 E89F3C0000          <1> 	call	writei
  2144                              <1> rw0: ; 1:
  2145 0000E0C7 A1[8C030300]        <1>         mov	eax, [u.nread]
  2146 0000E0CC A3[64030300]        <1> 	mov	[u.r0], eax
  2147 0000E0D1 E926F8FFFF          <1> 	jmp	sysret
  2148                              <1> 
  2149                              <1> rw1:	
  2150                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0) 
  2151                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
  2152                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
  2153                              <1> 	; 23/05/2013 - 24/05/2013 (Retro UNIX 8086 v1)
  2154                              <1> 	; System call registers: ebx, ecx, edx (through 'sysenter')
  2155                              <1> 	;
  2156                              <1> 	; EBX = File descriptor
  2157                              <1> 	;call	getf1 ; calling point in 'getf' from 'rw1'
  2158                              <1> 	;jc	short device_rw ; read/write data from/to device
  2159                              <1> 	; EAX = First cluster of the file
  2160                              <1> 
  2161 0000E0D6 83F802              <1> 	cmp 	eax, 2
  2162 0000E0D9 7217                <1> 	jb	short rw2
  2163                              <1> 	;
  2164 0000E0DB 890D[84030300]      <1> 	mov	[u.base], ecx 	; buffer address/offset 
  2165                              <1> 				;(in the user's virtual memory space)
  2166 0000E0E1 8915[88030300]      <1> 	mov	[u.count], edx 
  2167                              <1> 
  2168 0000E0E7 C705[C8030300]0000- <1>         mov     dword [u.error], 0 ; reset the last error code
  2168 0000E0EF 0000                <1>
  2169 0000E0F1 C3                  <1> 	retn
  2170                              <1> 
  2171                              <1> rw2:
  2172 0000E0F2 B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN ; file not open !
  2173 0000E0F7 A3[C8030300]        <1> 	mov	dword [u.error], eax
  2174 0000E0FC C3                  <1> 	retn
  2175                              <1> rw3: 
  2176 0000E0FD B80B000000          <1> 	mov	eax, ERR_FILE_ACCESS ; permission denied !
  2177 0000E102 A3[C8030300]        <1> 	mov	dword [u.error], eax
  2178 0000E107 F9                  <1> 	stc
  2179 0000E108 C3                  <1> 	retn
  2180                              <1> 
  2181                              <1> device_read:
  2182                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
  2183                              <1> 	; cl = DEV_OPENMODE ; open mode
  2184                              <1> 	; ch = DEV_ACCESS   ; access flags   
  2185                              <1> 	; al = DEV_DRIVER   ; device number (eax)
  2186                              <1> 
  2187 0000E109 F6C101              <1> 	test	cl, 1 ; 1 = read, 2 = write, 3 = read&write
  2188 0000E10C 74EF                <1> 	jz	short rw3
  2189                              <1> 
  2190 0000E10E 89C3                <1> 	mov	ebx, eax
  2191 0000E110 66C1E302            <1> 	shl	bx, 2 ; *4
  2192                              <1> 
  2193 0000E114 F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  2194 0000E117 7406                <1> 	jz	short d_read_2 ; Kernel device
  2195                              <1> 	; installable device
  2196                              <1> d_read_1:
  2197 0000E119 FFA3[44970100]      <1>         jmp	dword [ebx+IDEV_RADDR-4]
  2198                              <1> d_read_2:
  2199 0000E11F FFA3[E0480100]      <1> 	jmp	dword [ebx+KDEV_RADDR-4]
  2200                              <1> 
  2201                              <1> device_write:
  2202                              <1> 	; 11/10/2016 (TRDOS 386 = TRDOS v2.0)
  2203                              <1> 	; cl = DEV_OPENMODE ; open mode
  2204                              <1> 	; ch = DEV_ACCESS   ; access flags   
  2205                              <1> 	; al = DEV_DRIVER   ; device number (eax)
  2206                              <1> 
  2207 0000E125 F6C102              <1> 	test	cl, 2 ; 1 = read, 2 = write, 3 = read&write
  2208 0000E128 74D3                <1> 	jz	short rw3	
  2209                              <1> 
  2210 0000E12A 89C3                <1> 	mov	ebx, eax
  2211 0000E12C 66C1E302            <1> 	shl	bx, 2 ; *4
  2212                              <1> 
  2213 0000E130 F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  2214 0000E133 7406                <1> 	jz	short d_write_2 ; Kernel device
  2215                              <1> 	; installable device
  2216                              <1> d_write_1:
  2217 0000E135 FFA3[64970100]      <1>         jmp	dword [ebx+IDEV_WADDR-4]
  2218                              <1> d_write_2:
  2219 0000E13B FFA3[30490100]      <1> 	jmp	dword [ebx+KDEV_WADDR-4]
  2220                              <1> 
  2221                              <1> 
  2222                              <1> sysemt: ; enable (or disable) multi tasking -time sharing-
  2223                              <1> 	;
  2224                              <1> 	; 23/05/2016 - TRDOS 386 (TRDOS v2.0)
  2225                              <1> 	; 14/05/2015 (Retro UNIX 386 v1)
  2226                              <1> 	; 10/12/2013 - 20/04/2014 (Retro UNIX 8086 v1)
  2227                              <1> 	;
  2228                              <1> 	; Retro UNIX 8086 v1 modification: 
  2229                              <1> 	;	'Enable Multi Tasking'  system call instead 
  2230                              <1> 	;	of 'Emulator Trap' in original UNIX v1 for PDP-11.
  2231                              <1> 	;
  2232                              <1> 	; Retro UNIX 8086 v1 feature only!
  2233                              <1> 	;	Using purpose: Kernel will start without time-out
  2234                              <1> 	;	(internal clock/timer) functionality.
  2235                              <1> 	;	Then etc/init will enable clock/timer for
  2236                              <1> 	;	multi tasking. 
  2237                              <1> 	;
  2238                              <1> 	; INPUT ->
  2239                              <1> 	;	BL = 0 -> disable multi tasking
  2240                              <1> 	;	BL > 1 -> enable multi tasking (time sharing) 
  2241                              <1> 	; OUTPUT ->
  2242                              <1> 	;	none	
  2243                              <1> 	;
  2244                              <1> 	;  Note: Multi tasking is disabled during system
  2245                              <1> 	;	 initialization, it must be enabled by using
  2246                              <1> 	;	 this system call. (Otherwise, running proces 
  2247                              <1> 	;	 will not be changed by another process within
  2248                              <1> 	;	 run time sequence/schedule, if running process
  2249                              <1> 	;	 will not 'release' itself. Only 'wakeup' procedure
  2250                              <1> 	;	 for waiting processes and programmed timer events
  2251                              <1> 	;	 for other processes can change running process 
  2252                              <1> 	;	 while multi tasking is disabled.) ** 23/05/2016 **
  2253                              <1> 
  2254 0000E141 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0 ; root ?
  2255                              <1> 	;ja	error
  2256 0000E148 0F87D3F8FFFF        <1> 	ja	badsys ; 14/05/2015
  2257                              <1> 	;
  2258 0000E14E FA                  <1> 	cli
  2259 0000E14F 881D[62960100]      <1> 	mov	[multi_tasking], bl ; 0 to disable, >0 to enable
  2260 0000E155 E9A2F7FFFF          <1> 	jmp	sysret
  2261                              <1> 
  2262                              <1> systimer:
  2263                              <1> 	; 02/01/2017
  2264                              <1> 	; 21/12/2016
  2265                              <1> 	; 19/12/2016
  2266                              <1> 	; 10/12/2016 (callback)
  2267                              <1> 	; 10/06/2016
  2268                              <1> 	; 07/06/2016
  2269                              <1> 	; 06/06/2016
  2270                              <1> 	; 21/05/2016
  2271                              <1> 	; 19/05/2016
  2272                              <1> 	; 18/05/2016 - TRDOS 386 (TRDOS v2.0)
  2273                              <1> 	; (TRDOS 386 feature only!)
  2274                              <1> 	;
  2275                              <1> 	; (start or stop timer event(s))	
  2276                              <1> 	;
  2277                              <1> 	; INPUT ->
  2278                              <1> 	;	BL = Signal return byte (response byte)
  2279                              <1> 	;	     (Any requested value between 0 and 255)
  2280                              <1> 	;	     (Kernel will put it at the requested address)    	
  2281                              <1> 	;	BH = Time count unit
  2282                              <1> 	;	     0 = Stop timer event
  2283                              <1> 	;	     1 = 18.2 ticks per second
  2284                              <1> 	;	     2 = 10 milliseconds  		
  2285                              <1> 	;	     3 = 1 second (for real time clock interrupt) 	 
  2286                              <1> 	;	     4 = time/tick count in current time count unit
  2287                              <1> 	;	    // 10/12/2016			
  2288                              <1> 	;	    80h = Stop timer event (callback method)
  2289                              <1> 	;	    81h = 18.2 ticks per second, callback method
  2290                              <1> 	;	    82h = 10 milliseconds, callback method 	
  2291                              <1> 	;	    83h = 1 second (for RTC int), callback method 	
  2292                              <1> 	;	    84h = current time count unit, callback method
  2293                              <1> 	;
  2294                              <1> 	;	    Note: Only 03h or 83h will set real time clock
  2295                              <1> 	;		  (RTC) events (Others are for PIT events)! 	
  2296                              <1> 	;	
  2297                              <1> 	;	NOTE: If callback (user service) method is used,
  2298                              <1> 	;	    EDX will point to the return address (of service
  2299                              <1> 	;	    procedure) in user's space instead of signal 
  2300                              <1> 	;	    response byte address. (TRDOS 386 kernel will
  2301                              <1> 	;	    direct the cpu to that address -in user's space-
  2302                              <1> 	;	    at the return of system call or interrupt 
  2303                              <1> 	;	    just after the adjusted count/time is elapsed.)
  2304                              <1> 	;	    User's sevice routine must be ended with a
  2305                              <1> 	;	    'iret'. Normal return addresses from system 
  2306                              <1> 	;	    calls or and interrupts will be kept same except
  2307                              <1> 	;	    the timer returns. 			
  2308                              <1>      	;
  2309                              <1> 	;	BH = 0 -> Stop timer event
  2310                              <1> 	;	BL = Timer event number (1 to 255) if BH = 0     	
  2311                              <1> 	;	     If BL = 0, all timer events (which are belongs
  2312                              <1> 	;	      to running process) will be stopped 		    
  2313                              <1> 	;	ECX = Time/Tick count (depending on time count unit)
  2314                              <1> 	;	EDX = Signal return (Response) byte address
  2315                              <1> 	;	      (virtual address in user's memory space)
  2316                              <1> 	; OUTPUT ->
  2317                              <1> 	;	AL = Timer event number	(1 to 255) (max. value = 16)
  2318                              <1> 	;	IF BH Input = 0 & CF = 0 & AL = 0 -> 
  2319                              <1> 	;	     timer event(s) has/have been stopped/finished
  2320                              <1> 	;	CF = 1 & AL = 0 -> no timer setting space to set
  2321                              <1> 	;	CF = 1 & AL > 0 -> timer count unit is not usable
  2322                              <1> 	;
  2323                              <1> 	;	NOTE: To modify a time count for a user function,
  2324                              <1> 	;	      at first, current timer event must be stopped
  2325                              <1> 	;	      then a new timer event (which is related with
  2326                              <1> 	;	      same user function) must be started.
  2327                              <1> 	;		
  2328                              <1> 	;	      Signal return (response) byte may be used for 
  2329                              <1> 	;	      several purposes. Kernel will put this value 
  2330                              <1> 	;	      to requested address during timer interrupt,
  2331                              <1> 	;	      program/user can check this value to understand
  2332                              <1> 	;	      which event has been occurred and what is changed.
  2333                              <1> 	;	      (Multi timer events can share same signal address)
  2334                              <1> 	;	
  2335                              <1> 	;	NOTE: If the process is running while the time count
  2336                              <1> 	;	      is reached, kernel will put signal return (response)
  2337                              <1> 	;	      byte value at requested address during timer
  2338                              <1> 	;	      interrupt and the process will continue to run.
  2339                              <1> 	;	      Program/process must call (jump to) it's timer event
  2340                              <1> 	;	      function as required, for checking the timer event
  2341                              <1> 	;	      status via signal return (response) byte address. 
  2342                              <1> 	;
  2343                              <1> 	;	      If the process is not running (waiting or sleeping
  2344                              <1> 	;	      or released) while the time count is reached,
  2345                              <1> 	;	      it is restarted from where it left, to ensure
  2346                              <1> 	;	      proper multi media (video, audio, clock, timer)
  2347                              <1> 	;	      functionality.
  2348                              <1> 	;
  2349                              <1> 	;	      (It is better to use 'syswait' or 'syssleep',
  2350                              <1> 	;	      or 'sysrele' system call just after the timer
  2351                              <1> 	;	      function. Otherwise, timer events may block other
  2352                              <1> 	;	      processes which are not using timer events.)  	 		 			 		 	
  2353                              <1> 	;	     	      		 			
  2354                              <1> 	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  2355                              <1> 	;       Owner:	        resb 1 ; 0 = free
  2356                              <1> 	;		  	       ;>0 = process number (u.uno)
  2357                              <1> 	;	Calback:	resb 1 ; 1 = callback, 0 = response byte
  2358                              <1> 	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  2359                              <1> 	;		   	       ; 1 = Real Time Clock interrupt 
  2360                              <1> 	;	Response:       resb 1 ; 0 to 255, signal return value
  2361                              <1> 	;	Count Limit:	resd 1 ; count of ticks (total/set)
  2362                              <1> 	;	Current Count: 	resd 1 ; count of ticks (current)
  2363                              <1> 	;	Response Addr:  resd 1 ; response byte (pointer) address
  2364                              <1> 	;
  2365                              <1> 
  2366                              <1> 	; 19/12/2016 (timer callback)
  2367 0000E15A C605[A09B0100]00    <1> 	mov	byte [tcallback], 0 
  2368 0000E161 C605[A19B0100]00    <1> 	mov	byte [trtc], 0
  2369 0000E168 C705[D0030300]0000- <1> 	mov	dword [u.tcb], 0 ; this is not necessary...
  2369 0000E170 0000                <1>
  2370                              <1> 
  2371 0000E172 80FF80              <1> 	cmp	bh, 80h
  2372 0000E175 7225                <1> 	jb	short systimer_cb2
  2373 0000E177 7704                <1> 	ja	short systimer_cb0
  2374                              <1> 
  2375 0000E179 31D2                <1> 	xor	edx, edx ; 0, reset callback address
  2376 0000E17B EB0B                <1> 	jmp	short systimer_cb1
  2377                              <1> 
  2378                              <1> systimer_cb0:
  2379 0000E17D 80FF84              <1> 	cmp	bh, 84h	
  2380 0000E180 7764                <1> 	ja	short systimer_5 ;  undefined, error
  2381                              <1> 
  2382                              <1> 	;mov	byte [tcallback], 1 ; 19/12/2016
  2383 0000E182 FE05[A09B0100]      <1> 	inc	byte [tcallback]
  2384                              <1> 
  2385                              <1> systimer_cb1:
  2386 0000E188 0FB635[B3030300]    <1> 	movzx	esi, byte [u.uno] ; process number
  2387 0000E18F 66C1E602            <1> 	shl	si, 2	
  2388 0000E193 8996[0C010300]      <1> 	mov	[esi+p.tcb-4], edx ; set process timer callback address
  2389                              <1> 				   ; (overwrite prev value if it is set!)
  2390 0000E199 80E77F              <1> 	and	bh, 7Fh
  2391                              <1> 
  2392                              <1> systimer_cb2:
  2393 0000E19C 80FF02              <1> 	cmp	bh, 2
  2394 0000E19F 7445                <1>         je      short systimer_5  ; only 18.2 ticks per second is usable
  2395                              <1> 				  ; 10 milliseconds (100 Hertz) timer 
  2396                              <1> 				  ; will be set later (18/05/2016)
  2397 0000E1A1 774B                <1>         ja      short systimer_6 
  2398                              <1> 
  2399 0000E1A3 20FF                <1> 	and	bh, bh
  2400 0000E1A5 0F84BA000000        <1>         jz      systimer_9        ; stop timer event(s)
  2401                              <1> 
  2402                              <1> 	; bh = 1 (timer interrupt, 18.2 Hz, IBM PC/AT ROMBIOS default)
  2403                              <1> 
  2404                              <1> systimer_19:
  2405 0000E1AB B00A                <1> 	mov	al, 10 ; (*)
  2406                              <1> 
  2407                              <1> systimer_0:
  2408 0000E1AD B710                <1> 	mov	bh, 16
  2409                              <1> 	;
  2410 0000E1AF 383D[63960100]      <1> 	cmp	[timer_events], bh ; 16 ; 07/06/2016
  2411 0000E1B5 7319                <1> 	jnb 	short systimer_3  ; max. 16 timer events
  2412                              <1> 	;
  2413 0000E1B7 50                  <1> 	push	eax ; (*)
  2414                              <1> 
  2415 0000E1B8 BF[60040300]        <1> 	mov	edi, timer_set  ; beginning address of timer events
  2416                              <1> 				; setting space
  2417 0000E1BD 30C0                <1> 	xor	al, al ; 0
  2418                              <1> systimer_1:
  2419 0000E1BF FEC0                <1> 	inc	al
  2420 0000E1C1 803F00              <1> 	cmp	byte [edi], 0 	; is it free space ?
  2421 0000E1C4 7639                <1> 	jna	short systimer_7 ; yes
  2422 0000E1C6 FECF                <1> 	dec	bh
  2423 0000E1C8 7405                <1> 	jz	short systimer_2
  2424 0000E1CA 83C710              <1> 	add	edi, 16
  2425 0000E1CD EBF0                <1> 	jmp	short  systimer_1 ; next event space
  2426                              <1> 
  2427                              <1> systimer_2:
  2428 0000E1CF 58                  <1> 	pop	eax ; (*) discard
  2429                              <1> systimer_3:
  2430 0000E1D0 C605[64030300]00    <1> 	mov	byte [u.r0], 0
  2431                              <1> systimer_4:
  2432 0000E1D7 C705[C8030300]1B00- <1>         mov     dword [u.error], ERR_MISC
  2432 0000E1DF 0000                <1>
  2433                              <1>                                 ; one of miscellaneous/other errors
  2434 0000E1E1 E9F6F6FFFF          <1> 	jmp	error ; cf -> 1
  2435                              <1> 
  2436                              <1> systimer_5:
  2437 0000E1E6 883D[64030300]      <1> 	mov	[u.r0], bh ; Time count unit (=2 or >3)
  2438 0000E1EC EBE9                <1> 	jmp	short systimer_4 ; 07/06/2016
  2439                              <1> 
  2440                              <1> systimer_6:
  2441 0000E1EE 80FF04              <1> 	cmp	bh, 4
  2442 0000E1F1 77F3                <1>         ja      short systimer_5  ; undefined time count unit
  2443                              <1> 	;jb	short systimer_16	
  2444                              <1> 
  2445                              <1> 	;mov	al, 1	; default (use current timer unit)
  2446                              <1> 			; countdown value is in ECX ! 
  2447                              <1> 			; max. value of ecx = 4294967296/10
  2448                              <1>         ;jmp    short systimer_0
  2449                              <1> 	;jmp	short systimer_19	
  2450 0000E1F3 74B6                <1> 	je	short systimer_19
  2451                              <1> 
  2452                              <1> systimer_16:
  2453                              <1> 	; bh = 3
  2454                              <1> 	; timer event via real time clock interrupt
  2455                              <1> 	; interrupt/update frequency: 1 Hz (1 tick per second)
  2456                              <1> 	
  2457 0000E1F5 B0B6                <1> 	mov	al, 182 ; (*) ; 18.2 * 10
  2458 0000E1F7 FE05[A19B0100]      <1> 	inc	byte [trtc] ; timer event via real time clock
  2459 0000E1FD EBAE                <1>         jmp     short systimer_0
  2460                              <1> 
  2461                              <1> systimer_7:
  2462 0000E1FF A2[64030300]        <1> 	mov	[u.r0], al ; timer event number
  2463                              <1> 	;
  2464                              <1> 	; edi = address of empty timer event area
  2465 0000E204 A0[B3030300]        <1> 	mov	al, [u.uno]
  2466 0000E209 FA                  <1> 	cli 	; disable interrupts 
  2467 0000E20A AA                  <1> 	stosb	; process number
  2468 0000E20B A0[A09B0100]        <1> 	mov	al, [tcallback] ; timer callback flag
  2469 0000E210 AA                  <1> 	stosb 	; 1= callback method, 0= signal response byte method
  2470 0000E211 A0[A19B0100]        <1> 	mov	al, [trtc] ; timer interrupt type
  2471 0000E216 AA                  <1> 	stosb	; 1= real time clock, 0= programmable interval timer
  2472 0000E217 88D8                <1> 	mov	al, bl ; Signal return (Response) value
  2473 0000E219 AA                  <1> 	stosb   ; response byte
  2474 0000E21A 58                  <1> 	pop	eax ; (*) ; 10 or 182
  2475 0000E21B 89D3                <1> 	mov	ebx, edx ; virtual address for response/signal byte
  2476 0000E21D F7E1                <1> 	mul	ecx
  2477                              <1> 	; (eax = 10 * count of 18.2 Hz timer ticks)
  2478                              <1> 	; (count down step = 10)
  2479 0000E21F AB                  <1> 	stosd  ; count limit (reset value)
  2480 0000E220 AB                  <1> 	stosd  ; current count value
  2481                              <1> 
  2482                              <1> 	; 19/12/2016
  2483 0000E221 803D[A09B0100]00    <1> 	cmp	byte [tcallback], 0 ; timer callback method ?
  2484 0000E228 7604                <1> 	jna	short systimer_17 ; no	
  2485 0000E22A 89D8                <1> 	mov	eax, ebx ; virtual address for callback routine 
  2486 0000E22C EB0D                <1> 	jmp	short systimer_18
  2487                              <1> 
  2488                              <1> systimer_17: ; signal response byte method
  2489                              <1> 	; ebx = virtual address
  2490                              <1> 	; [u.pgdir] = page directory's physical address
  2491                              <1> 	; 20/02/2017
  2492 0000E22E FE05[A29B0100]      <1> 	inc	 byte [no_page_swap] ; 1 
  2493                              <1> 			; Do not add this page to swap queue
  2494                              <1> 			; and remove it from swap queue if it is
  2495                              <1> 			; on the queue.
  2496 0000E234 E8AF80FFFF          <1> 	call	get_physical_addr
  2497 0000E239 721A                <1> 	jc	short systimer_8 ; 07/06/2016
  2498                              <1> 	; eax = physical address of the virtual address in user's space
  2499                              <1> systimer_18:
  2500 0000E23B AB                  <1> 	stosd	; response addr (physical) or callback addr (virtual)
  2501 0000E23C FE05[63960100]      <1> 	inc	byte [timer_events] ; 07/06/201
  2502                              <1> 	; 02/01/2017
  2503 0000E242 0FB605[B3030300]    <1> 	movzx	eax, byte [u.uno]
  2504 0000E249 FE80[FF000300]      <1> 	inc	byte [eax+p.timer-1]	
  2505                              <1> 	;
  2506 0000E24F FB                  <1> 	sti 	; enable interrupts
  2507 0000E250 E9A7F6FFFF          <1> 	jmp	sysret
  2508                              <1> 
  2509                              <1> systimer_8:
  2510                              <1> 	; 10/06/2016
  2511                              <1> 	; 07/06/2016
  2512 0000E255 28C0                <1> 	sub	al, al ; 0
  2513 0000E257 8847F4              <1> 	mov	[edi-12], al ; clear process number (free timer event)
  2514                              <1> 	;mov	dword [edi], eax ; 0
  2515 0000E25A FB                  <1> 	sti
  2516 0000E25B A2[64030300]        <1> 	mov	[u.r0], al ; 0
  2517 0000E260 E977F6FFFF          <1> 	jmp	error
  2518                              <1> 
  2519                              <1> systimer_9:
  2520                              <1> 	; 10/06/2016
  2521                              <1> 	; 07/06/2016
  2522 0000E265 28C0                <1> 	sub	al, al
  2523 0000E267 A2[64030300]        <1> 	mov	byte [u.r0], al ; 0
  2524 0000E26C 3805[63960100]      <1> 	cmp     byte [timer_events], al ;  0
  2525 0000E272 7631                <1> 	jna	short systimer_12
  2526                              <1> 
  2527                              <1> 	; Note: ecx and edx are undefined here
  2528                              <1> 	;	(for stop timer function)
  2529                              <1> 
  2530 0000E274 BE[60040300]        <1> 	mov	esi, timer_set  ; beginning address of timer events
  2531                              <1> 				; setting space	 
  2532 0000E279 A0[B3030300]        <1> 	mov	al, [u.uno]
  2533                              <1> 	
  2534 0000E27E B710                <1> 	mov	bh, 16
  2535                              <1> 
  2536 0000E280 08DB                <1> 	or	bl, bl
  2537 0000E282 7544                <1> 	jnz	short systimer_15
  2538                              <1> 
  2539                              <1> 	; clear timer event areas belong to current process
  2540                              <1> 	; (for stopping all timer events belong to current process) 
  2541 0000E284 FA                  <1> 	cli 	; disable interrupts
  2542                              <1> systimer_10:
  2543                              <1> 	; 10/06/2016
  2544                              <1> 	; 07/06/2016 	
  2545 0000E285 8A26                <1> 	mov	ah, [esi]
  2546 0000E287 08E4                <1> 	or	ah, ah ; 0 ?
  2547 0000E289 7411                <1> 	jz	short systimer_11
  2548 0000E28B 38C4                <1> 	cmp	ah, al ; is the process number (owner) same ?
  2549 0000E28D 750D                <1>         jne     short systimer_11 ; no
  2550                              <1> 
  2551                              <1> 	;mov	byte [esi], 0
  2552 0000E28F 66C7060000          <1> 	mov	word [esi], 0 ; clear
  2553                              <1> 	;mov	dword [esi+12], 0 ; clear
  2554                              <1> 
  2555 0000E294 FE0D[63960100]      <1> 	dec	byte [timer_events]
  2556 0000E29A 7409                <1> 	jz	short systimer_12
  2557                              <1> 
  2558                              <1> systimer_11:
  2559 0000E29C FECF                <1> 	dec	bh
  2560 0000E29E 7405                <1> 	jz	short systimer_12
  2561 0000E2A0 83C610              <1> 	add	esi, 16
  2562 0000E2A3 EBE0                <1> 	jmp	short systimer_10
  2563                              <1> 
  2564                              <1> systimer_12:
  2565 0000E2A5 0FB635[B3030300]    <1> 	movzx	esi, byte [u.uno]
  2566 0000E2AC 08DB                <1> 	or	bl, bl ; all timer events or one timer event ?
  2567 0000E2AE 740C                <1> 	jz	short systimer_13
  2568 0000E2B0 8A9E[FF000300]      <1> 	mov	bl, [esi+p.timer-1]
  2569 0000E2B6 20DB                <1> 	and	bl, bl	; previous number of timer events for the process
  2570 0000E2B8 7408                <1> 	jz	short systimer_14
  2571 0000E2BA FECB                <1> 	dec	bl  ; previous number of timer events for the process - 1
  2572                              <1> systimer_13:
  2573 0000E2BC 889E[FF000300]      <1> 	mov	[esi+p.timer-1], bl ; 0 ; no timer events for process
  2574                              <1> systimer_14:
  2575 0000E2C2 FB                  <1> 	sti	; enable interrupts
  2576 0000E2C3 E934F6FFFF          <1> 	jmp	sysret
  2577                              <1> 
  2578                              <1> systimer_15:
  2579 0000E2C8 38FB                <1> 	cmp	bl, bh ; 16
  2580 0000E2CA 0F8707FFFFFF        <1>         ja      systimer_4      ; max. 16 timer events !
  2581                              <1> 	;
  2582 0000E2D0 88DA                <1> 	mov	dl, bl
  2583 0000E2D2 FECA                <1> 	dec	dl  ; 16 -> 15 ... 1 -> 0 
  2584 0000E2D4 C0E204              <1> 	shl	dl, 4 ; * 16
  2585 0000E2D7 0FB6FA              <1> 	movzx	edi, dl
  2586 0000E2DA 01F7                <1> 	add	edi, esi ; timer_set 
  2587                              <1> 	
  2588 0000E2DC 3A07                <1> 	cmp	al, [edi] ; process number
  2589 0000E2DE 0F85F3FEFFFF        <1>         jne     systimer_4
  2590                              <1> 	
  2591                              <1> 	; same process ID
  2592 0000E2E4 FA                  <1> 	cli	; disable interrupts
  2593                              <1>  	; 10/06/2016 ; 02/01/2017
  2594                              <1> 	;mov	byte [edi], 0 
  2595 0000E2E5 66C7070000          <1> 	mov	word [edi], 0 ; clear
  2596                              <1> 	;mov	dword [edi+12], 0 ; clear
  2597 0000E2EA FE0D[63960100]      <1> 	dec	byte [timer_events]
  2598 0000E2F0 EBB3                <1> 	jmp	short systimer_12
  2599                              <1> 
  2600                              <1> sysvideo: ; VIDEO DATA TRANSFER FUNCTIONS
  2601                              <1> 	; 27/02/2021
  2602                              <1> 	; 26/02/2021
  2603                              <1> 	; 25/02/2021
  2604                              <1> 	; 23/01/2021
  2605                              <1> 	; 22/02/2021
  2606                              <1> 	; 21/02/2021
  2607                              <1> 	; 15/02/2021, 16/02/2021, 18/02/2021
  2608                              <1> 	; 10/02/2021, 11/02/2021, 12/02/2021
  2609                              <1> 	; 07/02/2021, 08/02/2021
  2610                              <1> 	; 01/02/2021, 02/02/2021, 05/02/2021
  2611                              <1> 	; 29/01/2021, 30/01/2021, 31/01/2021
  2612                              <1> 	; 23/01/2021, 24/01/2021, 28/01/2021
  2613                              <1> 	; 18/01/2021, 19/01/2021, 22/01/2021
  2614                              <1> 	; 04/01/2021, 10/01/2021, 11/01/2021
  2615                              <1> 	; 01/01/2021, 02/01/2021, 03/01/2021
  2616                              <1> 	; 28/12/2020, 29/12/2020, 30/12/2020
  2617                              <1> 	; 25/12/2020, 26/12/2020
  2618                              <1> 	; 21/12/2020, 23/12/2020
  2619                              <1> 	; 12/12/2020, 14/12/2020
  2620                              <1> 	; 10/12/2020, 11/12/2020
  2621                              <1> 	; 03/12/2020, 04/12/2020
  2622                              <1> 	; 22/11/2020, 23/11/2020
  2623                              <1> 	; 21/11/2020 (TRDOS 386 v2.0.3)
  2624                              <1> 	; 12/05/2017
  2625                              <1> 	; 11/07/2016
  2626                              <1> 	; 13/06/2016
  2627                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  2628                              <1> 	;
  2629                              <1> 	; VIDEO DATA TRANSFER FUNCTIONS:
  2630                              <1> 	;
  2631                              <1> 	; Inputs:
  2632                              <1> 	;		; 07/02/2021
  2633                              <1> 	;	BH = 0 = VIDEO BIOS Mode 3, tty/text mode data transfers
  2634                              <1> 	;	     BL = 
  2635                              <1> 	;		Bits 0&1, Transfer direction
  2636                              <1> 	;	     	 	0 - System to system
  2637                              <1> 	;			1 - User to system
  2638                              <1> 	;			2 - System to user
  2639                              <1> 	;			3 - Exhange (Swap) - 28/01/2021
  2640                              <1> 	;		Bits 2, Transfer Type
  2641                              <1> 	;			0 - Display page (complete) transfer
  2642                              <1> 	;	     		1 - Display page window (col,row) transfer
  2643                              <1> 	;		; 28/01/2021
  2644                              <1> 	;		Bits 3..7 - Reserved, undefined (must be 0)
  2645                              <1> 	;	        ; 28/01/2021	
  2646                              <1> 	;	     /// BL = 0 -> System to system (display page) transfer
  2647                              <1> 	;		 CL = Source page (0FFh = current video page)
  2648                              <1> 	;		 DL = Destination page (0FFh = current video page)
  2649                              <1> 	;		 (Note: Nothing to do if src & dest are same page)
  2650                              <1> 	;	     /// BL = 1&2 -> user to system & system to user transfer
  2651                              <1> 	;		 ECX = User's buffer address
  2652                              <1> 	;		 DL = Video page (0FFh = current video page)
  2653                              <1> 	;	     /// BL = 3 -> exchange (swap) display page ; 28/01/2021
  2654                              <1> 	;		 ECX = User's buffer address
  2655                              <1> 	;		 DL = Video page (0FFh = current video page)
  2656                              <1> 	;		 EDI = Swap address in user's memory (must be > 0)
  2657                              <1> 	;	     /// BL = 5&6&7 -> user to system, system to user transfer 
  2658                              <1> 	;		(system window is in current/active display page)
  2659                              <1> 	;		 ESI = User's buffer address
  2660                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2661                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2662                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2663                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2664                              <1>         ;                If BL = 5 or BL bit 0 & bit 1 are 1 ; 28/01/2021
  2665                              <1> 	;		 EDI = Swap address (in user's memory space)
  2666                              <1> 	;		 (If swap address > 0, previous content of the window
  2667                              <1> 	;		 will be saved into swap area in user's memory space)
  2668                              <1> 	;	     /// BL = 4 -> system to system transfer
  2669                              <1> 	;		 ESI = System's source buffer (video page) address
  2670                              <1> 	;		 ECX Low 16 bits = Top left column (X1 position)
  2671                              <1> 	;		 ECX High 16 bits = Top row (Y1 position)
  2672                              <1> 	;		 EDX Low 16 bits = Bottom right column (X2 position)
  2673                              <1> 	;		 EDX High 16 bits = Bottom row (Y2 position)
  2674                              <1> 	;		 EDI = System's destination buffer (video page) addr
  2675                              <1> 	;
  2676                              <1> 	;		; 06/02/2021
  2677                              <1> 	;		; 05/02/2021
  2678                              <1> 	;		; 01/02/2021, 02/02/2021
  2679                              <1> 	;		; 30/01/2021, 31/02/2021
  2680                              <1> 	;		; 29/01/2021 (major modification)
  2681                              <1> 	;		; 23/11/2020 (major modification)
  2682                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
  2683                              <1> 	;	BH = 1 = VGA Graphics (0A0000h) data transfers
  2684                              <1> 	;		BL bit 7
  2685                              <1> 	;		   resolution (screen width) option
  2686                              <1> 	;		   0 = 320 pixels
  2687                              <1> 	;		   1 = 640 pixels
  2688                              <1> 	;		.. followings are same with SVGA transfer function
  2689                              <1> 	;		BL bit 6
  2690                              <1> 	;		   direction option
  2691                              <1> 	;		   0 = user to system (video memory)
  2692                              <1> 	;		   1 = system to user
  2693                              <1> 	;		BL bit 5
  2694                              <1> 	;		   masked/direct (non-masked) operations
  2695                              <1> 	;		   1 = masked, 0 = non-masked (direct)
  2696                              <1> 	;		BL bit 4
  2697                              <1> 	;		   page/window option
  2698                              <1> 	;		   1 = window, 0 = display page (screen)
  2699                              <1> 	;		BL bit 0 to 3 (pixel operation types)
  2700                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
  2701                              <1> 	;		   1 = Change (New, Fill) color
  2702                              <1> 	;		   2 = Add color
  2703                              <1> 	;		   3 = Sub color
  2704                              <1> 	;		   4 = OR color
  2705                              <1> 	;		   5 = AND color
  2706                              <1> 	;		   6 = XOR color
  2707                              <1> 	;		   7 = NOT color
  2708                              <1> 	;		   8 = NEG color
  2709                              <1> 	;		   9 = INC color
  2710                              <1> 	;		  10 = DEC color
  2711                              <1> 	;		  11 = Mix (Average) colors
  2712                              <1> 	;		  12 = Replace pixel colors
  2713                              <1> 	;		  13 = Copy pixel block(s)
  2714                              <1> 	;		  14 = Write line(s)
  2715                              <1> 	;		  15 = Write character (font)
  2716                              <1> 	;
  2717                              <1> 	;	   Input Registers for pixel operations:
  2718                              <1> 	;		 Same with LFB data transfer function below
  2719                              <1> 	;
  2720                              <1> 	;		; 25/02/2021		
  2721                              <1> 	;		; 05/02/2021, 06/02/2021
  2722                              <1> 	;		; 01/02/2021, 02/02/2021
  2723                              <1> 	;		; 30/01/2021, 31/02/2021
  2724                              <1> 	; 		; 29/01/2021 (major modification)
  2725                              <1> 	;		; 23/11/2020 (major modification)
  2726                              <1> 	;		; 22/11/2020 (bugfixes and extensions)
  2727                              <1> 	;	BH = 2 = Super VGA, LINEAR FRAME BUFFER data transfers
  2728                              <1> 	;		BL bit 7
  2729                              <1> 	;		   unused (invalid), must be 0
  2730                              <1> 	;		BL bit 6
  2731                              <1> 	;		   direction option
  2732                              <1> 	;		   0 = user to system (video memory)
  2733                              <1> 	;		   1 = system to user
  2734                              <1> 	;		BL bit 5
  2735                              <1> 	;		   masked/direct (non-masked) operations
  2736                              <1> 	;		   1 = masked, 0 = non-masked (direct)
  2737                              <1> 	;		BL bit 4
  2738                              <1> 	;		   page/window option
  2739                              <1> 	;		   1 = window, 0 = display page (screen)
  2740                              <1> 	;		BL bit 0 to 3 (pixel operation types)
  2741                              <1> 	;		   0 = Copy pixels (colors) ((mask color))
  2742                              <1> 	;		   1 = Change (New, Fill) color
  2743                              <1> 	;		   2 = Add color
  2744                              <1> 	;		   3 = Sub color
  2745                              <1> 	;		   4 = OR color
  2746                              <1> 	;		   5 = AND color
  2747                              <1> 	;		   6 = XOR color
  2748                              <1> 	;		   7 = NOT color
  2749                              <1> 	;		   8 = NEG color
  2750                              <1> 	;		   9 = INC color
  2751                              <1> 	;		  10 = DEC color
  2752                              <1> 	;		  11 = Mix (Average) colors
  2753                              <1> 	;		  12 = Replace pixel colors
  2754                              <1> 	;		  13 = Copy pixel block(s)
  2755                              <1> 	;		  14 = Write line(s)
  2756                              <1> 	;		  15 = Write character (font)
  2757                              <1> 	;
  2758                              <1> 	;	   Note: If HW of EBX > 0, it is VESA VBE mode number
  2759                              <1> 	;		 otherwise, function will be applied
  2760                              <1> 	;		 to current (VESA VBE) video mode.
  2761                              <1> 	;		
  2762                              <1> 	;	   Input Registers for pixel operations:
  2763                              <1> 	;		-- user to system & system to system --
  2764                              <1> 	;		-- (BL = 0 to 0Fh) -- non-masked, screen --
  2765                              <1> 	;		-- (BL = 10h to 1Fh) -- non-masked, window --
  2766                              <1> 	;		-- (BL = 20h to 2Fh) -- masked, screen --
  2767                              <1> 	;		-- (BL = 30h to 3Fh) -- masked, window --
  2768                              <1> 	;		(*) window, (**) masked (***) sys to sys
  2769                              <1> 	;		for BL bit 0 to 3
  2770                              <1> 	;		00h: COPY PIXELS
  2771                              <1> 	;		  If BL bit 4 = 0 ; 21/02/2021
  2772                              <1> 	;		     full screen copy	
  2773                              <1>    	;		     ECX & EDX will not be used
  2774                              <1> 	;		    (user buffer must fit to display page)	  	
  2775                              <1> 	;		  If BL bit 4 = 1 ; 21/02/2021		
  2776                              <1> 	;		    ECX = start position (row, column) (*)
  2777                              <1> 	;			  (HW = row, CX = column)
  2778                              <1> 	;		    EDX = size (rows, colums) (*)
  2779                              <1> 	;			  (HW = rows, DX = columns)
  2780                              <1> 	;		          (0 -> invalid)
  2781                              <1> 	;		          (1 -> horizontal or vertical line)
  2782                              <1> 	;		    ESI = user's buffer address
  2783                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  2784                              <1> 	;			  (this color will be excluded)
  2785                              <1> 	;		01h: CHANGE PIXEL COLORS
  2786                              <1> 	;		02h: ADD PIXEL COLORS
  2787                              <1> 	;		03h: SUB PIXEL COLORS
  2788                              <1> 	;		04h: OR PIXEL COLORS
  2789                              <1> 	;		05h: AND PIXEL COLORS
  2790                              <1> 	;		06h: XOR PIXEL COLORS
  2791                              <1> 	;		0Bh: MIX PIXEL COLORS
  2792                              <1> 	;		     CL = color (8 bit, 256 colors)
  2793                              <1> 	;		    ECX = color (16 bit and true colors)
  2794                              <1> 	;		    EDX = start position (row, column) (*)
  2795                              <1> 	;			 (HW = row, DX = column)
  2796                              <1> 	;		    ESI = size (rows, colums) (*)
  2797                              <1> 	;			  (HW = rows, SI = columns)
  2798                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  2799                              <1> 	;			  (this color will be excluded)
  2800                              <1> 	;		07h: NOT PIXEL COLORS
  2801                              <1> 	;		08h: NEG PIXEL COLORS
  2802                              <1> 	;		09h: INC PIXEL COLORS
  2803                              <1> 	;		0Ah: DEC PIXEL COLORS
  2804                              <1> 	;		    ECX = start position (row, column) (*)
  2805                              <1> 	;			  (HW = row, CX = column)
  2806                              <1> 	;		    EDX = size (rows, colums) (*)
  2807                              <1> 	;			  (HW = rows, DX = columns)
  2808                              <1> 	;		          (0 -> invalid)
  2809                              <1> 	;		          (1 -> horizontal or vertical line)
  2810                              <1> 	;		    EDI = mask color (**) ; 25/02/2021
  2811                              <1> 	;			  (this color will be excluded)
  2812                              <1> 	;		0Ch: REPLACE PIXEL COLORS
  2813                              <1> 	;		     CL = current color (8 bit, 256 colors)
  2814                              <1> 	;		    ECX = current color (16 bit and true colors)
  2815                              <1> 	;		     DL = new color (8 bit, 256 colors)
  2816                              <1> 	;		    EDX = new color (16 bit and true colors)
  2817                              <1> 	;		    ESI = start position (row, column) (*)
  2818                              <1> 	;			  (HW = row, SI = column)
  2819                              <1> 	;		    EDI = size (rows, colums) (*)
  2820                              <1> 	;			  (HW = rows, DI = columns)
  2821                              <1> 	;		0Dh: COPY PIXEL BLOCK(S) -full screen-
  2822                              <1> 	;		   -If BL bit 5 is 0-
  2823                              <1> 	;		    ECX = start position (row, column) (*)
  2824                              <1> 	;			  (HW = row, CX = column)
  2825                              <1> 	;		    EDX = size (rows, colums) (*)
  2826                              <1> 	;			  (HW = rows, DX = columns)
  2827                              <1> 	;		          (0 -> invalid)
  2828                              <1> 	;		          (1 -> horizontal or vertical line)
  2829                              <1> 	;		    ESI = destination (row, column) (***)
  2830                              <1> 	;		   -If BL bit 5 is 1-
  2831                              <1> 	;	               CL = color (8 bit, 256 colors)
  2832                              <1> 	;		      ECX = color (16 bit and true colors)
  2833                              <1> 	;	   	      EDX = count of blocks (not bytes)
  2834                              <1> 	;			    (limit: 2048 blocks)
  2835                              <1> 	;		      ESI = user's buffer address 
  2836                              <1> 	;			  contains 64 bits block data
  2837                              <1> 	;			  BLOCK ADDRESS - (row, col), dword
  2838                              <1> 	;			  (first 32 bits)
  2839                              <1> 	;			  BLOCK SIZE - (rows, cols), dword
  2840                              <1> 	;			  (second 32 bits)
  2841                              <1> 	;		; 10/02/2021
  2842                              <1> 	;		0Eh: WRITE LINE(s) -full screen- 
  2843                              <1> 	;		   -If BL bit 5 is 0-	
  2844                              <1> 	; 		    CL = color (8 bit, 256 colors)
  2845                              <1> 	; 		   ECX = color (16 bit and true colors)
  2846                              <1> 	; 		    DX = low 12 bits - size (length)
  2847                              <1> 	;			 high 4 bits - direction or type
  2848                              <1> 	;			     0 - Horizontal line
  2849                              <1> 	;			     1 - Vertical line
  2850                              <1> 	;			   > 1 - undefined, invalid
  2851                              <1> 	; 		   ESI = start position (row, column)
  2852                              <1> 	;			 (HW = row, SI = column)
  2853                              <1> 	;		   -If BL bit 5 is 1-
  2854                              <1> 	;		     CL = color (8 bit, 256 colors)
  2855                              <1> 	;		    ECX = color (16 bit and true colors)
  2856                              <1> 	;		     DX = number of lines (in user buffer)
  2857                              <1> 	;			   (limit: 2048 lines)	
  2858                              <1> 	;		    ESI = user's buffer
  2859                              <1> 	;		          contains 64 bit data for lines
  2860                              <1> 	;			   START POINT: 32 bit (row, col)
  2861                              <1> 	;			   LENGTH: 32 bit
  2862                              <1> 	;			   high 16 bits - 0
  2863                              <1> 	;			   bit 0-11 - length
  2864                              <1> 	;			   bit 12-15 - type (length)
  2865                              <1> 	;		0Fh: WRITE CHARACTER (FONT)
  2866                              <1> 	;		     CL = char's color (8 bit, 256 colors)
  2867                              <1> 	;		    ECX = char's color (16 bit and true colors)
  2868                              <1> 	;		     DL = Character's ASCII code
  2869                              <1> 	;		     DH bit 0 -> font height
  2870                              <1> 	;			  0 -> 8x16 character font
  2871                              <1> 	;			  1 -> 8x8 character font
  2872                              <1> 	;		     DH bit 1 & 2 -> scale	
  2873                              <1> 	;			  0 = 1/1 (8 pixels per char row)
  2874                              <1> 	;			  1 = 2/1 (16 pixels per char row)
  2875                              <1> 	;			  2 = 3/1 (24 pixels per char row)
  2876                              <1> 	;			  3 = 4/1 (32 pixels per char row) 
  2877                              <1> 	;		     DH bit 6 -> [ufont] option (1 = use [ufont])
  2878                              <1> 	;		     If DH bit 7 = 1
  2879                              <1> 	;			 USER FONT (from user buffer)
  2880                              <1> 	;			    DL = 0 -> 8x8 (width: 1 byte per row)
  2881                              <1> 	;			    DL = 1 -> 8x16
  2882                              <1> 	;			    DL = 2 -> 16x16 (width: 2 bytes)
  2883                              <1> 	;			    DL = 3 -> 16x32
  2884                              <1> 	;			    DL = 4 -> 24x24 (width: 3 bytes)
  2885                              <1> 	;			    DL = 5 -> 24x48
  2886                              <1> 	;			    DL = 6 -> 32x32 (width: 4 bytes)
  2887                              <1> 	;			    DL = 7 -> 32x64
  2888                              <1> 	;			    DL > 7 -> invalid (unused)
  2889                              <1> 	;			 EDI = user's font buffer address
  2890                              <1> 	;			    (NOTE: byte order is as row0,row1,row2..)
  2891                              <1> 	; 		    ESI = start position (row, column) (*)
  2892                              <1> 	;			     (HW = row, SI = column)
  2893                              <1> 	;
  2894                              <1> 	;		-- system to user --
  2895                              <1> 	;		   BL (bit 0 to 7) 
  2896                              <1> 	;	 	40h: COPY PIXELS (full screen, display page)
  2897                              <1> 	;		    EDI = user's buffer address
  2898                              <1> 	;		41h: COPY PIXELS (window)
  2899                              <1> 	;		    ECX = start position (row, column) (*)
  2900                              <1> 	;			  (HW = row, CX = column)
  2901                              <1> 	;		    EDX = size (rows, colums) (*)
  2902                              <1> 	;			  (HW = rows, DX = columns)
  2903                              <1> 	;		          (<=1 -> horizontal or vertical line)
  2904                              <1> 	;		    EDI = user's buffer address
  2905                              <1> 	;
  2906                              <1> 	;		Example: (29/01/2021)
  2907                              <1> 	;		    ecx = 00400064h (start at row 64, column 100) 
  2908                              <1> 	;		    edx = 00320048h (size: 50 rows, 72 columns)
  2909                              <1> 	;				    (end at row 114, column 172)
  2910                              <1> 	;		    If video memory starts at 0A0000h
  2911                              <1> 	;		    and if resolution is 320x200 (256 colors) ..
  2912                              <1> 	;		    window start offset: (64*320)+100 = 20580
  2913                              <1> 	;		    window size: 16072 bytes (pixels) 
  2914                              <1> 	;		    window end offset: 20580+16072 = 36652
  2915                              <1> 	;		    window start address: 0A0000h+564h = 0A5064h
  2916                              <1> 	; Outputs:
  2917                              <1> 	;	EAX = transfer/byte count
  2918                              <1> 	;
  2919                              <1> 	;	NOTE: If the source or destination address passes out of
  2920                              <1> 	;	video pages (display memory limits), data will not be transferred
  2921                              <1> 	;	and EAX will return as 0.
  2922                              <1> 	;
  2923                              <1> 	; 08/02/2021
  2924                              <1> 	; 07/02/2021	
  2925                              <1> 	; 04/01/2021
  2926                              <1> 	; PIXEL READ/WRITE (in current/active video mode)
  2927                              <1> 	;
  2928                              <1> 	;	BH = 3 = Read/Write pixel(s) -for all graphics modes-
  2929                              <1> 	;	     BL = 
  2930                              <1> 	;		0 = Read pixel
  2931                              <1> 	;		1 = Write pixel
  2932                              <1> 	;	     	2 = swap pixel colors
  2933                              <1> 	;		3 = mix pixel colors
  2934                              <1> 	;	     29/01/2021	
  2935                              <1> 	;		4 = read pixels from user defined positions 
  2936                              <1> 	;		5 = write single color pixels to user defined positions
  2937                              <1> 	;		6 = write multi color pixels to user defined positions 
  2938                              <1> 	; 
  2939                              <1> 	;	      > 6 = invalid/unimplemented	
  2940                              <1> 	;	
  2941                              <1> 	;	     .. for BL = 0 to 5		
  2942                              <1> 	;	     CL = color for writing pixel(s) or
  2943                              <1>  	;	     ECX = color for writing pixel(s) in true color modes
  2944                              <1> 	;
  2945                              <1> 	;	     EDX = Offset from start of video memory (0A0000h)
  2946                              <1> 	;		   or start of linear frame buffer
  2947                              <1> 	;
  2948                              <1> 	;	     07/02/2021	
  2949                              <1> 	;	     .. for BL = 4
  2950                              <1> 	;	     EDI = user's destination buffer address for pixel colors 	
  2951                              <1> 	;	     29/01/2021
  2952                              <1> 	;	     .. for BL = 4 & 5		
  2953                              <1> 	;	     ESI = user's source buffer address for BL = 4 & 5
  2954                              <1> 	;	     (buffer contains dword offset positions for pixels)
  2955                              <1> 	;	     EDX = number of pixels
  2956                              <1> 	;	     .. for BL = 6	 		
  2957                              <1> 	;	     ESI = user's buffer address for BL = 6
  2958                              <1> 	;	     (buffer contains dword offset position and dword color
  2959                              <1> 	;	      value for each pixel)
  2960                              <1> 	;	     EDX = number of pixels  
  2961                              <1> 	;	
  2962                              <1> 	; Note:
  2963                              <1> 	;	Pixel read/write will be performed in current video mode. 
  2964                              <1> 	;	If [CRT_MODE] < 0FFh, 0A0000h will be used 
  2965                              <1> 	;	   as video memory and limit will be 65536
  2966                              <1> 	;	   (new/mix pixel color will be in CL)  	
  2967                              <1> 	;	if [CRT_MODE] = 0FFh (VESA VBE video mode)
  2968                              <1> 	;	   LFB base address will be used as video memory
  2969                              <1> 	;	   and limit will be video page size
  2970                              <1> 	;	   (new/mix pixel color will be in CL)  
  2971                              <1> 	;
  2972                              <1> 	; Outputs:
  2973                              <1> 	;	EAX = pixel color (according to BL and ECX input)
  2974                              <1> 	;	EAX = 0 (pixel color is 0 or there is an error)
  2975                              <1> 	;	     (BL will return as 0FFh if there is an error)
  2976                              <1> 	;	; 29/01/2021 	
  2977                              <1> 	;	EAX = number of pixels (for BL input = 4&5&6)
  2978                              <1> 	;
  2979                              <1> 	; DIRECT (STANDARD VGA/CGA) DISPLAY MEMORY ACCESS FUNCTIONS:
  2980                              <1> 	;
  2981                              <1> 	;	BH = 4 = CGA direct video memory (0B8000h, 32K) access
  2982                              <1> 	;		Page directory & page tables of the user's
  2983                              <1> 	;		program will be updated to direct access to
  2984                              <1> 	;		0B8000h (32K) video (CGA, color) memory; if
  2985                              <1> 	;		there is not a permission conflict or lock!  
  2986                              <1> 	;	        (User's program/process will have permission to
  2987                              <1> 	;		access locked display memory if the owner is
  2988                              <1> 	;		it's parent.)
  2989                              <1>         ;
  2990                              <1> 	;	    Screen width = 320	
  2991                              <1> 	;
  2992                              <1> 	;	BH = 5 = VGA direct video memory (0A0000h, 64K) access
  2993                              <1> 	;		Page directory & page tables of the user's
  2994                              <1> 	;		program will be updated to direct access to
  2995                              <1> 	;		0A0000h (64K) video (VGA) memory; if there is not
  2996                              <1> 	;		a permission conflict or lock!  
  2997                              <1> 	;	        (User's program/process will have permission to
  2998                              <1> 	;		access locked display memory if the owner is
  2999                              <1> 	;		it's parent.)
  3000                              <1> 	;	
  3001                              <1> 	;	    ; 23/11/2020		
  3002                              <1> 	;	    Screen width options = 320, 640, 800 
  3003                              <1> 	;			
  3004                              <1> 	; Outputs:
  3005                              <1> 	;	EAX = Display memory address for direct access
  3006                              <1> 	;	      0A0000h for VGA, 0B8000h for CGA	
  3007                              <1> 	;	(Display memory size: 32K for CGA, 64K for VGA)
  3008                              <1> 	; 	EAX = 0 if display page access permission has been denied.
  3009                              <1> 	;	      (Locked!) 	
  3010                              <1> 	;	      	 	
  3011                              <1> 	; LINEAR FRAME BUFFER ACCESS FUNCTIONS:
  3012                              <1> 	;
  3013                              <1> 	;	BH = 6 = Linear Frame Buffer direct video memory access
  3014                              <1> 	;
  3015                              <1> 	;		Page directory & page tables of the user's
  3016                              <1> 	;		program will be updated to direct access to
  3017                              <1> 	;		the configured LFB (Linear Frame Buffer) address,
  3018                              <1> 	;		if there is not a permission conflict or lock!  
  3019                              <1> 	;	        (User's program/process will have permission to
  3020                              <1> 	;		access locked display memory if the owner is
  3021                              <1> 	;		it's parent.)
  3022                              <1> 	;
  3023                              <1> 	;	   ; 10/12/2020
  3024                              <1> 	;	   BL = 0FFh -> Direct LFB access for current video mode
  3025                              <1> 	;	   BL = XXh < 0FFh -> Direct LFB access
  3026                              <1> 	; 			      for VESA video mode 1XXh	
  3027                              <1> 	;		
  3028                              <1> 	;		Return: EAX = Linear Frame Buffer address
  3029                              <1> 	;			(EAX = 0 -> error)
  3030                              <1> 	;		     If EAX > 0
  3031                              <1> 	;			EDX = Frame Buffer Size in bytes
  3032                              <1> 	;		         BH = Requested Video Mode - 100h
  3033                              <1> 	;		              (VESA VBE video modes)	
  3034                              <1> 	;		         BL = bits per pixel
  3035                              <1> 	;			      8 = 256 colors, 8
  3036                              <1> 	;		             16 = 65536 colors, 5-6(G)-5 
  3037                              <1> 	;		             24 = RGB, 16M colors, 8-8-8
  3038                              <1> 	;		             32 = RGB + alpha bytes, 8-8-8-8
  3039                              <1> 	;		     If BH = 0FFh
  3040                              <1> 	;		        BL = VGA/CGA video mode (also EAX = 0)
  3041                              <1> 	;
  3042                              <1> 	;		** Function will return with EAX = 0 if the mode
  3043                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
  3044                              <1> 	;
  3045                              <1> 	;		ECX = Pixel resolution
  3046                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
  3047                              <1> 	;		      High 16 bits of ECX = Height 
  3048                              <1> 	;
  3049                              <1> 	; 	23/11/2020
  3050                              <1> 	; ***	GET VIDEO MODE & LINEAR FRAME BUFFER INFO   
  3051                              <1> 	;	(This function -7- also is used for VGA and CGA modes)
  3052                              <1> 	; 	
  3053                              <1> 	;	BH = 7 = Get Linear Frame Buffer info
  3054                              <1> 	;
  3055                              <1> 	;	   ; 22/01/2021	
  3056                              <1> 	;	   ; 10/12/2020
  3057                              <1> 	;	   BL = any -not used- (22/01/2021)
  3058                              <1> 	;	
  3059                              <1> 	;		Return:
  3060                              <1> 	;		EAX = Frame Buffer Address (0 = is not in use)
  3061                              <1> 	;		EDX = Frame Buffer Size in bytes
  3062                              <1> 	;		 BH = Current Video Mode - 100h  ; 22/01/2021
  3063                              <1> 	;		     (VESA VBE video modes)	
  3064                              <1> 	;		 BL = bits per pixel
  3065                              <1> 	;			8 = 256 colors, 8
  3066                              <1> 	;		       16 = 65536 colors, 5-6(G)-5 
  3067                              <1> 	;		       24 = RGB, 16M colors, 8-8-8
  3068                              <1> 	;		       32 = RGB + alpha bytes, 8-8-8-8
  3069                              <1> 	;		If BH = 0FFh
  3070                              <1> 	;		   BL = VGA/CGA video mode (also EAX = 0)
  3071                              <1> 	;
  3072                              <1> 	;		Note:	
  3073                              <1> 	;		Alpha byte will be used as virtual color index.
  3074                              <1> 	;		(32 bit pixel colors.. byte 0,1,2 rgb and 3 alpha)
  3075                              <1> 	;
  3076                              <1> 	;		** Function will return with EAX = 0 if the mode
  3077                              <1> 	;		is not a valid VESA VBE video mode as 1??h ** 	
  3078                              <1> 	;
  3079                              <1> 	;		ECX = Pixel resolution
  3080                              <1> 	;		      CX = Width (320, 640, 800, 1024, 1366, 1920)
  3081                              <1> 	;		      High 16 bits of ECX = Height  
  3082                              <1> 	;
  3083                              <1> 	;	NOTE: Each process will have it's own frame buffer
  3084                              <1> 	;	      address and resolution parameters in 'u' area.
  3085                              <1> 	;	      Then, if the current frame buffer & resolution
  3086                              <1> 	;	      is different, frame buffer r/w functions
  3087                              <1> 	;	      will use scale factor to convert process's
  3088                              <1>         ;             pixel coordinates to actual screen coordinates.
  3089                              <1> 	;	      resolution -> dimensional scale
  3090                              <1> 	;	      color size -> color scale
  3091                              <1> 	;	     * RGB (TRUE) colors to 256 colors conversion:
  3092                              <1>         ;             TRUE Colors -> 8,8,8 (R,G,B; byte 0 is R)
  3093                              <1> 	;	      256 colors -> 2,2,2,2 (R,G,B,L; bit 0&1 is R)
  3094                              <1> 	; 		  bit 6&7 -> luminosity base level (0,1,2,3)
  3095                              <1> 	;		  bit 4&5 -> blue level (0,1,2,3)
  3096                              <1> 	;		  bit 2%3 -> green level (0,1,2,3)
  3097                              <1> 	;		  bit 0&1 -> red level (0,1,2,3)
  3098                              <1> 	;	      Example: total red level : luminosity + red level
  3099                              <1> 	;	      Luminosity base level: 0 -> 16
  3100                              <1> 	;		 		     1 -> 32
  3101                              <1> 	;				     2 -> 64
  3102                              <1> 	;				     3 -> 128
  3103                              <1> 	;	      Color level:	
  3104                              <1> 	;				    0 -> 0
  3105                              <1> 	;				    1 -> luminosity level
  3106                              <1> 	;				    2 -> luminosity level + 64
  3107                              <1> 	;				    3 -> 255
  3108                              <1> 	;	     Luminosity base level = min (R,G,B)
  3109                              <1> 	;			if it is <16, it will be set to 16
  3110                              <1> 	;	     Color levels: Color values are fixed to (nearest) 
  3111                              <1> 	;		   one of all possible set level (step) values
  3112                              <1> 	;		   (according to luminosity base level); then
  3113                              <1> 	;		   color levels are set to R-L, G-L, B-L.
  3114                              <1> 	;	 For example: If luminosity base level is 32
  3115                              <1> 	;		  all possible set values are 0, 32, 96, 255.
  3116                              <1> 	;
  3117                              <1> 	;	    * RGB (TRUE) colors to 16 colors conversion:
  3118                              <1> 	;	    16 colors: R,B,G,L bits (4 bits)
  3119                              <1> 	;	    	   If any one of R,G,B >= 128 L = 1	
  3120                              <1>  	;		   If max. value of (R,G,B) >= 32, it is 1
  3121                              <1> 	;		      else all color bits (R&G&B&L) are 0
  3122                              <1> 	;		   If the second value >= max. value / 2
  3123                              <1> 	;		      it is 1
  3124                              <1> 	;		   If third value value >= max. value / 2
  3125                              <1> 	;		      it is 1
  3126                              <1> 	;	    Example: R = 132, G = 64, B = 78
  3127                              <1> 	;		     L = 1, R = 1
  3128                              <1> 	;		     G < 66 --> G = 0
  3129                              <1> 	;		     B >= 66 --> B = 1
  3130                              <1> 	;
  3131                              <1> 	; 10/12/2020
  3132                              <1> 	; SET VIDEO MODE (& RETURN LFB INFO for VESA VBE VIDEO MODES)
  3133                              <1> 	;	
  3134                              <1> 	;	BH = 8 = Set Video Mode
  3135                              <1> 	;		
  3136                              <1> 	;		BL = Requested Video Mode (method)
  3137                              <1> 	;		If BL = 0FFh
  3138                              <1> 	;		   CX = VESA VBE Video Mode
  3139                              <1> 	;		   ; 11/12/2020
  3140                              <1> 	;		   If EDX > 0 -> LFB INFO (user) buffer addr
  3141                              <1> 	;		If BL < 0FFh, it is VGA/CGA video mode and
  3142                              <1> 	;			CX & EDX will not be used
  3143                              <1> 	;
  3144                              <1> 	;	    NOTE: The last VESA VBE video mode is 11Bh but
  3145                              <1> 	;	    TRDOS 386 will permit to set video mode upto 11Fh.
  3146                              <1> 	;	    Above 11Fh, from 140h to 1FEh, it will be accepted
  3147                              <1> 	;	    as Bochs/Plex86 emulator video mode and it will be
  3148                              <1> 	;	    used only if [vbe3] = 2 and detected
  3149                              <1> 	;	    video bios is BOCHS/PLEX86/QEMU/VIRTUALBOX vbios.
  3150                              <1> 	;	 	  	 		 	
  3151                              <1> 	; Outputs:
  3152                              <1> 	;	EAX = Requested (Proper) video mode number + 1
  3153                              <1> 	;	      ("dec eax" by user will give requested video mode),
  3154                              <1> 	;
  3155                              <1> 	;	If BL input is 0FFh
  3156                              <1> 	;	   EDX = LFBINFO table/structure (in user's buffer addr)
  3157                              <1> 	;	   EDX = 0 -> Invalid LFBINFO (do not use it)
  3158                              <1> 	;
  3159                              <1> 	;	EAX = 0 -> Error (but EDX will not be changed)
  3160                              <1> 	;
  3161                              <1> 	; 03/12/2020
  3162                              <1> 	; VESA VBE3 VIDEO BIOS (32 bit) PROTECTED MODE INTERFACE SETTINGS
  3163                              <1> 	;	
  3164                              <1> 	;	BH = 9 = set/get VBE3 Protected Mode Interface parameters
  3165                              <1> 	;		
  3166                              <1> 	;		BL = 0 - Disable protected mode interface
  3167                              <1> 	;			([pmi32] = 0)
  3168                              <1> 	;		 	Return: AL = 1	
  3169                              <1> 	;		BL = 1 - Enable protected mode Interface
  3170                              <1> 	;			([pmi32] = 1)
  3171                              <1> 	;			Return: AL = 2
  3172                              <1> 	;		BL = 2 - Get protected mode interface status
  3173                              <1> 	;			Return: AL = [pmi32] + 1 (AL = 1 or 2)
  3174                              <1> 	;
  3175                              <1> 	;		If [vbe3] <> 3 --> AL = 0
  3176                              <1> 	;
  3177                              <1> 	;		; 17/01/2021
  3178                              <1> 	;		BL = 3 - Disable/Cancel restore permission to user
  3179                              <1> 	;			Return: AL = 1 (if disabled) or 0
  3180                              <1> 	;		BL = 4 - Enable/Give restore permission to user
  3181                              <1> 	;			Return: AL = 2 (if enabled) or 0
  3182                              <1> 	;		BL = 5 - Get video state save/restore status
  3183                              <1> 	;			 (permission status)
  3184                              <1> 	;		        Return: AL = Status (enabled = 1)
  3185                              <1> 	;				; 22/01/2021
  3186                              <1> 	;				AH = state options ([srvso])
  3187                              <1> 	;		BL = 6 - Return VESA VBE number/status
  3188                              <1> 	;		        Return: AX = status
  3189                              <1> 	;			      if AH =  2, AL > 0 : Emulator
  3190                              <1> 	;				 AH =  3, VESA VBE3 video bios 	 
  3191                              <1> 	;
  3192                              <1> 	;		BL > 6 : not implemented (17/01/2021)
  3193                              <1> 	;
  3194                              <1> 	;	; 19/01/2021 ([u.uid] check)	
  3195                              <1> 	;	Note: Enabling/Disabling are done by root ([u.uid] = 0)
  3196                              <1> 	;	      while [multi_tasking] = 0.
  3197                              <1> 	;
  3198                              <1>     	; 23/12/2020
  3199                              <1> 	; VIDEO MEMORY MAPPING:
  3200                              <1> 	;	BH = 10 = Map video memory to user's buffer
  3201                              <1> 	;
  3202                              <1> 	;	   BL = 0 : CGA memory (0B8000h) map (32K)
  3203                              <1> 	;	   BL = 1 : VGA memory (0A0000h) map (64K)
  3204                              <1> 	;	   BL = 2 : SVGA memory (LFB) map to user's buffer
  3205                              <1> 	;
  3206                              <1> 	;	ECX = User's buffer addr (low 12 bits will be cleared)
  3207                              <1> 	;	EDX = Buffer size in bytes (if BL = 2)
  3208                              <1> 	;		(will be trimmed if LFB size < EDX)
  3209                              <1> 	; Return:				
  3210                              <1>         ;	EAX = physical address of video memory (buffer)
  3211                              <1> 	;	EBX = mapped (actual) size of video memory (bytes)
  3212                              <1> 	;	ECX = virtual start address of user's video buffer 
  3213                              <1> 	;	EDX is same with EDX input
  3214                              <1> 	;
  3215                              <1> 	;	(Note: Memory page boundaries will be applied 
  3216                              <1> 	;	 to buffer size and buff start addr by rounding down.
  3217                              <1> 	;	 Rounded size & address values must not be zero.) 
  3218                              <1> 	;	-Normally, it is expected to request mapping by using
  3219                              <1> 	;	 correct buffer size of current or desired video mode-
  3220                              <1> 	;
  3221                              <1> 	;	EAX = 0 -> error ! memory can not mapped to user
  3222                              <1> 	;
  3223                              <1> 	; 04/01/2021
  3224                              <1> 	; SET/READ COLOR PALETTE (set/read DAC color registers)
  3225                              <1> 	;	((256 colors (8bpp) VGA/CGA video hardware feature))
  3226                              <1> 	;
  3227                              <1> 	;	BH = 11 = Set/Read DAC color registers
  3228                              <1> 	;
  3229                              <1> 	;	   (BL<4 Original method for std VGA video hardware)
  3230                              <1> 	;	   BL = 0 : Read all DAC color registers (256 colors)
  3231                              <1> 	;	       (6 bit colors, in RGB order)
  3232                              <1> 	;	   BL = 1 : Set all DAC color registers (256 colors)
  3233                              <1> 	;	       (6 bit colors, in RGB order)
  3234                              <1> 	;	   BL = 2 : Read single DAC color register
  3235                              <1> 	;	       (6 bit color, in RGB order)
  3236                              <1> 	;		((EAX will return with color value))
  3237                              <1> 	;		CL = DAC color register (index)
  3238                              <1> 	;	   BL = 3 : Set/Write single DAC color register
  3239                              <1> 	;	       (6 bit color, in RGB order, bit 6&7 are 0)
  3240                              <1> 	;		ECX byte 0 - DAC color register
  3241                              <1> 	;		ECX byte 1 - Red (6 bit)
  3242                              <1> 	;		ECX byte 2 - Green (6 bit)
  3243                              <1> 	;		ECX byte 3 - Blue (6 bit)
  3244                              <1> 	;	   (BL>3 Alternative method for BMP files etc.)	
  3245                              <1> 	;	   BL = 4 : Read all DAC color registers (256 colors)
  3246                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
  3247                              <1> 	;	   BL = 5 : Set all DAC color registers (256 colors)
  3248                              <1> 	;	       (8 bit colors, in BGR order, bit 0&1 is 0)
  3249                              <1> 	;	   BL = 6 : Read single DAC color register
  3250                              <1> 	;	       (8 bit color, in BGR order, bit 0&1 is 0)
  3251                              <1> 	;		((EAX will return with color value))
  3252                              <1> 	;		CL = DAC color register (index)
  3253                              <1> 	;	   BL = 7 : Set/Write single DAC color register
  3254                              <1> 	;	       (8 bit color, bit 0&1 are 0)
  3255                              <1> 	;		ECX byte 0 - DAC color register
  3256                              <1> 	;		ECX byte 1 - Blue (8 bit)
  3257                              <1> 	;		ECX byte 2 - Green (8 bit)
  3258                              <1> 	;		ECX byte 3 - Red (8 bit)
  3259                              <1> 	;
  3260                              <1> 	;	  BL > 7 : invalid (not implemented)
  3261                              <1> 	;
  3262                              <1> 	;   if BL bit 2 is 1, 6 bit colors converted to 8 bit colors
  3263                              <1> 	;	(low two bits of color bytes will be 0)
  3264                              <1> 	;     ((color byte 00111111b will be converted to 11111100b))
  3265                              <1> 	;	and RGB byte order will be 
  3266                              <1> 	;		byte 0 - Blue (low 2 bits are 0)
  3267                              <1> 	;		byte 1 - Green (low 2 bits are 0)
  3268                              <1> 	;		byte 2 - Red (low 2 bits are 0)
  3269                              <1> 	;		byte 3 - pad (or zero byte)
  3270                              <1> 	;	and 256 colors buffer size must be 256*4 = 1024 bytes
  3271                              <1> 	;   if BL bit 2 is 0, 6 bit colors will be used directly
  3272                              <1> 	;	  (high two bits of 8 bit color bytes will be 0)
  3273                              <1> 	;     ((dac color 111111b will be converted to 00111111b))
  3274                              <1> 	;		byte 0 - Red (high 2 bits are 0)
  3275                              <1> 	;		byte 1 - Green (high 2 bits are 0)
  3276                              <1> 	;		byte 2 - Blue (high 2 bits are 0)
  3277                              <1> 	;	and 256 colors buffer size must be 256*3 = 768 bytes
  3278                              <1> 	;
  3279                              <1> 	;	ECX = User's buffer addr (256*3 = 768 bytes) or
  3280                              <1> 	;	      Color 
  3281                              <1> 	;
  3282                              <1> 	; Return:				
  3283                              <1>         ;	EAX = buffer size (for BL input = 0,1,4,5)
  3284                              <1> 	;	      or color value (for BL input = 2,3,6,7)
  3285                              <1> 	;
  3286                              <1> 	; 10/01/2021
  3287                              <1> 	; SET/READ FONT DATA
  3288                              <1> 	;
  3289                              <1> 	;	BH = 12 = Set/Read Character Font Data
  3290                              <1> 	;
  3291                              <1> 	;	   BL = 0 : Disable system font overwrite
  3292                              <1> 	;	   BL = 1 : Enable system font overwrite
  3293                              <1> 	;	   BL = 2 : Read system font 8x8
  3294                              <1> 	;	   BL = 3 : Read system font 8x14
  3295                              <1> 	;	   BL = 4 : Read system font 8x16
  3296                              <1> 	;	   BL = 5 : Read user defined font 8x8
  3297                              <1> 	;	   BL = 6 : Read user defined font 8x16
  3298                              <1> 	;	   BL = 7 : Write system font 8x8
  3299                              <1> 	;	   BL = 8 : Write system font 8x14
  3300                              <1> 	;	   BL = 9 : Write system font 8x16
  3301                              <1> 	;	   BL = 10 : Write user defined font 8x8
  3302                              <1> 	;	   BL = 11 : Write user defined font 8x16
  3303                              <1> 	;
  3304                              <1> 	;	  BL > 11 : invalid (not implemented)
  3305                              <1> 	;
  3306                              <1> 	;	For BL = 1 to 11
  3307                              <1> 	;	   ECX = number of characters (<= 256)
  3308                              <1> 	;	   EDX = first character (ascii code in DL)
  3309                              <1> 	;	   ESI = user's buffer address
  3310                              <1> 	;
  3311                              <1> 	; Return:				
  3312                              <1>         ;	EAX = number of characters (ecx input)
  3313                              <1> 	;	EAX = 0 -> error
  3314                              <1> 	;	(EAX = 256 for BL = 0 and 1 if successful)
  3315                              <1> 	;	
  3316                              <1> 	; Note: system font overwrite permission will be
  3317                              <1> 	;       given if [multi_tasking] = 0 
  3318                              <1> 	;	and [u.uid] = 0 (BL = 1) ; 19/01/2021
  3319                              <1> 	;       and if [ufont] bit 7 is 1 (BL = 7,8,9)
  3320                              <1> 	;
  3321                              <1> 	; 18/01/2021
  3322                              <1> 	; SAVE/RESTORE STANDARD VGA VIDEO STATE
  3323                              <1> 	;
  3324                              <1> 	;	BH = 13 = Save/Restore std VGA video state
  3325                              <1> 	;
  3326                              <1> 	;	   BL = 0 : Save VGA state (without DAC regs)
  3327                              <1> 	;		Return: EAX = VideoStateID (>0)
  3328                              <1> 	;			EAX = 0 (failed!)
  3329                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
  3330                              <1> 	;	   BL = 1 : Restore VGA state (without DAC regs)
  3331                              <1> 	;		ECX = VideoStateID (to be verified)
  3332                              <1> 	;	        Return: EAX = Restore size (>0)
  3333                              <1> 	;	   BL = 2 : Save VGA state (complete)
  3334                              <1> 	;		Return: EAX = VideoStateID (>0)
  3335                              <1> 	;			EAX = 0 (failed!)
  3336                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3) 
  3337                              <1> 	;	   BL = 3 : Restore VGA state (complete)
  3338                              <1> 	;		ECX = VideoStateID (to be verified)
  3339                              <1> 	;	        Return: EAX = Restore size (>0)
  3340                              <1> 	;
  3341                              <1> 	;	* Above options are for saving
  3342                              <1> 	;	*       video state to system memory
  3343                              <1> 	;	*	(location: VBE3VIDEOSTATE, 2048 bytes)
  3344                              <1> 	;	
  3345                              <1> 	;	   BL = 4 : Save VGA state (without DAC regs)
  3346                              <1> 	;		ECX = buffer address  
  3347                              <1> 	;		Return: EAX = transfer count
  3348                              <1> 	;	       (size: 110 bytes for TRDOS 386 v2.0.3)
  3349                              <1> 	;		ECX = buffer address  
  3350                              <1> 	;	   BL = 5 : Restore VGA state (without DAC regs)
  3351                              <1> 	;		ECX = buffer address  
  3352                              <1> 	;	        Return: EAX = transfer count
  3353                              <1> 	;	   BL = 6 : Save VGA state (complete)
  3354                              <1> 	;		ECX = buffer address  
  3355                              <1> 	;		Return: EAX = transfer count
  3356                              <1> 	;	       (size: 882 bytes for TRDOS 386 v2.0.3)
  3357                              <1> 	;	   BL = 7 : Restore VGA state (complete)
  3358                              <1> 	;		ECX = buffer address  
  3359                              <1> 	;	        Return: EAX = transfer count
  3360                              <1> 	;
  3361                              <1> 	;	* Above options are for saving
  3362                              <1> 	;	*       video state to user's buffer
  3363                              <1> 	;	*	(buffer size: 110 bytes or 882 bytes)
  3364                              <1> 	;
  3365                              <1> 	;	  BL > 7 : invalid (not implemented)
  3366                              <1> 	;
  3367                              <1> 	; 18/01/2021
  3368                              <1> 	; SAVE/RESTORE SUPER VGA (VESA VBE 2/3) VIDEO STATE
  3369                              <1> 	;
  3370                              <1> 	;	BH = 14 = Save/Restore SVGA video state
  3371                              <1> 	;
  3372                              <1> 	;	   BL = options
  3373                              <1> 	;		bit 0 - Save (0) or Restore (1)	
  3374                              <1> 	;		bit 1 - controller hardware state
  3375                              <1> 	;		bit 2 - BIOS data state
  3376                              <1> 	;		bit 3 - DAC state
  3377                              <1> 	;		bit 4 - (extended) Register state
  3378                              <1> 	;		bit 5 - system (0) or user (1) memory
  3379                              <1> 	;		bit 6 - verify without transfer
  3380                              <1> 	;		bit 7 - not used (must be 0)
  3381                              <1> 	;			
  3382                              <1> 	;	     if bit 0 = 0 and bit 5 = 0
  3383                              <1> 	;		Return:	EAX = VideoStateID (>0)	
  3384                              <1> 	;	     if bit 0 = 1
  3385                              <1> 	;		ECX = VideoStateID (bit 5 = 0)
  3386                              <1> 	;		Return: EAX = restore (transfer) size
  3387                              <1> 	;	     if bit 5 = 1
  3388                              <1> 	;		ECX = Buffer address
  3389                              <1> 	;		Return: EAX = transfer count (size)
  3390                              <1> 	;
  3391                              <1> 	;	     ECX = Buffer address or VideoStateID
  3392                              <1> 	;
  3393                              <1> 	;	  BL > 127 : invalid (not implemented)
  3394                              <1> 	;
  3395                              <1> 	;  Note: Required buffer size may be > 2048 bytes
  3396                              <1> 	;	 (function fails when buff size > 2048 bytes)
  3397                              <1> 	;	 proper option must be used
  3398                              <1> 	;
  3399                              <1> 	; 18/01/2021
  3400                              <1> 	; READ VESA EDID (EXTENDED DISPLAY IDENTIFICATION DATA)
  3401                              <1> 	;
  3402                              <1> 	;	BH = 15 = Read VESA EDID for connected monitor  
  3403                              <1> 	;		  (copy EDID to user)	
  3404                              <1> 	;
  3405                              <1> 	;	   BL = any
  3406                              <1> 	;
  3407                              <1> 	;	Input:
  3408                              <1> 	;	    ECX = user's (EDID) buffer address 
  3409                              <1> 	;		 (buffer size: 128 bytes)
  3410                              <1> 	;	Output:
  3411                              <1> 	;	    EAX = 128 (EDID size)
  3412                              <1> 	;	    or EAX = 0 -> Error!
  3413                              <1> 	;	       (EDID not ready or buffer addr error)	
  3414                              <1> 	;
  3415                              <1>  	
  3416                              <1> 	; 16/05/2016
  3417 0000E2F2 31C0                <1> 	xor	eax, eax
  3418 0000E2F4 A3[64030300]        <1> 	mov	[u.r0], eax
  3419 0000E2F9 20FF                <1> 	and	bh, bh
  3420 0000E2FB 0F858B020000        <1> 	jnz	sysvideo_13 ; 11/07/2016
  3421                              <1> 
  3422                              <1> 	;; 21/11/2020 (TRDOS 386 v2.0.3)
  3423                              <1> 	;; tty/text mode transfers are only for video mode 3
  3424                              <1> 
  3425                              <1> 	; 22/11/2020
  3426                              <1> 	;cmp	byte [CRT_MODE], 3 ; 80x25 text, 16 colors
  3427                              <1> 	;jne	sysret ; invalid (nothing to do), [u.r0] = 0	
  3428                              <1> 	
  3429                              <1> 	; 23/11/2020
  3430                              <1> 	; bit 7,6,5,4 of BL are reserved and it must be 0
  3431                              <1> 	;	 	 for current 'sysvideo' version
  3432                              <1> 	;test	bl, 0F0h
  3433                              <1> 	;;jnz	sysret ; invalid (undefined) ! 
  3434                              <1> 	;; 28/01/2021
  3435                              <1> 	;jnz	short sysvideo_1_2 ; invalid (undefined) !
  3436                              <1> 	; 28/01/2021
  3437 0000E301 80FB07              <1> 	cmp	bl, 7
  3438 0000E304 776E                <1> 	ja	short sysvideo_1_2 ; invalid (undefined) !	
  3439                              <1> 
  3440                              <1> 	; Video mode 0, 80*25 text mode, CGA 16 colors  
  3441                              <1> 	; [CRT_MODE] = 3
  3442                              <1> 	;mov	bh, bl
  3443                              <1> 	;shr	bh, 2 ; 4..7 -> 1, 8..11 -> 2, 12..15 -> 3
  3444                              <1> 	;; 21/11/2020
  3445                              <1> 	;;and	bh, bh
  3446                              <1>         ;jnz	sysvideo_4  ; Display page window transfer etc.
  3447                              <1> 
  3448                              <1> 	; 28/01/2021
  3449 0000E306 F6C304              <1> 	test	bl, 4 ; bit 2
  3450 0000E309 0F85A2000000        <1> 	jnz	sysvideo_4 ; Display page window transfer
  3451                              <1> 
  3452                              <1> 	; Display page (complete) transfer
  3453 0000E30F 80FA07              <1> 	cmp	dl, 7
  3454                              <1> 	;jnz	sysret ; invalid (nothing to do), [u.r0] = 0
  3455 0000E312 760A                <1> 	jna	short sysvideo_0 ; 28/01/2021	
  3456 0000E314 FEC2                <1> 	inc	dl ; 0FFh -> 0 ("use current video page")
  3457 0000E316 755C                <1> 	jnz	short sysvideo_1_2  ; invalid
  3458                              <1> 	; dl = 0 -> use current current page
  3459 0000E318 8A15[FE890100]      <1> 	mov	dl, [ACTIVE_PAGE]
  3460                              <1> sysvideo_0:
  3461                              <1> 	; 28/01/2021 
  3462 0000E31E 80FB03              <1> 	cmp	bl, 3
  3463 0000E321 7206                <1> 	jb	short sysvideo_0_0
  3464 0000E323 09FF                <1> 	or	edi, edi
  3465 0000E325 744D                <1> 	jz	short sysvideo_1_2  ; invalid
  3466 0000E327 89FE                <1> 	mov	esi, edi ; save swap/exchange buffer addr
  3467                              <1> 	; ecx = user buffer for new video page content
  3468                              <1> 	; esi = user (swap) buffer for saving current video page  
  3469                              <1> sysvideo_0_0:
  3470 0000E329 BF00800B00          <1> 	mov	edi, 0B8000h
  3471                              <1> 	; dl = display page number, destination
  3472 0000E32E 66B80010            <1> 	mov	ax, 4096 ; 21/11/2020
  3473 0000E332 20D2                <1> 	and	dl, dl
  3474 0000E334 7408                <1> 	jz	short sysvideo_1
  3475                              <1> 	; 07/02/2021
  3476 0000E336 88D6                <1> 	mov	dh, dl
  3477                              <1> sysvideo_0_1:
  3478                              <1> 	; page length = 4096 bytes (but page content is 80*25*2 bytes)
  3479 0000E338 01C7                <1> 	add	edi, eax ; 21//11/2020 ([CRT_LEN] = 1000h for mode 3)
  3480 0000E33A FECE                <1> 	dec	dh
  3481 0000E33C 75FA                <1> 	jnz	short sysvideo_0_1
  3482                              <1> sysvideo_1:	
  3483 0000E33E 80E303              <1> 	and	bl, 3
  3484 0000E341 7536                <1> 	jnz	short sysvideo_2 ; user to system display page transfer
  3485                              <1> 	; system to system video page (content) transfer
  3486                              <1> 	; cl = display page number, source
  3487 0000E343 80F907              <1> 	cmp	cl, 7
  3488                              <1> 	;ja	sysret ; invalid (nothing to do), [u.r0] = 0
  3489 0000E346 760A                <1> 	jna	short sysvideo_1_0
  3490 0000E348 FEC1                <1> 	inc	cl ; 0FFh -> 0 ("use current video page")
  3491 0000E34A 7528                <1> 	jnz	short sysvideo_1_2  ; invalid
  3492 0000E34C 8A0D[FE890100]      <1> 	mov	cl, [ACTIVE_PAGE]
  3493                              <1> sysvideo_1_0:
  3494                              <1> 	; 28/01/2021
  3495 0000E352 38D1                <1> 	cmp	cl, dl
  3496 0000E354 741E                <1> 	je	short sysvideo_1_2  ; same video page !
  3497                              <1> 
  3498                              <1> 	; system to system video/display page transfer (mode 0)
  3499                              <1> 	; 21/11/2020
  3500                              <1> 	;mov	esi, 0B8000h
  3501                              <1> 	;movzx	eax, cl
  3502                              <1> 	;mov	edx, 4096 ; [CRT_LEN] = 1000h for video mode 3
  3503                              <1> 	;mov	ecx, edx
  3504                              <1> 	;mul	edx
  3505                              <1> 	;add	esi, eax
  3506                              <1> 	; 28/01/2021
  3507                              <1> 	;movzx	esi, cl
  3508                              <1> 	;shl	si, 12 ; * 4096
  3509                              <1> 	;add	esi, 0B8000h 
  3510                              <1> 	
  3511                              <1> 	; 28/01/2021
  3512 0000E356 A3[64030300]        <1> 	mov	[u.r0], eax ; 4096
  3513 0000E35B BE00800B00          <1> 	mov	esi, 0B8000h
  3514 0000E360 08C9                <1> 	or	cl, cl
  3515 0000E362 740A                <1> 	jz	short sysvideo_1_1
  3516                              <1> 	; 07/02/2021
  3517 0000E364 88C8                <1> 	mov	al, cl ; display/video page
  3518 0000E366 30E4                <1> 	xor	ah, ah
  3519 0000E368 66C1E00C            <1> 	shl	ax, 12 ; * 4096	
  3520 0000E36C 01C6                <1>  	add	esi, eax
  3521                              <1> sysvideo_1_1:
  3522                              <1> 	; 21/11/2020
  3523                              <1> 	;;mov	ecx, 4096
  3524                              <1> 	;mov	ecx, eax ; 4096
  3525                              <1> 	;;mov	[u.r0], ecx ; 4096 bytes
  3526                              <1> 	; 28/01/2021	
  3527                              <1> 	;mov	[u.r0], cx
  3528 0000E36E 31C9                <1> 	xor	ecx, ecx
  3529 0000E370 B504                <1> 	mov	ch, 4 ; mov ecx, 1024
  3530                              <1> 	;shr	cx, 2 ; / 4
  3531 0000E372 F3A5                <1> 	rep	movsd
  3532                              <1> sysvideo_1_2:
  3533 0000E374 E983F5FFFF          <1> 	jmp	sysret
  3534                              <1> sysvideo_2:  
  3535 0000E379 80FB02              <1> 	cmp	bl, 2
  3536                              <1>         ;ja	sysret; invalid (user to user), [u.r0] = 0
  3537                              <1> 	; 28/01/2021
  3538 0000E37C 7226                <1> 	jb	short sysvideo_3 ; user to system
  3539 0000E37E 7404                <1> 	je	short sysvideo_2_0 ; system to user
  3540                              <1> 	; bl = 3
  3541 0000E380 89CA                <1> 	mov	edx, ecx ; save user's buffer addr
  3542 0000E382 89F1                <1> 	mov	ecx, esi ; save swap address
  3543                              <1> sysvideo_2_0:
  3544                              <1> 	; bl = 2 (or bl = 3, stage 1)
  3545                              <1> 	; system to user video/display page transfer (mode 0)
  3546 0000E384 89FE                <1> 	mov	esi, edi
  3547 0000E386 89CF                <1> 	mov	edi, ecx ; user buffer ; 28/01/2021
  3548                              <1> 	; 21/11/2020
  3549 0000E388 89C1                <1> 	mov	ecx, eax ; 4096
  3550 0000E38A E875370000          <1> 	call	transfer_to_user_buffer ; fast transfer
  3551                              <1> 	;jc	sysret ; [u.r0] = 0
  3552 0000E38F 72E3                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
  3553                              <1> 	; 28/01/2021
  3554 0000E391 80FB03              <1> 	cmp	bl, 3
  3555 0000E394 7408                <1> 	je	short sysvideo_2_2
  3556                              <1> sysvideo_2_1:
  3557                              <1> 	; 21/11/2020
  3558 0000E396 890D[64030300]      <1> 	mov	[u.r0], ecx
  3559                              <1> 	;;mov	[u.r0], cx
  3560                              <1> 	;jmp	sysret
  3561 0000E39C EBD6                <1> 	jmp	short sysvideo_1_2
  3562                              <1> 
  3563                              <1> sysvideo_2_2:
  3564                              <1> 	; bl = 3 (exchange/swap) complete display page
  3565                              <1> 	; esi = video page start address
  3566                              <1> 	; edx = user's buffer address
  3567                              <1> 	
  3568                              <1> 	;mov	ecx, 4096
  3569 0000E39E 89F7                <1> 	mov	edi, esi ; video page start address
  3570 0000E3A0 89D6                <1> 	mov	esi, edx ; user's (new page) buffer address
  3571 0000E3A2 EB04                <1> 	jmp	short sysvideo_2_3
  3572                              <1> sysvideo_3: 
  3573                              <1> 	; bl = 1 (or bl = 3, stage 2)
  3574                              <1> 	; user to system video/display page transfer (mode 0)	
  3575 0000E3A4 89CE                <1> 	mov	esi, ecx ; user buffer
  3576                              <1> 	; edi = video page address
  3577                              <1> 	; 21/11/2020
  3578 0000E3A6 89C1                <1> 	mov	ecx, eax ; 4096
  3579                              <1> sysvideo_2_3:
  3580 0000E3A8 E8A1370000          <1> 	call	transfer_from_user_buffer ; fast transfer
  3581                              <1> 	;jc	sysret ; [u.r0] = 0
  3582 0000E3AD 72C5                <1> 	jc	short sysvideo_1_2 ; 28/01/2021
  3583 0000E3AF EBE5                <1> 	jmp	short sysvideo_2_1
  3584                              <1> 
  3585                              <1> 	; 21/11/2020
  3586                              <1> 	;mov	[u.r0], ecx
  3587                              <1> 	;;mov	[u.r0], cx
  3588                              <1> 	;;jmp	sysret
  3589                              <1> 	;jmp	short sysvideo_1_2 ; 28/01/2021
  3590                              <1> 
  3591                              <1> sysvideo_4:
  3592                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  3593                              <1> 
  3594                              <1> 	; Display page window transfer etc.
  3595 0000E3B1 80E303              <1> 	and	bl, 3
  3596 0000E3B4 0F85F7000000        <1>         jnz     sysvideo_9 ; user to system or system to user
  3597                              <1> 	; 21/11/2020
  3598                              <1> 	; system to system video/display page window transfer (mode 0)
  3599 0000E3BA 81FE00800B00        <1> 	cmp	esi, 0B8000h	; source buffer address (system)
  3600 0000E3C0 0F8236F5FFFF        <1> 	jb	sysret
  3601 0000E3C6 81FE00000C00        <1> 	cmp	esi, 0B8000h+(4096*8)
  3602 0000E3CC 0F832AF5FFFF        <1> 	jnb	sysret
  3603 0000E3D2 81FF00800B00        <1> 	cmp	edi, 0B8000h	; destination buffer address (system)	
  3604 0000E3D8 0F821EF5FFFF        <1> 	jb	sysret
  3605 0000E3DE 81FF00000C00        <1>         cmp     edi, 0B8000h+(4096*8)
  3606 0000E3E4 0F8312F5FFFF        <1> 	jnb	sysret
  3607                              <1> 	;
  3608 0000E3EA 51                  <1> 	push	ecx ; X1 and Y1 position - top left column, row
  3609 0000E3EB 0FB7C1              <1> 	movzx	eax, cx ; top left column
  3610                              <1> 	; 21/11/2020
  3611 0000E3EE C1E910              <1> 	shr	ecx, 16 ; top row
  3612 0000E3F1 740E                <1> 	jz	short sysvideo_4_0 ; bypass following code
  3613 0000E3F3 52                  <1> 	push	edx ; X2 and Y2 position - bottom right column, row
  3614 0000E3F4 50                  <1> 	push	eax
  3615 0000E3F5 66B8A000            <1> 	mov	ax, 80*2 ; 80 colums, 160 bytes per row
  3616 0000E3F9 F7E1                <1> 	mul	ecx
  3617                              <1> 		; eax = offset for start row number 
  3618 0000E3FB 01C6                <1> 	add	esi, eax
  3619 0000E3FD 01C7                <1> 	add	edi, eax
  3620 0000E3FF 58                  <1> 	pop	eax
  3621 0000E400 5A                  <1> 	pop	edx
  3622                              <1> sysvideo_4_0:
  3623 0000E401 66D1E0              <1> 	shl	ax, 1 ; * 2 ; convert start column number to offset
  3624 0000E404 7404                <1> 	jz	short sysvideo_4_1	
  3625 0000E406 01C6                <1> 	add	esi, eax
  3626 0000E408 01C7                <1> 	add	edi, eax
  3627                              <1> 		; esi = source page window start offset
  3628                              <1> 		; edi = destination page window start offset
  3629                              <1> sysvideo_4_1:
  3630 0000E40A 59                  <1> 	pop	ecx
  3631                              <1> 	;mov	eax, 0B8000h+(80*25*2*8)
  3632                              <1> 	; 21/11/2020
  3633 0000E40B B800000C00          <1> 	mov	eax, 0B8000h+(4096*8)
  3634 0000E410 39C6                <1> 	cmp	esi, eax
  3635 0000E412 0F83E4F4FFFF        <1> 	jnb	sysret ; out of video page
  3636 0000E418 39C6                <1> 	cmp	esi, eax
  3637 0000E41A 0F83DCF4FFFF        <1> 	jnb	sysret  ;out of video page	
  3638                              <1> 
  3639 0000E420 56                  <1> 	push	esi ; ****
  3640 0000E421 57                  <1> 	push	edi ; ***
  3641 0000E422 52                  <1> 	push	edx ; **
  3642 0000E423 51                  <1> 	push	ecx ; *
  3643 0000E424 C1E910              <1> 	shr	ecx, 16 ; top row
  3644 0000E427 C1EA10              <1> 	shr	edx, 16 ; bottom row
  3645                              <1> 	; 21/11/2020
  3646                              <1> 	;cmp	ecx, 24 ; max. 25 rows
  3647 0000E42A 6683F918            <1> 	cmp	cx, 24
  3648 0000E42E 7778                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3649                              <1> 	;cmp	edx, 24 ; max. 25 rows
  3650 0000E430 6683FA18            <1> 	cmp	dx, 24
  3651 0000E434 7772                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0		
  3652 0000E436 28CA                <1> 	sub	dl, cl ; end >= start
  3653 0000E438 726E                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
  3654                              <1> 	; 21/11/2020
  3655 0000E43A 89D3                <1> 	mov	ebx, edx ; row count - 1
  3656 0000E43C 7415                <1> 	jz	short sysvideo_4_2
  3657 0000E43E 50                  <1> 	push	eax ; *****
  3658 0000E43F B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
  3659 0000E444 F7E3                <1> 	mul	ebx ; 21/11/2020
  3660                              <1> 		; eax = window end offset 
  3661                              <1> 		; (for the last row, before adding column bytes)
  3662 0000E446 01C6                <1> 	add	esi, eax
  3663 0000E448 01C7                <1> 	add	edi, eax
  3664 0000E44A 58                  <1> 	pop	eax ; ***** ; mode 3 video memory end (0C000h)
  3665 0000E44B 39C6                <1> 	cmp	esi, eax
  3666                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3667 0000E44D 7359                <1> 	jnb	short sysvideo_6 ; 21/11/2020
  3668 0000E44F 39C7                <1> 	cmp	edi, eax
  3669                              <1> 	;ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3670 0000E451 7355                <1> 	jnb	short sysvideo_6 ; 21/11/2020
  3671                              <1> sysvideo_4_2:
  3672 0000E453 59                  <1> 	pop	ecx ; *
  3673 0000E454 5A                  <1> 	pop	edx ; **
  3674 0000E455 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  3675 0000E45B 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  3676                              <1> 	; 21/11/2020
  3677                              <1> 	;cmp	ecx, 79 ; max. 80 columns
  3678 0000E461 6683F94F            <1> 	cmp	cx, 79
  3679 0000E465 7743                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  3680                              <1> 	;cmp	edx, 79 ; max. 80 columns
  3681 0000E467 6683FA4F            <1> 	cmp	dx, 79 
  3682 0000E46B 773D                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  3683 0000E46D 28CA                <1> 	sub	dl, cl
  3684 0000E46F 7639                <1> 	jna	short sysvideo_7 ; invalid, [u.r0] = 0
  3685                              <1> 	; 21/11/2020
  3686 0000E471 740E                <1> 	jz	short sysvideo_4_3 
  3687                              <1> 	; edx = column count (width) - 1
  3688 0000E473 D0E2                <1> 	shl	dl, 1 ; * 2 ; byte offset (in end row)
  3689 0000E475 01D6                <1> 	add	esi, edx
  3690 0000E477 01D7                <1> 	add	edi, edx
  3691                              <1> 		; esi = source page window end offset
  3692                              <1> 		; edi = destination page window end offset
  3693 0000E479 39C6                <1> 	cmp	esi, eax ; video memory end
  3694                              <1> 	;ja	short sysvideo_7
  3695 0000E47B 732D                <1> 	jnb	short sysvideo_7 ; 21/11/2020
  3696 0000E47D 39C7                <1> 	cmp	edi, eax ; video memory end
  3697                              <1> 	;ja	short sysvideo_7
  3698 0000E47F 7329                <1> 	jnb	short sysvideo_7 ; 21/11/2020
  3699                              <1> sysvideo_4_3:
  3700 0000E481 5F                  <1> 	pop	edi ; ***
  3701 0000E482 5E                  <1> 	pop	esi ; ****
  3702 0000E483 FEC3                <1> 	inc	bl ; row count - 1 -> row count	
  3703 0000E485 FEC2                <1> 	inc	dl ; column count
  3704 0000E487 88D7                <1> 	mov	bh, dl
  3705 0000E489 D0E2                <1> 	shl	dl, 1 ; convert column count to byte offset
  3706                              <1> 	; 21/11/2020
  3707                              <1> 	; esi = source page window start offset
  3708                              <1> 	; edi = destination page window start offset
  3709 0000E48B B8A0000000          <1> 	mov	eax, 80*2 ; bytes per row
  3710                              <1> 	; Note: 160 bytes per row (even if move count < 160)
  3711                              <1> sysvideo_5:	
  3712 0000E490 88F9                <1> 	mov	cl, bh ; move/transfer -word- count per row
  3713 0000E492 0115[64030300]      <1> 	add	[u.r0], edx ; transfer count in bytes
  3714 0000E498 F366A5              <1> 	rep	movsw
  3715 0000E49B 01C6                <1> 	add	esi, eax ; + 160 bytes to next row
  3716 0000E49D 01C7                <1> 	add	edi, eax ; + 160 bytes to next row
  3717 0000E49F FECB                <1> 	dec	bl ; remain count of rows
  3718 0000E4A1 75ED                <1> 	jnz	short sysvideo_5
  3719 0000E4A3 E954F4FFFF          <1> 	jmp	sysret
  3720                              <1> 
  3721                              <1> sysvideo_6:
  3722 0000E4A8 59                  <1> 	pop	ecx ; *
  3723 0000E4A9 5A                  <1> 	pop	edx ; **
  3724                              <1> sysvideo_7:	
  3725 0000E4AA 5F                  <1> 	pop	edi ; ***
  3726 0000E4AB 5E                  <1> 	pop	esi ; ****
  3727                              <1> sysvideo_8:
  3728 0000E4AC E94BF4FFFF          <1> 	jmp	sysret
  3729                              <1> 
  3730                              <1> sysvideo_9:
  3731                              <1> 	; user to system or system to user window transfer
  3732                              <1> 	; 28/01/2021 (bl = 3 -> swap/exchange)
  3733                              <1> 	;cmp	bl, 2
  3734                              <1> 	;;ja	sysret	; user to user transfer is invalid
  3735                              <1> 	;		; [u.r0] = 0
  3736                              <1> 	;ja	short sysvideo_8 ; 26/12/2020
  3737                              <1> 
  3738                              <1> 	; 28/01/2021
  3739 0000E4B1 80FB02              <1> 	cmp	bl, 2
  3740 0000E4B4 7604                <1> 	jna	short sysvideo_9_8 
  3741                              <1> 
  3742                              <1> 	; swap/ exchange video memory and user mem windows
  3743                              <1> 	; edi = swap address in user's memory space
  3744 0000E4B6 21FF                <1> 	and	edi, edi
  3745 0000E4B8 74F2                <1> 	jz	short sysvideo_8 ; invalid ; 28/01/2021
  3746                              <1>  
  3747                              <1> sysvideo_9_8:		
  3748 0000E4BA 56                  <1> 	push	esi ; ****
  3749 0000E4BB 57                  <1> 	push	edi ; ***
  3750 0000E4BC 52                  <1> 	push	edx ; **
  3751 0000E4BD 51                  <1> 	push	ecx ; *
  3752                              <1> 
  3753 0000E4BE C1E910              <1> 	shr	ecx, 16 ; top row
  3754 0000E4C1 C1EA10              <1> 	shr	edx, 16 ; bottom row
  3755                              <1> 	
  3756                              <1> 	; 21/11/2020
  3757                              <1> 	;cmp	ecx, 24 ; max. 25 rows
  3758 0000E4C4 6683F918            <1> 	cmp	cx, 24
  3759 0000E4C8 77DE                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0
  3760                              <1> 	;cmp	edx, 24 ; max. 25 rows
  3761 0000E4CA 6683FA18            <1> 	cmp	dx, 24
  3762 0000E4CE 77D8                <1> 	ja	short sysvideo_6 ; invalid, [u.r0] = 0	
  3763 0000E4D0 28CA                <1> 	sub	dl, cl
  3764 0000E4D2 72D4                <1> 	jc	short sysvideo_6 ; invalid, [u.r0] = 0
  3765                              <1> 
  3766                              <1> 	;mov	ch, cl ; top row
  3767                              <1> 	;mov	cl, [ACTIVE_PAGE]
  3768                              <1> 
  3769                              <1> 	;mov	edi, 80*25*2 ; 4000
  3770                              <1> 	; 21/11/2020
  3771                              <1> 	;mov	edi, 4096 ; [CRT_LEN = 4096 for video mode 3 
  3772                              <1> 	;shl	edi, cl  ; ! wrong for page 2 to page 7 !
  3773                              <1> 	;;add	edi, 0B8000h - 80*25*2
  3774                              <1> 	;add	edi, 0B8000h - 1000h ; - 4096
  3775                              <1> 	
  3776                              <1> 	; 21/11/2020
  3777                              <1> 	;xor	eax, eax
  3778                              <1> 	;mov	edi, 0B8000h
  3779                              <1> 	;and	cl, cl ; is video page = 0 ?
  3780                              <1> 	;jz	short sysvideo_9_1 ; yes
  3781                              <1> 	; eax = 0
  3782                              <1> 
  3783                              <1> ;sysvideo_9_0:
  3784                              <1> 	;add	ax, 4096
  3785                              <1> 	;dec	cl
  3786                              <1> 	;jnz	short sysvideo_9_0
  3787                              <1> 	;add	edi, eax
  3788                              <1> 	;	; edi = video page start address
  3789                              <1> 
  3790                              <1> 	; 21/11/2020
  3791 0000E4D4 BF00800B00          <1> 	mov	edi, 0B8000h
  3792 0000E4D9 803D[FE890100]00    <1> 	cmp	byte [ACTIVE_PAGE], 0
  3793 0000E4E0 760C                <1> 	jna	short sysvideo_9_1
  3794                              <1> stsvideo_9_0:
  3795 0000E4E2 B010                <1> 	mov	al, 16 ; 4096/256
  3796 0000E4E4 F625[FE890100]      <1> 	mul	byte [ACTIVE_PAGE] 
  3797 0000E4EA 86E0                <1> 	xchg	ah, al ; * 256
  3798 0000E4EC 01C7                <1> 	add	edi, eax
  3799                              <1> 		; edi = video page start address
  3800                              <1> sysvideo_9_1:
  3801                              <1> 	; bl = transfer direction 
  3802                              <1> 	;     (1 = from user, 2 = to user)
  3803                              <1> 	;     (3 = swap) ; 28/01/2021
  3804 0000E4EE 88D7                <1> 	mov	bh, dl ; row count - 1
  3805                              <1> 	;mov	dl, ch ; top row
  3806                              <1> 	; 21/11/2020
  3807 0000E4F0 08C9                <1> 	or	cl, cl ; top row number
  3808 0000E4F2 7408                <1> 	jz	short sysvideo_9_2
  3809                              <1> 
  3810                              <1> 	;mov	eax, 80*2
  3811 0000E4F4 66B8A000            <1> 	mov	ax, 80*2 ; 160, bytes per row
  3812 0000E4F8 F7E1                <1> 	mul	ecx ; 22/11/2020
  3813 0000E4FA 01C7                <1> 	add	edi, eax
  3814                              <1> 		; edi = window start address for top row
  3815                              <1> sysvideo_9_2:
  3816 0000E4FC 59                  <1> 	pop	ecx ; *
  3817 0000E4FD 5A                  <1> 	pop	edx ; **
  3818 0000E4FE 81E1FFFF0000        <1> 	and	ecx, 0FFFFh
  3819 0000E504 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  3820                              <1> 	; 21/11/2020
  3821                              <1> 	;cmp	ecx, 79 ; max. 80 columns
  3822 0000E50A 6683F94F            <1> 	cmp	cx, 79
  3823 0000E50E 779A                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  3824                              <1> 	;cmp	edx, 79 ; max. 80 columns
  3825 0000E510 6683FA4F            <1> 	cmp	dx, 79
  3826 0000E514 7794                <1> 	ja	short sysvideo_7 ; invalid, [u.r0] = 0
  3827                              <1> 	
  3828 0000E516 28CA                <1> 	sub	dl, cl
  3829 0000E518 7290                <1> 	jc	short sysvideo_7 ; invalid, [u.r0] = 0
  3830                              <1> 	
  3831 0000E51A 08C9                <1> 	or	cl, cl ; left column 
  3832 0000E51C 7404                <1> 	jz	short sysvideo_9_3 ; 0
  3833                              <1> 
  3834                              <1> 	; 21/11/2020
  3835 0000E51E D0E1                <1> 	shl	cl, 1  ; column * 2
  3836 0000E520 01CF                <1> 	add	edi, ecx
  3837                              <1> 		; edi = window start addr for top left column
  3838                              <1> sysvideo_9_3:
  3839 0000E522 88D1                <1> 	mov	cl, dl
  3840 0000E524 FEC1                <1> 	inc	cl ; column count
  3841 0000E526 D0E1                <1> 	shl	cl, 1 ; column count * 2
  3842                              <1> 		; ecx = transfer count per row
  3843                              <1> 
  3844 0000E528 58                  <1> 	pop	eax ; *** (swap address)
  3845 0000E529 5E                  <1> 	pop	esi ; ****
  3846                              <1> 
  3847 0000E52A FEC7                <1> 	inc	bh  ; row count	
  3848                              <1> 	
  3849                              <1> 	;mov	edx, 80*2
  3850 0000E52C B2A0                <1> 	mov	dl, 80*2  ; bytes per row
  3851                              <1> 	;
  3852                              <1> 	;cmp	bl, 1 ; transfer direction
  3853                              <1> 	;ja	short sysvideo_11 ; system to user transfer
  3854                              <1> 	; 28/01/2021
  3855 0000E52E F6C301              <1> 	test	bl, 1
  3856 0000E531 7439                <1> 	jz	short sysvideo_11 ; system to user transfer
  3857                              <1> 
  3858                              <1> 	; user to system video/display page window transfer (mode 0)	
  3859 0000E533 21C0                <1> 	and	eax, eax ; swap address
  3860 0000E535 741B                <1> 	jz	short sysvideo_10 ; no window swap
  3861                              <1> sysvideo_9_7: ; 28/01/2021
  3862                              <1> 	; save previous window content in user's buffer (swap address)
  3863 0000E537 56                  <1> 	push	esi ; user buffer
  3864 0000E538 57                  <1> 	push	edi ; beginning address of the window
  3865                              <1> 	; 21/11/2020
  3866 0000E539 53                  <1> 	push	ebx ; save bh
  3867 0000E53A 89FE                <1> 	mov	esi, edi
  3868 0000E53C 89C7                <1> 	mov	edi, eax
  3869                              <1> sysvideo_9_4:
  3870 0000E53E E8C1350000          <1> 	call	transfer_to_user_buffer ; fast transfer
  3871 0000E543 7208                <1> 	jc	short sysvideo_9_5
  3872                              <1> 	; ecx = actual transfer count (must be same with input)
  3873 0000E545 01D6                <1> 	add	esi, edx ; next row address of (video page) window 
  3874 0000E547 01CF                <1> 	add	edi, ecx ; next row address of user's window
  3875                              <1> 		; Note: ecx may be less than row length of video page
  3876                              <1> 		; user's window uses offset according to window width
  3877 0000E549 FECF                <1> 	dec	bh
  3878 0000E54B 75F1                <1> 	jnz	short sysvideo_9_4 ; repeat for next row
  3879                              <1> sysvideo_9_5:
  3880 0000E54D 5B                  <1> 	pop	ebx ; restore bh
  3881 0000E54E 5F                  <1> 	pop	edi
  3882 0000E54F 5E                  <1> 	pop	esi
  3883                              <1> 	;jnc	short sysvideo_10
  3884 0000E550 7215                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
  3885                              <1> ;sysvideo_9_6:
  3886                              <1> ;	jmp	sysret ; [u.r0] = 0
  3887                              <1> 
  3888                              <1> sysvideo_10:
  3889                              <1> 	; user to system video/display page window transfer (mode 0)	
  3890                              <1> 	; esi =	user buffer
  3891 0000E552 E8F7350000          <1> 	call	transfer_from_user_buffer ; fast transfer
  3892                              <1> 	;jc	sysret
  3893 0000E557 720E                <1> 	jc	short sysvideo_9_6 ; 28/01/2021
  3894                              <1> 	; ecx = actual transfer count (must be same with input)
  3895 0000E559 010D[64030300]      <1> 	add	[u.r0], ecx ; actual transfer count
  3896 0000E55F 01D7                <1> 	add	edi, edx ; next row address of (video page) window 
  3897 0000E561 01CE                <1> 	add	esi, ecx ; next row address of user's window
  3898                              <1> 		; Note: ecx may be less than row length of video page
  3899                              <1> 		; user's window uses offset according to window width
  3900 0000E563 FECF                <1> 	dec	bh
  3901 0000E565 75EB                <1> 	jnz	short sysvideo_10 ; repeat for next row
  3902                              <1> 	;jmp	sysret
  3903                              <1> sysvideo_9_6:
  3904 0000E567 E990F3FFFF          <1> 	jmp	sysret
  3905                              <1> 	
  3906                              <1> sysvideo_11:
  3907                              <1> 	; system to user video/display page window transfer (mode 0)
  3908 0000E56C 87FE                <1> 	xchg	edi, esi
  3909                              <1> sysvideo_12:
  3910                              <1> 	; esi = beginning addr of the (screen, video page) window
  3911                              <1> 	; edi =	user's buffer	
  3912 0000E56E E891350000          <1> 	call	transfer_to_user_buffer ; fast transfer
  3913 0000E573 0F8283F3FFFF        <1> 	jc	sysret
  3914                              <1> 	; ecx = actual transfer count (must be same with input)
  3915 0000E579 010D[64030300]      <1> 	add	[u.r0], ecx
  3916 0000E57F 01D6                <1> 	add	esi, edx ; next row (edx = 160)
  3917 0000E581 01CF                <1> 	add	edi, ecx ; next row of the user's window 
  3918                              <1> 			 ; (ecx <= 160)
  3919 0000E583 FECF                <1> 	dec	bh
  3920 0000E585 75E7                <1> 	jnz	short sysvideo_12
  3921                              <1> sysvideo_12_0:
  3922 0000E587 E970F3FFFF          <1> 	jmp	sysret
  3923                              <1> 
  3924                              <1> sysvideo_13:
  3925                              <1> 	; 28/12/2020
  3926 0000E58C 80FF01              <1> 	cmp	bh, 1
  3927 0000E58F 7753                <1>         ja      short sysvideo_15 ; 23/11/2020
  3928                              <1> 
  3929                              <1> 	; 25/02/2021
  3930                              <1> 	; 12/02/2021
  3931                              <1> 	; 29/01/2021, 31/01/2021
  3932                              <1> 	; 23/11/2020 (TRDOS 386 v2.0.3)
  3933                              <1> 	; (major modification, from mode 13h to all VGA modes,
  3934                              <1> 	;  except super VGA modes and liner frame buffer method)
  3935                              <1> 
  3936                              <1> 	; BH = 1 = VGA Graphics mode (0A0000h) data transfers
  3937                              <1> 
  3938                              <1> 	; 29/01/2021
  3939 0000E591 66B84001            <1> 	mov	ax, 320	; 320 pixels
  3940 0000E595 F6C380              <1> 	test	bl, 80h	; bit 7 (screen width, 640 pixels)		
  3941 0000E598 7408                <1> 	jz	short sysvideo_13_0
  3942 0000E59A 66D1E0              <1> 	shl	ax, 1	; 640 pixels
  3943                              <1> 	;
  3944 0000E59D 80E37F              <1> 	and	bl, 7Fh
  3945 0000E5A0 7405                <1> 	jz	short sysvideo_14
  3946                              <1> sysvideo_13_0:
  3947                              <1> 	; 29/01/2021
  3948 0000E5A2 80FB41              <1> 	cmp	bl, 41h
  3949 0000E5A5 77E0                <1> 	ja	short sysvideo_12_0 ; invalid (unknown) sub function
  3950                              <1> sysvideo_14:
  3951 0000E5A7 66A3[86120300]      <1> 	mov	[v_width], ax	; save screen width
  3952 0000E5AD C705[8A120300]0000- <1> 	mov	dword [v_mem], 0A0000h  ; save video memory address
  3952 0000E5B5 0A00                <1>
  3953 0000E5B7 C705[8E120300]0000- <1> 	mov	dword [v_siz], 65536	; save video memory size
  3953 0000E5BF 0100                <1>
  3954 0000E5C1 C705[96120300]0000- <1> 	mov	dword [v_end], 0B0000h	; save end of video page
  3954 0000E5C9 0B00                <1>
  3955 0000E5CB B708                <1> 	mov	bh, 8
  3956 0000E5CD 883D[89120300]      <1> 	mov	[v_bpp], bh ; 8	; bits per pixel (256 colors)
  3957 0000E5D3 881D[88120300]      <1> 	mov	[v_ops], bl	; VGA data transfer options
  3958                              <1> 	;mov	[maskbuff], edi ; 25/02/2021 
  3959 0000E5D9 893D[9A120300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
  3960                              <1> 			; save mask color or bitmask buffer address
  3961 0000E5DF E9AD000000          <1> 	jmp	sysvideo_15_7
  3962                              <1> 
  3963                              <1> sysvideo_15:
  3964                              <1> 	; 28/12/2020
  3965 0000E5E4 80FF02              <1> 	cmp	bh, 2
  3966 0000E5E7 0F87C71E0000        <1>         ja      sysvideo_16
  3967                              <1> 
  3968                              <1> 	; 25/02/2021
  3969                              <1> 	; 12/02/2021
  3970                              <1> 	; 30/01/2021, 31/01/2021
  3971                              <1> 	; 01/01/2021, 29/01/2021
  3972                              <1> 	; 26/12/2020, 27/12/2020
  3973                              <1> 	; 25/12/2020 (TRDOS 386 v2.0.3)
  3974                              <1> 	;
  3975                              <1> 	; BH = 2 = SVGA (VESA VBE) Graphics mode (LFB) data transfers
  3976                              <1> 
  3977                              <1> 	; 25/12/2020
  3978                              <1> 	; resolution table entry will be saved into EBP register
  3979                              <1> 
  3980 0000E5ED 803D[54090000]02    <1> 	cmp	byte [vbe3], 2 ; VESA VBE 3 video bios 
  3981                              <1> 			  ; or BOCHS/QEMU/VIRTUALBOX emu video bios
  3982 0000E5F4 724E                <1> 	jb	short sysvideo_15_4 ; no, nothing to do !
  3983 0000E5F6 770B                <1> 	ja	short sysvideo_15_0 ; yes
  3984                              <1> 
  3985                              <1> 	; Only Bochs/Plex86 (emu) vbe2 video bios is usable in pmid
  3986                              <1> 	; (if [vbe3] = 2) 
  3987 0000E5F8 A0[55090000]        <1> 	mov	al, [vbe2bios] ; Bochs vbios sign is from C0h to C5h
  3988 0000E5FD 24F0                <1> 	and	al, 0F0h
  3989 0000E5FF 3CC0                <1> 	cmp	al, 0C0h
  3990 0000E601 7541                <1> 	jne	short sysvideo_15_4 ; unknown (vbe2) video bios
  3991                              <1> sysvideo_15_0:
  3992                              <1> 	; 29/01/2021
  3993 0000E603 80FB41              <1> 	cmp	bl, 41h
  3994 0000E606 773C                <1> 	ja	short sysvideo_15_4 ; invalid (unknown) sub function
  3995                              <1> 	; 29/01/2021
  3996 0000E608 881D[88120300]      <1> 	mov	[v_ops], bl	; SVGA data transfer options
  3997                              <1> 
  3998 0000E60E 89D8                <1> 	mov	eax, ebx ; hw of ebx is vesa vbe video mode
  3999 0000E610 C1E810              <1> 	shr	eax, 16 ; ax = vesa vbe video mode
  4000 0000E613 7513                <1> 	jnz	short sysvideo_15_2 
  4001                              <1> 	; ax = 0
  4002                              <1> 
  4003                              <1> 	; check & use current video mode
  4004 0000E615 803D[CA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; extended (SVGA) mode ?
  4005 0000E61C 7526                <1> 	jne	short sysvideo_15_4 ; no
  4006                              <1> sysvideo_15_1:
  4007                              <1> 	; use current vbe (svga) video mode
  4008 0000E61E 66A1[1E120300]      <1> 	mov	ax, [video_mode] ; extended (SVGA, VESA VBE) mode
  4009 0000E624 6625FF01            <1> 	and	ax, 1FFh ; vesa vbe video mode: 1XXh
  4010                              <1> sysvideo_15_2:
  4011                              <1> 	; 29/01/2021
  4012                              <1> 	;mov	[maskbuff], edi ; 25/02/2021
  4013 0000E628 893D[9A120300]      <1> 	mov	[maskcolor], edi ; 25/02/2021
  4014                              <1> 			; save mask color or bitmask buffer address
  4015 0000E62E BD[56730000]        <1> 	mov	ebp, b_vbe_modes ; vbe mode table (in 'vidata.s')
  4016                              <1> sysvideo_15_3:
  4017 0000E633 663B4500            <1> 	cmp	ax, [ebp]
  4018 0000E637 7410                <1> 	je	short sysvideo_15_5
  4019 0000E639 83C508              <1> 	add	ebp, 8 ; vbe mode table entry size
  4020 0000E63C 81FD[16740000]      <1> 	cmp	ebp, end_of_b_vbe_modes
  4021 0000E642 72EF                <1>  	jb	short sysvideo_15_3	
  4022                              <1> sysvideo_15_4:
  4023                              <1> 	; desired video mode is not a valid (implemented)
  4024                              <1> 	;	  extended (VESA VBE, SVGA) video mode
  4025                              <1> 	;
  4026                              <1> 	; nothing to do !
  4027                              <1> 
  4028                              <1>  	; [u.r0] = 0  ; return value of EAX
  4029 0000E644 E9B3F2FFFF          <1>  	jmp	sysret
  4030                              <1> 
  4031                              <1> sysvideo_15_5:
  4032                              <1> 	; get LFB address
  4033 0000E649 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  4034 0000E64E 09C0                <1> 	or	eax, eax
  4035 0000E650 7509                <1> 	jnz	short sysvideo_15_6
  4036 0000E652 66A1[E30E0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB addr 
  4037                              <1> 				   ; (for vbe mode 118h)
  4038 0000E658 C1E010              <1> 	shl	eax, 16
  4039                              <1> 	; 27/12/2020
  4040                              <1> 	;jz	short sysvideo_15_4
  4041                              <1> sysvideo_15_6:
  4042                              <1> 	; 29/01/2021
  4043 0000E65B A3[8A120300]        <1> 	mov	[v_mem], eax ; save video memory address
  4044                              <1> 	
  4045                              <1> 	; 27/12/2020
  4046                              <1> 	; 26/12/2020
  4047 0000E660 8B4502              <1> 	mov	eax, [ebp+2] ; width, height
  4048                              <1> 	; 29/01/2021
  4049 0000E663 66A3[86120300]      <1> 	mov	[v_width], ax ; save screen width
  4050                              <1> 	; 28/12/2020
  4051 0000E669 8A7D06              <1> 	mov	bh, [ebp+6] ; bpp
  4052                              <1> 	; 29/01/2021
  4053 0000E66C 883D[89120300]      <1> 	mov	[v_bpp], bh ; bits per pixel
  4054                              <1> 
  4055 0000E672 52                  <1> 	push	edx ; *
  4056 0000E673 0FB7D0              <1> 	movzx	edx, ax  ; width
  4057 0000E676 C1E810              <1> 	shr	eax, 16  ; height
  4058 0000E679 F7E2                <1> 	mul	edx
  4059                              <1> 	; eax = linear frame buffer size (pixels)
  4060                              <1> 	; 29/01/2021
  4061 0000E67B A3[8E120300]        <1> 	mov	[v_siz], eax ; save video page size
  4062 0000E680 E8FD000000          <1> 	call	pixels_to_byte_count
  4063 0000E685 0305[8A120300]      <1> 	add	eax, [v_mem]
  4064 0000E68B A3[96120300]        <1> 	mov	[v_end], eax ; save end of video page 
  4065 0000E690 5A                  <1> 	pop	edx ; *
  4066                              <1> 
  4067                              <1> 	; bh = bits per pixel
  4068                              <1> 	; (bh will not be used after here, 29/01/2021)
  4069                              <1> 
  4070                              <1> 	; bl = pixel operations & options
  4071                              <1> 	; ecx, edx, esi, edi input parameters
  4072                              <1> 	; [maskcolor] = edi input ; 25/02/2021
  4073                              <1> 
  4074                              <1> sysvideo_15_7:
  4075                              <1> 	; 29/01/2021
  4076                              <1> 	;test	byte [v_ops], 40h  ; system to user ?
  4077 0000E691 F6C340              <1> 	test	bl, 40h
  4078 0000E694 7517                <1> 	jnz	short sysvideo_15_9
  4079                              <1> 
  4080 0000E696 31C0                <1> 	xor	eax, eax
  4081 0000E698 88D8                <1> 	mov	al, bl
  4082 0000E69A BB[C0E70000]        <1> 	mov	ebx, pixel_ops
  4083 0000E69F 240F                <1> 	and	al, 0Fh ; isolate 16 pixel operations
  4084 0000E6A1 C0E002              <1> 	shl	al, 2 ; * 4 for dword table pointers 
  4085 0000E6A4 01C3                <1> 	add	ebx, eax
  4086                              <1> 
  4087                              <1> 	; ebx = subroutine address
  4088                              <1> 
  4089                              <1> 	; ecx, edx, esi, edi input parameters
  4090                              <1> 	; [maskbuff] = edi input
  4091                              <1> 	; [maskcolor] = edi input ; 25/02/2021
  4092                              <1> 
  4093 0000E6A6 FF13                <1> 	call	[ebx]		
  4094                              <1> sysvideo_15_8:
  4095 0000E6A8 E94FF2FFFF          <1> 	jmp	sysret
  4096                              <1> 
  4097                              <1> sysvideo_15_9:
  4098                              <1> 	; system to user display page or window copy
  4099                              <1> 	;test	byte [v_ops], 1 ; window copy ?
  4100 0000E6AD F6C301              <1> 	test	bl, 1	
  4101 0000E6B0 7521                <1> 	jnz	short sysvideo_15_10
  4102                              <1> 
  4103                              <1> 	; display page (full screen copy)
  4104 0000E6B2 8B35[8A120300]      <1> 	mov	esi, [v_mem] ; LFB start address
  4105 0000E6B8 A1[8E120300]        <1> 	mov	eax, [v_siz]
  4106 0000E6BD E8C0000000          <1> 	call	pixels_to_byte_count
  4107 0000E6C2 89C1                <1> 	mov	ecx, eax ; transfer count in bytes
  4108                              <1> 	;edi = user's buffer address
  4109 0000E6C4 E83B340000          <1> 	call	transfer_to_user_buffer
  4110 0000E6C9 72DD                <1> 	jc	short sysvideo_15_8	
  4111 0000E6CB 890D[64030300]      <1> 	mov	[u.r0], ecx
  4112 0000E6D1 EBD5                <1> 	jmp	short sysvideo_15_8
  4113                              <1> 
  4114                              <1> sysvideo_15_10:
  4115 0000E6D3 E820000000          <1> 	call	sysvideo_15_12 ; window preparations
  4116 0000E6D8 72CE                <1> 	jc	short sysvideo_15_8
  4117                              <1> 
  4118 0000E6DA 8B35[92120300]      <1> 	mov	esi, [v_str]
  4119                              <1> sysvideo_15_11:
  4120                              <1> 	; esi = window's current row address (video mem)
  4121                              <1> 	; edi = current row (virtual) addr in user's buff
  4122                              <1> 	; ecx = transfer count per row
  4123 0000E6E0 E81F340000          <1> 	call	transfer_to_user_buffer
  4124 0000E6E5 72C1                <1> 	jc	short sysvideo_15_8
  4125 0000E6E7 010D[64030300]      <1>  	add	[u.r0], ecx
  4126 0000E6ED 4B                  <1> 	dec	ebx
  4127 0000E6EE 74B8                <1> 	jz	short sysvideo_15_8 ; ok.
  4128                              <1> 	; next row
  4129 0000E6F0 01CF                <1> 	add	edi, ecx ; next row in user's buffer
  4130 0000E6F2 01D6                <1> 	add	esi, edx ; next row of window (system)
  4131 0000E6F4 EBEA                <1> 	jmp	short sysvideo_15_11
  4132                              <1> 
  4133                              <1> sysvideo_15_14:
  4134 0000E6F6 F9                  <1> 	stc	 ; error !
  4135                              <1> sysvideo_15_15:
  4136 0000E6F7 C3                  <1> 	retn
  4137                              <1> 
  4138                              <1> sysvideo_15_12:
  4139                              <1> 	; 30/01/2021
  4140                              <1> 	; 29/01/2021
  4141                              <1> 	; Window address preparations for window copy
  4142 0000E6F8 6621D2              <1> 	and	dx, dx
  4143 0000E6FB 74F9                <1> 	jz	short sysvideo_15_14 ; invalid (zero columns)
  4144                              <1> 	;test	edx, 0FFFF0000h
  4145                              <1> 	;jz	short sysvideo_15_14 ; invalid (zero rows)
  4146 0000E6FD 81FA00000100        <1> 	cmp	edx, 65536
  4147 0000E703 72F2                <1> 	jb	short sysvideo_15_15 ; invalid (zero rows)
  4148 0000E705 89C8                <1> 	mov	eax, ecx ; start position (row, column)
  4149 0000E707 E899000000          <1> 	call	calc_pixel_offset
  4150 0000E70C 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  4151 0000E712 73E2                <1> 	jnb	short sysvideo_15_14 ; out of display page
  4152                              <1> 				; nothing to do
  4153 0000E714 E869000000          <1> 	call	pixels_to_byte_count
  4154 0000E719 0305[8A120300]      <1> 	add	eax, [v_mem]
  4155 0000E71F A3[92120300]        <1> 	mov	[v_str], eax ; window start address
  4156                              <1> 			     ; (addr of top left corner)
  4157                              <1> 	; check column limit
  4158 0000E724 89C8                <1> 	mov	eax, ecx
  4159 0000E726 6601D0              <1> 	add	ax, dx  ; add columns to start column
  4160 0000E729 72CC                <1> 	jc	short sysvideo_15_15 ; cf = 1
  4161 0000E72B 663B05[86120300]    <1> 	cmp	ax, [v_width]
  4162 0000E732 77C2                <1> 	ja	short sysvideo_15_14
  4163                              <1> 
  4164 0000E734 89D0                <1> 	mov	eax, edx ; size
  4165 0000E736 2D00000100          <1> 	sub	eax, 65536 ; row count -> 0 based row #
  4166 0000E73B E865000000          <1> 	call	calc_pixel_offset
  4167 0000E740 3B05[8E120300]      <1> 	cmp	eax, [v_siz] ; video (display) page size
  4168 0000E746 77AE                <1> 	ja	short sysvideo_15_14 ; out of display page
  4169                              <1> 				; nothing to do
  4170 0000E748 E835000000          <1> 	call	pixels_to_byte_count
  4171 0000E74D 0305[92120300]      <1> 	add	eax, [v_str] ; window start address
  4172 0000E753 3B05[96120300]      <1> 	cmp	eax, [v_end] ; window end address (+1)
  4173                              <1> 			 ; (addr of bottom right corner +1)	
  4174 0000E759 779B                <1> 	ja	short sysvideo_15_14 ; out of display page
  4175                              <1> 				; nothing to do
  4176 0000E75B 89D3                <1> 	mov	ebx, edx
  4177 0000E75D C1EB10              <1> 	shr	ebx, 16 
  4178                              <1> 	; ebx = row count
  4179 0000E760 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  4180                              <1> 	; edx = transfer count per row (from user's buffer)
  4181                              <1> 	;	(in pixels, window width)
  4182 0000E766 89D0                <1> 	mov	eax, edx
  4183 0000E768 A3[9E120300]        <1> 	mov	[pixcount], eax ; 27/02/2021
  4184 0000E76D E810000000          <1> 	call	pixels_to_byte_count
  4185 0000E772 89C1                <1> 	mov	ecx, eax
  4186                              <1> 	; ecx = transfer count per row (from user's buffer)
  4187                              <1> 	;	(in bytes, window width)
  4188 0000E774 66A1[86120300]      <1> 	mov	ax, [v_width]
  4189 0000E77A E803000000          <1> 	call	pixels_to_byte_count
  4190 0000E77F 89C2                <1> 	mov	edx, eax
  4191                              <1> 	; edx = byte count per row
  4192 0000E781 C3                  <1> 	retn ; cf = 0
  4193                              <1> 
  4194                              <1> pixels_to_byte_count:
  4195                              <1> 	; 29/01/2021
  4196                              <1> 	; INPUT:
  4197                              <1> 	;   eax = pixel count
  4198                              <1> 	; OUTPUT:
  4199                              <1> 	;   eax = byte count
  4200                              <1> 	;
  4201 0000E782 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8
  4202 0000E789 7619                <1> 	jna	short pixtobc_3 ; 8 bit colors
  4203 0000E78B 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24
  4204 0000E792 720A                <1> 	jb	short pixtobc_1 ; 16 bit colors
  4205 0000E794 770B                <1> 	ja	short pixtobc_2 ; 32 bit colors
  4206                              <1> 	; 24 bit pixels
  4207                              <1> 	; eax = eax * 3
  4208                              <1> 	;push	edx
  4209                              <1> 	;mov	edx, eax
  4210                              <1> 	;shl	eax, 1
  4211                              <1> 	;add	eax, edx
  4212                              <1> 	;pop	edx
  4213 0000E796 50                  <1> 	push	eax
  4214 0000E797 D1E0                <1> 	shl	eax, 1
  4215 0000E799 010424              <1> 	add	[esp], eax
  4216 0000E79C 58                  <1> 	pop	eax
  4217 0000E79D C3                  <1> 	retn		
  4218                              <1> pixtobc_1:
  4219                              <1> 	; 32 bit pixels
  4220                              <1> 	; eax = eax * 2
  4221 0000E79E D1E0                <1> 	shl	eax, 1
  4222 0000E7A0 C3                  <1> 	retn
  4223                              <1> pixtobc_2:
  4224                              <1> 	; 16 bit pixels
  4225                              <1> 	; eax = eax * 4
  4226 0000E7A1 C1E002              <1> 	shl	eax, 2
  4227                              <1> pixtobc_3:
  4228 0000E7A4 C3                  <1> 	retn
  4229                              <1> 
  4230                              <1> calc_pixel_offset:
  4231                              <1> 	; 29/01/2021
  4232                              <1> 	; INPUT:
  4233                              <1> 	;   eax = pixel position (row, column)
  4234                              <1> 	; OUTPUT:
  4235                              <1> 	;   eax = pixel offset (linear address)
  4236                              <1> 	;
  4237 0000E7A5 52                  <1> 	push	edx
  4238 0000E7A6 50                  <1> 	push	eax
  4239 0000E7A7 C1E810              <1> 	shr	eax, 16
  4240 0000E7AA 7409                <1> 	jz	short cpixo_0
  4241                              <1> 	; eax = row 
  4242 0000E7AC 0FB715[86120300]    <1> 	movzx	edx, word [v_width]
  4243 0000E7B3 F7E2                <1> 	mul	edx
  4244                              <1> cpixo_0:
  4245                              <1> 	; eax = row * screen width
  4246 0000E7B5 5A                  <1> 	pop	edx
  4247 0000E7B6 81E2FFFF0000        <1> 	and	edx, 0FFFFh
  4248                              <1> 	; edx = column
  4249 0000E7BC 01D0                <1> 	add	eax, edx
  4250                              <1> 	; eax = (row * screen width) + column		
  4251 0000E7BE 5A                  <1> 	pop	edx
  4252 0000E7BF C3                  <1> 	retn
  4253                              <1> 
  4254                              <1> 	; 02/02/2021
  4255                              <1> 	; 29/01/2021
  4256                              <1> pixel_ops:
  4257 0000E7C0 [00E80000]          <1> 	dd	pix_op_cpy ; copy pixels (user to system)
  4258 0000E7C4 [4BED0000]          <1> 	dd	pix_op_new ; change (new, fill) color
  4259 0000E7C8 [68E80000]          <1> 	dd	pix_op_add ; add color (up to 0FFh)
  4260 0000E7CC [1AE90000]          <1> 	dd	pix_op_sub ; sub color (down to 0)
  4261 0000E7D0 [35EB0000]          <1> 	dd	pix_op_orc ; or color
  4262 0000E7D4 [E7EB0000]          <1> 	dd	pix_op_and ; and color
  4263 0000E7D8 [99EC0000]          <1> 	dd	pix_op_xor ; xor color
  4264 0000E7DC [0FEE0000]          <1> 	dd	pix_op_not ; not color
  4265 0000E7E0 [B9EE0000]          <1> 	dd	pix_op_neg ; neg color
  4266 0000E7E4 [63EF0000]          <1> 	dd	pix_op_inc ; inc color
  4267 0000E7E8 [0DF00000]          <1> 	dd	pix_op_dec ; dec color
  4268 0000E7EC [CCE90000]          <1> 	dd	pix_op_mix ; mix color
  4269 0000E7F0 [93EA0000]          <1> 	dd	pix_op_rpl ; replace color
  4270 0000E7F4 [B7F00000]          <1> 	dd	pix_op_blk ; copy pixel block(s) (sys)
  4271 0000E7F8 [66F10000]          <1> 	dd	pix_op_lin ; write line(s)
  4272 0000E7FC [49F50000]          <1> 	dd	pix_op_chr ; write character (font)
  4273                              <1> 
  4274                              <1> pix_op_cpy:
  4275                              <1> 	; 21/02/2021
  4276                              <1> 	; 06/02/2021
  4277                              <1> 	; 30/01/2021
  4278                              <1> 	; COPY PIXELS
  4279                              <1> 	;
  4280                              <1> 	; INPUT:
  4281                              <1> 	;  If bit 4 of BL or [v_ops] = 1 -window copy-
  4282                              <1> 	;  ECX = start position (row, column)
  4283                              <1> 	;        (HW = row, CX = column)
  4284                              <1> 	;  EDX = size (rows, colums)
  4285                              <1> 	;        (HW = rows, DX = columns)
  4286                              <1> 	;	 (0 -> invalid 	
  4287                              <1> 	;        (1 -> horizontal or vertical line)
  4288                              <1> 	;  If bit 4 of BL or [v_ops] = 0 -full screen-
  4289                              <1> 	;     ECX and EDX will not be used
  4290                              <1>   	;  ESI = user's buffer address
  4291                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4292                              <1> 	;
  4293                              <1> 	; OUTPUT:
  4294                              <1> 	; 	[u.r0] will be > 0 if succesful
  4295                              <1> 
  4296 0000E800 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4297 0000E807 752E                <1> 	jnz	short pix_op_cpy_w ; window
  4298                              <1> 
  4299 0000E809 8B3D[8A120300]      <1> 	mov	edi, [v_mem] ; 21/02/2021
  4300                              <1> 	
  4301                              <1> 	; Copy user's buffer content do display page
  4302                              <1> 	; (full screen copy)
  4303 0000E80F A1[8E120300]        <1> 	mov	eax, [v_siz] ; video page size
  4304 0000E814 E869FFFFFF          <1> 	call	pixels_to_byte_count
  4305 0000E819 89C1                <1> 	mov	ecx, eax ; transfer count
  4306                              <1> 	; esi = user's buffer address (virtual)
  4307 0000E81B F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
  4308 0000E822 7405                <1> 	jz	short pix_op_cpy_0 ; no	
  4309 0000E824 E9720F0000          <1> 	jmp	m_pix_op_cpy ; copy pixels except mask color
  4310                              <1> pix_op_cpy_0:
  4311                              <1> 	; esi = user buffer for full screen copy
  4312                              <1> 	; edi = start of video memory 
  4313                              <1> 	;	(start of display page)
  4314                              <1> 	; ecx = byte count (display page size in bytes)
  4315 0000E829 E820330000          <1> 	call	transfer_from_user_buffer
  4316 0000E82E 7206                <1> 	jc	short pix_op_cpy_1
  4317 0000E830 890D[64030300]      <1> 	mov	[u.r0], ecx
  4318                              <1> pix_op_cpy_1:
  4319 0000E836 C3                  <1> 	retn	; 06/02/2021
  4320                              <1> 
  4321                              <1> pix_op_cpy_w:
  4322 0000E837 E8BCFEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4323 0000E83C 72F8                <1> 	jc	short pix_op_cpy_1
  4324                              <1> 	; ecx = bytes per row (to be applied)
  4325                              <1> 	; edx = screen width in bytes
  4326                              <1> 	; ebx = row count
  4327 0000E83E 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4328 0000E844 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked copy ?
  4329 0000E84B 7405                <1> 	jz	short pix_op_cpy_w_0 ; no
  4330 0000E84D E90C100000          <1> 	jmp	m_pix_op_cpy_w ; window copy except mask color
  4331                              <1> pix_op_cpy_w_0:
  4332                              <1> 	; esi = current row (virtual) addr in user's buff
  4333                              <1> 	; edi = window's current row address (video mem)
  4334                              <1> 	; ecx = transfer count per row
  4335 0000E852 E8F7320000          <1> 	call	transfer_from_user_buffer
  4336 0000E857 72DD                <1> 	jc	short pix_op_cpy_1
  4337 0000E859 010D[64030300]      <1>  	add	[u.r0], ecx
  4338 0000E85F 4B                  <1> 	dec	ebx
  4339 0000E860 74D4                <1> 	jz	short pix_op_cpy_1 ; ok.
  4340                              <1> 	; next row
  4341 0000E862 01CE                <1> 	add	esi, ecx ; next row in user's buffer
  4342 0000E864 01D7                <1> 	add	edi, edx ; next row of window (system)
  4343 0000E866 EBEA                <1> 	jmp	short pix_op_cpy_w_0
  4344                              <1> 
  4345                              <1> pix_op_add:
  4346                              <1> 	; 31/01/2021
  4347                              <1> 	; 30/01/2021
  4348                              <1> 	; ADD COLOR
  4349                              <1> 	;
  4350                              <1> 	; INPUT:
  4351                              <1> 	;   CL = color (8 bit, 256 colors)
  4352                              <1> 	;  ECX = color (16 bit and true colors)
  4353                              <1> 	;  EDX = start position (row, column)
  4354                              <1> 	;        (HW = row, DX = column)
  4355                              <1> 	;  ESI = size (rows, colums)
  4356                              <1> 	;        (HW = rows, SI = columns)
  4357                              <1> 	;
  4358                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4359                              <1> 	;
  4360                              <1> 	; OUTPUT:
  4361                              <1> 	; 	[u.r0] will be > 0 if succesful
  4362                              <1> 	
  4363 0000E868 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4364 0000E86F 7555                <1> 	jnz	short pix_op_add_w ; window
  4365                              <1> 	
  4366 0000E871 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  4367 0000E877 89FE                <1> 	mov	esi, edi
  4368                              <1> 	; ecx = color (CL, CX, ECX)
  4369 0000E879 89C8                <1> 	mov	eax, ecx
  4370 0000E87B 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4371                              <1> 
  4372 0000E881 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
  4373 0000E888 7405                <1> 	jz	short pix_op_add_0 ; no
  4374 0000E88A E9CE100000          <1> 	jmp	m_pix_op_add ; add color except mask color
  4375                              <1> pix_op_add_0:
  4376 0000E88F 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4377 0000E896 7707                <1> 	ja	short pix_op_add_1
  4378                              <1> 
  4379                              <1> 	; 256 colors (8bpp)
  4380 0000E898 E84D0A0000          <1> 	call	pix_op_add_8
  4381 0000E89D EB1E                <1> 	jmp	short pix_op_add_4	
  4382                              <1> 			
  4383                              <1> pix_op_add_1:
  4384 0000E89F 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4385 0000E8A6 7710                <1> 	ja	short pix_op_add_3 ; 32bpp	
  4386 0000E8A8 7207                <1> 	jb	short pix_op_add_2 ; 16bpp
  4387                              <1> 	
  4388                              <1> 	; 24 bit true colors
  4389 0000E8AA E85B0A0000          <1> 	call	pix_op_add_24
  4390 0000E8AF EB0C                <1> 	jmp	short pix_op_add_4
  4391                              <1> 
  4392                              <1> 	; 65536 colors (16bpp)
  4393                              <1> pix_op_add_2:
  4394 0000E8B1 E8420A0000          <1> 	call	pix_op_add_16
  4395 0000E8B6 EB05                <1> 	jmp	short pix_op_add_4
  4396                              <1> 
  4397                              <1> 	; 32 bit true colors
  4398                              <1> pix_op_add_3:
  4399 0000E8B8 E86D0A0000          <1> 	call	pix_op_add_32
  4400                              <1> pix_op_add_4:
  4401 0000E8BD 29F7                <1> 	sub	edi, esi
  4402 0000E8BF 893D[64030300]      <1> 	mov	[u.r0], edi	
  4403                              <1> pix_op_add_5:
  4404 0000E8C5 C3                  <1> 	retn		
  4405                              <1> 
  4406                              <1> pix_op_add_w:
  4407                              <1> 	; 31/01/2021
  4408 0000E8C6 51                  <1> 	push	ecx ; * ; color
  4409 0000E8C7 89D1                <1> 	mov	ecx, edx ; win start pos
  4410 0000E8C9 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4411 0000E8CB E828FEFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4412 0000E8D0 58                  <1> 	pop	eax ; * ; color
  4413 0000E8D1 72F2                <1> 	jc	short pix_op_add_5
  4414                              <1> 
  4415 0000E8D3 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color adding ?
  4416 0000E8DA 7405                <1> 	jz	short pix_op_add_w_0 ; no
  4417 0000E8DC E92A110000          <1> 	jmp	m_pix_op_add_w 
  4418                              <1> 			; window add color except mask color
  4419                              <1> pix_op_add_w_0:
  4420                              <1> 	; ecx = bytes per row (to be applied)
  4421                              <1> 	; edx = screen width in bytes
  4422                              <1> 	; ebx = row count
  4423                              <1> 	; eax = color
  4424                              <1> 
  4425 0000E8E1 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4426 0000E8E7 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4427 0000E8EE 7707                <1> 	ja	short pix_op_add_w_1
  4428                              <1> 
  4429                              <1> 	; 256 colors (8bpp)
  4430 0000E8F0 BD[EAF20000]        <1> 	mov	ebp, pix_op_add_8
  4431 0000E8F5 EB1E                <1> 	jmp	short pix_op_add_w_4
  4432                              <1> 			
  4433                              <1> pix_op_add_w_1:
  4434 0000E8F7 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4435 0000E8FE 7710                <1> 	ja	short pix_op_add_w_3 ; 32bpp
  4436 0000E900 7207                <1> 	jb	short pix_op_add_w_2 ; 16bpp
  4437                              <1> 
  4438                              <1> 	; 24 bit true colors
  4439 0000E902 BD[0AF30000]        <1> 	mov	ebp, pix_op_add_24
  4440 0000E907 EB0C                <1> 	jmp	short pix_op_add_w_4
  4441                              <1> 
  4442                              <1> 	; 65536 colors (16bpp)
  4443                              <1> pix_op_add_w_2:
  4444 0000E909 BD[F8F20000]        <1> 	mov	ebp, pix_op_add_16
  4445 0000E90E EB05                <1> 	jmp	short pix_op_add_w_4
  4446                              <1> 
  4447                              <1> 	; 32 bit true colors
  4448                              <1> pix_op_add_w_3:
  4449 0000E910 BD[2AF30000]        <1> 	mov	ebp, pix_op_add_32
  4450                              <1> pix_op_add_w_4:
  4451 0000E915 E95F010000          <1> 	jmp	pix_op_add_w_x
  4452                              <1> 
  4453                              <1> pix_op_sub:
  4454                              <1> 	; 31/01/2021
  4455                              <1> 	; SUB COLOR
  4456                              <1> 	;
  4457                              <1> 	; INPUT:
  4458                              <1> 	;   CL = color (8 bit, 256 colors)
  4459                              <1> 	;  ECX = color (16 bit and true colors)
  4460                              <1> 	;  EDX = start position (row, column)
  4461                              <1> 	;        (HW = row, DX = column)
  4462                              <1> 	;  ESI = size (rows, colums)
  4463                              <1> 	;        (HW = rows, SI = columns)
  4464                              <1> 	;
  4465                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4466                              <1> 	;
  4467                              <1> 	; OUTPUT:
  4468                              <1> 	; 	[u.r0] will be > 0 if succesful
  4469                              <1> 	
  4470 0000E91A F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4471 0000E921 7555                <1> 	jnz	short pix_op_sub_w ; window
  4472                              <1> 	
  4473 0000E923 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  4474 0000E929 89FE                <1> 	mov	esi, edi
  4475                              <1> 	; ecx = color (CL, CX, ECX)
  4476 0000E92B 89C8                <1> 	mov	eax, ecx
  4477 0000E92D 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4478                              <1> 
  4479 0000E933 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
  4480 0000E93A 7405                <1> 	jz	short pix_op_sub_0 ; no
  4481 0000E93C E9FD100000          <1> 	jmp	m_pix_op_sub ; sub color except mask color
  4482                              <1> pix_op_sub_0:
  4483 0000E941 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4484 0000E948 7707                <1> 	ja	short pix_op_sub_1
  4485                              <1> 
  4486                              <1> 	; 256 colors (8bpp)
  4487 0000E94A E8EA090000          <1> 	call	pix_op_sub_8
  4488 0000E94F EB1E                <1> 	jmp	short pix_op_sub_4	
  4489                              <1> 			
  4490                              <1> pix_op_sub_1:
  4491 0000E951 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4492 0000E958 7710                <1> 	ja	short pix_op_sub_3 ; 32bpp	
  4493 0000E95A 7207                <1> 	jb	short pix_op_sub_2 ; 16bpp
  4494                              <1> 	
  4495                              <1> 	; 24 bit true colors
  4496 0000E95C E8FB090000          <1> 	call	pix_op_sub_24
  4497 0000E961 EB0C                <1> 	jmp	short pix_op_sub_4
  4498                              <1> 
  4499                              <1> 	; 65536 colors (16bpp)
  4500                              <1> pix_op_sub_2:
  4501 0000E963 E8E1090000          <1> 	call	pix_op_sub_16
  4502 0000E968 EB05                <1> 	jmp	short pix_op_sub_4
  4503                              <1> 
  4504                              <1> 	; 32 bit true colors
  4505                              <1> pix_op_sub_3:
  4506 0000E96A E8070A0000          <1> 	call	pix_op_sub_32
  4507                              <1> pix_op_sub_4:
  4508 0000E96F 29F7                <1> 	sub	edi, esi
  4509 0000E971 893D[64030300]      <1> 	mov	[u.r0], edi	
  4510                              <1> pix_op_sub_5:
  4511 0000E977 C3                  <1> 	retn		
  4512                              <1> 
  4513                              <1> pix_op_sub_w:
  4514                              <1> 	; 31/01/2021
  4515 0000E978 51                  <1> 	push	ecx ; * ; color
  4516 0000E979 89D1                <1> 	mov	ecx, edx ; win start pos
  4517 0000E97B 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4518 0000E97D E876FDFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4519 0000E982 58                  <1> 	pop	eax ; * ; color
  4520 0000E983 72F2                <1> 	jc	short pix_op_sub_5
  4521                              <1> 
  4522 0000E985 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color subtract ?
  4523 0000E98C 7405                <1> 	jz	short pix_op_sub_w_0 ; no
  4524 0000E98E E954110000          <1> 	jmp	m_pix_op_sub_w 
  4525                              <1> 			; window sub color except mask color
  4526                              <1> pix_op_sub_w_0:
  4527                              <1> 	; ecx = bytes per row (to be applied)
  4528                              <1> 	; edx = screen width in bytes
  4529                              <1> 	; ebx = row count
  4530                              <1> 	; eax = color
  4531                              <1> 
  4532 0000E993 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4533 0000E999 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4534 0000E9A0 7707                <1> 	ja	short pix_op_sub_w_1
  4535                              <1> 
  4536                              <1> 	; 256 colors (8bpp)
  4537 0000E9A2 BD[39F30000]        <1> 	mov	ebp, pix_op_sub_8
  4538 0000E9A7 EB1E                <1> 	jmp	short pix_op_sub_w_4
  4539                              <1> 			
  4540                              <1> pix_op_sub_w_1:
  4541 0000E9A9 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4542 0000E9B0 7710                <1> 	ja	short pix_op_sub_w_3 ; 32bpp
  4543 0000E9B2 7207                <1> 	jb	short pix_op_sub_w_2 ; 16bpp
  4544                              <1> 
  4545                              <1> 	; 24 bit true colors
  4546 0000E9B4 BD[5CF30000]        <1> 	mov	ebp, pix_op_sub_24
  4547 0000E9B9 EB0C                <1> 	jmp	short pix_op_sub_w_4
  4548                              <1> 
  4549                              <1> 	; 65536 colors (16bpp)
  4550                              <1> pix_op_sub_w_2:
  4551 0000E9BB BD[49F30000]        <1> 	mov	ebp, pix_op_sub_16
  4552 0000E9C0 EB05                <1> 	jmp	short pix_op_sub_w_4
  4553                              <1> 
  4554                              <1> 	; 32 bit true colors
  4555                              <1> pix_op_sub_w_3:
  4556 0000E9C2 BD[76F30000]        <1> 	mov	ebp, pix_op_sub_32
  4557                              <1> pix_op_sub_w_4:
  4558 0000E9C7 E9AD000000          <1> 	jmp	pix_op_sub_w_x
  4559                              <1> 
  4560                              <1> pix_op_mix:
  4561                              <1> 	; 31/01/2021
  4562                              <1> 	; MIX COLOR
  4563                              <1> 	;
  4564                              <1> 	; INPUT:
  4565                              <1> 	;   CL = color (8 bit, 256 colors)
  4566                              <1> 	;  ECX = color (16 bit and true colors)
  4567                              <1> 	;  EDX = start position (row, column)
  4568                              <1> 	;        (HW = row, DX = column)
  4569                              <1> 	;  ESI = size (rows, colums)
  4570                              <1> 	;        (HW = rows, SI = columns)
  4571                              <1> 	;
  4572                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4573                              <1> 	;
  4574                              <1> 	; OUTPUT:
  4575                              <1> 	; 	[u.r0] will be > 0 if succesful
  4576                              <1> 	
  4577 0000E9CC F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4578 0000E9D3 7555                <1> 	jnz	short pix_op_mix_w ; window
  4579                              <1> 	
  4580 0000E9D5 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  4581 0000E9DB 89FE                <1> 	mov	esi, edi
  4582                              <1> 	; ecx = color (CL, CX, ECX)
  4583 0000E9DD 89C8                <1> 	mov	eax, ecx
  4584 0000E9DF 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4585                              <1> 
  4586 0000E9E5 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
  4587 0000E9EC 7405                <1> 	jz	short pix_op_mix_0 ; no
  4588 0000E9EE E927110000          <1> 	jmp	m_pix_op_mix ; mix colors except mask color
  4589                              <1> pix_op_mix_0:
  4590 0000E9F3 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4591 0000E9FA 7707                <1> 	ja	short pix_op_mix_1
  4592                              <1> 
  4593                              <1> 	; 256 colors (8bpp)
  4594 0000E9FC E8F4090000          <1> 	call	pix_op_mix_8
  4595 0000EA01 EB1E                <1> 	jmp	short pix_op_mix_4	
  4596                              <1> 			
  4597                              <1> pix_op_mix_1:
  4598 0000EA03 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4599 0000EA0A 7710                <1> 	ja	short pix_op_mix_3 ; 32bpp	
  4600 0000EA0C 7207                <1> 	jb	short pix_op_mix_2 ; 16bpp
  4601                              <1> 	
  4602                              <1> 	; 24 bit true colors
  4603 0000EA0E E8FD090000          <1> 	call	pix_op_mix_24
  4604 0000EA13 EB0C                <1> 	jmp	short pix_op_mix_4
  4605                              <1> 
  4606                              <1> 	; 65536 colors (16bpp)
  4607                              <1> pix_op_mix_2:
  4608 0000EA15 E8E7090000          <1> 	call	pix_op_mix_16
  4609 0000EA1A EB05                <1> 	jmp	short pix_op_mix_4
  4610                              <1> 
  4611                              <1> 	; 32 bit true colors
  4612                              <1> pix_op_mix_3:
  4613 0000EA1C E80B0A0000          <1> 	call	pix_op_mix_32
  4614                              <1> pix_op_mix_4:
  4615 0000EA21 29F7                <1> 	sub	edi, esi
  4616 0000EA23 893D[64030300]      <1> 	mov	[u.r0], edi	
  4617                              <1> pix_op_mix_5:
  4618 0000EA29 C3                  <1> 	retn		
  4619                              <1> 
  4620                              <1> pix_op_mix_w:
  4621                              <1> 	; 31/01/2021
  4622 0000EA2A 51                  <1> 	push	ecx ; * ; color
  4623 0000EA2B 89D1                <1> 	mov	ecx, edx ; win start pos
  4624 0000EA2D 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4625 0000EA2F E8C4FCFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4626 0000EA34 58                  <1> 	pop	eax ; * ; color
  4627 0000EA35 72F2                <1> 	jc	short pix_op_mix_5
  4628                              <1> 
  4629 0000EA37 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color mix ?
  4630 0000EA3E 7405                <1> 	jz	short pix_op_mix_w_0 ; no
  4631 0000EA40 E974110000          <1> 	jmp	m_pix_op_mix_w 
  4632                              <1> 			; window mix colors except mask color
  4633                              <1> pix_op_mix_w_0:
  4634                              <1> 	; ecx = bytes per row (to be applied)
  4635                              <1> 	; edx = screen width in bytes
  4636                              <1> 	; ebx = row count
  4637                              <1> 	; eax = color
  4638                              <1> 
  4639 0000EA45 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4640 0000EA4B 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4641 0000EA52 7707                <1> 	ja	short pix_op_mix_w_1
  4642                              <1> 
  4643                              <1> 	; 256 colors (8bpp)
  4644 0000EA54 BD[F5F30000]        <1> 	mov	ebp, pix_op_mix_8
  4645 0000EA59 EB1E                <1> 	jmp	short pix_op_mix_w_x
  4646                              <1> 			
  4647                              <1> pix_op_mix_w_1:
  4648 0000EA5B 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4649 0000EA62 7710                <1> 	ja	short pix_op_mix_w_3 ; 32bpp
  4650 0000EA64 7207                <1> 	jb	short pix_op_mix_w_2 ; 16bpp
  4651                              <1> 
  4652                              <1> 	; 24 bit true colors
  4653 0000EA66 BD[10F40000]        <1> 	mov	ebp, pix_op_mix_24
  4654 0000EA6B EB0C                <1> 	jmp	short pix_op_mix_w_x
  4655                              <1> 
  4656                              <1> 	; 65536 colors (16bpp)
  4657                              <1> pix_op_mix_w_2:
  4658 0000EA6D BD[01F40000]        <1> 	mov	ebp, pix_op_mix_16
  4659 0000EA72 EB05                <1> 	jmp	short pix_op_mix_w_x
  4660                              <1> 
  4661                              <1> 	; 32 bit true colors
  4662                              <1> pix_op_mix_w_3:
  4663 0000EA74 BD[2CF40000]        <1> 	mov	ebp, pix_op_mix_32
  4664                              <1> 	;jmp	short pix_op_mix_w_x
  4665                              <1> 
  4666                              <1> pix_op_mix_w_x:
  4667                              <1> pix_op_add_w_x:
  4668                              <1> pix_op_sub_w_x:
  4669                              <1> pix_op_rpl_w_x:
  4670                              <1> pix_op_orc_w_x:
  4671                              <1> pix_op_and_w_x:
  4672                              <1> pix_op_xor_w_x:
  4673                              <1> 	; 27/02/2021
  4674                              <1> 	; 31/01/2021
  4675                              <1> 	; ecx = bytes per row (to be applied)
  4676                              <1> 	; edx = windows (screen) width in bytes
  4677                              <1> 	; ebx = row count
  4678                              <1> 	; eax = color
  4679                              <1> 	; ebp = pixel operation subroutine address
  4680 0000EA79 52                  <1> 	push	edx
  4681 0000EA7A 51                  <1> 	push	ecx
  4682 0000EA7B 57                  <1> 	push	edi
  4683 0000EA7C 8B0D[9E120300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
  4684 0000EA82 FFD5                <1> 	call	ebp ; call pixel-row operation
  4685 0000EA84 5F                  <1> 	pop	edi
  4686 0000EA85 59                  <1> 	pop	ecx ; bytes per row
  4687 0000EA86 010D[64030300]      <1> 	add	[u.r0], ecx
  4688 0000EA8C 5A                  <1> 	pop	edx
  4689 0000EA8D 01D7                <1> 	add	edi, edx ; next row
  4690 0000EA8F 4B                  <1> 	dec	ebx
  4691 0000EA90 75E7                <1> 	jnz	short pix_op_mix_w_x
  4692 0000EA92 C3                  <1> 	retn
  4693                              <1> 
  4694                              <1> pix_op_rpl:
  4695                              <1> 	; 01/02/2021
  4696                              <1> 	; REPLACE COLOR
  4697                              <1> 	;
  4698                              <1> 	; INPUT:
  4699                              <1> 	;   CL = old/current color (8 bit, 256 colors)
  4700                              <1> 	;  ECX = old/current color (16 bit and true colors)
  4701                              <1> 	;   DL = new color (8 bit, 256 colors)
  4702                              <1> 	;  EDX = new color (16 bit and true colors)
  4703                              <1> 	;  ESI = start position (row, column)
  4704                              <1> 	;        (HW = row, DX = column)
  4705                              <1> 	;  EDI = size (rows, colums)
  4706                              <1> 	;        (HW = rows, SI = columns)
  4707                              <1> 	; OUTPUT:
  4708                              <1> 	; 	[u.r0] will be > 0 if succesful
  4709                              <1> 	
  4710 0000EA93 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4711 0000EA9A 754D                <1> 	jnz	short pix_op_rpl_w ; window
  4712                              <1> 	
  4713 0000EA9C 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  4714 0000EAA2 89FE                <1> 	mov	esi, edi
  4715                              <1> 	; ecx = old color (CL, CX, ECX) -to be replaced with-
  4716                              <1> 	; edx = new color (CL, CX, ECX) -new one-
  4717 0000EAA4 89D0                <1> 	mov	eax, edx ; new color
  4718 0000EAA6 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; old color
  4719 0000EAAC 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4720                              <1> pix_op_rpl_0:
  4721 0000EAB2 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4722 0000EAB9 7707                <1> 	ja	short pix_op_rpl_1
  4723                              <1> 
  4724                              <1> 	; 256 colors (8bpp)
  4725 0000EABB E8300A0000          <1> 	call	pix_op_rpl_8
  4726 0000EAC0 EB1E                <1> 	jmp	short pix_op_rpl_4
  4727                              <1> 			
  4728                              <1> pix_op_rpl_1:
  4729 0000EAC2 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4730 0000EAC9 7710                <1> 	ja	short pix_op_rpl_3 ; 32bpp	
  4731 0000EACB 7207                <1> 	jb	short pix_op_rpl_2 ; 16bpp
  4732                              <1> 
  4733                              <1> 	; 24 bit true colors
  4734 0000EACD E8410A0000          <1> 	call	pix_op_rpl_24
  4735 0000EAD2 EB0C                <1> 	jmp	short pix_op_rpl_4
  4736                              <1> 
  4737                              <1> 	; 65536 colors (16bpp)
  4738                              <1> pix_op_rpl_2:
  4739 0000EAD4 E8270A0000          <1> 	call	pix_op_rpl_16
  4740 0000EAD9 EB05                <1> 	jmp	short pix_op_rpl_4
  4741                              <1> 
  4742                              <1> 	; 32 bit true colors	
  4743                              <1> pix_op_rpl_3:
  4744 0000EADB E8550A0000          <1> 	call	pix_op_rpl_32
  4745                              <1> pix_op_rpl_4:
  4746 0000EAE0 29F7                <1> 	sub	edi, esi
  4747 0000EAE2 893D[64030300]      <1> 	mov	[u.r0], edi	
  4748                              <1> pix_op_rpl_5:
  4749 0000EAE8 C3                  <1> 	retn
  4750                              <1> 
  4751                              <1> pix_op_rpl_w:
  4752                              <1> 	; 01/02/2021
  4753 0000EAE9 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; old color
  4754 0000EAEF 52                  <1> 	push	edx ; * ; new color
  4755 0000EAF0 89F1                <1> 	mov	ecx, esi ; win start pos
  4756 0000EAF2 89FA                <1> 	mov	edx, edi ; size (rows, cols)
  4757 0000EAF4 E8FFFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4758 0000EAF9 58                  <1> 	pop	eax ; * ; new color
  4759 0000EAFA 72EC                <1> 	jc	short pix_op_rpl_5
  4760                              <1> 
  4761                              <1> 	; replace window color
  4762                              <1> pix_op_rpl_w_0:
  4763                              <1> 	; ecx = bytes per row (to be applied)
  4764                              <1> 	; edx = screen width in bytes
  4765                              <1> 	; ebx = row count
  4766                              <1> 	; eax = new color
  4767                              <1> 	; [maskcolor] = old color
  4768                              <1>  
  4769 0000EAFC 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4770                              <1> 
  4771 0000EB02 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4772 0000EB09 7707                <1> 	ja	short pix_op_rpl_w_1
  4773                              <1> 
  4774                              <1> 	; 256 colors (8bpp)
  4775 0000EB0B BD[F0F40000]        <1> 	mov	ebp, pix_op_rpl_8
  4776 0000EB10 EB1E                <1> 	jmp	short pix_op_rpl_w_4
  4777                              <1> 			
  4778                              <1> pix_op_rpl_w_1:
  4779 0000EB12 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4780 0000EB19 7710                <1> 	ja	short pix_op_rpl_w_3 ; 32bpp
  4781 0000EB1B 7207                <1> 	jb	short pix_op_rpl_w_2 ; 16bpp
  4782                              <1> 
  4783                              <1> 	; 24 bit true colors
  4784 0000EB1D BD[13F50000]        <1> 	mov	ebp, pix_op_rpl_24
  4785 0000EB22 EB0C                <1> 	jmp	short pix_op_rpl_w_4
  4786                              <1> 
  4787                              <1> 	; 65536 colors (16bpp)
  4788                              <1> pix_op_rpl_w_2:
  4789 0000EB24 BD[00F50000]        <1> 	mov	ebp, pix_op_rpl_16
  4790 0000EB29 EB05                <1> 	jmp	short pix_op_rpl_w_4
  4791                              <1> 
  4792                              <1> 	; 32 bit true colors
  4793                              <1> pix_op_rpl_w_3:
  4794 0000EB2B BD[35F50000]        <1> 	mov	ebp, pix_op_rpl_32
  4795                              <1> pix_op_rpl_w_4:
  4796 0000EB30 E944FFFFFF          <1> 	jmp	pix_op_rpl_w_x
  4797                              <1> 
  4798                              <1> pix_op_orc:
  4799                              <1> 	; 31/01/2021
  4800                              <1> 	; OR COLOR
  4801                              <1> 	;
  4802                              <1> 	; INPUT:
  4803                              <1> 	;   CL = color (8 bit, 256 colors)
  4804                              <1> 	;  ECX = color (16 bit and true colors)
  4805                              <1> 	;  EDX = start position (row, column)
  4806                              <1> 	;        (HW = row, DX = column)
  4807                              <1> 	;  ESI = size (rows, colums)
  4808                              <1> 	;        (HW = rows, SI = columns)
  4809                              <1> 	;
  4810                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4811                              <1> 	;
  4812                              <1> 	; OUTPUT:
  4813                              <1> 	; 	[u.r0] will be > 0 if succesful
  4814                              <1> 	
  4815 0000EB35 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4816 0000EB3C 7555                <1> 	jnz	short pix_op_or_w ; window
  4817                              <1> 	
  4818 0000EB3E 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  4819 0000EB44 89FE                <1> 	mov	esi, edi
  4820                              <1> 	; ecx = color (CL, CX, ECX)
  4821 0000EB46 89C8                <1> 	mov	eax, ecx
  4822 0000EB48 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4823                              <1> 
  4824 0000EB4E F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
  4825 0000EB55 7405                <1> 	jz	short pix_op_or_0 ; no
  4826 0000EB57 E950110000          <1> 	jmp	m_pix_op_or ; 'or' color except mask color
  4827                              <1> pix_op_or_0:
  4828 0000EB5C 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4829 0000EB63 7707                <1> 	ja	short pix_op_or_1
  4830                              <1> 
  4831                              <1> 	; 256 colors (8bpp)
  4832 0000EB65 E81C080000          <1> 	call	pix_op_or_8
  4833 0000EB6A EB1E                <1> 	jmp	short pix_op_or_4	
  4834                              <1> 			
  4835                              <1> pix_op_or_1:
  4836 0000EB6C 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4837 0000EB73 7710                <1> 	ja	short pix_op_or_3 ; 32bpp	
  4838 0000EB75 7207                <1> 	jb	short pix_op_or_2 ; 16bpp
  4839                              <1> 	
  4840                              <1> 	; 24 bit true colors
  4841 0000EB77 E818080000          <1> 	call	pix_op_or_24
  4842 0000EB7C EB0C                <1> 	jmp	short pix_op_or_4
  4843                              <1> 
  4844                              <1> 	; 65536 colors (16bpp)
  4845                              <1> pix_op_or_2:
  4846 0000EB7E E809080000          <1> 	call	pix_op_or_16
  4847 0000EB83 EB05                <1> 	jmp	short pix_op_or_4
  4848                              <1> 
  4849                              <1> 	; 32 bit true colors
  4850                              <1> pix_op_or_3:
  4851 0000EB85 E819080000          <1> 	call	pix_op_or_32
  4852                              <1> pix_op_or_4:
  4853 0000EB8A 29F7                <1> 	sub	edi, esi
  4854 0000EB8C 893D[64030300]      <1> 	mov	[u.r0], edi	
  4855                              <1> pix_op_or_5:
  4856 0000EB92 C3                  <1> 	retn		
  4857                              <1> 
  4858                              <1> pix_op_or_w:
  4859                              <1> 	; 31/01/2021
  4860 0000EB93 51                  <1> 	push	ecx ; * ; color
  4861 0000EB94 89D1                <1> 	mov	ecx, edx ; win start pos
  4862 0000EB96 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4863 0000EB98 E85BFBFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4864 0000EB9D 58                  <1> 	pop	eax ; * ; color
  4865 0000EB9E 72F2                <1> 	jc	short pix_op_or_5
  4866                              <1> 
  4867 0000EBA0 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'or' ?
  4868 0000EBA7 7405                <1> 	jz	short pix_op_or_w_0 ; no
  4869 0000EBA9 E98B110000          <1> 	jmp	m_pix_op_or_w 
  4870                              <1> 			; window 'or' color except mask color
  4871                              <1> pix_op_or_w_0:
  4872                              <1> 	; ecx = bytes per row (to be applied)
  4873                              <1> 	; edx = screen width in bytes
  4874                              <1> 	; ebx = row count
  4875                              <1> 	; eax = color
  4876                              <1> 
  4877 0000EBAE 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4878 0000EBB4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4879 0000EBBB 7707                <1> 	ja	short pix_op_or_w_1
  4880                              <1> 
  4881                              <1> 	; 256 colors (8bpp)
  4882 0000EBBD BD[86F30000]        <1> 	mov	ebp, pix_op_or_8
  4883 0000EBC2 EB1E                <1> 	jmp	short pix_op_or_w_4
  4884                              <1> 			
  4885                              <1> pix_op_or_w_1:
  4886 0000EBC4 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4887 0000EBCB 7710                <1> 	ja	short pix_op_or_w_3 ; 32bpp
  4888 0000EBCD 7207                <1> 	jb	short pix_op_or_w_2 ; 16bpp
  4889                              <1> 
  4890                              <1> 	; 24 bit true colors
  4891 0000EBCF BD[94F30000]        <1> 	mov	ebp, pix_op_or_24
  4892 0000EBD4 EB0C                <1> 	jmp	short pix_op_or_w_4
  4893                              <1> 
  4894                              <1> 	; 65536 colors (16bpp)
  4895                              <1> pix_op_or_w_2:
  4896 0000EBD6 BD[8CF30000]        <1> 	mov	ebp, pix_op_or_16
  4897 0000EBDB EB05                <1> 	jmp	short pix_op_or_w_4
  4898                              <1> 
  4899                              <1> 	; 32 bit true colors
  4900                              <1> pix_op_or_w_3:
  4901 0000EBDD BD[A3F30000]        <1> 	mov	ebp, pix_op_or_32
  4902                              <1> pix_op_or_w_4:
  4903 0000EBE2 E992FEFFFF          <1> 	jmp	pix_op_orc_w_x
  4904                              <1> 
  4905                              <1> pix_op_and:
  4906                              <1> 	; 31/01/2021
  4907                              <1> 	; AND COLOR
  4908                              <1> 	;
  4909                              <1> 	; INPUT:
  4910                              <1> 	;   CL = color (8 bit, 256 colors)
  4911                              <1> 	;  ECX = color (16 bit and true colors)
  4912                              <1> 	;  EDX = start position (row, column)
  4913                              <1> 	;        (HW = row, DX = column)
  4914                              <1> 	;  ESI = size (rows, colums)
  4915                              <1> 	;        (HW = rows, SI = columns)
  4916                              <1> 	;
  4917                              <1> 	;  [maskcolor] = mask color (to be excluded)
  4918                              <1> 	;
  4919                              <1> 	; OUTPUT:
  4920                              <1> 	; 	[u.r0] will be > 0 if succesful
  4921                              <1> 	
  4922 0000EBE7 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  4923 0000EBEE 7555                <1> 	jnz	short pix_op_and_w ; window
  4924                              <1> 	
  4925 0000EBF0 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  4926 0000EBF6 89FE                <1> 	mov	esi, edi
  4927                              <1> 	; ecx = color (CL, CX, ECX)
  4928 0000EBF8 89C8                <1> 	mov	eax, ecx
  4929 0000EBFA 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  4930                              <1> 
  4931 0000EC00 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
  4932 0000EC07 7405                <1> 	jz	short pix_op_and_0 ; no
  4933 0000EC09 E9DE0F0000          <1> 	jmp	m_pix_op_and ; 'and' color except mask color
  4934                              <1> pix_op_and_0:
  4935 0000EC0E 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4936 0000EC15 7707                <1> 	ja	short pix_op_and_1
  4937                              <1> 
  4938                              <1> 	; 256 colors (8bpp)
  4939 0000EC17 E88F070000          <1> 	call	pix_op_and_8
  4940 0000EC1C EB1E                <1> 	jmp	short pix_op_and_4	
  4941                              <1> 			
  4942                              <1> pix_op_and_1:
  4943 0000EC1E 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4944 0000EC25 7710                <1> 	ja	short pix_op_and_3 ; 32bpp	
  4945 0000EC27 7207                <1> 	jb	short pix_op_and_2 ; 16bpp
  4946                              <1> 	
  4947                              <1> 	; 24 bit true colors
  4948 0000EC29 E88B070000          <1> 	call	pix_op_and_24
  4949 0000EC2E EB0C                <1> 	jmp	short pix_op_and_4
  4950                              <1> 
  4951                              <1> 	; 65536 colors (16bpp)
  4952                              <1> pix_op_and_2:
  4953 0000EC30 E87C070000          <1> 	call	pix_op_and_16
  4954 0000EC35 EB05                <1> 	jmp	short pix_op_and_4
  4955                              <1> 
  4956                              <1> 	; 32 bit true colors
  4957                              <1> pix_op_and_3:
  4958 0000EC37 E88C070000          <1> 	call	pix_op_and_32
  4959                              <1> pix_op_and_4:
  4960 0000EC3C 29F7                <1> 	sub	edi, esi
  4961 0000EC3E 893D[64030300]      <1> 	mov	[u.r0], edi	
  4962                              <1> pix_op_and_5:
  4963 0000EC44 C3                  <1> 	retn		
  4964                              <1> 
  4965                              <1> pix_op_and_w:
  4966                              <1> 	; 31/01/2021
  4967 0000EC45 51                  <1> 	push	ecx ; * ; color
  4968 0000EC46 89D1                <1> 	mov	ecx, edx ; win start pos
  4969 0000EC48 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  4970 0000EC4A E8A9FAFFFF          <1> 	call	sysvideo_15_12 ; window preparations
  4971 0000EC4F 58                  <1> 	pop	eax ; * ; color
  4972 0000EC50 72F2                <1> 	jc	short pix_op_and_5
  4973                              <1> 
  4974 0000EC52 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'and' ?
  4975 0000EC59 7405                <1> 	jz	short pix_op_and_w_0 ; no
  4976 0000EC5B E919100000          <1> 	jmp	m_pix_op_and_w 
  4977                              <1> 			; window 'and' color except mask color
  4978                              <1> pix_op_and_w_0:
  4979                              <1> 	; ecx = bytes per row (to be applied)
  4980                              <1> 	; edx = screen width in bytes
  4981                              <1> 	; ebx = row count
  4982                              <1> 	; eax = color
  4983                              <1> 
  4984 0000EC60 8B3D[92120300]      <1> 	mov	edi, [v_str]
  4985 0000EC66 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  4986 0000EC6D 7707                <1> 	ja	short pix_op_and_w_1
  4987                              <1> 
  4988                              <1> 	; 256 colors (8bpp)
  4989 0000EC6F BD[ABF30000]        <1> 	mov	ebp, pix_op_and_8
  4990 0000EC74 EB1E                <1> 	jmp	short pix_op_and_w_4
  4991                              <1> 			
  4992                              <1> pix_op_and_w_1:
  4993 0000EC76 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  4994 0000EC7D 7710                <1> 	ja	short pix_op_and_w_3 ; 32bpp
  4995 0000EC7F 7207                <1> 	jb	short pix_op_and_w_2 ; 16bpp
  4996                              <1> 
  4997                              <1> 	; 24 bit true colors
  4998 0000EC81 BD[B9F30000]        <1> 	mov	ebp, pix_op_and_24
  4999 0000EC86 EB0C                <1> 	jmp	short pix_op_and_w_4
  5000                              <1> 
  5001                              <1> 	; 65536 colors (16bpp)
  5002                              <1> pix_op_and_w_2:
  5003 0000EC88 BD[B1F30000]        <1> 	mov	ebp, pix_op_and_16
  5004 0000EC8D EB05                <1> 	jmp	short pix_op_and_w_4
  5005                              <1> 
  5006                              <1> 	; 32 bit true colors
  5007                              <1> pix_op_and_w_3:
  5008 0000EC8F BD[C8F30000]        <1> 	mov	ebp, pix_op_and_32
  5009                              <1> pix_op_and_w_4:
  5010 0000EC94 E9E0FDFFFF          <1> 	jmp	pix_op_and_w_x
  5011                              <1> 
  5012                              <1> pix_op_xor:
  5013                              <1> 	; 31/01/2021
  5014                              <1> 	; XOR COLOR
  5015                              <1> 	;
  5016                              <1> 	; INPUT:
  5017                              <1> 	;   CL = color (8 bit, 256 colors)
  5018                              <1> 	;  ECX = color (16 bit and true colors)
  5019                              <1> 	;  EDX = start position (row, column)
  5020                              <1> 	;        (HW = row, DX = column)
  5021                              <1> 	;  ESI = size (rows, colums)
  5022                              <1> 	;        (HW = rows, SI = columns)
  5023                              <1> 	;
  5024                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5025                              <1> 	;
  5026                              <1> 	; OUTPUT:
  5027                              <1> 	; 	[u.r0] will be > 0 if succesful
  5028                              <1> 	
  5029 0000EC99 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5030 0000ECA0 7555                <1> 	jnz	short pix_op_xor_w ; window
  5031                              <1> 	
  5032 0000ECA2 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  5033 0000ECA8 89FE                <1> 	mov	esi, edi
  5034                              <1> 	; ecx = color (CL, CX, ECX)
  5035 0000ECAA 89C8                <1> 	mov	eax, ecx
  5036 0000ECAC 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5037                              <1> 
  5038 0000ECB2 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
  5039 0000ECB9 7405                <1> 	jz	short pix_op_xor_0 ; no
  5040 0000ECBB E9AC100000          <1> 	jmp	m_pix_op_xor ; 'xor' color except mask color
  5041                              <1> pix_op_xor_0:
  5042 0000ECC0 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5043 0000ECC7 7707                <1> 	ja	short pix_op_xor_1
  5044                              <1> 
  5045                              <1> 	; 256 colors (8bpp)
  5046 0000ECC9 E802070000          <1> 	call	pix_op_xor_8
  5047 0000ECCE EB1E                <1> 	jmp	short pix_op_xor_4	
  5048                              <1> 			
  5049                              <1> pix_op_xor_1:
  5050 0000ECD0 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5051 0000ECD7 7710                <1> 	ja	short pix_op_xor_3 ; 32bpp	
  5052 0000ECD9 7207                <1> 	jb	short pix_op_xor_2 ; 16bpp
  5053                              <1> 	
  5054                              <1> 	; 24 bit true colors
  5055 0000ECDB E8FE060000          <1> 	call	pix_op_xor_24
  5056 0000ECE0 EB0C                <1> 	jmp	short pix_op_xor_4
  5057                              <1> 
  5058                              <1> 	; 65536 colors (16bpp)
  5059                              <1> pix_op_xor_2:
  5060 0000ECE2 E8EF060000          <1> 	call	pix_op_xor_16
  5061 0000ECE7 EB05                <1> 	jmp	short pix_op_xor_4
  5062                              <1> 
  5063                              <1> 	; 32 bit true colors
  5064                              <1> pix_op_xor_3:
  5065 0000ECE9 E8FF060000          <1> 	call	pix_op_xor_32
  5066                              <1> pix_op_xor_4:
  5067 0000ECEE 29F7                <1> 	sub	edi, esi
  5068 0000ECF0 893D[64030300]      <1> 	mov	[u.r0], edi	
  5069                              <1> pix_op_xor_5:
  5070 0000ECF6 C3                  <1> 	retn		
  5071                              <1> 
  5072                              <1> pix_op_xor_w:
  5073                              <1> 	; 31/01/2021
  5074 0000ECF7 51                  <1> 	push	ecx ; * ; color
  5075 0000ECF8 89D1                <1> 	mov	ecx, edx ; win start pos
  5076 0000ECFA 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  5077 0000ECFC E8F7F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5078 0000ED01 58                  <1> 	pop	eax ; * ; color
  5079 0000ED02 72F2                <1> 	jc	short pix_op_xor_5
  5080                              <1> 
  5081 0000ED04 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'xor' ?
  5082 0000ED0B 7405                <1> 	jz	short pix_op_xor_w_0 ; no
  5083 0000ED0D E9E7100000          <1> 	jmp	m_pix_op_xor_w 
  5084                              <1> 			; window 'xor' color except mask color
  5085                              <1> pix_op_xor_w_0:
  5086                              <1> 	; ecx = bytes per row (to be applied)
  5087                              <1> 	; edx = screen width in bytes
  5088                              <1> 	; ebx = row count
  5089                              <1> 	; eax = color
  5090                              <1> 
  5091 0000ED12 8B3D[92120300]      <1> 	mov	edi, [v_str]
  5092 0000ED18 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5093 0000ED1F 7707                <1> 	ja	short pix_op_xor_w_1
  5094                              <1> 
  5095                              <1> 	; 256 colors (8bpp)
  5096 0000ED21 BD[D0F30000]        <1> 	mov	ebp, pix_op_xor_8
  5097 0000ED26 EB1E                <1> 	jmp	short pix_op_xor_w_4
  5098                              <1> 			
  5099                              <1> pix_op_xor_w_1:
  5100 0000ED28 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5101 0000ED2F 7710                <1> 	ja	short pix_op_xor_w_3 ; 32bpp
  5102 0000ED31 7207                <1> 	jb	short pix_op_xor_w_2 ; 16bpp
  5103                              <1> 
  5104                              <1> 	; 24 bit true colors
  5105 0000ED33 BD[DEF30000]        <1> 	mov	ebp, pix_op_xor_24
  5106 0000ED38 EB0C                <1> 	jmp	short pix_op_xor_w_4
  5107                              <1> 
  5108                              <1> 	; 65536 colors (16bpp)
  5109                              <1> pix_op_xor_w_2:
  5110 0000ED3A BD[D6F30000]        <1> 	mov	ebp, pix_op_xor_16
  5111 0000ED3F EB05                <1> 	jmp	short pix_op_xor_w_4
  5112                              <1> 
  5113                              <1> 	; 32 bit true colors
  5114                              <1> pix_op_xor_w_3:
  5115 0000ED41 BD[EDF30000]        <1> 	mov	ebp, pix_op_xor_32
  5116                              <1> pix_op_xor_w_4:
  5117 0000ED46 E92EFDFFFF          <1> 	jmp	pix_op_xor_w_x
  5118                              <1> 
  5119                              <1> pix_op_new:
  5120                              <1> 	; 31/01/2021
  5121                              <1> 	; 30/01/2021
  5122                              <1> 	; CHANGE COLOR
  5123                              <1> 	;
  5124                              <1> 	; INPUT:
  5125                              <1> 	;   CL = color (8 bit, 256 colors)
  5126                              <1> 	;  ECX = color (16 bit and true colors)
  5127                              <1> 	;  EDX = start position (row, column)
  5128                              <1> 	;        (HW = row, DX = column)
  5129                              <1> 	;  ESI = size (rows, colums)
  5130                              <1> 	;        (HW = rows, SI = columns)
  5131                              <1> 	;
  5132                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5133                              <1> 	;
  5134                              <1> 	; OUTPUT:
  5135                              <1> 	; 	[u.r0] will be > 0 if succesful
  5136                              <1> 	
  5137 0000ED4B F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5138 0000ED52 7554                <1> 	jnz	short pix_op_new_w ; window
  5139                              <1> 	
  5140 0000ED54 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  5141 0000ED5A 89FE                <1> 	mov	esi, edi
  5142                              <1> 	; ecx = color (CL, CX, ECX)
  5143 0000ED5C 89C8                <1> 	mov	eax, ecx
  5144 0000ED5E 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5145                              <1> 
  5146 0000ED64 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
  5147 0000ED6B 7405                <1> 	jz	short pix_op_new_0 ; no
  5148 0000ED6D E90D0B0000          <1> 	jmp	m_pix_op_new ; change color except mask color
  5149                              <1> pix_op_new_0:
  5150 0000ED72 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5151 0000ED79 7706                <1> 	ja	short pix_op_new_2
  5152                              <1> 
  5153                              <1> 	; 256 colors (8bpp)
  5154                              <1> pix_op_new_1:
  5155 0000ED7B 88C4                <1> 	mov	ah, al
  5156 0000ED7D D1E9                <1> 	shr	ecx, 1	
  5157 0000ED7F EB12                <1> 	jmp	short pix_op_new_3
  5158                              <1> 			
  5159                              <1> pix_op_new_2:
  5160 0000ED81 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5161 0000ED88 7713                <1> 	ja	short pix_op_new_4 ; 32bpp	
  5162 0000ED8A 7207                <1> 	jb	short pix_op_new_3 ; 16bpp
  5163                              <1> 
  5164                              <1> 	; 31/01/2021
  5165                              <1> 	
  5166                              <1> 	; 24 bit true colors
  5167 0000ED8C E84A050000          <1> 	call	pix_op_new_24
  5168                              <1> 
  5169 0000ED91 EB0C                <1> 	jmp	short pix_op_new_5
  5170                              <1> 
  5171                              <1> 	; 65536 colors (16bpp)
  5172                              <1> pix_op_new_3:
  5173 0000ED93 89C2                <1> 	mov	edx, eax
  5174 0000ED95 C1E010              <1> 	shl	eax, 16
  5175 0000ED98 6689D0              <1> 	mov	ax, dx
  5176 0000ED9B D1E9                <1> 	shr	ecx, 1 ; dword counts
  5177                              <1> 	; 32 bit true colors	
  5178                              <1> pix_op_new_4:
  5179 0000ED9D F3AB                <1> 	rep	stosd
  5180                              <1> pix_op_new_5:
  5181 0000ED9F 29F7                <1> 	sub	edi, esi
  5182 0000EDA1 893D[64030300]      <1> 	mov	[u.r0], edi	
  5183                              <1> pix_op_new_6:
  5184 0000EDA7 C3                  <1> 	retn		
  5185                              <1> 
  5186                              <1> pix_op_new_w:
  5187                              <1> 	; 31/01/2021
  5188                              <1> 	; 30/01/2021
  5189 0000EDA8 51                  <1> 	push	ecx ; * ; color
  5190 0000EDA9 89D1                <1> 	mov	ecx, edx ; win start pos
  5191 0000EDAB 89F2                <1> 	mov	edx, esi ; size (rows, cols)
  5192 0000EDAD E846F9FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5193 0000EDB2 58                  <1> 	pop	eax ; * ; color
  5194 0000EDB3 72F2                <1> 	jc	short pix_op_new_6
  5195                              <1> 
  5196 0000EDB5 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color change ?
  5197 0000EDBC 7405                <1> 	jz	short pix_op_new_w_0 ; no
  5198 0000EDBE E94A0B0000          <1> 	jmp	m_pix_op_new_w 
  5199                              <1> 			; window chg color except mask color
  5200                              <1> pix_op_new_w_0:
  5201                              <1> 	; ecx = bytes per row (to be applied)
  5202                              <1> 	; edx = screen width in bytes
  5203                              <1> 	; ebx = row count
  5204                              <1> 	; eax = color
  5205                              <1> 
  5206 0000EDC3 8B3D[92120300]      <1> 	mov	edi, [v_str]
  5207                              <1> 
  5208 0000EDC9 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5209 0000EDD0 7707                <1> 	ja	short pix_op_new_w_1
  5210                              <1> 
  5211                              <1> 	; 256 colors (8bpp)
  5212 0000EDD2 BD[D4F20000]        <1> 	mov	ebp, pix_op_new_8
  5213 0000EDD7 EB1E                <1> 	jmp	short pix_op_new_w_x
  5214                              <1> 			
  5215                              <1> pix_op_new_w_1:
  5216 0000EDD9 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5217 0000EDE0 7710                <1> 	ja	short pix_op_new_w_3 ; 32bpp
  5218 0000EDE2 7207                <1> 	jb	short pix_op_new_w_2 ; 16bpp
  5219                              <1> 
  5220                              <1> 	; 24 bit true colors
  5221 0000EDE4 BD[DBF20000]        <1> 	mov	ebp, pix_op_new_24
  5222 0000EDE9 EB0C                <1> 	jmp	short pix_op_new_w_x
  5223                              <1> 
  5224                              <1> 	; 65536 colors (16bpp)
  5225                              <1> pix_op_new_w_2:
  5226 0000EDEB BD[D7F20000]        <1> 	mov	ebp, pix_op_new_16
  5227 0000EDF0 EB05                <1> 	jmp	short pix_op_new_w_x
  5228                              <1> 
  5229                              <1> 	; 32 bit true colors
  5230                              <1> pix_op_new_w_3:
  5231 0000EDF2 BD[E7F20000]        <1> 	mov	ebp, pix_op_new_32
  5232                              <1> 	;jmp	short pix_op_new_w_x
  5233                              <1> 
  5234                              <1> pix_op_new_w_x:
  5235                              <1> pix_op_not_w_x:
  5236                              <1> pix_op_neg_w_x:
  5237                              <1> pix_op_inc_w_x:
  5238                              <1> pix_op_dec_w_x:
  5239                              <1> 	; 27/02/2021
  5240                              <1> 	; 01/02/2021
  5241                              <1> 	; 31/01/2021
  5242                              <1> 	; ecx = bytes per row (to be applied)
  5243                              <1> 	; edx = windows (screen) width in bytes
  5244                              <1> 	; ebx = row count
  5245                              <1> 	; eax = color
  5246                              <1> 	; ebp = pixel operation subroutine address
  5247                              <1> 	;push	edx ; 01/02/2021
  5248 0000EDF7 51                  <1> 	push	ecx
  5249 0000EDF8 57                  <1> 	push	edi
  5250 0000EDF9 8B0D[9E120300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021
  5251 0000EDFF FFD5                <1> 	call	ebp ; call pixel-row operation
  5252 0000EE01 5F                  <1> 	pop	edi
  5253 0000EE02 59                  <1> 	pop	ecx ; bytes per row
  5254 0000EE03 010D[64030300]      <1> 	add	[u.r0], ecx
  5255                              <1> 	;pop	edx ; 01/02/2021
  5256 0000EE09 01D7                <1> 	add	edi, edx ; next row
  5257 0000EE0B 4B                  <1> 	dec	ebx
  5258 0000EE0C 75E9                <1> 	jnz	short pix_op_new_w_x
  5259 0000EE0E C3                  <1> 	retn
  5260                              <1> 
  5261                              <1> pix_op_not:
  5262                              <1> 	; 31/01/2021
  5263                              <1> 	; NOT COLOR
  5264                              <1> 	;
  5265                              <1> 	; INPUT:
  5266                              <1> 	;  ECX = start position (row, column)
  5267                              <1> 	;        (HW = row, CX = column)
  5268                              <1> 	;  EDX = size (rows, colums)
  5269                              <1> 	;        (HW = rows, DX = columns)
  5270                              <1> 	;	 (0 -> invalid 	
  5271                              <1> 	;        (1 -> horizontal or vertical line)
  5272                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5273                              <1> 	;
  5274                              <1> 	; OUTPUT:
  5275                              <1> 	; 	[u.r0] will be > 0 if succesful
  5276                              <1> 	
  5277 0000EE0F F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5278 0000EE16 7553                <1> 	jnz	short pix_op_not_w ; window
  5279                              <1> 	
  5280 0000EE18 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  5281 0000EE1E 89FE                <1> 	mov	esi, edi
  5282 0000EE20 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5283                              <1> 
  5284 0000EE26 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
  5285 0000EE2D 7405                <1> 	jz	short pix_op_not_0 ; no
  5286 0000EE2F E9F80F0000          <1> 	jmp	m_pix_op_not ; 'not' color except mask color
  5287                              <1> pix_op_not_0:
  5288 0000EE34 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5289 0000EE3B 7707                <1> 	ja	short pix_op_not_1
  5290                              <1> 
  5291                              <1> 	; 256 colors (8bpp)
  5292 0000EE3D E8F6050000          <1> 	call	pix_op_not_8
  5293 0000EE42 EB1E                <1> 	jmp	short pix_op_not_4
  5294                              <1> 			
  5295                              <1> pix_op_not_1:
  5296 0000EE44 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5297 0000EE4B 7710                <1> 	ja	short pix_op_not_3 ; 32bpp	
  5298 0000EE4D 7207                <1> 	jb	short pix_op_not_2 ; 16bpp
  5299                              <1> 
  5300                              <1> 	; 24 bit true colors
  5301 0000EE4F E8F2050000          <1> 	call	pix_op_not_24
  5302 0000EE54 EB0C                <1> 	jmp	short pix_op_not_4
  5303                              <1> 
  5304                              <1> 	; 65536 colors (16bpp)
  5305                              <1> pix_op_not_2:
  5306 0000EE56 E8E3050000          <1> 	call	pix_op_not_16
  5307 0000EE5B EB05                <1> 	jmp	short pix_op_not_4
  5308                              <1> 
  5309                              <1> 	; 32 bit true colors	
  5310                              <1> pix_op_not_3:
  5311 0000EE5D E8EF050000          <1> 	call	pix_op_not_32
  5312                              <1> pix_op_not_4:
  5313 0000EE62 29F7                <1> 	sub	edi, esi
  5314 0000EE64 893D[64030300]      <1> 	mov	[u.r0], edi	
  5315                              <1> pix_op_not_5:
  5316 0000EE6A C3                  <1> 	retn
  5317                              <1> 
  5318                              <1> pix_op_not_w:
  5319                              <1> 	; 31/01/2021
  5320                              <1> 	; ecx = win start pos (row, column)
  5321                              <1> 	; edx = size (rows, columns)
  5322 0000EE6B E888F8FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5323 0000EE70 72F8                <1> 	jc	short pix_op_not_5
  5324                              <1> 
  5325 0000EE72 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked color 'not' ?
  5326 0000EE79 7405                <1> 	jz	short pix_op_not_w_0 ; no
  5327 0000EE7B E931100000          <1> 	jmp	m_pix_op_not_w 
  5328                              <1> 			; window 'not' color except mask color
  5329                              <1> pix_op_not_w_0:
  5330                              <1> 	; ecx = bytes per row (to be applied)
  5331                              <1> 	; edx = screen width in bytes
  5332                              <1> 	; ebx = row count
  5333                              <1> 
  5334 0000EE80 8B3D[92120300]      <1> 	mov	edi, [v_str]
  5335                              <1> 
  5336 0000EE86 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5337 0000EE8D 7707                <1> 	ja	short pix_op_not_w_1
  5338                              <1> 
  5339                              <1> 	; 256 colors (8bpp)
  5340 0000EE8F BD[38F40000]        <1> 	mov	ebp, pix_op_not_8
  5341 0000EE94 EB1E                <1> 	jmp	short pix_op_not_w_4
  5342                              <1> 			
  5343                              <1> pix_op_not_w_1:
  5344 0000EE96 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5345 0000EE9D 7710                <1> 	ja	short pix_op_not_w_3 ; 32bpp
  5346 0000EE9F 7207                <1> 	jb	short pix_op_not_w_2 ; 16bpp
  5347                              <1> 
  5348                              <1> 	; 24 bit true colors
  5349 0000EEA1 BD[46F40000]        <1> 	mov	ebp, pix_op_not_24
  5350 0000EEA6 EB0C                <1> 	jmp	short pix_op_not_w_4
  5351                              <1> 
  5352                              <1> 	; 65536 colors (16bpp)
  5353                              <1> pix_op_not_w_2:
  5354 0000EEA8 BD[3EF40000]        <1> 	mov	ebp, pix_op_not_16
  5355 0000EEAD EB05                <1> 	jmp	short pix_op_not_w_4
  5356                              <1> 
  5357                              <1> 	; 32 bit true colors
  5358                              <1> pix_op_not_w_3:
  5359 0000EEAF BD[51F40000]        <1> 	mov	ebp, pix_op_not_32
  5360                              <1> pix_op_not_w_4:
  5361 0000EEB4 E93EFFFFFF          <1> 	jmp	pix_op_not_w_x
  5362                              <1> 
  5363                              <1> pix_op_neg:
  5364                              <1> 	; 31/01/2021
  5365                              <1> 	; NEGATE COLOR
  5366                              <1> 	;
  5367                              <1> 	; INPUT:
  5368                              <1> 	;  ECX = start position (row, column)
  5369                              <1> 	;        (HW = row, CX = column)
  5370                              <1> 	;  EDX = size (rows, colums)
  5371                              <1> 	;        (HW = rows, DX = columns)
  5372                              <1> 	;	 (0 -> invalid 	
  5373                              <1> 	;        (1 -> horizontal or vertical line)
  5374                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5375                              <1> 	;
  5376                              <1> 	; OUTPUT:
  5377                              <1> 	; 	[u.r0] will be > 0 if succesful
  5378                              <1> 	
  5379 0000EEB9 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5380 0000EEC0 7553                <1> 	jnz	short pix_op_neg_w ; window
  5381                              <1> 	
  5382 0000EEC2 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  5383 0000EEC8 89FE                <1> 	mov	esi, edi
  5384 0000EECA 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5385                              <1> 
  5386 0000EED0 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
  5387 0000EED7 7405                <1> 	jz	short pix_op_neg_0 ; no
  5388 0000EED9 E906100000          <1> 	jmp	m_pix_op_neg ; 'neg' color except mask color
  5389                              <1> pix_op_neg_0:
  5390 0000EEDE 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5391 0000EEE5 7707                <1> 	ja	short pix_op_neg_1
  5392                              <1> 
  5393                              <1> 	; 256 colors (8bpp)
  5394 0000EEE7 E86D050000          <1> 	call	pix_op_neg_8
  5395 0000EEEC EB1E                <1> 	jmp	short pix_op_neg_4
  5396                              <1> 			
  5397                              <1> pix_op_neg_1:
  5398 0000EEEE 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5399 0000EEF5 7710                <1> 	ja	short pix_op_neg_3 ; 32bpp	
  5400 0000EEF7 7207                <1> 	jb	short pix_op_neg_2 ; 16bpp
  5401                              <1> 
  5402                              <1> 	; 24 bit true colors
  5403 0000EEF9 E869050000          <1> 	call	pix_op_neg_24
  5404 0000EEFE EB0C                <1> 	jmp	short pix_op_neg_4
  5405                              <1> 
  5406                              <1> 	; 65536 colors (16bpp)
  5407                              <1> pix_op_neg_2:
  5408 0000EF00 E85A050000          <1> 	call	pix_op_neg_16
  5409 0000EF05 EB05                <1> 	jmp	short pix_op_neg_4
  5410                              <1> 
  5411                              <1> 	; 32 bit true colors	
  5412                              <1> pix_op_neg_3:
  5413 0000EF07 E86D050000          <1> 	call	pix_op_neg_32
  5414                              <1> pix_op_neg_4:
  5415 0000EF0C 29F7                <1> 	sub	edi, esi
  5416 0000EF0E 893D[64030300]      <1> 	mov	[u.r0], edi	
  5417                              <1> pix_op_neg_5:
  5418 0000EF14 C3                  <1> 	retn
  5419                              <1> 
  5420                              <1> pix_op_neg_w:
  5421                              <1> 	; 31/01/2021
  5422                              <1> 	; ecx = win start pos (row, column)
  5423                              <1> 	; edx = size (rows, columns)
  5424 0000EF15 E8DEF7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5425 0000EF1A 72F8                <1> 	jc	short pix_op_neg_5
  5426                              <1> 
  5427 0000EF1C F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked negate color ?
  5428 0000EF23 7405                <1> 	jz	short pix_op_neg_w_0 ; no
  5429 0000EF25 E93F100000          <1> 	jmp	m_pix_op_neg_w 
  5430                              <1> 			; window 'neg' color except mask color
  5431                              <1> pix_op_neg_w_0:
  5432                              <1> 	; ecx = bytes per row (to be applied)
  5433                              <1> 	; edx = screen width in bytes
  5434                              <1> 	; ebx = row count
  5435                              <1> 
  5436 0000EF2A 8B3D[92120300]      <1> 	mov	edi, [v_str]
  5437                              <1> 
  5438 0000EF30 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5439 0000EF37 7707                <1> 	ja	short pix_op_neg_w_1
  5440                              <1> 
  5441                              <1> 	; 256 colors (8bpp)
  5442 0000EF39 BD[59F40000]        <1> 	mov	ebp, pix_op_neg_8
  5443 0000EF3E EB1E                <1> 	jmp	short pix_op_neg_w_4
  5444                              <1> 			
  5445                              <1> pix_op_neg_w_1:
  5446 0000EF40 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5447 0000EF47 7710                <1> 	ja	short pix_op_neg_w_3 ; 32bpp
  5448 0000EF49 7207                <1> 	jb	short pix_op_neg_w_2 ; 16bpp
  5449                              <1> 
  5450                              <1> 	; 24 bit true colors
  5451 0000EF4B BD[67F40000]        <1> 	mov	ebp, pix_op_neg_24
  5452 0000EF50 EB0C                <1> 	jmp	short pix_op_neg_w_4
  5453                              <1> 
  5454                              <1> 	; 65536 colors (16bpp)
  5455                              <1> pix_op_neg_w_2:
  5456 0000EF52 BD[5FF40000]        <1> 	mov	ebp, pix_op_neg_16
  5457 0000EF57 EB05                <1> 	jmp	short pix_op_neg_w_4
  5458                              <1> 
  5459                              <1> 	; 32 bit true colors
  5460                              <1> pix_op_neg_w_3:
  5461 0000EF59 BD[79F40000]        <1> 	mov	ebp, pix_op_neg_32
  5462                              <1> pix_op_neg_w_4:
  5463 0000EF5E E994FEFFFF          <1> 	jmp	pix_op_neg_w_x
  5464                              <1> 
  5465                              <1> pix_op_inc:
  5466                              <1> 	; 31/01/2021
  5467                              <1> 	; INCREASE COLOR
  5468                              <1> 	;
  5469                              <1> 	; INPUT:
  5470                              <1> 	;  ECX = start position (row, column)
  5471                              <1> 	;        (HW = row, CX = column)
  5472                              <1> 	;  EDX = size (rows, colums)
  5473                              <1> 	;        (HW = rows, DX = columns)
  5474                              <1> 	;	 (0 -> invalid 	
  5475                              <1> 	;        (1 -> horizontal or vertical line)
  5476                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5477                              <1> 	;
  5478                              <1> 	; OUTPUT:
  5479                              <1> 	; 	[u.r0] will be > 0 if succesful
  5480                              <1> 	
  5481 0000EF63 F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5482 0000EF6A 7553                <1> 	jnz	short pix_op_inc_w ; window
  5483                              <1> 	
  5484 0000EF6C 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  5485 0000EF72 89FE                <1> 	mov	esi, edi
  5486 0000EF74 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5487                              <1> 
  5488 0000EF7A F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
  5489 0000EF81 7405                <1> 	jz	short pix_op_inc_0 ; no
  5490 0000EF83 E914100000          <1> 	jmp	m_pix_op_inc ; 'inc' color except mask color
  5491                              <1> pix_op_inc_0:
  5492 0000EF88 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5493 0000EF8F 7707                <1> 	ja	short pix_op_inc_1
  5494                              <1> 
  5495                              <1> 	; 256 colors (8bpp)
  5496 0000EF91 E8EB040000          <1> 	call	pix_op_inc_8
  5497 0000EF96 EB1E                <1> 	jmp	short pix_op_inc_4
  5498                              <1> 			
  5499                              <1> pix_op_inc_1:
  5500 0000EF98 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5501 0000EF9F 7710                <1> 	ja	short pix_op_inc_3 ; 32bpp	
  5502 0000EFA1 7207                <1> 	jb	short pix_op_inc_2 ; 16bpp
  5503                              <1> 
  5504                              <1> 	; 24 bit true colors
  5505 0000EFA3 E8F0040000          <1> 	call	pix_op_inc_24
  5506 0000EFA8 EB0C                <1> 	jmp	short pix_op_inc_4
  5507                              <1> 
  5508                              <1> 	; 65536 colors (16bpp)
  5509                              <1> pix_op_inc_2:
  5510 0000EFAA E8DC040000          <1> 	call	pix_op_inc_16
  5511 0000EFAF EB05                <1> 	jmp	short pix_op_inc_4
  5512                              <1> 
  5513                              <1> 	; 32 bit true colors	
  5514                              <1> pix_op_inc_3:
  5515 0000EFB1 E8F6040000          <1> 	call	pix_op_inc_32
  5516                              <1> pix_op_inc_4:
  5517 0000EFB6 29F7                <1> 	sub	edi, esi
  5518 0000EFB8 893D[64030300]      <1> 	mov	[u.r0], edi	
  5519                              <1> pix_op_inc_5:
  5520 0000EFBE C3                  <1> 	retn			
  5521                              <1> 
  5522                              <1> pix_op_inc_w:
  5523                              <1> 	; 31/01/2021
  5524                              <1> 	; ecx = win start pos (row, column)
  5525                              <1> 	; edx = size (rows, columns)
  5526 0000EFBF E834F7FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5527 0000EFC4 72F8                <1> 	jc	short pix_op_inc_5
  5528                              <1> 
  5529 0000EFC6 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked increase color ?
  5530 0000EFCD 7405                <1> 	jz	short pix_op_inc_w_0 ; no
  5531 0000EFCF E961100000          <1> 	jmp	m_pix_op_inc_w 
  5532                              <1> 			; window 'inc' color except mask color
  5533                              <1> pix_op_inc_w_0:
  5534                              <1> 	; ecx = bytes per row (to be applied)
  5535                              <1> 	; edx = screen width in bytes
  5536                              <1> 	; ebx = row count
  5537                              <1> 
  5538 0000EFD4 8B3D[92120300]      <1> 	mov	edi, [v_str]
  5539                              <1> 
  5540 0000EFDA 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5541 0000EFE1 7707                <1> 	ja	short pix_op_inc_w_1
  5542                              <1> 
  5543                              <1> 	; 256 colors (8bpp)
  5544 0000EFE3 BD[81F40000]        <1> 	mov	ebp, pix_op_inc_8
  5545 0000EFE8 EB1E                <1> 	jmp	short pix_op_inc_w_4
  5546                              <1> 			
  5547                              <1> pix_op_inc_w_1:
  5548 0000EFEA 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5549 0000EFF1 7710                <1> 	ja	short pix_op_inc_w_3 ; 32bpp
  5550 0000EFF3 7207                <1> 	jb	short pix_op_inc_w_2 ; 16bpp
  5551                              <1> 
  5552                              <1> 	; 24 bit true colors
  5553 0000EFF5 BD[98F40000]        <1> 	mov	ebp, pix_op_inc_24
  5554 0000EFFA EB0C                <1> 	jmp	short pix_op_inc_w_4
  5555                              <1> 
  5556                              <1> 	; 65536 colors (16bpp)
  5557                              <1> pix_op_inc_w_2:
  5558 0000EFFC BD[8BF40000]        <1> 	mov	ebp, pix_op_inc_16
  5559 0000F001 EB05                <1> 	jmp	short pix_op_inc_w_4
  5560                              <1> 
  5561                              <1> 	; 32 bit true colors
  5562                              <1> pix_op_inc_w_3:
  5563 0000F003 BD[ACF40000]        <1> 	mov	ebp, pix_op_inc_32
  5564                              <1> pix_op_inc_w_4:
  5565 0000F008 E9EAFDFFFF          <1> 	jmp	pix_op_inc_w_x
  5566                              <1> 
  5567                              <1> pix_op_dec:
  5568                              <1> 	; 31/01/2021
  5569                              <1> 	; DECREASE COLOR
  5570                              <1> 	;
  5571                              <1> 	; INPUT:
  5572                              <1> 	;  ECX = start position (row, column)
  5573                              <1> 	;        (HW = row, CX = column)
  5574                              <1> 	;  EDX = size (rows, colums)
  5575                              <1> 	;        (HW = rows, DX = columns)
  5576                              <1> 	;	 (0 -> invalid 	
  5577                              <1> 	;        (1 -> horizontal or vertical line)
  5578                              <1> 	;  [maskcolor] = mask color (to be excluded)
  5579                              <1> 	;
  5580                              <1> 	; OUTPUT:
  5581                              <1> 	; 	[u.r0] will be > 0 if succesful
  5582                              <1> 	
  5583 0000F00D F605[88120300]10    <1> 	test	byte [v_ops], 10h ; display page or window ?
  5584 0000F014 7553                <1> 	jnz	short pix_op_dec_w ; window
  5585                              <1> 	
  5586 0000F016 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  5587 0000F01C 89FE                <1> 	mov	esi, edi
  5588 0000F01E 8B0D[8E120300]      <1> 	mov	ecx, [v_siz] ; display page pixel count
  5589                              <1> 
  5590 0000F024 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
  5591 0000F02B 7405                <1> 	jz	short pix_op_dec_0 ; no
  5592 0000F02D E936100000          <1> 	jmp	m_pix_op_dec ; 'dec' color except mask color
  5593                              <1> pix_op_dec_0:
  5594 0000F032 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5595 0000F039 7707                <1> 	ja	short pix_op_dec_1
  5596                              <1> 
  5597                              <1> 	; 256 colors (8bpp)
  5598 0000F03B E878040000          <1> 	call	pix_op_dec_8
  5599 0000F040 EB1E                <1> 	jmp	short pix_op_dec_4
  5600                              <1> 			
  5601                              <1> pix_op_dec_1:
  5602 0000F042 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5603 0000F049 7710                <1> 	ja	short pix_op_dec_3 ; 32bpp	
  5604 0000F04B 7207                <1> 	jb	short pix_op_dec_2 ; 16bpp
  5605                              <1> 
  5606                              <1> 	; 24 bit true colors
  5607 0000F04D E87D040000          <1> 	call	pix_op_dec_24
  5608 0000F052 EB0C                <1> 	jmp	short pix_op_dec_4
  5609                              <1> 
  5610                              <1> 	; 65536 colors (16bpp)
  5611                              <1> pix_op_dec_2:
  5612 0000F054 E869040000          <1> 	call	pix_op_dec_16
  5613 0000F059 EB05                <1> 	jmp	short pix_op_dec_4
  5614                              <1> 
  5615                              <1> 	; 32 bit true colors	
  5616                              <1> pix_op_dec_3:
  5617 0000F05B E882040000          <1> 	call	pix_op_dec_32
  5618                              <1> pix_op_dec_4:
  5619 0000F060 29F7                <1> 	sub	edi, esi
  5620 0000F062 893D[64030300]      <1> 	mov	[u.r0], edi	
  5621                              <1> pix_op_dec_5:
  5622 0000F068 C3                  <1> 	retn			
  5623                              <1> 
  5624                              <1> pix_op_dec_w:
  5625                              <1> 	; 31/01/2021
  5626                              <1> 	; ecx = win start pos (row, column)
  5627                              <1> 	; edx = size (rows, columns)
  5628 0000F069 E88AF6FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5629 0000F06E 72F8                <1> 	jc	short pix_op_dec_5
  5630                              <1> 
  5631 0000F070 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked decrease color ?
  5632 0000F077 7405                <1> 	jz	short pix_op_dec_w_0 ; no
  5633 0000F079 E97E100000          <1> 	jmp	m_pix_op_dec_w 
  5634                              <1> 			; window 'dec' color except mask color
  5635                              <1> pix_op_dec_w_0:
  5636                              <1> 	; ecx = bytes per row (to be applied)
  5637                              <1> 	; edx = screen width in bytes
  5638                              <1> 	; ebx = row count
  5639                              <1> 
  5640 0000F07E 8B3D[92120300]      <1> 	mov	edi, [v_str]
  5641                              <1> 
  5642 0000F084 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5643 0000F08B 7707                <1> 	ja	short pix_op_dec_w_1
  5644                              <1> 
  5645                              <1> 	; 256 colors (8bpp)
  5646 0000F08D BD[B8F40000]        <1> 	mov	ebp, pix_op_dec_8
  5647 0000F092 EB1E                <1> 	jmp	short pix_op_dec_w_4
  5648                              <1> 			
  5649                              <1> pix_op_dec_w_1:
  5650 0000F094 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5651 0000F09B 7710                <1> 	ja	short pix_op_dec_w_3 ; 32bpp
  5652 0000F09D 7207                <1> 	jb	short pix_op_dec_w_2 ; 16bpp
  5653                              <1> 
  5654                              <1> 	; 24 bit true colors
  5655 0000F09F BD[CFF40000]        <1> 	mov	ebp, pix_op_dec_24
  5656 0000F0A4 EB0C                <1> 	jmp	short pix_op_dec_w_4
  5657                              <1> 
  5658                              <1> 	; 65536 colors (16bpp)
  5659                              <1> pix_op_dec_w_2:
  5660 0000F0A6 BD[C2F40000]        <1> 	mov	ebp, pix_op_dec_16
  5661 0000F0AB EB05                <1> 	jmp	short pix_op_dec_w_4
  5662                              <1> 
  5663                              <1> 	; 32 bit true colors
  5664                              <1> pix_op_dec_w_3:
  5665 0000F0AD BD[E2F40000]        <1> 	mov	ebp, pix_op_dec_32
  5666                              <1> pix_op_dec_w_4:
  5667 0000F0B2 E940FDFFFF          <1> 	jmp	pix_op_dec_w_x
  5668                              <1> 
  5669                              <1> pix_op_blk:
  5670                              <1> 	; 23/01/2021
  5671                              <1> 	; 22/02/2021
  5672                              <1> 	; 02/02/2021
  5673                              <1> 	; COPY PIXEL BLOCK -system to system-
  5674                              <1> 	; WRITE PIXEL BLOCKS -user to system-
  5675                              <1> 	;
  5676                              <1> 	; INPUT:
  5677                              <1> 	;   -If BL bit 5 is 0-	
  5678                              <1> 	;    ECX = start position (row, column) (*)
  5679                              <1> 	;    (HW = row, CX = column)
  5680                              <1> 	;    EDX = size (rows, colums) (*)
  5681                              <1> 	;    (HW = rows, DX = columns)
  5682                              <1> 	;         (0 -> invalid)
  5683                              <1> 	;         (1 -> horizontal or vertical line)
  5684                              <1> 	;    ESI = destination (row, column) (***)
  5685                              <1> 	;   -If BL bit 5 is 1-	
  5686                              <1> 	;     CL = color (8 bit, 256 colors)
  5687                              <1> 	;    ECX = color (16 bit and true colors)
  5688                              <1> 	;    EDX = count of blocks (not bytes)
  5689                              <1> 	;	 (limit: 2048 blocks/windows)	  	
  5690                              <1> 	;    ESI = user's buffer address 
  5691                              <1> 	;	  contains 64 bit block data
  5692                              <1> 	;	  BLOCK ADDRESS - (row, col), dword
  5693                              <1> 	;	  (first 32 bits)
  5694                              <1> 	;	  BLOCK SIZE - (rows, cols), dword
  5695                              <1> 	;	  (second 32 bits)
  5696                              <1> 	; OUTPUT:
  5697                              <1> 	; 	[u.r0] will be > 0 if succesful
  5698                              <1> 
  5699                              <1> 	; Window option ([v_ops] bit 4) will be ignored  	
  5700                              <1> 	; (Function is used for display page coordinates)
  5701                              <1> 
  5702 0000F0B7 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
  5703 0000F0BE 755A                <1> 	jnz	short pix_op_blk_u ; blocks from user's buffer
  5704                              <1> 
  5705 0000F0C0 89F0                <1> 	mov	eax, esi ; destination position (row, col)
  5706 0000F0C2 E8DEF6FFFF          <1> 	call	calc_pixel_offset
  5707 0000F0C7 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  5708 0000F0CD 734A                <1> 	jnb	short pix_op_blk_retn ; out of display page
  5709 0000F0CF 89C6                <1> 	mov	esi, eax
  5710 0000F0D1 E8ACF6FFFF          <1> 	call	pixels_to_byte_count
  5711 0000F0D6 89C7                <1> 	mov	edi, eax
  5712 0000F0D8 89D0                <1> 	mov	eax, edx  ; size
  5713 0000F0DA E8C6F6FFFF          <1> 	call	calc_pixel_offset
  5714                              <1> 	; 22/02/2021
  5715 0000F0DF 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  5716 0000F0E5 7732                <1> 	ja	short pix_op_blk_retn ; out of display page
  5717 0000F0E7 01C6                <1> 	add	esi, eax
  5718 0000F0E9 3B35[8E120300]      <1> 	cmp	esi, [v_siz]
  5719 0000F0EF 7728                <1> 	ja	short pix_op_blk_retn ; out of display page
  5720                              <1> 
  5721 0000F0F1 033D[8A120300]      <1> 	add	edi, [v_mem] ; destination address
  5722                              <1> 	
  5723                              <1> 	; 23/01/2021
  5724                              <1> 	;call	pixels_to_byte_count
  5725                              <1> 	;add	edi, eax
  5726                              <1> 	;jc	short pix_op_blk_retn ; out of display page
  5727                              <1> 	;cmp	edi, [v_end]
  5728                              <1> 	;ja	short pix_op_blk_retn ; out of display page
  5729                              <1> 	;sub	edi, eax
  5730                              <1> 
  5731 0000F0F7 E8FCF5FFFF          <1> 	call	sysvideo_15_12 ; window preparations
  5732 0000F0FC 721B                <1> 	jc	short pix_op_blk_retn ; something wrong !?
  5733                              <1> 	; ecx = bytes per row (to be applied)
  5734                              <1> 	; edx = screen width in bytes
  5735                              <1> 	; ebx = row count
  5736                              <1> 
  5737 0000F0FE 8B35[92120300]      <1> 	mov	esi, [v_str] ; source address
  5738                              <1> 
  5739                              <1> 	; Note:
  5740                              <1> 	; ecx & edx are already adjusted for pixel sizes
  5741                              <1> 	; so, following code is proper all pixel sizes
  5742                              <1> 
  5743 0000F104 29CA                <1> 	sub	edx, ecx ; screen width - window width
  5744                              <1> pix_op_blk_0:
  5745 0000F106 89C8                <1> 	mov	eax, ecx
  5746 0000F108 0105[64030300]      <1> 	add	[u.r0], eax
  5747 0000F10E F3A4                <1> 	rep	movsb
  5748 0000F110 89C1                <1> 	mov	ecx, eax	
  5749 0000F112 01D6                <1> 	add	esi, edx ; next row
  5750 0000F114 01D7                <1> 	add	edi, edx ; next row
  5751 0000F116 4B                  <1> 	dec	ebx
  5752 0000F117 75ED                <1> 	jnz	short pix_op_blk_0
  5753                              <1> pix_op_blk_retn:
  5754 0000F119 C3                  <1> 	retn
  5755                              <1> 
  5756                              <1> pix_op_blk_u:
  5757                              <1> 	; fill blocks (windows) with desired color
  5758                              <1> 	; according to block definitions in user's buffer
  5759 0000F11A 81FA00080000        <1> 	cmp	edx, 2048
  5760 0000F120 7605                <1> 	jna	short pix_op_blk_u_0
  5761                              <1> 	; Maximum 2048 blocks
  5762 0000F122 BA00080000          <1> 	mov	edx, 2048
  5763                              <1> pix_op_blk_u_0:
  5764 0000F127 8025[88120300]DF    <1> 	and	byte [v_ops], ~20h ; clear masked bit
  5765 0000F12E 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; save pixel color
  5766                              <1> 	; 22/02/2021
  5767                              <1> 	;mov	ebp, edx ; save blocks count
  5768                              <1> 	;push	ebp
  5769                              <1> pix_op_blk_u_next:
  5770 0000F134 52                  <1> 	push	edx
  5771 0000F135 B908000000          <1> 	mov	ecx, 8
  5772 0000F13A BF[A2120300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
  5773                              <1> 	; esi = user's buffer address
  5774 0000F13F E80A2A0000          <1> 	call	transfer_from_user_buffer
  5775 0000F144 72D3                <1> 	jc	short pix_op_blk_retn
  5776 0000F146 01CE                <1> 	add	esi, ecx ; 22/02/2021
  5777 0000F148 56                  <1> 	push	esi
  5778 0000F149 8B15[A2120300]      <1> 	mov	edx, [buffer8] ; block start pos (row,col)
  5779 0000F14F 8B35[A6120300]      <1> 	mov	esi, [buffer8+4] ; block size (rows,cols)
  5780 0000F155 8B0D[9A120300]      <1> 	mov	ecx, [maskcolor]
  5781 0000F15B E848FCFFFF          <1> 	call	pix_op_new_w ; new (change) color (window)
  5782 0000F160 5E                  <1> 	pop	esi
  5783                              <1> 	;pop	ebp
  5784                              <1> 	;dec	ebp
  5785 0000F161 5A                  <1> 	pop	edx
  5786 0000F162 4A                  <1> 	dec	edx
  5787 0000F163 75CF                <1> 	jnz	short pix_op_blk_u_next
  5788 0000F165 C3                  <1> 	retn
  5789                              <1> 
  5790                              <1> pix_op_lin:
  5791                              <1> 	; 12/02/2021
  5792                              <1> 	; 11/02/2021
  5793                              <1> 	; 10/02/2021
  5794                              <1> 	; 05/02/2021
  5795                              <1> 	; 02/02/2021
  5796                              <1> 	; WRITE LINE -direct-
  5797                              <1> 	; WRITE LINE(S) -via user's buffer-
  5798                              <1> 	;
  5799                              <1> 	; INPUT:
  5800                              <1> 	;   -If BL bit 5 is 0-	
  5801                              <1> 	;     CL = color (8 bit, 256 colors)
  5802                              <1> 	;    ECX = color (16 bit and true colors)
  5803                              <1> 	;     DX = low 12 bits - size (length)
  5804                              <1> 	;	   high 4 bits - direction or type
  5805                              <1> 	;	     0 - Horizontal line
  5806                              <1> 	;	     1 - Vertical line
  5807                              <1> 	;	   > 1 - undefined, invalid
  5808                              <1> 	;    ESI = start position (row, column)
  5809                              <1> 	;	  (HW = row, SI = column)
  5810                              <1> 	;   -If BL bit 5 is 1-
  5811                              <1> 	;     CL = color (8 bit, 256 colors)
  5812                              <1> 	;    ECX = color (16 bit and true colors)
  5813                              <1> 	;     DX = number of lines (in user buffer)
  5814                              <1> 	;	   (limit: 2048 lines)	
  5815                              <1> 	;    ESI = user's buffer
  5816                              <1> 	;          contains 64 bit data for lines
  5817                              <1> 	;	   START POINT: 32 bit (row, col)
  5818                              <1> 	;	   LENGTH: 32 bit
  5819                              <1> 	;		   high 16 bits - 0
  5820                              <1> 	;		   bit 0-11 - length
  5821                              <1> 	;	   	   bit 12-15 - type (length)
  5822                              <1> 	; OUTPUT:
  5823                              <1> 	; 	[u.r0] will be > 0 if succesful
  5824                              <1> 
  5825                              <1> 	; Window option ([v_ops] bit 4) will be ignored
  5826                              <1> 	; (Function is used for display page coordinates)
  5827                              <1> 
  5828                              <1> 	; 10/02/2021
  5829 0000F166 F605[88120300]20    <1> 	test	byte [v_ops], 20h ; masked or direct ?
  5830 0000F16D 7445                <1> 	jz	short pix_op_lin_vh ; direct (v/h lines) 
  5831                              <1> 
  5832                              <1> 	; lines from user's buffer
  5833                              <1> pix_op_lin_u:
  5834                              <1> 	; draw lines with desired color
  5835                              <1> 	; according to line definitions in user's buffer
  5836 0000F16F 81FA00080000        <1> 	cmp	edx, 2048
  5837 0000F175 7605                <1> 	jna	short pix_op_lin_u_0
  5838                              <1> 	; Maximum 2048 lines
  5839 0000F177 BA00080000          <1> 	mov	edx, 2048
  5840                              <1> pix_op_lin_u_0:
  5841 0000F17C 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; save pixel color
  5842 0000F182 89D5                <1> 	mov	ebp, edx ; save line count
  5843                              <1> pix_op_lin_u_next:
  5844 0000F184 B908000000          <1> 	mov	ecx, 8
  5845 0000F189 BF[A2120300]        <1> 	mov	edi, buffer8 ; 8 bytes small buffer
  5846                              <1> 	; esi = user's buffer address
  5847 0000F18E E8BB290000          <1> 	call	transfer_from_user_buffer
  5848 0000F193 721E                <1> 	jc	short pix_op_lin_retn
  5849 0000F195 01CE                <1> 	add	esi, ecx ; 11/02/2021
  5850 0000F197 56                  <1> 	push	esi
  5851 0000F198 8B35[A2120300]      <1> 	mov	esi, [buffer8] ; line start pos (row,col)
  5852 0000F19E 8B15[A6120300]      <1> 	mov	edx, [buffer8+4] ; line length
  5853 0000F1A4 8B0D[9A120300]      <1> 	mov	ecx, [maskcolor]
  5854 0000F1AA E805000000          <1> 	call	pix_op_lin_vh ; new (change) color (window)
  5855 0000F1AF 5E                  <1> 	pop	esi
  5856 0000F1B0 4D                  <1> 	dec	ebp
  5857 0000F1B1 75D1                <1> 	jnz	short pix_op_lin_u_next
  5858                              <1> pix_op_lin_retn:
  5859 0000F1B3 C3                  <1> 	retn
  5860                              <1> 
  5861                              <1> pix_op_lin_vh:
  5862 0000F1B4 81FA38140000        <1> 	cmp	edx, 1438h ; 1920*1080 (780hx438h) limit
  5863 0000F1BA 7761                <1> 	ja	short pix_op_lin_err1 ; invalid type 
  5864                              <1> 			    	; (for current version)
  5865 0000F1BC 66F7C2FF0F          <1> 	test	dx, 0FFFh
  5866 0000F1C1 745A                <1> 	jz	short pix_op_lin_err1 ; zero length!
  5867                              <1> 
  5868 0000F1C3 89F0                <1> 	mov	eax, esi ; start point (row, col)
  5869 0000F1C5 E8DBF5FFFF          <1> 	call	calc_pixel_offset
  5870 0000F1CA 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  5871 0000F1D0 734B                <1> 	jnb	short pix_op_lin_err1 ; out of display page!
  5872 0000F1D2 E8ABF5FFFF          <1> 	call	pixels_to_byte_count
  5873 0000F1D7 89C7                <1> 	mov	edi, eax ; start point offset
  5874 0000F1D9 033D[8A120300]      <1> 	add	edi, [v_mem] ; LFB start address
  5875 0000F1DF 89C8                <1> 	mov	eax, ecx ; color
  5876                              <1> 
  5877 0000F1E1 F6C610              <1> 	test	dh, 10h
  5878 0000F1E4 0F848A000000        <1> 	jz	pix_op_lin_h ; Horizontal line
  5879                              <1> 
  5880                              <1> pix_op_lin_v:
  5881                              <1> 	; Vertical line
  5882 0000F1EA 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
  5883 0000F1ED 51                  <1> 	push	ecx ; color
  5884 0000F1EE 89D1                <1> 	mov	ecx, edx
  5885 0000F1F0 0FB705[86120300]    <1> 	movzx	eax, word [v_width]
  5886 0000F1F7 89C3                <1> 	mov	ebx, eax
  5887                              <1> 	; 12/02/2021
  5888 0000F1F9 F7E2                <1> 	mul	edx ; rows * [v_width]
  5889 0000F1FB 01F8                <1> 	add	eax, edi
  5890 0000F1FD 3B05[96120300]      <1> 	cmp	eax, [v_end]
  5891 0000F203 58                  <1> 	pop	eax ; color
  5892 0000F204 7717                <1> 	ja	short pix_op_lin_err1 ; out of display page
  5893                              <1> 	; ecx = rows	
  5894 0000F206 89CA                <1> 	mov	edx, ecx
  5895                              <1> 
  5896 0000F208 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5897 0000F20F 770D                <1> 	ja	short pix_op_lin_v_2
  5898                              <1> 	; 256 colors (1 byte per pixel)
  5899 0000F211 010D[64030300]      <1> 	add	[u.r0], ecx ; byte count
  5900                              <1> pix_op_lin_v_1:
  5901 0000F217 8807                <1> 	mov	[edi], al
  5902 0000F219 01DF                <1> 	add	edi, ebx  ; next row	
  5903 0000F21B E2FA                <1> 	loop	pix_op_lin_v_1
  5904                              <1> pix_op_lin_err1:
  5905 0000F21D C3                  <1> 	retn
  5906                              <1> 
  5907                              <1> pix_op_lin_v_2:
  5908 0000F21E 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5909 0000F225 773A                <1> 	ja	short pix_op_lin_v_6 ; 32bpp
  5910 0000F227 7226                <1> 	jb	short pix_op_lin_v_4 ; 16bpp
  5911                              <1> 	
  5912                              <1> 	; 24 bit true colors
  5913                              <1> 	; * 3
  5914 0000F229 53                  <1> 	push	ebx ; screen width in pixels
  5915 0000F22A D1E3                <1> 	shl	ebx, 1
  5916 0000F22C 011C24              <1> 	add	[esp], ebx
  5917 0000F22F 5B                  <1> 	pop	ebx ; screen width in bytes
  5918 0000F230 010D[64030300]      <1> 	add	[u.r0], ecx
  5919 0000F236 D1E2                <1> 	shl	edx, 1
  5920 0000F238 0115[64030300]      <1> 	add	[u.r0], edx ; byte count
  5921                              <1> pix_op_lin_v_3:
  5922 0000F23E 668907              <1> 	mov	[edi], ax
  5923 0000F241 C1C810              <1> 	ror	eax, 16
  5924 0000F244 884702              <1> 	mov	[edi+2], al	
  5925 0000F247 C1C010              <1> 	rol	eax, 16
  5926 0000F24A 01DF                <1> 	add	edi, ebx  ; next row	
  5927 0000F24C E2F0                <1> 	loop	pix_op_lin_v_3
  5928 0000F24E C3                  <1> 	retn
  5929                              <1> 
  5930                              <1> pix_op_lin_v_4:
  5931                              <1> 	; 16 bit (65536) colors
  5932 0000F24F D1E3                <1> 	shl	ebx, 1
  5933 0000F251 D1E2                <1> 	shl	edx, 1
  5934 0000F253 0115[64030300]      <1> 	add	[u.r0], edx
  5935                              <1> pix_op_lin_v_5:
  5936 0000F259 668907              <1> 	mov	[edi], ax
  5937 0000F25C 01DF                <1> 	add	edi, ebx  ; next row	
  5938 0000F25E E2F9                <1> 	loop	pix_op_lin_v_5
  5939 0000F260 C3                  <1> 	retn
  5940                              <1> 
  5941                              <1> pix_op_lin_v_6:
  5942                              <1> 	; 32 bit true colors
  5943 0000F261 C1E302              <1> 	shl	ebx, 2
  5944 0000F264 C1E202              <1> 	shl	edx, 2
  5945 0000F267 0115[64030300]      <1> 	add	[u.r0], edx ; byte count
  5946                              <1> pix_op_lin_v_7:
  5947 0000F26D 8907                <1> 	mov	[edi], eax
  5948 0000F26F 01DF                <1> 	add	edi, ebx  ; next row	
  5949 0000F271 E2FA                <1> 	loop	pix_op_lin_v_7
  5950 0000F273 C3                  <1> 	retn		
  5951                              <1> 
  5952                              <1> pix_op_lin_h:
  5953                              <1> 	; Horizontal line
  5954 0000F274 80E60F              <1> 	and 	dh, 0Fh ; low 12 bits
  5955 0000F277 89D1                <1>   	mov	ecx, edx
  5956 0000F279 6601D6              <1> 	add	si, dx ; start column + columns
  5957 0000F27C 663B35[86120300]    <1> 	cmp	si, [v_width] ; screen width
  5958 0000F283 7711                <1> 	ja	short pix_op_lin_err2 ; out of columns limit
  5959                              <1> 
  5960 0000F285 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  5961 0000F28C 7709                <1> 	ja	short pix_op_lin_h_1
  5962                              <1> 	; 256 colors (1 byte per pixel)
  5963 0000F28E 010D[64030300]      <1> 	add	[u.r0], ecx
  5964 0000F294 F3AA                <1> 	rep	stosb
  5965                              <1> pix_op_lin_err2:
  5966 0000F296 C3                  <1> 	retn
  5967                              <1> 
  5968                              <1> pix_op_lin_h_1:
  5969 0000F297 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  5970 0000F29E 7728                <1> 	ja	short pix_op_lin_h_4 ; 32bpp
  5971 0000F2A0 721A                <1> 	jb	short pix_op_lin_h_3 ; 16bpp
  5972                              <1> 	
  5973                              <1> 	; 24 bit true colors
  5974                              <1> 	; * 3
  5975 0000F2A2 0115[64030300]      <1> 	add	[u.r0], edx
  5976 0000F2A8 D1E2                <1> 	shl	edx, 1
  5977 0000F2AA 0115[64030300]      <1> 	add	[u.r0], edx
  5978                              <1> pix_op_lin_h_2:
  5979 0000F2B0 66AB                <1> 	stosw
  5980 0000F2B2 C1C810              <1> 	ror	eax, 16
  5981 0000F2B5 AA                  <1> 	stosb	
  5982 0000F2B6 C1C010              <1> 	rol	eax, 16
  5983 0000F2B9 E2F5                <1> 	loop	pix_op_lin_h_2
  5984 0000F2BB C3                  <1> 	retn
  5985                              <1> 
  5986                              <1> pix_op_lin_h_3:
  5987                              <1> 	; 16 bit (65536) colors
  5988 0000F2BC D1E2                <1> 	shl	edx, 1
  5989 0000F2BE 0115[64030300]      <1> 	add	[u.r0], edx
  5990 0000F2C4 F366AB              <1> 	rep	stosw
  5991 0000F2C7 C3                  <1> 	retn
  5992                              <1> 
  5993                              <1> pix_op_lin_h_4:
  5994                              <1> 	; 32 bit true colors
  5995 0000F2C8 C1E202              <1> 	shl	edx, 2
  5996 0000F2CB 0115[64030300]      <1> 	add	[u.r0], edx
  5997 0000F2D1 F3AB                <1> 	rep	stosd
  5998 0000F2D3 C3                  <1> 	retn
  5999                              <1> 
  6000                              <1> pix_op_new_8:
  6001                              <1> 	; 8 bit colors (256 colors)
  6002                              <1> 	; CHANGE PIXEL COLOR
  6003                              <1> 	; ecx = pixel count per row
  6004                              <1> 	;  al = color
  6005                              <1> 	; edi = start pixel address 
  6006                              <1> 
  6007 0000F2D4 F3AA                <1> 	rep	stosb
  6008 0000F2D6 C3                  <1> 	retn
  6009                              <1> 
  6010                              <1> pix_op_new_16:
  6011                              <1> 	; 16 bit colors (65536 colors)
  6012                              <1> 	; CHANGE PIXEL COLOR
  6013                              <1> 	; ecx = pixel count per row
  6014                              <1> 	;  ax = color
  6015                              <1> 	; edi = start pixel address 
  6016                              <1> 
  6017 0000F2D7 F366AB              <1> 	rep	stosw
  6018 0000F2DA C3                  <1> 	retn
  6019                              <1> 
  6020                              <1> pix_op_new_24:
  6021                              <1> 	; 24 bit true colors
  6022                              <1> 	; CHANGE PIXEL COLOR
  6023                              <1> 	; ecx = pixel count per row
  6024                              <1> 	; eax = color
  6025                              <1> 	; edi = start pixel address 
  6026                              <1> 
  6027 0000F2DB 66AB                <1> 	stosw
  6028 0000F2DD C1C810              <1> 	ror	eax, 16	
  6029 0000F2E0 AA                  <1> 	stosb
  6030 0000F2E1 C1C010              <1> 	rol	eax, 16
  6031 0000F2E4 E2F5                <1> 	loop	pix_op_new_24
  6032 0000F2E6 C3                  <1> 	retn
  6033                              <1> 
  6034                              <1> pix_op_new_32:
  6035                              <1> 	; 32 bit true colors
  6036                              <1> 	; CHANGE PIXEL COLOR
  6037                              <1> 	; ecx = pixel count per row
  6038                              <1> 	; eax = color
  6039                              <1> 	; edi = start pixel address 
  6040                              <1> 
  6041 0000F2E7 F3AB                <1> 	rep	stosd
  6042 0000F2E9 C3                  <1> 	retn
  6043                              <1> 
  6044                              <1> pix_op_add_8:
  6045                              <1> 	; 8 bit colors (256 colors)
  6046                              <1> 	; ADD PIXEL COLOR
  6047                              <1> 	; ecx = pixel count per row
  6048                              <1> 	;  al = color
  6049                              <1> 	; edi = start pixel address 
  6050                              <1> 
  6051 0000F2EA 88C4                <1> 	mov	ah, al
  6052                              <1> pix_op_add_8_0:
  6053 0000F2EC 0207                <1> 	add	al, [edi]
  6054 0000F2EE 7302                <1> 	jnc	short pix_op_add_8_1
  6055 0000F2F0 B0FF                <1> 	mov	al, 0FFh ; Max. value	
  6056                              <1> pix_op_add_8_1:
  6057 0000F2F2 AA                  <1> 	stosb
  6058 0000F2F3 88E0                <1> 	mov	al, ah
  6059 0000F2F5 E2F5                <1> 	loop	pix_op_add_8_0
  6060 0000F2F7 C3                  <1> 	retn
  6061                              <1> 
  6062                              <1> pix_op_add_16:
  6063                              <1> 	; 16 bit colors (65536 colors)
  6064                              <1> 	; ADD PIXEL COLOR
  6065                              <1> 	; ecx = pixel count per row
  6066                              <1> 	;  ax = color
  6067                              <1> 	; edi = start pixel address 
  6068                              <1> 
  6069 0000F2F8 89C2                <1> 	mov	edx, eax
  6070                              <1> pix_op_add_16_0:
  6071 0000F2FA 660307              <1> 	add	ax, [edi]
  6072 0000F2FD 7304                <1> 	jnc	short pix_op_add_16_1
  6073 0000F2FF 66B8FFFF            <1> 	mov	ax, 0FFFFh ; Max. value	
  6074                              <1> pix_op_add_16_1:
  6075 0000F303 66AB                <1> 	stosw
  6076 0000F305 89D0                <1> 	mov	eax, edx
  6077 0000F307 E2F1                <1> 	loop	pix_op_add_16_0
  6078 0000F309 C3                  <1> 	retn
  6079                              <1> 
  6080                              <1> pix_op_add_24:
  6081                              <1> 	; 24 bit true colors
  6082                              <1> 	; ADD PIXEL COLOR
  6083                              <1> 	; ecx = pixel count per row
  6084                              <1> 	; eax = color
  6085                              <1> 	; edi = start pixel address 
  6086                              <1> 
  6087 0000F30A 53                  <1> 	push	ebx
  6088 0000F30B BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
  6089                              <1> 	;and	eax, ebx ; 0FFFFFFh
  6090 0000F310 89C2                <1> 	mov	edx, eax
  6091                              <1> pix_op_add_24_0:
  6092 0000F312 8B07                <1> 	mov	eax, [edi]
  6093 0000F314 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
  6094 0000F316 01D0                <1> 	add	eax, edx
  6095 0000F318 39D8                <1> 	cmp	eax, ebx
  6096 0000F31A 7602                <1> 	jna	short pix_op_add_24_1
  6097 0000F31C 89D8                <1> 	mov	eax, ebx ; 0FFFFFFh  ; Max. value
  6098                              <1> pix_op_add_24_1: 
  6099 0000F31E 66AB                <1> 	stosw
  6100 0000F320 C1E810              <1> 	shr	eax, 16
  6101 0000F323 AA                  <1> 	stosb
  6102 0000F324 E2EC                <1> 	loop	pix_op_add_24_0
  6103 0000F326 89D0                <1> 	mov	eax, edx
  6104 0000F328 5B                  <1> 	pop	ebx
  6105 0000F329 C3                  <1> 	retn
  6106                              <1> 
  6107                              <1> pix_op_add_32:
  6108                              <1> 	; 32 bit true colors
  6109                              <1> 	; ADD PIXEL COLOR
  6110                              <1> 	; ecx = pixel count per row
  6111                              <1> 	; eax = color
  6112                              <1> 	; edi = start pixel address 
  6113                              <1> 
  6114 0000F32A 89C2                <1> 	mov	edx, eax
  6115                              <1> pix_op_add_32_0:
  6116 0000F32C 0307                <1> 	add	eax, [edi]
  6117 0000F32E 7303                <1> 	jnc	short pix_op_add_32_1
  6118                              <1> 	;mov	eax, 0FFFFFFFFh ; Max. value
  6119 0000F330 29C0                <1> 	sub	eax, eax
  6120 0000F332 48                  <1> 	dec	eax	
  6121                              <1> pix_op_add_32_1:
  6122 0000F333 AB                  <1> 	stosd
  6123 0000F334 89D0                <1> 	mov	eax, edx
  6124 0000F336 E2F4                <1> 	loop	pix_op_add_32_0
  6125 0000F338 C3                  <1> 	retn
  6126                              <1> 
  6127                              <1> pix_op_sub_8:
  6128                              <1> 	; 8 bit colors (256 colors)
  6129                              <1> 	; SUBTRACT PIXEL COLOR
  6130                              <1> 	; ecx = pixel count per row
  6131                              <1> 	;  al = color
  6132                              <1> 	; edi = start pixel address 
  6133                              <1> 
  6134 0000F339 88C4                <1> 	mov	ah, al
  6135                              <1> pix_op_sub_8_0:
  6136 0000F33B 8A07                <1> 	mov	al, [edi]
  6137 0000F33D 28E0                <1> 	sub	al, ah
  6138 0000F33F 7302                <1> 	jnb	short pix_op_sub_8_1
  6139 0000F341 30C0                <1> 	xor	al, al ; 0 ; Min. value	
  6140                              <1> pix_op_sub_8_1:
  6141 0000F343 AA                  <1> 	stosb
  6142 0000F344 E2F5                <1> 	loop	pix_op_sub_8_0
  6143 0000F346 88E0                <1> 	mov	al, ah
  6144 0000F348 C3                  <1> 	retn
  6145                              <1> 
  6146                              <1> pix_op_sub_16:
  6147                              <1> 	; 16 bit colors (65536 colors)
  6148                              <1> 	; SUBTRACT PIXEL COLOR
  6149                              <1> 	; ecx = pixel count per row
  6150                              <1> 	;  ax = color
  6151                              <1> 	; edi = start pixel address 
  6152                              <1> 
  6153 0000F349 89C2                <1> 	mov	edx, eax
  6154                              <1> pix_op_sub_16_0:
  6155 0000F34B 668B07              <1> 	mov	ax, [edi]
  6156 0000F34E 6629D0              <1> 	sub	ax, dx
  6157 0000F351 7302                <1> 	jnb	short pix_op_sub_16_1
  6158 0000F353 31C0                <1> 	xor	eax, eax ; 0 ; Min. value	
  6159                              <1> pix_op_sub_16_1:
  6160 0000F355 66AB                <1> 	stosw
  6161 0000F357 E2F2                <1> 	loop	pix_op_sub_16_0
  6162 0000F359 89D0                <1> 	mov	eax, edx
  6163 0000F35B C3                  <1> 	retn
  6164                              <1> 
  6165                              <1> pix_op_sub_24:
  6166                              <1> 	; 24 bit true colors
  6167                              <1> 	; SUBTRACT PIXEL COLOR
  6168                              <1> 	; ecx = pixel count per row
  6169                              <1> 	; eax = color
  6170                              <1> 	; edi = start pixel address 
  6171                              <1> 
  6172                              <1> 	;and	eax, 0FFFFFFh
  6173 0000F35C 89C2                <1> 	mov	edx, eax
  6174                              <1> pix_op_sub_24_0:
  6175 0000F35E 8B07                <1> 	mov	eax, [edi]
  6176                              <1> 	; 27/02/2021
  6177 0000F360 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6178 0000F365 29D0                <1> 	sub	eax, edx
  6179 0000F367 7302                <1> 	jnb	short pix_op_sub_24_1
  6180 0000F369 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
  6181                              <1> pix_op_sub_24_1: 
  6182 0000F36B 66AB                <1> 	stosw
  6183 0000F36D C1E810              <1> 	shr	eax, 16
  6184 0000F370 AA                  <1> 	stosb
  6185 0000F371 E2EB                <1> 	loop	pix_op_sub_24_0
  6186 0000F373 89D0                <1> 	mov	eax, edx
  6187 0000F375 C3                  <1> 	retn
  6188                              <1> 
  6189                              <1> pix_op_sub_32:
  6190                              <1> 	; 32 bit true colors
  6191                              <1> 	; SUBTRACT PIXEL COLOR
  6192                              <1> 	; ecx = pixel count per row
  6193                              <1> 	; eax = color
  6194                              <1> 	; edi = start pixel address 
  6195                              <1> 
  6196 0000F376 89C2                <1> 	mov	edx, eax
  6197                              <1> pix_op_sub_32_0:
  6198 0000F378 8B07                <1> 	mov	eax, [edi]
  6199 0000F37A 29D0                <1> 	sub	eax, edx
  6200 0000F37C 7302                <1> 	jnb	short pix_op_sub_32_1
  6201 0000F37E 31C0                <1> 	xor	eax, eax ; 0 ; Min. value
  6202                              <1> pix_op_sub_32_1:
  6203 0000F380 AB                  <1> 	stosd
  6204 0000F381 E2F5                <1> 	loop	pix_op_sub_32_0
  6205 0000F383 89D0                <1> 	mov	eax, edx
  6206 0000F385 C3                  <1> 	retn
  6207                              <1> 
  6208                              <1> pix_op_or_8:
  6209                              <1> 	; 8 bit colors (256 colors)
  6210                              <1> 	; OR PIXEL COLOR
  6211                              <1> 	; ecx = pixel count per row
  6212                              <1> 	;  al = color
  6213                              <1> 	; edi = start pixel address 
  6214                              <1> 
  6215                              <1> pix_op_or_8_0:
  6216 0000F386 0807                <1> 	or	[edi], al
  6217 0000F388 47                  <1> 	inc	edi
  6218 0000F389 E2FB                <1> 	loop	pix_op_or_8_0
  6219 0000F38B C3                  <1> 	retn
  6220                              <1> 
  6221                              <1> pix_op_or_16:
  6222                              <1> 	; 16 bit colors (65536 colors)
  6223                              <1> 	; OR PIXEL COLOR
  6224                              <1> 	; ecx = pixel count per row
  6225                              <1> 	;  ax = color
  6226                              <1> 	; edi = start pixel address 
  6227                              <1> 
  6228                              <1> pix_op_or_16_0:
  6229 0000F38C 660907              <1> 	or	[edi], ax
  6230 0000F38F 47                  <1> 	inc	edi
  6231 0000F390 47                  <1> 	inc	edi
  6232 0000F391 E2F9                <1> 	loop	pix_op_or_16_0
  6233 0000F393 C3                  <1> 	retn
  6234                              <1> 
  6235                              <1> pix_op_or_24:
  6236                              <1> 	; 24 bit true colors
  6237                              <1> 	; OR PIXEL COLOR
  6238                              <1> 	; ecx = pixel count per row
  6239                              <1> 	; eax = color
  6240                              <1> 	; edi = start pixel address 
  6241                              <1> 
  6242 0000F394 89C2                <1> 	mov	edx, eax
  6243                              <1> pix_op_or_24_0:
  6244 0000F396 0B07                <1> 	or	eax, [edi]
  6245 0000F398 66AB                <1> 	stosw
  6246 0000F39A C1E810              <1> 	shr	eax, 16
  6247 0000F39D AA                  <1> 	stosb	
  6248 0000F39E 89D0                <1> 	mov	eax, edx
  6249 0000F3A0 E2F4                <1> 	loop	pix_op_or_24_0
  6250 0000F3A2 C3                  <1> 	retn
  6251                              <1> 
  6252                              <1> pix_op_or_32:
  6253                              <1> 	; 32 bit true colors
  6254                              <1> 	; OR PIXEL COLOR
  6255                              <1> 	; ecx = pixel count per row
  6256                              <1> 	; eax = color
  6257                              <1> 	; edi = start pixel address 
  6258                              <1> 
  6259                              <1> 	;mov	edx, eax
  6260                              <1> pix_op_or_32_0:
  6261                              <1> 	;or	eax, [edi]
  6262                              <1> 	;stosd
  6263                              <1> 	;mov	eax, edx
  6264 0000F3A3 0907                <1> 	or	[edi], eax
  6265 0000F3A5 83C704              <1> 	add	edi, 4
  6266 0000F3A8 E2F9                <1> 	loop	pix_op_or_32_0
  6267 0000F3AA C3                  <1> 	retn
  6268                              <1> 
  6269                              <1> pix_op_and_8:
  6270                              <1> 	; 8 bit colors (256 colors)
  6271                              <1> 	; AND PIXEL COLOR
  6272                              <1> 	; ecx = pixel count per row
  6273                              <1> 	;  al = color
  6274                              <1> 	; edi = start pixel address 
  6275                              <1> 
  6276                              <1> pix_op_and_8_0:
  6277 0000F3AB 2007                <1> 	and	[edi], al
  6278 0000F3AD 47                  <1> 	inc	edi
  6279 0000F3AE E2FB                <1> 	loop	pix_op_and_8_0
  6280 0000F3B0 C3                  <1> 	retn
  6281                              <1> 
  6282                              <1> pix_op_and_16:
  6283                              <1> 	; 16 bit colors (65536 colors)
  6284                              <1> 	; AND PIXEL COLOR
  6285                              <1> 	; ecx = pixel count per row
  6286                              <1> 	;  ax = color
  6287                              <1> 	; edi = start pixel address 
  6288                              <1> 
  6289                              <1> pix_op_and_16_0:
  6290 0000F3B1 662107              <1> 	and	[edi], ax
  6291 0000F3B4 47                  <1> 	inc	edi
  6292 0000F3B5 47                  <1> 	inc	edi
  6293 0000F3B6 E2F9                <1> 	loop	pix_op_and_16_0
  6294 0000F3B8 C3                  <1> 	retn
  6295                              <1> 
  6296                              <1> pix_op_and_24:
  6297                              <1> 	; 24 bit true colors
  6298                              <1> 	; AND PIXEL COLOR
  6299                              <1> 	; ecx = pixel count per row
  6300                              <1> 	; eax = color
  6301                              <1> 	; edi = start pixel address 
  6302                              <1> 
  6303 0000F3B9 89C2                <1> 	mov	edx, eax
  6304                              <1> pix_op_and_24_0:
  6305 0000F3BB 2307                <1> 	and	eax, [edi]
  6306 0000F3BD 66AB                <1> 	stosw
  6307 0000F3BF C1E810              <1> 	shr	eax, 16
  6308 0000F3C2 AA                  <1> 	stosb	
  6309 0000F3C3 89D0                <1> 	mov	eax, edx
  6310 0000F3C5 E2F4                <1> 	loop	pix_op_and_24_0
  6311 0000F3C7 C3                  <1> 	retn
  6312                              <1> 
  6313                              <1> pix_op_and_32:
  6314                              <1> 	; 32 bit true colors
  6315                              <1> 	; AND PIXEL COLOR
  6316                              <1> 	; ecx = pixel count per row
  6317                              <1> 	; eax = color
  6318                              <1> 	; edi = start pixel address 
  6319                              <1> 
  6320                              <1> 	;mov	edx, eax
  6321                              <1> pix_op_and_32_0:
  6322                              <1> 	;and	eax, [edi]
  6323                              <1> 	;stosd
  6324                              <1> 	;mov	eax, edx
  6325 0000F3C8 2107                <1> 	and	[edi], eax
  6326 0000F3CA 83C704              <1> 	add	edi, 4
  6327 0000F3CD E2F9                <1> 	loop	pix_op_and_32_0
  6328 0000F3CF C3                  <1> 	retn
  6329                              <1> 
  6330                              <1> pix_op_xor_8:
  6331                              <1> 	; 8 bit colors (256 colors)
  6332                              <1> 	; XOR PIXEL COLOR
  6333                              <1> 	; ecx = pixel count per row
  6334                              <1> 	;  al = color
  6335                              <1> 	; edi = start pixel address 
  6336                              <1> 
  6337                              <1> pix_op_xor_8_0:
  6338 0000F3D0 3007                <1> 	xor	[edi], al
  6339 0000F3D2 47                  <1> 	inc	edi
  6340 0000F3D3 E2FB                <1> 	loop	pix_op_xor_8_0
  6341 0000F3D5 C3                  <1> 	retn
  6342                              <1> 
  6343                              <1> pix_op_xor_16:
  6344                              <1> 	; 16 bit colors (65536 colors)
  6345                              <1> 	; XOR PIXEL COLOR
  6346                              <1> 	; ecx = pixel count per row
  6347                              <1> 	;  ax = color
  6348                              <1> 	; edi = start pixel address 
  6349                              <1> 
  6350                              <1> pix_op_xor_16_0:
  6351 0000F3D6 663107              <1> 	xor	[edi], ax
  6352 0000F3D9 47                  <1> 	inc	edi
  6353 0000F3DA 47                  <1> 	inc	edi
  6354 0000F3DB E2F9                <1> 	loop	pix_op_xor_16_0
  6355 0000F3DD C3                  <1> 	retn
  6356                              <1> 
  6357                              <1> pix_op_xor_24:
  6358                              <1> 	; 24 bit true colors
  6359                              <1> 	; XOR PIXEL COLOR
  6360                              <1> 	; ecx = pixel count per row
  6361                              <1> 	; eax = color
  6362                              <1> 	; edi = start pixel address 
  6363                              <1> 
  6364 0000F3DE 89C2                <1> 	mov	edx, eax
  6365                              <1> pix_op_xor_24_0:
  6366 0000F3E0 3307                <1> 	xor	eax, [edi]
  6367 0000F3E2 66AB                <1> 	stosw
  6368 0000F3E4 C1E810              <1> 	shr	eax, 16
  6369 0000F3E7 AA                  <1> 	stosb	
  6370 0000F3E8 89D0                <1> 	mov	eax, edx
  6371 0000F3EA E2F4                <1> 	loop	pix_op_xor_24_0
  6372 0000F3EC C3                  <1> 	retn
  6373                              <1> 
  6374                              <1> pix_op_xor_32:
  6375                              <1> 	; 32 bit true colors
  6376                              <1> 	; XOR PIXEL COLOR
  6377                              <1> 	; ecx = pixel count per row
  6378                              <1> 	; eax = color
  6379                              <1> 	; edi = start pixel address 
  6380                              <1> 
  6381                              <1> 	;mov	edx, eax
  6382                              <1> pix_op_xor_32_0:
  6383                              <1> 	;xor	eax, [edi]
  6384                              <1> 	;stosd
  6385                              <1> 	;mov	eax, edx
  6386 0000F3ED 3107                <1> 	xor	[edi], eax
  6387 0000F3EF 83C704              <1> 	add	edi, 4
  6388 0000F3F2 E2F9                <1> 	loop	pix_op_xor_32_0
  6389 0000F3F4 C3                  <1> 	retn
  6390                              <1> 
  6391                              <1> pix_op_mix_8:
  6392                              <1> 	; 8 bit colors (256 colors)
  6393                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6394                              <1> 	; ecx = pixel count per row
  6395                              <1> 	;  al = color
  6396                              <1> 	; edi = start pixel address 
  6397                              <1> 
  6398 0000F3F5 88C4                <1> 	mov	ah, al
  6399                              <1> pix_op_mix_8_0:
  6400 0000F3F7 0207                <1> 	add	al, [edi]
  6401 0000F3F9 D0D8                <1> 	rcr	al, 1
  6402 0000F3FB AA                  <1> 	stosb
  6403 0000F3FC 88E0                <1> 	mov	al, ah
  6404 0000F3FE E2F7                <1> 	loop	pix_op_mix_8_0
  6405 0000F400 C3                  <1> 	retn
  6406                              <1> 
  6407                              <1> pix_op_mix_16:
  6408                              <1> 	; 16 bit colors (65536 colors)
  6409                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6410                              <1> 	; ecx = pixel count per row
  6411                              <1> 	;  ax = color
  6412                              <1> 	; edi = start pixel address 
  6413                              <1> 
  6414 0000F401 89C2                <1> 	mov	edx, eax
  6415                              <1> pix_op_mix_16_0:
  6416 0000F403 660307              <1> 	add	ax, [edi]
  6417 0000F406 66D1D8              <1> 	rcr	ax, 1
  6418 0000F409 66AB                <1> 	stosw
  6419 0000F40B 89D0                <1> 	mov	eax, edx
  6420 0000F40D E2F4                <1> 	loop	pix_op_mix_16_0
  6421 0000F40F C3                  <1> 	retn
  6422                              <1> 
  6423                              <1> pix_op_mix_24:
  6424                              <1> 	; 24 bit true colors
  6425                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6426                              <1> 	; ecx = pixel count per row
  6427                              <1> 	; eax = color
  6428                              <1> 	; edi = start pixel address 
  6429                              <1> 
  6430 0000F410 53                  <1> 	push	ebx
  6431 0000F411 BBFFFFFF00          <1> 	mov	ebx, 0FFFFFFh
  6432                              <1> 	;and	eax, ebx ; 0FFFFFFh
  6433 0000F416 89C2                <1> 	mov	edx, eax
  6434                              <1> pix_op_mix_24_0:
  6435 0000F418 8B07                <1> 	mov	eax, [edi]
  6436 0000F41A 21D8                <1> 	and	eax, ebx ; 0FFFFFFh
  6437 0000F41C 01D0                <1> 	add	eax, edx
  6438 0000F41E D1E8                <1> 	shr	eax, 1
  6439                              <1> 	;rcr	eax, 1
  6440 0000F420 66AB                <1> 	stosw
  6441 0000F422 C1E810              <1> 	shr	eax, 16
  6442 0000F425 AA                  <1> 	stosb
  6443 0000F426 E2F0                <1> 	loop	pix_op_mix_24_0
  6444 0000F428 89D0                <1> 	mov	eax, edx
  6445 0000F42A 5B                  <1> 	pop	ebx
  6446 0000F42B C3                  <1> 	retn
  6447                              <1> 
  6448                              <1> pix_op_mix_32:
  6449                              <1> 	; 32 bit true colors
  6450                              <1> 	; MIX (AVERAGE) PIXEL COLORS
  6451                              <1> 	; ecx = pixel count per row
  6452                              <1> 	; eax = color
  6453                              <1> 	; edi = start pixel address 
  6454                              <1> 
  6455 0000F42C 89C2                <1> 	mov	edx, eax
  6456                              <1> pix_op_mix_32_0:
  6457 0000F42E 0307                <1> 	add	eax, [edi]
  6458 0000F430 D1D8                <1> 	rcr	eax, 1	
  6459 0000F432 AB                  <1> 	stosd
  6460 0000F433 89D0                <1> 	mov	eax, edx
  6461 0000F435 E2F7                <1> 	loop	pix_op_mix_32_0
  6462 0000F437 C3                  <1> 	retn
  6463                              <1> 
  6464                              <1> pix_op_not_8:
  6465                              <1> 	; 8 bit colors (256 colors)
  6466                              <1> 	; NOT PIXEL COLOR
  6467                              <1> 	; ecx = pixel count per row
  6468                              <1> 	; edi = start pixel address 
  6469                              <1> 
  6470                              <1> pix_op_not_8_0:
  6471 0000F438 F617                <1> 	not	byte [edi]
  6472 0000F43A 47                  <1> 	inc	edi
  6473 0000F43B E2FB                <1> 	loop	pix_op_not_8_0
  6474 0000F43D C3                  <1> 	retn
  6475                              <1> 
  6476                              <1> pix_op_not_16:
  6477                              <1> 	; 16 bit colors (65536 colors)
  6478                              <1> 	; NOT PIXEL COLOR
  6479                              <1> 	; ecx = pixel count per row
  6480                              <1> 	; edi = start pixel address 
  6481                              <1> 
  6482                              <1> pix_op_not_16_0:
  6483 0000F43E 66F717              <1> 	not	word [edi]
  6484 0000F441 47                  <1> 	inc	edi
  6485 0000F442 47                  <1> 	inc	edi
  6486 0000F443 E2F9                <1> 	loop	pix_op_not_16_0
  6487 0000F445 C3                  <1> 	retn
  6488                              <1> 
  6489                              <1> pix_op_not_24:
  6490                              <1> 	; 24 bit true colors
  6491                              <1> 	; NOT PIXEL COLOR
  6492                              <1> 	; ecx = pixel count per row
  6493                              <1> 	; edi = start pixel address 
  6494                              <1> 
  6495                              <1> pix_op_not_24_0:
  6496 0000F446 66F717              <1> 	not	word [edi]
  6497 0000F449 47                  <1> 	inc	edi
  6498 0000F44A 47                  <1> 	inc	edi
  6499 0000F44B F617                <1> 	not	byte [edi]
  6500 0000F44D 47                  <1> 	inc	edi
  6501 0000F44E E2F6                <1> 	loop	pix_op_not_24_0
  6502 0000F450 C3                  <1> 	retn
  6503                              <1> 
  6504                              <1> pix_op_not_32:
  6505                              <1> 	; 32 bit true colors
  6506                              <1> 	; NOT PIXEL COLOR
  6507                              <1> 	; ecx = pixel count per row
  6508                              <1> 	; eax = color
  6509                              <1> 	; edi = start pixel address 
  6510                              <1> pix_op_not_32_0:
  6511 0000F451 F717                <1> 	not	dword [edi]
  6512 0000F453 83C704              <1> 	add	edi, 4
  6513 0000F456 E2F9                <1> 	loop	pix_op_not_32_0
  6514 0000F458 C3                  <1> 	retn
  6515                              <1> 
  6516                              <1> pix_op_neg_8:
  6517                              <1> 	; 8 bit colors (256 colors)
  6518                              <1> 	; NEG PIXEL COLOR
  6519                              <1> 	; ecx = pixel count per row
  6520                              <1> 	; edi = start pixel address 
  6521                              <1> 
  6522                              <1> pix_op_neg_8_0:
  6523 0000F459 F61F                <1> 	neg	byte [edi]
  6524 0000F45B 47                  <1> 	inc	edi
  6525 0000F45C E2FB                <1> 	loop	pix_op_neg_8_0
  6526 0000F45E C3                  <1> 	retn
  6527                              <1> 
  6528                              <1> pix_op_neg_16:
  6529                              <1> 	; 16 bit colors (65536 colors)
  6530                              <1> 	; NEG PIXEL COLOR
  6531                              <1> 	; ecx = pixel count per row
  6532                              <1> 	; edi = start pixel address 
  6533                              <1> 
  6534                              <1> pix_op_neg_16_0:
  6535 0000F45F 66F71F              <1> 	neg	word [edi]
  6536 0000F462 47                  <1> 	inc	edi
  6537 0000F463 47                  <1> 	inc	edi
  6538 0000F464 E2F9                <1> 	loop	pix_op_neg_16_0
  6539 0000F466 C3                  <1> 	retn
  6540                              <1> 
  6541                              <1> pix_op_neg_24:
  6542                              <1> 	; 24 bit true colors
  6543                              <1> 	; NEG PIXEL COLOR
  6544                              <1> 	; ecx = pixel count per row
  6545                              <1> 	; edi = start pixel address 
  6546                              <1> 
  6547                              <1> pix_op_neg_24_0:
  6548 0000F467 8B07                <1> 	mov	eax, [edi]
  6549 0000F469 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6550 0000F46E F7D8                <1> 	neg	eax
  6551 0000F470 66AB                <1> 	stosw
  6552 0000F472 C1E810              <1> 	shr	eax, 16
  6553 0000F475 AA                  <1> 	stosb
  6554 0000F476 E2EF                <1> 	loop	pix_op_neg_24_0
  6555 0000F478 C3                  <1> 	retn
  6556                              <1> 
  6557                              <1> pix_op_neg_32:
  6558                              <1> 	; 32 bit true colors
  6559                              <1> 	; NEG PIXEL COLOR
  6560                              <1> 	; ecx = pixel count per row
  6561                              <1> 	; eax = color
  6562                              <1> 	; edi = start pixel address 
  6563                              <1> pix_op_neg_32_0:
  6564 0000F479 F71F                <1> 	neg	dword [edi]
  6565 0000F47B 83C704              <1> 	add	edi, 4
  6566 0000F47E E2F9                <1> 	loop	pix_op_neg_32_0
  6567 0000F480 C3                  <1> 	retn
  6568                              <1> 
  6569                              <1> pix_op_inc_8:
  6570                              <1> 	; 8 bit colors (256 colors)
  6571                              <1> 	; INCREASE PIXEL COLOR
  6572                              <1> 	; ecx = pixel count per row
  6573                              <1> 	; edi = start pixel address 
  6574                              <1> 
  6575                              <1> pix_op_inc_8_0:
  6576 0000F481 FE07                <1> 	inc	byte [edi]
  6577 0000F483 7502                <1> 	jnz	short pix_op_inc_8_1
  6578                              <1> 	;mov	[edi], 0FFh ; Max. value	
  6579 0000F485 FE0F                <1> 	dec	byte [edi]
  6580                              <1> pix_op_inc_8_1:
  6581 0000F487 47                  <1> 	inc	edi
  6582 0000F488 E2F7                <1> 	loop	pix_op_inc_8_0
  6583 0000F48A C3                  <1> 	retn
  6584                              <1> 
  6585                              <1> pix_op_inc_16:
  6586                              <1> 	; 16 bit colors (65536 colors)
  6587                              <1> 	; INCREASE PIXEL COLOR
  6588                              <1> 	; ecx = pixel count per row
  6589                              <1> 	; edi = start pixel address 
  6590                              <1> 
  6591                              <1> pix_op_inc_16_0:
  6592 0000F48B 66FF07              <1> 	inc	word [edi]
  6593 0000F48E 7503                <1> 	jnz	short pix_op_inc_16_1
  6594                              <1> 	;mov	word [edi], 0FFFFh ; Max. value
  6595 0000F490 66FF0F              <1> 	dec	word [edi]
  6596                              <1> pix_op_inc_16_1:
  6597 0000F493 47                  <1> 	inc	edi
  6598 0000F494 47                  <1> 	inc	edi
  6599 0000F495 E2F4                <1> 	loop	pix_op_inc_16_0
  6600 0000F497 C3                  <1> 	retn
  6601                              <1> 
  6602                              <1> pix_op_inc_24:
  6603                              <1> 	; 24 bit true colors
  6604                              <1> 	; INCREASE PIXEL COLOR
  6605                              <1> 	; ecx = pixel count per row
  6606                              <1> 	; edi = start pixel address 
  6607                              <1> 
  6608                              <1> pix_op_inc_24_0:
  6609 0000F498 8B07                <1> 	mov	eax, [edi]
  6610 0000F49A 40                  <1> 	inc	eax
  6611 0000F49B 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6612 0000F4A0 7501                <1> 	jnz	short pix_op_inc_24_1
  6613                              <1> 	;mov	eax, 0FFFFFFh  ; Max. value
  6614 0000F4A2 48                  <1> 	dec	eax ; 0FFFFFFFFh
  6615                              <1> pix_op_inc_24_1: 
  6616 0000F4A3 66AB                <1> 	stosw
  6617 0000F4A5 C1E810              <1> 	shr	eax, 16
  6618 0000F4A8 AA                  <1> 	stosb
  6619 0000F4A9 E2ED                <1> 	loop	pix_op_inc_24_0
  6620 0000F4AB C3                  <1> 	retn
  6621                              <1> 
  6622                              <1> pix_op_inc_32:
  6623                              <1> 	; 32 bit true colors
  6624                              <1> 	; INCREASE PIXEL COLOR
  6625                              <1> 	; ecx = pixel count per row
  6626                              <1> 	; edi = start pixel address 
  6627                              <1> 
  6628                              <1> pix_op_inc_32_0:
  6629 0000F4AC FF07                <1> 	inc	dword [edi]
  6630 0000F4AE 7502                <1> 	jnz	short pix_op_inc_32_1
  6631                              <1> 	;mov	dword [edi], 0FFFFFFFFh ; Max. value
  6632 0000F4B0 FF0F                <1> 	dec	dword [edi]
  6633                              <1> pix_op_inc_32_1:
  6634 0000F4B2 83C704              <1> 	add	edi, 4
  6635 0000F4B5 E2F5                <1> 	loop	pix_op_inc_32_0
  6636 0000F4B7 C3                  <1> 	retn
  6637                              <1> 
  6638                              <1> pix_op_dec_8:
  6639                              <1> 	; 8 bit colors (256 colors)
  6640                              <1> 	; DECREASE PIXEL COLOR
  6641                              <1> 	; ecx = pixel count per row
  6642                              <1> 	; edi = start pixel address 
  6643                              <1> 
  6644                              <1> pix_op_dec_8_0:
  6645 0000F4B8 FE0F                <1> 	dec	byte [edi]
  6646 0000F4BA 7902                <1> 	jns	short pix_op_dec_8_1
  6647 0000F4BC FE07                <1> 	inc	byte [edi] ; 0 ; Min. value	
  6648                              <1> pix_op_dec_8_1:
  6649 0000F4BE 47                  <1> 	inc	edi
  6650 0000F4BF E2F7                <1> 	loop	pix_op_dec_8_0
  6651 0000F4C1 C3                  <1> 	retn
  6652                              <1> 
  6653                              <1> pix_op_dec_16:
  6654                              <1> 	; 16 bit colors (65536 colors)
  6655                              <1> 	; DECREASE PIXEL COLOR
  6656                              <1> 	; ecx = pixel count per row
  6657                              <1> 	; edi = start pixel address 
  6658                              <1> 
  6659                              <1> pix_op_dec_16_0:
  6660 0000F4C2 66FF0F              <1> 	dec	word [edi]
  6661 0000F4C5 7903                <1> 	jns	short pix_op_dec_16_1
  6662 0000F4C7 66FF07              <1> 	inc	word [edi] ; 0 ; Min. value	
  6663                              <1> pix_op_dec_16_1:
  6664 0000F4CA 47                  <1> 	inc edi
  6665 0000F4CB 47                  <1> 	inc edi
  6666 0000F4CC E2F4                <1> 	loop	pix_op_dec_16_0
  6667 0000F4CE C3                  <1> 	retn
  6668                              <1> 
  6669                              <1> pix_op_dec_24:
  6670                              <1> 	; 24 bit true colors
  6671                              <1> 	; DECREASE PIXEL COLOR
  6672                              <1> 	; ecx = pixel count per row
  6673                              <1> 	; edi = start pixel address 
  6674                              <1> 
  6675                              <1> pix_op_dec_24_0:
  6676 0000F4CF 8B07                <1> 	mov	eax, [edi]
  6677 0000F4D1 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  6678 0000F4D6 7401                <1> 	jz	short pix_op_dec_24_1
  6679                              <1> 			; 0 ; Min. value
  6680 0000F4D8 48                  <1> 	dec	eax
  6681                              <1> pix_op_dec_24_1:
  6682 0000F4D9 66AB                <1> 	stosw
  6683 0000F4DB C1E810              <1> 	shr	eax, 16
  6684 0000F4DE AA                  <1> 	stosb
  6685 0000F4DF E2B7                <1> 	loop	pix_op_inc_24_0
  6686 0000F4E1 C3                  <1> 	retn
  6687                              <1> 
  6688                              <1> pix_op_dec_32:
  6689                              <1> 	; 32 bit true colors
  6690                              <1> 	; DECREASE PIXEL COLOR
  6691                              <1> 	; ecx = pixel count per row
  6692                              <1> 	; edi = start pixel address 
  6693                              <1> 
  6694                              <1> pix_op_dec_32_0:
  6695 0000F4E2 FF0F                <1> 	dec	dword [edi]
  6696 0000F4E4 7902                <1> 	jns	short pix_op_dec_32_1
  6697 0000F4E6 FF07                <1> 	inc	dword [edi] ; 0 ; Min. value
  6698                              <1> pix_op_dec_32_1:
  6699 0000F4E8 83C704              <1> 	add	edi, 4
  6700 0000F4EB E2F5                <1> 	loop	pix_op_dec_32_0
  6701 0000F4ED 89D0                <1> 	mov	eax, edx
  6702 0000F4EF C3                  <1> 	retn
  6703                              <1> 
  6704                              <1> pix_op_rpl_8:
  6705                              <1> 	; 8 bit colors (256 colors)
  6706                              <1> 	; REPLACE PIXEL COLORS
  6707                              <1> 	; ecx = pixel count per row
  6708                              <1> 	;  al = new color
  6709                              <1> 	; byte [maskcolor] = old color
  6710                              <1> 	; edi = start pixel address
  6711                              <1> 
  6712 0000F4F0 8A25[9A120300]      <1> 	mov	ah, [maskcolor]
  6713                              <1> pix_op_rpl_8_0:
  6714 0000F4F6 3A27                <1> 	cmp	ah, [edi]
  6715 0000F4F8 7502                <1> 	jne	short pix_op_rpl_8_1
  6716 0000F4FA 8807                <1> 	mov	[edi], al
  6717                              <1> pix_op_rpl_8_1:
  6718 0000F4FC 47                  <1> 	inc	edi
  6719 0000F4FD E2F7                <1> 	loop	pix_op_rpl_8_0
  6720 0000F4FF C3                  <1> 	retn
  6721                              <1> 
  6722                              <1> pix_op_rpl_16:
  6723                              <1> 	; 16 bit colors (65536 colors)
  6724                              <1> 	; REPLACE PIXEL COLORS
  6725                              <1> 	; ecx = pixel count per row
  6726                              <1> 	;  ax = new color
  6727                              <1> 	; word [maskcolor] = old color
  6728                              <1> 	; edi = start pixel address
  6729                              <1> 
  6730 0000F500 8B15[9A120300]      <1> 	mov	edx, [maskcolor]
  6731                              <1> pix_op_rpl_16_0:
  6732 0000F506 663B17              <1> 	cmp	dx, [edi]
  6733 0000F509 7503                <1> 	jne	short pix_op_rpl_16_1
  6734 0000F50B 668907              <1> 	mov	[edi], ax
  6735                              <1> pix_op_rpl_16_1:
  6736 0000F50E 47                  <1> 	inc	edi
  6737 0000F50F 47                  <1> 	inc	edi
  6738 0000F510 E2F4                <1> 	loop	pix_op_rpl_16_0
  6739 0000F512 C3                  <1> 	retn
  6740                              <1> 
  6741                              <1> pix_op_rpl_24:
  6742                              <1> 	; 24 bit true colors
  6743                              <1> 	; REPLACE PIXEL COLORS
  6744                              <1> 	; ecx = pixel count per row
  6745                              <1> 	; eax = new color
  6746                              <1> 	; [maskcolor] = old color
  6747                              <1> 	; edi = start pixel address
  6748                              <1> 
  6749                              <1> pix_op_rpl_24_0:
  6750 0000F513 8B17                <1> 	mov	edx, [edi]
  6751 0000F515 81E2FFFFFF00        <1> 	and	edx, 0FFFFFFh
  6752 0000F51B 3B15[9A120300]      <1> 	cmp	edx, [maskcolor]
  6753 0000F521 7406                <1> 	je	short pix_op_rpl_24_1
  6754 0000F523 83C703              <1> 	add	edi, 3
  6755 0000F526 E2EB                <1> 	loop	pix_op_rpl_24_0
  6756 0000F528 C3                  <1> 	retn
  6757                              <1> pix_op_rpl_24_1: 
  6758 0000F529 AA                  <1> 	stosb
  6759 0000F52A C1C808              <1> 	ror	eax, 8
  6760 0000F52D 66AB                <1> 	stosw
  6761 0000F52F C1C008              <1> 	rol	eax, 8
  6762 0000F532 E2DF                <1> 	loop	pix_op_rpl_24_0
  6763 0000F534 C3                  <1> 	retn
  6764                              <1> 
  6765                              <1> pix_op_rpl_32:
  6766                              <1> 	; 32 bit true colors
  6767                              <1> 	; REPLACE PIXEL COLORS
  6768                              <1> 	; ecx = pixel count per row
  6769                              <1> 	; eax = new color
  6770                              <1> 	; [maskcolor] = old color
  6771                              <1> 	; edi = start pixel address
  6772                              <1> 
  6773 0000F535 8B15[9A120300]      <1> 	mov	edx, [maskcolor]
  6774                              <1> pix_op_rpl_32_0:
  6775 0000F53B 3B17                <1> 	cmp	edx, [edi]
  6776 0000F53D 7504                <1> 	jne	short pix_op_rpl_32_2
  6777 0000F53F AB                  <1> 	stosd
  6778 0000F540 E2F9                <1> 	loop	pix_op_rpl_32_0
  6779 0000F542 C3                  <1> 	retn	
  6780                              <1> pix_op_rpl_32_2:
  6781 0000F543 83C704              <1> 	add	edi, 4
  6782 0000F546 E2F3                <1> 	loop	pix_op_rpl_32_0
  6783 0000F548 C3                  <1> 	retn
  6784                              <1> 
  6785                              <1> pix_op_chr:
  6786                              <1> 	; 15/02/2021
  6787                              <1> 	; 05/02/2021
  6788                              <1> 	; WRITE CHARACTER (FONT)
  6789                              <1> 	; 05/01/2021 ([ufont])
  6790                              <1> 	; 01/01/2021
  6791                              <1> 	;     CL = char's color (8 bit, 256 colors)
  6792                              <1> 	;    ECX = char's color (16 bit and true colors)
  6793                              <1> 	;     DL = Character's ASCII code
  6794                              <1> 	;     DH bit 0 -> font height
  6795                              <1> 	;	  0 -> 8x16 character font
  6796                              <1> 	;	  1 -> 8x8 character font
  6797                              <1> 	;     DH bit 1 & 2 -> scale	
  6798                              <1> 	;	  0 = 1/1 (8 pixels per char row)
  6799                              <1> 	;	  1 = 2/1 (16 pixels per char row)
  6800                              <1> 	;	  2 = 3/1 (24 pixels per char row)
  6801                              <1> 	;	  3 = 4/1 (32 pixels per char row) 
  6802                              <1> 	;     DH bit 6 -> [ufont] option (1 = use [ufont])
  6803                              <1> 	;     If DH bit 7 = 1
  6804                              <1> 	;	 USER FONT (from user buffer)
  6805                              <1> 	;	    DL = 0 -> 8x8 (width: 1 byte per row)
  6806                              <1> 	;	    DL = 1 -> 8x16
  6807                              <1> 	;	    DL = 2 -> 16x16 (width: 2 bytes)
  6808                              <1> 	;	    DL = 3 -> 16x32
  6809                              <1> 	;	    DL = 4 -> 24x24 (width: 3 bytes)
  6810                              <1> 	;	    DL = 5 -> 24x48
  6811                              <1> 	;	    DL = 6 -> 32x32 (width: 4 bytes)
  6812                              <1> 	;	    DL = 7 -> 32x64
  6813                              <1> 	;	    DL > 7 -> invalid (unused)
  6814                              <1> 	;	 EDI = user's font buffer address
  6815                              <1> 	;	    (NOTE: byte order is as row0,row1,row2..)
  6816                              <1> 	;     ESI = start position (row, column) (*)
  6817                              <1> 	;	     (HW = row, SI = column)
  6818                              <1> 
  6819 0000F549 89F0                <1> 	mov	eax, esi ; start position
  6820 0000F54B E855F2FFFF          <1> 	call	calc_pixel_offset
  6821 0000F550 3B05[8E120300]      <1> 	cmp	eax, [v_siz]
  6822 0000F556 736D                <1> 	jnb	short pix_op_chr_err ; out of display page!
  6823 0000F558 E825F2FFFF          <1> 	call	pixels_to_byte_count
  6824                              <1> 	; eax = font start offset
  6825 0000F55D 0305[8A120300]      <1> 	add	eax, [v_mem] ; LFB start address
  6826 0000F563 A3[92120300]        <1> 	mov	[v_str], eax ; font start address 
  6827                              <1> 
  6828 0000F568 890D[9A120300]      <1> 	mov	[maskcolor], ecx ; save char's color
  6829                              <1> 
  6830 0000F56E 8835[88120300]      <1> 	mov	[v_ops], dh
  6831                              <1> 
  6832 0000F574 81E6FFFF0000        <1> 	and	esi, 0FFFFh
  6833 0000F57A 8935[A2120300]      <1> 	mov	[buffer8], esi ; start column
  6834                              <1> 
  6835 0000F580 31DB                <1> 	xor	ebx, ebx ; 0
  6836 0000F582 31C0                <1> 	xor	eax, eax ; 15/02/2021
  6837                              <1> 
  6838 0000F584 F6C680              <1> 	test	dh, 80h
  6839 0000F587 7577                <1> 	jnz	short pix_op_chr_u ; user font
  6840                              <1> 
  6841 0000F589 80E63F              <1> 	and	dh, 3Fh ; clear bit 6, [UFONT] option bit
  6842 0000F58C 7409                <1> 	jz	short pix_op_chr_0
  6843                              <1> 
  6844 0000F58E 80FE07              <1> 	cmp	dh, 7
  6845 0000F591 7732                <1> 	ja	short pix_op_chr_err
  6846                              <1> 			 ; invalid (undefined) option 
  6847 0000F593 88F4                <1> 	mov	ah, dh
  6848 0000F595 D0EC                <1> 	shr	ah, 1
  6849                              <1> 	; ah = 0 to 3, scale
  6850                              <1> 	;jmp	short pix_op_chr_font_pixels
  6851                              <1> 
  6852                              <1> pix_op_chr_font_pixels:
  6853                              <1> 	; 05/02/2021
  6854                              <1> 	; write scaled font to buffer
  6855                              <1> 
  6856                              <1> 	; DL = ASCII code of character
  6857                              <1> 	; AH = scale
  6858                              <1> 	; EDI = buffer address (kernel)
  6859                              <1> 
  6860                              <1> pix_op_chr_0:
  6861 0000F597 88D3                <1> 	mov	bl, dl ; 15/02/2021
  6862 0000F599 31C9                <1> 	xor	ecx, ecx
  6863 0000F59B B610                <1> 	mov	dh, 16
  6864 0000F59D F605[88120300]01    <1> 	test	byte [v_ops], 1 ; 8x8 font ?
  6865 0000F5A4 7428                <1> 	jz	short pix_op_chr_2 ; 8x16 font 
  6866 0000F5A6 B608                <1> 	mov	dh, 8
  6867 0000F5A8 C1E303              <1> 	shl	ebx, 3 ; * 8
  6868 0000F5AB F605[88120300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
  6869 0000F5B2 7412                <1> 	jz	short pix_op_chr_1  ; no
  6870                              <1> 	; test 8x8 user font is ready flag
  6871 0000F5B4 F605[7E120300]01    <1> 	test	byte [ufont], 1
  6872 0000F5BB 7409                <1> 	jz	short pix_op_chr_1 ; no
  6873 0000F5BD 81C300500900        <1> 	add	ebx, VGAFONT8USER
  6874 0000F5C3 EB2C                <1> 	jmp	short pix_op_chr_fpos_0
  6875                              <1> pix_op_chr_err:
  6876 0000F5C5 C3                  <1> 	retn
  6877                              <1> pix_op_chr_1:
  6878 0000F5C6 81C3[64600100]      <1> 	add	ebx, vgafont8 ; system font (8x8)
  6879 0000F5CC EB23                <1> 	jmp	short pix_op_chr_fpos_0
  6880                              <1> pix_op_chr_2:
  6881 0000F5CE C1E304              <1> 	shl	ebx, 4 ; * 16
  6882 0000F5D1 F605[88120300]40    <1> 	test	byte [v_ops], 40h ; [ufont] option
  6883 0000F5D8 7411                <1> 	jz	short pix_op_chr_3  ; no
  6884                              <1> 	; test 8x16 user font is ready flag
  6885 0000F5DA F605[7E120300]02    <1> 	test	byte [ufont], 2
  6886 0000F5E1 7408                <1> 	jz	short pix_op_chr_3 ; no
  6887 0000F5E3 81C300400900        <1> 	add	ebx, VGAFONT16USER
  6888 0000F5E9 EB06                <1> 	jmp	short pix_op_chr_fpos_0
  6889                              <1> pix_op_chr_3:
  6890 0000F5EB 81C3[64760100]      <1> 	add	ebx, vgafont16 ; system font (8x16)
  6891                              <1> pix_op_chr_fpos_0:
  6892 0000F5F1 20E4                <1> 	and	ah, ah
  6893 0000F5F3 754B                <1> 	jnz	short pix_op_chr_fpos_1 ; scale > 1 
  6894                              <1> 	; no scale (scale = 1)
  6895 0000F5F5 89DE                <1> 	mov	esi, ebx ; 15/02/2021
  6896 0000F5F7 88F1                <1> 	mov	cl, dh ; rows/height (16 or 8)	
  6897 0000F5F9 B608                <1> 	mov	dh, 8  ; columns/width
  6898 0000F5FB E9CD000000          <1> 	jmp	pix_op_chr_f2p
  6899                              <1> pix_op_chr_u:
  6900                              <1> 	; write user defined font 
  6901 0000F600 80FE80              <1> 	cmp	dh, 80h
  6902 0000F603 75C0                <1> 	jne	short pix_op_chr_err
  6903 0000F605 80FA07              <1> 	cmp	dl, 7
  6904 0000F608 77BB                <1> 	ja	short pix_op_chr_err
  6905                              <1> 
  6906                              <1> 	; 16/02/2021
  6907 0000F60A 89FE                <1> 	mov	esi, edi ; user's font buffer
  6908                              <1> 	
  6909                              <1> 	;xor	eax, eax
  6910                              <1> 	; eax = 0 ; 15/02/2021	
  6911 0000F60C 88D4                <1> 	mov	ah, dl
  6912 0000F60E D0EC                <1> 	shr	ah, 1
  6913 0000F610 FEC4                <1> 	inc	ah	
  6914                              <1> 	; ah =  1 to 4
  6915 0000F612 88E0                <1> 	mov	al, ah
  6916 0000F614 C0E003              <1> 	shl	al, 3 ; * 8
  6917                              <1> 	; al = 8,16,24,32
  6918 0000F617 88C3                <1> 	mov	bl, al
  6919 0000F619 88C7                <1> 	mov	bh, al
  6920 0000F61B F6E4                <1> 	mul	ah
  6921                              <1> 	; ax = 8,32,72,128 bytes 
  6922 0000F61D F6C201              <1> 	test	dl, 1
  6923 0000F620 7405                <1> 	jz	short pix_op_chr_u_0
  6924 0000F622 66D1E0              <1> 	shl	ax, 1 ; *2
  6925                              <1> 	; ax = 16,32,144,256 bytes
  6926 0000F625 D0E7                <1> 	shl	bh, 1
  6927                              <1> pix_op_chr_u_0:
  6928                              <1> 	; eax = byte count
  6929 0000F627 89C1                <1> 	mov	ecx, eax
  6930 0000F629 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
  6931                              <1> 	; esi = user buffer
  6932 0000F62E E81B250000          <1> 	call	transfer_from_user_buffer
  6933 0000F633 7290                <1> 	jc	short pix_op_chr_err
  6934                              <1> 
  6935 0000F635 88F9                <1> 	mov	cl, bh ; rows/height
  6936 0000F637 88DE                <1> 	mov	dh, bl ; columns (width)
  6937 0000F639 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
  6938 0000F63B E98D000000          <1> 	jmp	pix_op_chr_f2p
  6939                              <1> 
  6940                              <1> pix_op_chr_fpos_1:
  6941                              <1> 	; 18/02/2021
  6942                              <1> 	; scale > 1
  6943 0000F640 88F5                <1> 	mov	ch, dh ; 16 or 8
  6944 0000F642 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
  6945 0000F647 89FE                <1> 	mov	esi, edi
  6946 0000F649 FECC                <1> 	dec	ah
  6947 0000F64B 7523                <1> 	jnz	short pix_op_chr_fpos_5 ; scale > 2
  6948                              <1> 	; scale = 2
  6949                              <1> pix_op_chr_fpos_2:	
  6950 0000F64D B108                <1> 	mov	cl, 8
  6951 0000F64F 8A13                <1> 	mov	dl, [ebx]
  6952                              <1> pix_op_chr_fpos_3:
  6953 0000F651 66C1E002            <1> 	shl 	ax, 2
  6954 0000F655 D0E2                <1> 	shl	dl, 1
  6955 0000F657 7302                <1> 	jnc	short pix_op_chr_fpos_4
  6956 0000F659 0C03                <1> 	or	al, 3
  6957                              <1> pix_op_chr_fpos_4:
  6958 0000F65B FEC9                <1> 	dec	cl
  6959 0000F65D 75F2                <1> 	jnz	short pix_op_chr_fpos_3
  6960 0000F65F 66AB                <1> 	stosw
  6961                              <1> 	; 18/02/2021
  6962 0000F661 66AB                <1> 	stosw
  6963 0000F663 43                  <1> 	inc	ebx
  6964 0000F664 FECD                <1> 	dec	ch
  6965 0000F666 75E5                <1> 	jnz	short pix_op_chr_fpos_2
  6966                              <1> 	; scale = 2
  6967 0000F668 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
  6968 0000F66A D0E1                <1> 	shl	cl, 1  ; 32 or 16 rows
  6969 0000F66C B610                <1> 	mov	dh, 16 ; columns (width)
  6970 0000F66E EB5D                <1> 	jmp	short pix_op_chr_f2p
  6971                              <1> pix_op_chr_fpos_5:
  6972 0000F670 FECC                <1> 	dec	ah
  6973 0000F672 7538                <1> 	jnz	short pix_op_chr_fpos_9 ; scale = 4
  6974                              <1> 	; scale = 3
  6975                              <1> pix_op_chr_fpos_6:	
  6976 0000F674 B108                <1> 	mov	cl, 8
  6977 0000F676 8A13                <1> 	mov	dl, [ebx]
  6978                              <1> pix_op_chr_fpos_7:
  6979 0000F678 C1E003              <1> 	shl 	eax, 3
  6980 0000F67B D0E2                <1> 	shl	dl, 1 ; 18/02/2021
  6981 0000F67D 7302                <1> 	jnc	short pix_op_chr_fpos_8
  6982 0000F67F 0C07                <1> 	or	al, 7
  6983                              <1> pix_op_chr_fpos_8:
  6984 0000F681 FEC9                <1> 	dec	cl
  6985 0000F683 75F3                <1> 	jnz	short pix_op_chr_fpos_7
  6986 0000F685 66AB                <1> 	stosw
  6987                              <1> 	; 18/02/2021
  6988 0000F687 C1C810              <1> 	ror	eax, 16
  6989 0000F68A AA                  <1> 	stosb
  6990 0000F68B C1C010              <1> 	rol	eax, 16
  6991 0000F68E 66AB                <1> 	stosw
  6992 0000F690 C1C810              <1> 	ror	eax, 16
  6993 0000F693 AA                  <1> 	stosb	
  6994 0000F694 C1C010              <1> 	rol	eax, 16
  6995 0000F697 66AB                <1> 	stosw
  6996 0000F699 C1E810              <1> 	shr	eax, 16 ; 27/02/2021
  6997 0000F69C AA                  <1> 	stosb
  6998 0000F69D 43                  <1> 	inc	ebx
  6999                              <1> 	; 18/02/2021
  7000 0000F69E FECD                <1> 	dec	ch
  7001 0000F6A0 75D2                <1> 	jnz	short pix_op_chr_fpos_6
  7002                              <1> 	; scale = 3
  7003 0000F6A2 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
  7004 0000F6A4 D0E1                <1> 	shl	cl, 1 
  7005 0000F6A6 00F1                <1> 	add	cl, dh ; 48 or 24 rows
  7006 0000F6A8 B618                <1> 	mov	dh, 24 ; columns (width)
  7007 0000F6AA EB21                <1> 	jmp	short pix_op_chr_f2p
  7008                              <1> 
  7009                              <1> pix_op_chr_fpos_9:
  7010                              <1> 	; scale = 4
  7011 0000F6AC B108                <1> 	mov	cl, 8
  7012 0000F6AE 8A13                <1> 	mov	dl, [ebx]
  7013                              <1> pix_op_chr_fpos_10:
  7014                              <1> 	; 18/02/2021
  7015 0000F6B0 C1E004              <1> 	shl 	eax, 4
  7016 0000F6B3 D0E2                <1> 	shl	dl, 1 ; 18/02/2021
  7017 0000F6B5 7302                <1> 	jnc	short pix_op_chr_fpos_11
  7018 0000F6B7 0C0F                <1> 	or	al, 0Fh ; or al, 15
  7019                              <1> pix_op_chr_fpos_11:
  7020 0000F6B9 FEC9                <1> 	dec	cl
  7021 0000F6BB 75F3                <1> 	jnz	short pix_op_chr_fpos_10
  7022 0000F6BD AB                  <1> 	stosd
  7023                              <1> 	; 18/02/2021
  7024 0000F6BE AB                  <1> 	stosd
  7025 0000F6BF AB                  <1> 	stosd
  7026 0000F6C0 AB                  <1> 	stosd
  7027 0000F6C1 43                  <1> 	inc	ebx
  7028 0000F6C2 FECD                <1> 	dec	ch
  7029 0000F6C4 75E6                <1> 	jnz	short pix_op_chr_fpos_9
  7030                              <1> 	; scale = 4
  7031 0000F6C6 88F1                <1> 	mov	cl, dh ; 16 or 8 (height/rows)
  7032 0000F6C8 C0E102              <1> 	shl	cl, 2 ; 64 or 32 rows
  7033 0000F6CB B620                <1> 	mov	dh, 32 ; columns (width)
  7034                              <1> 	;jmp	short pix_op_chr_f2p
  7035                              <1>  	
  7036                              <1> pix_op_chr_f2p:
  7037                              <1> 	; write font pixels
  7038 0000F6CD 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7039                              <1> 	; 15/02/2021
  7040                              <1> pix_op_chr_f2p_next:
  7041 0000F6D3 80FE08              <1> 	cmp	dh, 8
  7042 0000F6D6 7706                <1> 	ja	short pix_op_chr_f2p_24
  7043                              <1> pix_op_chr_f2p_8:
  7044 0000F6D8 AC                  <1> 	lodsb
  7045 0000F6D9 C1E018              <1> 	shl	eax, 24 ; 15/02/2021
  7046 0000F6DC EB16                <1> 	jmp	short pix_op_chr_f2p_0
  7047                              <1> pix_op_chr_f2p_24:
  7048 0000F6DE 80FE18              <1> 	cmp	dh, 24
  7049 0000F6E1 7710                <1> 	ja	short pix_op_chr_f2p_32
  7050 0000F6E3 7207                <1> 	jb	short pix_op_chr_f2p_16	
  7051                              <1> 	; 27/02/2021
  7052                              <1> 	;mov	eax, [esi]
  7053 0000F6E5 AD                  <1> 	lodsd
  7054 0000F6E6 C1E008              <1> 	shl	eax, 8
  7055                              <1> 	;add	esi, 3
  7056 0000F6E9 4E                  <1> 	dec	esi
  7057 0000F6EA EB08                <1> 	jmp	short pix_op_chr_f2p_0
  7058                              <1> pix_op_chr_f2p_16:
  7059 0000F6EC 66AD                <1> 	lodsw
  7060 0000F6EE C1E010              <1> 	shl	eax, 16 ; 15/02/2021
  7061 0000F6F1 EB01                <1> 	jmp	short pix_op_chr_f2p_0
  7062                              <1> pix_op_chr_f2p_32:
  7063 0000F6F3 AD                  <1> 	lodsd
  7064                              <1> pix_op_chr_f2p_0:
  7065                              <1> 	; EAX = font row (8,16,24,32 pixels)
  7066                              <1> 	;	(bits are shifted to left)
  7067                              <1> 	; CL = rows
  7068                              <1> 	; DH = bits per row (8,16,24,32)
  7069 0000F6F4 8B1D[A2120300]      <1> 	mov	ebx, [buffer8] ; start column
  7070 0000F6FA 57                  <1> 	push	edi ; *
  7071 0000F6FB 52                  <1> 	push	edx ; **
  7072                              <1> pix_op_chr_f2p_1:
  7073 0000F6FC E82E000000          <1> 	call	pix_op_chr_w_pixel
  7074                              <1> pix_op_chr_f2p_2:
  7075 0000F701 663B1D[86120300]    <1> 	cmp	bx, [v_width] ; current column
  7076 0000F708 7304                <1> 	jnb	short pix_op_chr_f2p_3
  7077 0000F70A FECE                <1> 	dec	dh
  7078 0000F70C 75EE                <1> 	jnz	short pix_op_chr_f2p_1 ; next bit
  7079                              <1> pix_op_chr_f2p_3:
  7080                              <1> 	;mov	ebx, [buffer8]
  7081 0000F70E 5A                  <1> 	pop	edx ; **
  7082 0000F70F 58                  <1> 	pop	eax ; *
  7083 0000F710 3B3D[96120300]      <1> 	cmp	edi, [v_end]
  7084 0000F716 7316                <1> 	jnb	short pix_op_chr_f2p_4
  7085 0000F718 FEC9                <1> 	dec	cl
  7086 0000F71A 7412                <1> 	jz	short pix_op_chr_f2p_4
  7087                              <1> 	; 27/02/2021
  7088 0000F71C 89C7                <1> 	mov	edi, eax
  7089 0000F71E 0FB705[86120300]    <1> 	movzx	eax, word [v_width]
  7090 0000F725 E858F0FFFF          <1> 	call	pixels_to_byte_count
  7091 0000F72A 01C7                <1> 	add	edi, eax ; next position
  7092 0000F72C EBA5                <1> 	jmp	short pix_op_chr_f2p_next
  7093                              <1> pix_op_chr_f2p_4:
  7094 0000F72E C3                  <1> 	retn
  7095                              <1> 
  7096                              <1> pix_op_chr_w_pixel:
  7097                              <1> 	; 15/02/2021
  7098 0000F72F 89C5                <1> 	mov	ebp, eax
  7099 0000F731 A1[9A120300]        <1> 	mov	eax, [maskcolor]
  7100 0000F736 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7101 0000F73D 7711                <1> 	ja	short pix_op_chr_wp_2
  7102                              <1> 	; 256 colors (1 byte per pixel)
  7103 0000F73F D1E5                <1> 	shl	ebp, 1
  7104 0000F741 7302                <1> 	jnc	short pix_op_chr_wp_0
  7105 0000F743 8807                <1> 	mov	[edi], al
  7106                              <1> pix_op_chr_wp_0:
  7107 0000F745 47                  <1> 	inc	edi
  7108 0000F746 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  7109                              <1> pix_op_chr_wp_1:
  7110 0000F74C 43                  <1> 	inc	ebx
  7111 0000F74D 89E8                <1> 	mov	eax, ebp
  7112 0000F74F C3                  <1> 	retn
  7113                              <1> pix_op_chr_wp_2:
  7114 0000F750 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7115 0000F757 772E                <1> 	ja	short pix_op_chr_wp_6 ; 32bpp
  7116 0000F759 721C                <1> 	jb	short pix_op_chr_wp_4 ; 16bpp
  7117                              <1> 	; 24 bit true colors
  7118                              <1> 	; * 3
  7119 0000F75B D1E5                <1> 	shl	ebp, 1
  7120 0000F75D 7309                <1> 	jnc	short pix_op_chr_wp_3
  7121 0000F75F 668907              <1> 	mov	[edi], ax
  7122 0000F762 C1E810              <1> 	shr	eax, 16
  7123 0000F765 884702              <1> 	mov	[edi+2], al
  7124                              <1> pix_op_chr_wp_3:
  7125 0000F768 B803000000          <1> 	mov	eax, 3 ; 27/02/2021 
  7126 0000F76D 01C7                <1> 	add	edi, eax  ; add edi, 3
  7127 0000F76F 0105[64030300]      <1> 	add	[u.r0], eax ; +3
  7128                              <1> 	
  7129 0000F775 EBD5                <1> 	jmp	short pix_op_chr_wp_1
  7130                              <1> 
  7131                              <1> pix_op_chr_wp_4:
  7132                              <1> 	; 16 bit (65536) colors
  7133 0000F777 D1E5                <1> 	shl	ebp, 1
  7134 0000F779 7303                <1> 	jnc	short pix_op_chr_wp_5
  7135 0000F77B 668907              <1> 	mov	[edi], ax
  7136                              <1> pix_op_chr_wp_5:
  7137 0000F77E 47                  <1> 	inc	edi
  7138 0000F77F FF05[64030300]      <1> 	inc	dword [u.r0] ; +1 
  7139 0000F785 EBBE                <1> 	jmp	short pix_op_chr_wp_0
  7140                              <1> 
  7141                              <1> pix_op_chr_wp_6:
  7142                              <1> 	; 32 bit true colors
  7143 0000F787 D1E5                <1> 	shl	ebp, 1
  7144 0000F789 7302                <1> 	jnc	short pix_op_chr_wp_7
  7145 0000F78B 8907                <1> 	mov	[edi], eax
  7146                              <1> pix_op_chr_wp_7:
  7147 0000F78D 31C0                <1> 	xor	eax, eax
  7148 0000F78F B004                <1> 	mov	al, 4
  7149 0000F791 01C7                <1> 	add	edi, eax ; add edi, 4
  7150 0000F793 0105[64030300]      <1> 	add	[u.r0], eax ; +4
  7151 0000F799 EBB1                <1> 	jmp	short pix_op_chr_wp_1
  7152                              <1> 
  7153                              <1> m_pix_op_cpy:
  7154                              <1> 	; 26/02/2021
  7155                              <1> 	; 06/02/2021
  7156                              <1> 	; MASKED COPY PIXELS (full screen)
  7157                              <1> 	;
  7158                              <1> 	; jump from pix_op_cpy
  7159                              <1> 	;
  7160                              <1> 	; INPUT:
  7161                              <1> 	;   ecx = transfer count (bytes)
  7162                              <1> 	;   edi = [v_mem] = start address of LFB 
  7163                              <1> 	;   esi = user's buffer address (virtual)
  7164                              <1> 	;
  7165                              <1> 	; OUTPUT:
  7166                              <1> 	;   [u.r0] will be > 0 if succesful
  7167                              <1> 
  7168                              <1> 	; Full screen masked copy
  7169                              <1> 
  7170                              <1> 	; Modified regs: eax, ebx, edx, esi, edi, ecx
  7171                              <1> 
  7172                              <1> m_pix_op_cpy_0:
  7173                              <1> 	;push	ebx ; *** ; 26/02/2021
  7174 0000F79B 57                  <1> 	push	edi ; **
  7175 0000F79C 51                  <1> 	push	ecx ; *
  7176 0000F79D 81F9F8070000        <1> 	cmp	ecx, 2040 ; (3*680) ; 26/02/2021
  7177 0000F7A3 7605                <1> 	jna	short m_pix_op_cpy_1
  7178 0000F7A5 B9F8070000          <1> 	mov	ecx, 2040
  7179                              <1> m_pix_op_cpy_1:
  7180 0000F7AA BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; temporary buff
  7181 0000F7AF E89A230000          <1> 	call	transfer_from_user_buffer
  7182 0000F7B4 726C                <1> 	jc	short m_pix_op_cpy_3
  7183 0000F7B6 01CE                <1> 	add	esi, ecx
  7184 0000F7B8 89F5                <1> 	mov	ebp, esi  ; save user's buffer address
  7185 0000F7BA 89FE                <1> 	mov	esi, edi
  7186 0000F7BC 89CB                <1> 	mov	ebx, ecx
  7187 0000F7BE 59                  <1> 	pop	ecx ; *
  7188 0000F7BF 29D9                <1> 	sub	ecx, ebx
  7189 0000F7C1 5F                  <1> 	pop	edi ; **
  7190 0000F7C2 31D2                <1> 	xor	edx, edx ; 26/02/2021
  7191 0000F7C4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8
  7192 0000F7CB 7435                <1> 	je	short m_pix_op_cpy_1_8
  7193 0000F7CD 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24
  7194 0000F7D4 776D                <1> 	ja	short m_pix_op_cpy_1_32
  7195 0000F7D6 724D                <1> 	jb	short m_pix_op_cpy_1_16
  7196                              <1> m_pix_op_cpy_1_24:
  7197                              <1> 	; 24 bit masked copy
  7198                              <1> 	;mov	edx, 3
  7199 0000F7D8 B203                <1> 	mov	dl, 3 ; 26/02/2021
  7200                              <1> m_pix_op_cpy_1_24_0:
  7201 0000F7DA 66AD                <1> 	lodsw
  7202 0000F7DC C1E010              <1> 	shl	eax, 16
  7203 0000F7DF AC                  <1> 	lodsb
  7204 0000F7E0 C1C010              <1> 	rol	eax, 16
  7205 0000F7E3 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7206 0000F7E9 740F                <1> 	je	short m_pix_op_cpy_1_24_1 ; exclude
  7207 0000F7EB 668907              <1> 	mov	[edi], ax
  7208 0000F7EE C1E810              <1> 	shr	eax, 16
  7209 0000F7F1 884702              <1> 	mov	[edi+2], al
  7210 0000F7F4 0115[64030300]      <1> 	add	[u.r0], edx ; +3
  7211                              <1> m_pix_op_cpy_1_24_1:
  7212 0000F7FA 01D7                <1> 	add	edi, edx ; +3
  7213 0000F7FC 29D3                <1> 	sub	ebx, edx ; sub ebx, 3
  7214 0000F7FE 77DA                <1> 	ja	short m_pix_op_cpy_1_24_0
  7215 0000F800 EB15                <1>  	jmp	short m_pix_op_cpy_2
  7216                              <1> 
  7217                              <1> m_pix_op_cpy_1_8:
  7218                              <1> 	; 8 bit masked copy
  7219 0000F802 AC                  <1> 	lodsb
  7220 0000F803 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  7221 0000F809 7408                <1> 	je	short m_pix_op_cpy_1_8_1 ; exclude
  7222 0000F80B 8807                <1> 	mov	[edi], al
  7223 0000F80D FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  7224                              <1> m_pix_op_cpy_1_8_1:
  7225 0000F813 47                  <1> 	inc	edi ; +1
  7226 0000F814 4B                  <1> 	dec	ebx 	
  7227 0000F815 75EB                <1> 	jnz	short m_pix_op_cpy_1_8
  7228                              <1> m_pix_op_cpy_2:
  7229 0000F817 89EE                <1> 	mov	esi, ebp ; restore user's buffer addr
  7230 0000F819 09C9                <1> 	or	ecx, ecx
  7231                              <1> 	; 26/02/2021
  7232 0000F81B 7407                <1> 	jz	short m_pix_of_cpy_4
  7233 0000F81D E979FFFFFF          <1> 	jmp	m_pix_op_cpy_0
  7234                              <1> m_pix_op_cpy_3:
  7235 0000F822 59                  <1> 	pop	ecx ; *
  7236 0000F823 5F                  <1> 	pop	edi ; **
  7237                              <1> m_pix_of_cpy_4:
  7238                              <1> 	;pop	ebx ; *** ; 26/02/2021 
  7239 0000F824 C3                  <1> 	retn
  7240                              <1> 
  7241                              <1> m_pix_op_cpy_1_16:
  7242                              <1> 	; 16 bit masked copy
  7243                              <1> 	;mov	edx, 2
  7244 0000F825 B202                <1> 	mov	dl, 2 ; 26/02/2021
  7245                              <1> m_pix_op_cpy_1_16_0:
  7246 0000F827 66AD                <1> 	lodsw
  7247 0000F829 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  7248 0000F830 7409                <1> 	je	short m_pix_op_cpy_1_16_1 ; exclude
  7249 0000F832 668907              <1> 	mov	[edi], ax
  7250 0000F835 0115[64030300]      <1> 	add	[u.r0], edx ; +2
  7251                              <1> m_pix_op_cpy_1_16_1:
  7252 0000F83B 01D7                <1> 	add	edi, edx ; +2
  7253 0000F83D 29D3                <1> 	sub	ebx, edx ; sub ebx, 2
  7254 0000F83F 77E6                <1> 	ja	short m_pix_op_cpy_1_16_0
  7255 0000F841 EBD4                <1>  	jmp	short m_pix_op_cpy_2
  7256                              <1> 
  7257                              <1> m_pix_op_cpy_1_32:
  7258                              <1> 	; 32 bit masked copy
  7259                              <1> 	;mov	edx, 4
  7260 0000F843 B204                <1> 	mov	dl, 4 ; 26/02/2021
  7261                              <1> m_pix_op_cpy_1_32_0:
  7262 0000F845 AD                  <1> 	lodsd
  7263 0000F846 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7264 0000F84C 7408                <1> 	je	short m_pix_op_cpy_1_32_1 ; exclude
  7265 0000F84E 8907                <1> 	mov	[edi], eax
  7266 0000F850 0115[64030300]      <1> 	add	[u.r0], edx ; +4
  7267                              <1> m_pix_op_cpy_1_32_1:
  7268 0000F856 01D7                <1> 	add	edi, edx ; +4
  7269 0000F858 29D3                <1> 	sub	ebx, edx ; sub ebx, 4
  7270 0000F85A 77E9                <1> 	ja	short m_pix_op_cpy_1_32_0
  7271 0000F85C EBB9                <1>  	jmp	short m_pix_op_cpy_2
  7272                              <1> 	
  7273                              <1> m_pix_op_cpy_w:
  7274                              <1> 	; 26/02/2021
  7275                              <1> 	; 06/02/2021
  7276                              <1> 	; MASKED COPY PIXELS (window)
  7277                              <1> 	;
  7278                              <1> 	; jump from pix_op_cpy_w
  7279                              <1> 	;
  7280                              <1> 	; INPUT:
  7281                              <1> 	;   ecx = bytes per row (to be applied)
  7282                              <1> 	;   edx = screen width in bytes
  7283                              <1> 	;   ebx = row count
  7284                              <1> 	;   esi = user's buffer address
  7285                              <1> 	;   [v_str] = window start address
  7286                              <1> 	;
  7287                              <1> 	; OUTPUT:
  7288                              <1> 	;   [u.r0] will be > 0 if succesful
  7289                              <1> 
  7290                              <1> 	; Window masked copy
  7291                              <1> 
  7292                              <1> m_pix_op_cpy_w_0:
  7293 0000F85E 8B3D[92120300]      <1> 	mov	edi, [v_str]
  7294                              <1> m_pix_op_cpy_w_1:
  7295 0000F864 57                  <1> 	push	edi
  7296 0000F865 56                  <1> 	push	esi
  7297 0000F866 53                  <1> 	push	ebx
  7298 0000F867 52                  <1> 	push	edx
  7299 0000F868 51                  <1> 	push	ecx
  7300 0000F869 E82DFFFFFF          <1> 	call	m_pix_op_cpy ; 26/02/2021
  7301 0000F86E 59                  <1> 	pop	ecx
  7302 0000F86F 5A                  <1> 	pop	edx
  7303 0000F870 5B                  <1> 	pop	ebx
  7304 0000F871 5E                  <1> 	pop	esi
  7305 0000F872 5F                  <1> 	pop	edi
  7306 0000F873 7209                <1> 	jc	short m_pix_op_cpy_w_2
  7307 0000F875 4B                  <1> 	dec	ebx
  7308 0000F876 7406                <1> 	jz	short m_pix_op_cpy_w_2 ; ok.
  7309                              <1> 	; next row
  7310 0000F878 01CE                <1> 	add	esi, ecx ; next row in user's buffer
  7311 0000F87A 01D7                <1> 	add	edi, edx ; next row of window (system)
  7312 0000F87C EBE6                <1> 	jmp	short m_pix_op_cpy_w_1
  7313                              <1> m_pix_op_cpy_w_2:
  7314 0000F87E C3                  <1> 	retn
  7315                              <1> 
  7316                              <1> m_pix_op_new:
  7317                              <1> 	; 06/02/2021
  7318                              <1> 	; CHANGE COLOR (MASKED, full screen)
  7319                              <1> 	;
  7320                              <1> 	; jump from pix_op_new
  7321                              <1> 	;
  7322                              <1> 	; INPUT:
  7323                              <1> 	;   eax = color (AL, AX, EAX)
  7324                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7325                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7326                              <1> 	;
  7327                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7328                              <1> 	;
  7329                              <1> 	; OUTPUT:
  7330                              <1> 	; 	[u.r0] will be > 0 if succesful
  7331                              <1> 	
  7332                              <1> 	; Full screen
  7333                              <1> m_pix_op_new_0:
  7334 0000F87F 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7335 0000F886 7717                <1> 	ja	short m_pix_op_new_1
  7336                              <1> 	; 256 colors (8bpp)
  7337                              <1> 	;jmp	short m_pix_op_new_8
  7338                              <1> m_pix_op_new_8:
  7339                              <1> 	; 8 bit colors (256 colors)
  7340 0000F888 88C2                <1> 	mov	dl, al ; new color
  7341                              <1> m_pix_op_new_8_0:
  7342 0000F88A AC                  <1> 	lodsb 
  7343 0000F88B 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  7344 0000F891 7408                <1> 	je	short m_pix_op_new_8_1 ; exclude
  7345 0000F893 8817                <1> 	mov	[edi], dl
  7346 0000F895 FF05[64030300]      <1> 	inc	dword [u.r0]
  7347                              <1> m_pix_op_new_8_1:
  7348 0000F89B 47                  <1> 	inc	edi
  7349 0000F89C E2EC                <1> 	loop	m_pix_op_new_8_0
  7350 0000F89E C3                  <1> 	retn
  7351                              <1> m_pix_op_new_1:
  7352 0000F89F 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7353 0000F8A6 774B                <1> 	ja	short m_pix_op_new_3 ; 32bpp	
  7354 0000F8A8 722C                <1> 	jb	short m_pix_op_new_2 ; 16bpp
  7355                              <1> 	; 24 bit true colors
  7356                              <1> 	;jmp	short m_pix_op_new_24
  7357                              <1> m_pix_op_new_24:
  7358                              <1> 	; 24 bit true colors
  7359 0000F8AA 89C2                <1> 	mov	edx, eax ; new color
  7360                              <1> m_pix_op_new_24_0:
  7361 0000F8AC 66AD                <1> 	lodsw
  7362 0000F8AE C1E010              <1> 	shl	eax, 16
  7363 0000F8B1 AC                  <1> 	lodsb
  7364 0000F8B2 C1C010              <1> 	rol	eax, 16	
  7365 0000F8B5 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7366 0000F8BB 7413                <1> 	je	short m_pix_op_new_24_1 ; exclude
  7367 0000F8BD 668917              <1> 	mov	[edi], dx
  7368 0000F8C0 C1CA10              <1> 	ror	edx, 16
  7369 0000F8C3 885702              <1> 	mov	[edi+2], dl
  7370 0000F8C6 C1C210              <1> 	rol	edx, 16
  7371 0000F8C9 8305[64030300]03    <1> 	add	dword [u.r0], 3
  7372                              <1> m_pix_op_new_24_1:
  7373 0000F8D0 83C703              <1> 	add	edi, 3
  7374 0000F8D3 E2D7                <1> 	loop	m_pix_op_new_24_0
  7375 0000F8D5 C3                  <1> 	retn
  7376                              <1> 	; 65536 colors (16bpp)
  7377                              <1> m_pix_op_new_2:
  7378                              <1> 	;jmp	short m_pix_op_new_16
  7379                              <1> m_pix_op_new_16:
  7380                              <1> 	; 16 bit colors (65536 colors)
  7381 0000F8D6 89C2                <1> 	mov	edx, eax ; new color
  7382                              <1> m_pix_op_new_16_0:
  7383 0000F8D8 66AD                <1> 	lodsw
  7384 0000F8DA 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  7385 0000F8E1 740A                <1> 	je	short m_pix_op_new_16_1 ; exclude
  7386 0000F8E3 668917              <1> 	mov	[edi], dx
  7387 0000F8E6 8305[64030300]02    <1> 	add	dword [u.r0], 2
  7388                              <1> m_pix_op_new_16_1:
  7389 0000F8ED 83C702              <1> 	add	edi, 2
  7390 0000F8F0 E2E6                <1> 	loop	m_pix_op_new_16_0
  7391 0000F8F2 C3                  <1> 	retn
  7392                              <1> m_pix_op_new_3:
  7393                              <1> 	; 32 bit true colors
  7394                              <1> 	;jmp	short m_pix_op_new_32
  7395                              <1> m_pix_op_new_32:
  7396                              <1> 	; 32 bit true colors
  7397 0000F8F3 89C2                <1> 	mov	edx, eax ; new color
  7398                              <1> m_pix_op_new_32_0:
  7399 0000F8F5 AD                  <1> 	lodsd 
  7400 0000F8F6 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7401 0000F8FC 7409                <1> 	je	short m_pix_op_new_32_1 ; exclude
  7402 0000F8FE 8917                <1> 	mov	[edi], edx
  7403 0000F900 8305[64030300]04    <1> 	add	dword [u.r0], 4
  7404                              <1> m_pix_op_new_32_1:
  7405 0000F907 83C704              <1> 	add	edi, 4
  7406 0000F90A E2E9                <1> 	loop	m_pix_op_new_32_0
  7407 0000F90C C3                  <1> 	retn
  7408                              <1> 
  7409                              <1> m_pix_op_new_w:
  7410                              <1> 	; 06/02/2021
  7411                              <1> 	; CHANGE COLOR (MASKED, window)
  7412                              <1> 	;
  7413                              <1> 	; jump from pix_op_new_w
  7414                              <1> 	;
  7415                              <1> 	; INPUT:
  7416                              <1> 	;   ecx = bytes per row (to be applied)
  7417                              <1> 	;   edx = screen width in bytes
  7418                              <1> 	;   ebx = row count
  7419                              <1> 	;   eax = color
  7420                              <1> 	;
  7421                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7422                              <1> 	;
  7423                              <1> 	; OUTPUT:
  7424                              <1> 	; 	[u.r0] will be > 0 if succesful
  7425                              <1> 
  7426                              <1> 	; Window
  7427                              <1> 	;mov	edi, [v_str] ; LFB start address
  7428                              <1> 	;mov	esi, edi 
  7429                              <1> 
  7430 0000F90D 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7431 0000F914 7707                <1> 	ja	short m_pix_op_new_w_1
  7432                              <1> 
  7433                              <1> 	; 256 colors (8bpp)
  7434 0000F916 BD[88F80000]        <1> 	mov	ebp, m_pix_op_new_8
  7435 0000F91B EB1E                <1> 	jmp	short m_pix_op_new_w_x
  7436                              <1> 			
  7437                              <1> m_pix_op_new_w_1:
  7438 0000F91D 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7439 0000F924 7710                <1> 	ja	short m_pix_op_new_w_3 ; 32bpp
  7440 0000F926 7207                <1> 	jb	short m_pix_op_new_w_2 ; 16bpp
  7441                              <1> 
  7442                              <1> 	; 24 bit true colors
  7443 0000F928 BD[AAF80000]        <1> 	mov	ebp, m_pix_op_new_24
  7444 0000F92D EB0C                <1> 	jmp	short m_pix_op_new_w_x
  7445                              <1> 
  7446                              <1> 	; 65536 colors (16bpp)
  7447                              <1> m_pix_op_new_w_2:
  7448 0000F92F BD[D6F80000]        <1> 	mov	ebp, m_pix_op_new_16
  7449 0000F934 EB05                <1> 	jmp	short m_pix_op_new_w_x
  7450                              <1> 
  7451                              <1> 	; 32 bit true colors
  7452                              <1> m_pix_op_new_w_3:
  7453 0000F936 BD[F3F80000]        <1> 	mov	ebp, m_pix_op_new_32
  7454                              <1> 	;jmp	short m_pix_op_new_w_x
  7455                              <1> 
  7456                              <1> m_pix_op_new_w_x:
  7457                              <1> m_pix_op_add_w_x:
  7458                              <1> m_pix_op_sub_w_x:
  7459                              <1> m_pix_op_mix_w_x:
  7460                              <1> m_pix_op_and_w_x:
  7461                              <1> m_pix_op_orc_w_x:
  7462                              <1> m_pix_op_xor_w_x:
  7463                              <1> m_pix_op_not_w_x:
  7464                              <1> m_pix_op_neg_w_x:
  7465                              <1> m_pix_op_inc_w_x:
  7466                              <1> m_pix_op_dec_w_x:
  7467                              <1> 	; 27/02/2021
  7468                              <1> 	; 26/02/2021
  7469                              <1> 	; 06/02/2021
  7470                              <1> 	; ecx = bytes per row (to be applied)
  7471                              <1> 	; edx = windows (screen) width in bytes
  7472                              <1> 	; ebx = row count
  7473                              <1> 	; eax = color
  7474                              <1> 	; ebp = pixel operation subroutine address
  7475                              <1> 	; edi = esi = window start address
  7476                              <1> 
  7477 0000F93B 8B3D[92120300]      <1> 	mov	edi, [v_str] ; LFB start address
  7478 0000F941 89FE                <1> 	mov	esi, edi
  7479                              <1> m_pix_op_w_x_next:
  7480 0000F943 52                  <1> 	push	edx
  7481 0000F944 51                  <1> 	push	ecx
  7482 0000F945 56                  <1> 	push	esi
  7483 0000F946 57                  <1> 	push	edi
  7484 0000F947 50                  <1> 	push	eax ; 26/02/2021
  7485 0000F948 8B0D[9E120300]      <1> 	mov	ecx, [pixcount] ; 27/02/2021  
  7486 0000F94E FFD5                <1> 	call	ebp ; call masked pixel-row operation
  7487 0000F950 58                  <1> 	pop	eax ; 26/02/2021
  7488 0000F951 5F                  <1> 	pop	edi
  7489 0000F952 5E                  <1> 	pop	esi
  7490 0000F953 59                  <1> 	pop	ecx
  7491 0000F954 5A                  <1> 	pop	edx
  7492 0000F955 01D6                <1> 	add	esi, edx ; next row
  7493 0000F957 01D7                <1> 	add	edi, edx ; next row
  7494 0000F959 4B                  <1> 	dec	ebx
  7495 0000F95A 75E7                <1> 	jnz	short m_pix_op_w_x_next
  7496 0000F95C C3                  <1> 	retn
  7497                              <1> 
  7498                              <1> m_pix_op_add:
  7499                              <1> 	; 06/02/2021
  7500                              <1> 	; ADD COLOR (MASKED, full screen)
  7501                              <1> 	;
  7502                              <1> 	; jump from pix_op_add
  7503                              <1> 	;
  7504                              <1> 	; INPUT:
  7505                              <1> 	;   eax = color (AL, AX, EAX)
  7506                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7507                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7508                              <1> 	;
  7509                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7510                              <1> 	;
  7511                              <1> 	; OUTPUT:
  7512                              <1> 	; 	[u.r0] will be > 0 if succesful
  7513                              <1> 	
  7514                              <1> 	; Full screen
  7515                              <1> m_pix_op_add_0:
  7516 0000F95D 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7517 0000F964 771C                <1> 	ja	short m_pix_op_add_1
  7518                              <1> 	; 256 colors (8bpp)
  7519                              <1> 	;jmp	short m_pix_op_add_8
  7520                              <1> m_pix_op_add_8:
  7521                              <1> 	; 8 bit colors (256 colors)
  7522 0000F966 88C2                <1> 	mov	dl, al ; new color
  7523                              <1> m_pix_op_add_8_0:
  7524 0000F968 AC                  <1> 	lodsb 
  7525 0000F969 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  7526 0000F96F 740D                <1> 	je	short m_pix_op_add_8_1 ; exclude
  7527 0000F971 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  7528 0000F977 0017                <1> 	add	[edi], dl
  7529 0000F979 7303                <1> 	jnc	short m_pix_op_add_8_1
  7530 0000F97B C607FF              <1> 	mov	byte [edi], 0FFh 
  7531                              <1> m_pix_op_add_8_1:
  7532 0000F97E 47                  <1> 	inc	edi
  7533 0000F97F E2E7                <1> 	loop	m_pix_op_add_8_0
  7534 0000F981 C3                  <1> 	retn
  7535                              <1> m_pix_op_add_1:
  7536 0000F982 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7537 0000F989 775E                <1> 	ja	short m_pix_op_add_3 ; 32bpp	
  7538 0000F98B 7238                <1> 	jb	short m_pix_op_add_2 ; 16bpp
  7539                              <1> 	; 24 bit true colors
  7540                              <1> 	;jmp	short m_pix_op_add_24
  7541                              <1> m_pix_op_add_24:
  7542                              <1> 	; 24 bit true colors
  7543 0000F98D 89C2                <1> 	mov	edx, eax ; new color
  7544 0000F98F 81CA000000FF        <1> 	or	edx, 0FF000000h
  7545                              <1> m_pix_op_add_24_0:
  7546 0000F995 66AD                <1> 	lodsw
  7547 0000F997 C1E010              <1> 	shl	eax, 16
  7548 0000F99A AC                  <1> 	lodsb
  7549 0000F99B C1C010              <1> 	rol	eax, 16	
  7550 0000F99E 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7551 0000F9A4 7419                <1> 	je	short m_pix_op_add_24_2 ; exclude
  7552 0000F9A6 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  7553 0000F9AD 01D0                <1> 	add	eax, edx
  7554 0000F9AF 7305                <1> 	jnc	short m_pix_op_add_24_1
  7555 0000F9B1 B8FFFFFF00          <1> 	mov	eax, 0FFFFFFh
  7556                              <1> m_pix_op_add_24_1:	
  7557 0000F9B6 668907              <1> 	mov	[edi], ax
  7558 0000F9B9 C1E810              <1> 	shr	eax, 16
  7559 0000F9BC 884702              <1> 	mov	[edi+2], al
  7560                              <1> m_pix_op_add_24_2:
  7561 0000F9BF 83C703              <1> 	add	edi, 3 ; +3
  7562 0000F9C2 E2D1                <1> 	loop	m_pix_op_add_24_0
  7563 0000F9C4 C3                  <1> 	retn
  7564                              <1> 	; 65536 colors (16bpp)
  7565                              <1> m_pix_op_add_2:
  7566                              <1> 	;jmp	short m_pix_op_add_16
  7567                              <1> m_pix_op_add_16:
  7568                              <1> 	; 16 bit colors (65536 colors)
  7569 0000F9C5 89C2                <1> 	mov	edx, eax ; new color
  7570                              <1> m_pix_op_add_16_0:
  7571 0000F9C7 66AD                <1> 	lodsw
  7572 0000F9C9 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  7573 0000F9D0 7411                <1> 	je	short m_pix_op_add_16_1 ; exclude
  7574 0000F9D2 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  7575 0000F9D9 660117              <1> 	add	[edi], dx
  7576 0000F9DC 7305                <1> 	jnc	short m_pix_op_add_16_1
  7577 0000F9DE 66C707FFFF          <1> 	mov	word [edi], 0FFFFh
  7578                              <1> m_pix_op_add_16_1:
  7579 0000F9E3 83C702              <1> 	add	edi, 2 ; +2
  7580 0000F9E6 E2DF                <1> 	loop	m_pix_op_add_16_0
  7581 0000F9E8 C3                  <1> 	retn
  7582                              <1> m_pix_op_add_3:
  7583                              <1> 	; 32 bit true colors
  7584                              <1> 	;jmp	short m_pix_op_add_32
  7585                              <1> m_pix_op_add_32:
  7586                              <1> 	; 32 bit true colors
  7587 0000F9E9 89C2                <1> 	mov	edx, eax ; new color
  7588                              <1> m_pix_op_add_32_0:
  7589 0000F9EB AD                  <1> 	lodsd 
  7590 0000F9EC 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7591 0000F9F2 7411                <1> 	je	short m_pix_op_add_32_1 ; exclude
  7592 0000F9F4 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  7593 0000F9FB 0117                <1> 	add	[edi], edx
  7594 0000F9FD 7306                <1> 	jnc	short m_pix_op_add_32_1
  7595 0000F9FF C707FFFFFFFF        <1> 	mov	dword [edi], 0FFFFFFFFh
  7596                              <1> m_pix_op_add_32_1:
  7597 0000FA05 83C704              <1> 	add	edi, 4 ; +4
  7598 0000FA08 E2E1                <1> 	loop	m_pix_op_add_32_0
  7599 0000FA0A C3                  <1> 	retn
  7600                              <1> 
  7601                              <1> m_pix_op_add_w:
  7602                              <1> 	; 06/02/2021
  7603                              <1> 	; ADD COLOR (MASKED, window)
  7604                              <1> 	;
  7605                              <1> 	; jump from pix_op_add_w
  7606                              <1> 	;
  7607                              <1> 	; INPUT:
  7608                              <1> 	;   ecx = bytes per row (to be applied)
  7609                              <1> 	;   edx = screen width in bytes
  7610                              <1> 	;   ebx = row count
  7611                              <1> 	;   eax = color
  7612                              <1> 	;
  7613                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7614                              <1> 	;
  7615                              <1> 	; OUTPUT:
  7616                              <1> 	; 	[u.r0] will be > 0 if succesful
  7617                              <1> 
  7618                              <1> 	; window
  7619                              <1> 	;mov	edi, [v_str] ; LFB start address
  7620                              <1> 	;mov	esi, edi 
  7621                              <1> 
  7622 0000FA0B 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7623 0000FA12 7707                <1> 	ja	short m_pix_op_add_w_1
  7624                              <1> 
  7625                              <1> 	; 256 colors (8bpp)
  7626 0000FA14 BD[66F90000]        <1> 	mov	ebp, m_pix_op_add_8
  7627 0000FA19 EB1E                <1> 	jmp	short m_pix_op_add_w_4
  7628                              <1> 			
  7629                              <1> m_pix_op_add_w_1:
  7630 0000FA1B 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7631 0000FA22 7710                <1> 	ja	short m_pix_op_add_w_3 ; 32bpp
  7632 0000FA24 7207                <1> 	jb	short m_pix_op_add_w_2 ; 16bpp
  7633                              <1> 
  7634                              <1> 	; 24 bit true colors
  7635 0000FA26 BD[8DF90000]        <1> 	mov	ebp, m_pix_op_add_24
  7636 0000FA2B EB0C                <1> 	jmp	short m_pix_op_add_w_4
  7637                              <1> 
  7638                              <1> 	; 65536 colors (16bpp)
  7639                              <1> m_pix_op_add_w_2:
  7640 0000FA2D BD[C5F90000]        <1> 	mov	ebp, m_pix_op_add_16
  7641 0000FA32 EB05                <1> 	jmp	short m_pix_op_add_w_4
  7642                              <1> 
  7643                              <1> 	; 32 bit true colors
  7644                              <1> m_pix_op_add_w_3:
  7645 0000FA34 BD[E9F90000]        <1> 	mov	ebp, m_pix_op_add_32
  7646                              <1> m_pix_op_add_w_4:
  7647 0000FA39 E9FDFEFFFF          <1> 	jmp	m_pix_op_add_w_x
  7648                              <1> 
  7649                              <1> m_pix_op_sub:
  7650                              <1> 	; 06/02/2021
  7651                              <1> 	; SUBTRACT COLOR (MASKED, full screen)
  7652                              <1> 	;
  7653                              <1> 	; jump from pix_op_sub
  7654                              <1> 	;
  7655                              <1> 	; INPUT:
  7656                              <1> 	;   eax = color (AL, AX, EAX)
  7657                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7658                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7659                              <1> 	;
  7660                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7661                              <1> 	;
  7662                              <1> 	; OUTPUT:
  7663                              <1> 	; 	[u.r0] will be > 0 if succesful
  7664                              <1> 	
  7665                              <1> 	; Full screen
  7666                              <1> m_pix_op_sub_0:
  7667 0000FA3E 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7668 0000FA45 771C                <1> 	ja	short m_pix_op_sub_1
  7669                              <1> 	; 256 colors (8bpp)
  7670                              <1> 	;jmp	short m_pix_op_sub_8
  7671                              <1> m_pix_op_sub_8:
  7672                              <1> 	; 8 bit colors (256 colors)
  7673 0000FA47 88C2                <1> 	mov	dl, al ; new color
  7674                              <1> m_pix_op_sub_8_0:
  7675 0000FA49 AC                  <1> 	lodsb 
  7676 0000FA4A 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  7677 0000FA50 740D                <1> 	je	short m_pix_op_sub_8_1 ; exclude
  7678 0000FA52 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  7679 0000FA58 2817                <1> 	sub	[edi], dl
  7680 0000FA5A 7303                <1> 	jnb	short m_pix_op_sub_8_1
  7681 0000FA5C C60700              <1> 	mov	byte [edi], 0 
  7682                              <1> m_pix_op_sub_8_1:
  7683 0000FA5F 47                  <1> 	inc	edi
  7684 0000FA60 E2E7                <1> 	loop	m_pix_op_sub_8_0
  7685 0000FA62 C3                  <1> 	retn
  7686                              <1> m_pix_op_sub_1:
  7687 0000FA63 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7688 0000FA6A 775B                <1> 	ja	short m_pix_op_sub_3 ; 32bpp	
  7689 0000FA6C 7235                <1> 	jb	short m_pix_op_sub_2 ; 16bpp
  7690                              <1> 	; 24 bit true colors
  7691                              <1> 	;jmp	short m_pix_op_sub_24
  7692                              <1> m_pix_op_sub_24:
  7693                              <1> 	; 24 bit true colors
  7694 0000FA6E 89C2                <1> 	mov	edx, eax ; new color
  7695 0000FA70 81CA000000FF        <1> 	or	edx, 0FF000000h
  7696                              <1> m_pix_op_sub_24_0:
  7697 0000FA76 66AD                <1> 	lodsw
  7698 0000FA78 C1E010              <1> 	shl	eax, 16
  7699 0000FA7B AC                  <1> 	lodsb
  7700 0000FA7C C1C010              <1> 	rol	eax, 16	
  7701 0000FA7F 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7702 0000FA85 7416                <1> 	je	short m_pix_op_sub_24_2 ; exclude
  7703 0000FA87 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  7704 0000FA8E 29D0                <1> 	sub	eax, edx
  7705 0000FA90 7302                <1> 	jnb	short m_pix_op_sub_24_1
  7706 0000FA92 31C0                <1> 	xor	eax, eax ; 0
  7707                              <1> m_pix_op_sub_24_1:	
  7708 0000FA94 668907              <1> 	mov	[edi], ax
  7709 0000FA97 C1E810              <1> 	shr	eax, 16
  7710 0000FA9A 884702              <1> 	mov	[edi+2], al
  7711                              <1> m_pix_op_sub_24_2:
  7712 0000FA9D 83C703              <1> 	add	edi, 3 ; +3
  7713 0000FAA0 E2D4                <1> 	loop	m_pix_op_sub_24_0
  7714 0000FAA2 C3                  <1> 	retn
  7715                              <1> 	; 65536 colors (16bpp)
  7716                              <1> m_pix_op_sub_2:
  7717                              <1> 	;jmp	short m_pix_op_sub_16
  7718                              <1> m_pix_op_sub_16:
  7719                              <1> 	; 16 bit colors (65536 colors)
  7720 0000FAA3 89C2                <1> 	mov	edx, eax ; new color
  7721                              <1> m_pix_op_sub_16_0:
  7722 0000FAA5 66AD                <1> 	lodsw
  7723 0000FAA7 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  7724 0000FAAE 7411                <1> 	je	short m_pix_op_sub_16_1 ; exclude
  7725 0000FAB0 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  7726 0000FAB7 662917              <1> 	sub	[edi], dx
  7727 0000FABA 7305                <1> 	jnb	short m_pix_op_sub_16_1
  7728 0000FABC 31C0                <1> 	xor	eax, eax
  7729 0000FABE 668907              <1> 	mov	[edi], ax ; 0
  7730                              <1> m_pix_op_sub_16_1:
  7731 0000FAC1 83C702              <1> 	add	edi, 2 ; +2
  7732 0000FAC4 E2DF                <1> 	loop	m_pix_op_sub_16_0
  7733 0000FAC6 C3                  <1> 	retn
  7734                              <1> m_pix_op_sub_3:
  7735                              <1> 	; 32 bit true colors
  7736                              <1> 	;jmp	short m_pix_op_sub_32
  7737                              <1> m_pix_op_sub_32:
  7738                              <1> 	; 32 bit true colors
  7739 0000FAC7 89C2                <1> 	mov	edx, eax ; new color
  7740                              <1> m_pix_op_sub_32_0:
  7741 0000FAC9 AD                  <1> 	lodsd 
  7742 0000FACA 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7743 0000FAD0 740F                <1> 	je	short m_pix_op_sub_32_1 ; exclude
  7744 0000FAD2 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  7745 0000FAD9 2917                <1> 	sub	[edi], edx
  7746 0000FADB 7304                <1> 	jnb	short m_pix_op_sub_32_1
  7747 0000FADD 31C0                <1> 	xor	eax, eax
  7748 0000FADF 8907                <1> 	mov	[edi], eax ; 0
  7749                              <1> m_pix_op_sub_32_1:
  7750 0000FAE1 83C704              <1> 	add	edi, 4 ; +4
  7751 0000FAE4 E2E3                <1> 	loop	m_pix_op_sub_32_0
  7752 0000FAE6 C3                  <1> 	retn
  7753                              <1> 
  7754                              <1> m_pix_op_sub_w:
  7755                              <1> 	; 06/02/2021
  7756                              <1> 	; SUBTRACT COLOR (MASKED, window)
  7757                              <1> 	;
  7758                              <1> 	; jump from pix_op_sub_w
  7759                              <1> 	;
  7760                              <1> 	; INPUT:
  7761                              <1> 	;   ecx = bytes per row (to be applied)
  7762                              <1> 	;   edx = screen width in bytes
  7763                              <1> 	;   ebx = row count
  7764                              <1> 	;   eax = color
  7765                              <1> 	;
  7766                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7767                              <1> 	;
  7768                              <1> 	; OUTPUT:
  7769                              <1> 	; 	[u.r0] will be > 0 if succesful
  7770                              <1> 
  7771                              <1> 	; window
  7772                              <1> 	;mov	edi, [v_str] ; LFB start address
  7773                              <1> 	;mov	esi, edi 
  7774                              <1> 
  7775 0000FAE7 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7776 0000FAEE 7707                <1> 	ja	short m_pix_op_sub_w_1
  7777                              <1> 
  7778                              <1> 	; 256 colors (8bpp)
  7779 0000FAF0 BD[47FA0000]        <1> 	mov	ebp, m_pix_op_sub_8
  7780 0000FAF5 EB1E                <1> 	jmp	short m_pix_op_sub_w_4
  7781                              <1> 			
  7782                              <1> m_pix_op_sub_w_1:
  7783 0000FAF7 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7784 0000FAFE 7710                <1> 	ja	short m_pix_op_sub_w_3 ; 32bpp
  7785 0000FB00 7207                <1> 	jb	short m_pix_op_sub_w_2 ; 16bpp
  7786                              <1> 
  7787                              <1> 	; 24 bit true colors
  7788 0000FB02 BD[6EFA0000]        <1> 	mov	ebp, m_pix_op_sub_24
  7789 0000FB07 EB0C                <1> 	jmp	short m_pix_op_sub_w_4
  7790                              <1> 
  7791                              <1> 	; 65536 colors (16bpp)
  7792                              <1> m_pix_op_sub_w_2:
  7793 0000FB09 BD[A3FA0000]        <1> 	mov	ebp, m_pix_op_sub_16
  7794 0000FB0E EB05                <1> 	jmp	short m_pix_op_sub_w_4
  7795                              <1> 
  7796                              <1> 	; 32 bit true colors
  7797                              <1> m_pix_op_sub_w_3:
  7798 0000FB10 BD[C7FA0000]        <1> 	mov	ebp, m_pix_op_sub_32
  7799                              <1> m_pix_op_sub_w_4:
  7800 0000FB15 E921FEFFFF          <1> 	jmp	m_pix_op_sub_w_x
  7801                              <1> 
  7802                              <1> m_pix_op_mix:
  7803                              <1> 	; 25/02/2021
  7804                              <1> 	; 06/02/2021
  7805                              <1> 	; MIX COLOR (MASKED, full screen)
  7806                              <1> 	;
  7807                              <1> 	; jump from pix_op_mix
  7808                              <1> 	;
  7809                              <1> 	; INPUT:
  7810                              <1> 	;   eax = color (AL, AX, EAX)
  7811                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7812                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7813                              <1> 	;
  7814                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7815                              <1> 	;
  7816                              <1> 	; OUTPUT:
  7817                              <1> 	; 	[u.r0] will be > 0 if succesful
  7818                              <1> 	
  7819                              <1> 	; Full screen
  7820                              <1> m_pix_op_mix_0:
  7821 0000FB1A 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7822 0000FB21 771B                <1> 	ja	short m_pix_op_mix_1
  7823                              <1> 	; 256 colors (8bpp)
  7824                              <1> 	;jmp	short m_pix_op_mix_8
  7825                              <1> m_pix_op_mix_8:
  7826                              <1> 	; 8 bit colors (256 colors)
  7827 0000FB23 88C2                <1> 	mov	dl, al ; new (mixing) color
  7828                              <1> m_pix_op_mix_8_0:
  7829 0000FB25 AC                  <1> 	lodsb 
  7830 0000FB26 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  7831 0000FB2C 740C                <1> 	je	short m_pix_op_mix_8_1 ; exclude
  7832 0000FB2E 00D0                <1> 	add	al, dl ; 25/02/2021
  7833 0000FB30 D0D8                <1> 	rcr	al, 1	
  7834 0000FB32 8807                <1> 	mov	[edi], al
  7835 0000FB34 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  7836                              <1> m_pix_op_mix_8_1:
  7837 0000FB3A 47                  <1> 	inc	edi
  7838 0000FB3B E2E8                <1> 	loop	m_pix_op_mix_8_0
  7839 0000FB3D C3                  <1> 	retn
  7840                              <1> m_pix_op_mix_1:
  7841 0000FB3E 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7842 0000FB45 7752                <1> 	ja	short m_pix_op_mix_3 ; 32bpp	
  7843 0000FB47 722D                <1> 	jb	short m_pix_op_mix_2 ; 16bpp
  7844                              <1> 	; 24 bit true colors
  7845                              <1> 	;jmp	short m_pix_op_mix_24
  7846                              <1> m_pix_op_mix_24:
  7847                              <1> 	; 24 bit true colors
  7848 0000FB49 89C2                <1> 	mov	edx, eax ; new color
  7849                              <1> 	;and	edx, 0FFFFFFh
  7850                              <1> m_pix_op_mix_24_0:
  7851 0000FB4B 66AD                <1> 	lodsw
  7852 0000FB4D C1E010              <1> 	shl	eax, 16
  7853 0000FB50 AC                  <1> 	lodsb
  7854 0000FB51 C1C010              <1> 	rol	eax, 16	
  7855 0000FB54 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7856 0000FB5A 7414                <1> 	je	short m_pix_op_mix_24_1 ; exclude
  7857 0000FB5C 01D0                <1> 	add	eax, edx
  7858 0000FB5E D1E8                <1> 	shr	eax, 1
  7859 0000FB60 668907              <1> 	mov	[edi], ax
  7860 0000FB63 C1E810              <1> 	shr	eax, 16
  7861 0000FB66 884702              <1> 	mov	[edi+2], al
  7862 0000FB69 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  7863                              <1> m_pix_op_mix_24_1:
  7864 0000FB70 83C703              <1> 	add	edi, 3 ; +3
  7865 0000FB73 E2D6                <1> 	loop	m_pix_op_mix_24_0
  7866 0000FB75 C3                  <1> 	retn
  7867                              <1> 	; 65536 colors (16bpp)
  7868                              <1> m_pix_op_mix_2:
  7869                              <1> 	;jmp	short m_pix_op_mix_16
  7870                              <1> m_pix_op_mix_16:
  7871                              <1> 	; 16 bit colors (65536 colors)
  7872 0000FB76 89C2                <1> 	mov	edx, eax ; new color
  7873                              <1> 	;and	edx, 0FFFFh
  7874                              <1> m_pix_op_mix_16_0:
  7875 0000FB78 66AD                <1> 	lodsw
  7876 0000FB7A 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  7877 0000FB81 7410                <1> 	je	short m_pix_op_mix_16_1 ; exclude
  7878 0000FB83 6601D0              <1> 	add	ax, dx
  7879 0000FB86 66D1D8              <1> 	rcr	ax, 1
  7880 0000FB89 668907              <1> 	mov	[edi], ax
  7881 0000FB8C 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  7882                              <1> m_pix_op_mix_16_1:
  7883 0000FB93 83C702              <1> 	add	edi, 2 ; +2
  7884 0000FB96 E2E0                <1> 	loop	m_pix_op_mix_16_0
  7885 0000FB98 C3                  <1> 	retn
  7886                              <1> m_pix_op_mix_3:
  7887                              <1> 	; 32 bit true colors
  7888                              <1> 	;jmp	short m_pix_op_mix_32
  7889                              <1> m_pix_op_mix_32:
  7890                              <1> 	; 32 bit true colors
  7891 0000FB99 89C2                <1> 	mov	edx, eax ; new color
  7892                              <1> m_pix_op_mix_32_0:
  7893 0000FB9B AD                  <1> 	lodsd 
  7894 0000FB9C 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  7895 0000FBA2 740F                <1> 	je	short m_pix_op_mix_32_1 ; exclude
  7896 0000FBA4 01D0                <1> 	add	eax, edx
  7897 0000FBA6 730B                <1> 	jnc	short m_pix_op_mix_32_1
  7898 0000FBA8 D1D8                <1> 	rcr	eax, 1
  7899 0000FBAA 8907                <1> 	mov	[edi], eax	
  7900 0000FBAC 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  7901                              <1> m_pix_op_mix_32_1:
  7902 0000FBB3 83C704              <1> 	add	edi, 4 ; +4
  7903 0000FBB6 E2E3                <1> 	loop	m_pix_op_mix_32_0
  7904 0000FBB8 C3                  <1> 	retn
  7905                              <1> 
  7906                              <1> m_pix_op_mix_w:
  7907                              <1> 	; 06/02/2021
  7908                              <1> 	; MIX COLOR (MASKED, window)
  7909                              <1> 	;
  7910                              <1> 	; jump from pix_op_mix_w
  7911                              <1> 	;
  7912                              <1> 	; INPUT:
  7913                              <1> 	;   ecx = bytes per row (to be applied)
  7914                              <1> 	;   edx = screen width in bytes
  7915                              <1> 	;   ebx = row count
  7916                              <1> 	;   eax = color
  7917                              <1> 	;
  7918                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7919                              <1> 	;
  7920                              <1> 	; OUTPUT:
  7921                              <1> 	; 	[u.r0] will be > 0 if succesful
  7922                              <1> 
  7923                              <1> 	; window
  7924                              <1> 	;mov	edi, [v_str] ; LFB start address
  7925                              <1> 	;mov	esi, edi 
  7926                              <1> 
  7927 0000FBB9 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7928 0000FBC0 7707                <1> 	ja	short m_pix_op_mix_w_1
  7929                              <1> 
  7930                              <1> 	; 256 colors (8bpp)
  7931 0000FBC2 BD[23FB0000]        <1> 	mov	ebp, m_pix_op_mix_8
  7932 0000FBC7 EB1E                <1> 	jmp	short m_pix_op_mix_w_4
  7933                              <1> 			
  7934                              <1> m_pix_op_mix_w_1:
  7935 0000FBC9 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7936 0000FBD0 7710                <1> 	ja	short m_pix_op_mix_w_3 ; 32bpp
  7937 0000FBD2 7207                <1> 	jb	short m_pix_op_mix_w_2 ; 16bpp
  7938                              <1> 
  7939                              <1> 	; 24 bit true colors
  7940 0000FBD4 BD[49FB0000]        <1> 	mov	ebp, m_pix_op_mix_24
  7941 0000FBD9 EB0C                <1> 	jmp	short m_pix_op_mix_w_4
  7942                              <1> 
  7943                              <1> 	; 65536 colors (16bpp)
  7944                              <1> m_pix_op_mix_w_2:
  7945 0000FBDB BD[76FB0000]        <1> 	mov	ebp, m_pix_op_mix_16
  7946 0000FBE0 EB05                <1> 	jmp	short m_pix_op_mix_w_4
  7947                              <1> 
  7948                              <1> 	; 32 bit true colors
  7949                              <1> m_pix_op_mix_w_3:
  7950 0000FBE2 BD[99FB0000]        <1> 	mov	ebp, m_pix_op_mix_32
  7951                              <1> m_pix_op_mix_w_4:
  7952 0000FBE7 E94FFDFFFF          <1> 	jmp	m_pix_op_mix_w_x
  7953                              <1> 
  7954                              <1> m_pix_op_and:
  7955                              <1> 	; 06/02/2021
  7956                              <1> 	; AND COLOR (MASKED, full screen)
  7957                              <1> 	;
  7958                              <1> 	; jump from pix_op_and
  7959                              <1> 	;
  7960                              <1> 	; INPUT:
  7961                              <1> 	;   eax = color (AL, AX, EAX)
  7962                              <1> 	;   ecx = [v_siz] ; display page pixel count
  7963                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  7964                              <1> 	;
  7965                              <1> 	;   [maskcolor] = mask color (to be excluded)
  7966                              <1> 	;
  7967                              <1> 	; OUTPUT:
  7968                              <1> 	; 	[u.r0] will be > 0 if succesful
  7969                              <1> 	
  7970                              <1> 	; Full screen
  7971                              <1> m_pix_op_and_0:
  7972 0000FBEC 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  7973 0000FBF3 7717                <1> 	ja	short m_pix_op_and_1
  7974                              <1> 	; 256 colors (8bpp)
  7975                              <1> 	;jmp	short m_pix_op_and_8
  7976                              <1> m_pix_op_and_8:
  7977                              <1> 	; 8 bit colors (256 colors)
  7978 0000FBF5 88C2                <1> 	mov	dl, al ; new color
  7979                              <1> m_pix_op_and_8_0:
  7980 0000FBF7 AC                  <1> 	lodsb 
  7981 0000FBF8 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  7982 0000FBFE 7408                <1> 	je	short m_pix_op_and_8_1 ; exclude
  7983 0000FC00 2017                <1> 	and	[edi], dl
  7984 0000FC02 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  7985                              <1> m_pix_op_and_8_1:
  7986 0000FC08 47                  <1> 	inc	edi
  7987 0000FC09 E2EC                <1> 	loop	m_pix_op_and_8_0
  7988 0000FC0B C3                  <1> 	retn
  7989                              <1> m_pix_op_and_1:
  7990 0000FC0C 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  7991 0000FC13 774A                <1> 	ja	short m_pix_op_and_3 ; 32bpp	
  7992 0000FC15 722B                <1> 	jb	short m_pix_op_and_2 ; 16bpp
  7993                              <1> 	; 24 bit true colors
  7994                              <1> 	;jmp	short m_pix_op_and_24
  7995                              <1> m_pix_op_and_24:
  7996                              <1> 	; 24 bit true colors
  7997 0000FC17 89C2                <1> 	mov	edx, eax ; new color
  7998                              <1> 	;and	edx, 0FFFFFFh
  7999                              <1> m_pix_op_and_24_0:
  8000 0000FC19 66AD                <1> 	lodsw
  8001 0000FC1B C1E010              <1> 	shl	eax, 16
  8002 0000FC1E AC                  <1> 	lodsb
  8003 0000FC1F C1C010              <1> 	rol	eax, 16	
  8004 0000FC22 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8005 0000FC28 7412                <1> 	je	short m_pix_op_and_24_1 ; exclude
  8006 0000FC2A 21D0                <1> 	and	eax, edx
  8007 0000FC2C 668907              <1> 	mov	[edi], ax
  8008 0000FC2F C1E810              <1> 	shr	eax, 16
  8009 0000FC32 884702              <1> 	mov	[edi+2], al
  8010 0000FC35 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8011                              <1> m_pix_op_and_24_1:
  8012 0000FC3C 83C703              <1> 	add	edi, 3 ; +3
  8013 0000FC3F E2D8                <1> 	loop	m_pix_op_and_24_0
  8014 0000FC41 C3                  <1> 	retn
  8015                              <1> 	; 65536 colors (16bpp)
  8016                              <1> m_pix_op_and_2:
  8017                              <1> 	;jmp	short m_pix_op_and_16
  8018                              <1> m_pix_op_and_16:
  8019                              <1> 	; 16 bit colors (65536 colors)
  8020 0000FC42 89C2                <1> 	mov	edx, eax ; new color
  8021                              <1> 	;and	edx, 0FFFFh
  8022                              <1> m_pix_op_and_16_0:
  8023 0000FC44 66AD                <1> 	lodsw
  8024 0000FC46 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8025 0000FC4D 740A                <1> 	je	short m_pix_op_and_16_1 ; exclude
  8026 0000FC4F 662117              <1> 	and	[edi], dx
  8027 0000FC52 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8028                              <1> m_pix_op_and_16_1:
  8029 0000FC59 83C702              <1> 	add	edi, 2 ; +2
  8030 0000FC5C E2E6                <1> 	loop	m_pix_op_and_16_0
  8031 0000FC5E C3                  <1> 	retn
  8032                              <1> m_pix_op_and_3:
  8033                              <1> 	; 32 bit true colors
  8034                              <1> 	;jmp	short m_pix_op_and_32
  8035                              <1> m_pix_op_and_32:
  8036                              <1> 	; 32 bit true colors
  8037 0000FC5F 89C2                <1> 	mov	edx, eax ; new color
  8038                              <1> m_pix_op_and_32_0:
  8039 0000FC61 AD                  <1> 	lodsd 
  8040 0000FC62 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8041 0000FC68 7409                <1> 	je	short m_pix_op_and_32_1 ; exclude
  8042 0000FC6A 2117                <1> 	and	[edi], edx ; 25/02/2021	
  8043 0000FC6C 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8044                              <1> m_pix_op_and_32_1:
  8045 0000FC73 83C704              <1> 	add	edi, 4 ; +4
  8046 0000FC76 E2E9                <1> 	loop	m_pix_op_and_32_0
  8047 0000FC78 C3                  <1> 	retn
  8048                              <1> 
  8049                              <1> m_pix_op_and_w:
  8050                              <1> 	; 06/02/2021
  8051                              <1> 	; AND COLOR (MASKED, window)
  8052                              <1> 	;
  8053                              <1> 	; jump from pix_op_and_w
  8054                              <1> 	;
  8055                              <1> 	; INPUT:
  8056                              <1> 	;   ecx = bytes per row (to be applied)
  8057                              <1> 	;   edx = screen width in bytes
  8058                              <1> 	;   ebx = row count
  8059                              <1> 	;   eax = color
  8060                              <1> 	;
  8061                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8062                              <1> 	;
  8063                              <1> 	; OUTPUT:
  8064                              <1> 	; 	[u.r0] will be > 0 if succesful
  8065                              <1> 
  8066                              <1> 	; window
  8067                              <1> 	;mov	edi, [v_str] ; LFB start address
  8068                              <1> 	;mov	esi, edi 
  8069                              <1> 
  8070 0000FC79 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8071 0000FC80 7707                <1> 	ja	short m_pix_op_and_w_1
  8072                              <1> 
  8073                              <1> 	; 256 colors (8bpp)
  8074 0000FC82 BD[F5FB0000]        <1> 	mov	ebp, m_pix_op_and_8
  8075 0000FC87 EB1E                <1> 	jmp	short m_pix_op_and_w_4
  8076                              <1> 			
  8077                              <1> m_pix_op_and_w_1:
  8078 0000FC89 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8079 0000FC90 7710                <1> 	ja	short m_pix_op_and_w_3 ; 32bpp
  8080 0000FC92 7207                <1> 	jb	short m_pix_op_and_w_2 ; 16bpp
  8081                              <1> 
  8082                              <1> 	; 24 bit true colors
  8083 0000FC94 BD[17FC0000]        <1> 	mov	ebp, m_pix_op_and_24
  8084 0000FC99 EB0C                <1> 	jmp	short m_pix_op_and_w_4
  8085                              <1> 
  8086                              <1> 	; 65536 colors (16bpp)
  8087                              <1> m_pix_op_and_w_2:
  8088 0000FC9B BD[42FC0000]        <1> 	mov	ebp, m_pix_op_and_16
  8089 0000FCA0 EB05                <1> 	jmp	short m_pix_op_and_w_4
  8090                              <1> 
  8091                              <1> 	; 32 bit true colors
  8092                              <1> m_pix_op_and_w_3:
  8093 0000FCA2 BD[5FFC0000]        <1> 	mov	ebp, m_pix_op_and_32
  8094                              <1> m_pix_op_and_w_4:
  8095 0000FCA7 E98FFCFFFF          <1> 	jmp	m_pix_op_and_w_x
  8096                              <1> 
  8097                              <1> m_pix_op_or:
  8098                              <1> 	; 06/02/2021
  8099                              <1> 	; OR COLOR (MASKED, full screen)
  8100                              <1> 	;
  8101                              <1> 	; jump from pix_op_orc
  8102                              <1> 	;
  8103                              <1> 	; INPUT:
  8104                              <1> 	;   eax = color (AL, AX, EAX)
  8105                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8106                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8107                              <1> 	;
  8108                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8109                              <1> 	;
  8110                              <1> 	; OUTPUT:
  8111                              <1> 	; 	[u.r0] will be > 0 if succesful
  8112                              <1> 	
  8113                              <1> 	; Full screen
  8114                              <1> m_pix_op_or_0:
  8115 0000FCAC 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8116 0000FCB3 7717                <1> 	ja	short m_pix_op_or_1
  8117                              <1> 	; 256 colors (8bpp)
  8118                              <1> 	;jmp	short m_pix_op_or_8
  8119                              <1> m_pix_op_or_8:
  8120                              <1> 	; 8 bit colors (256 colors)
  8121 0000FCB5 88C2                <1> 	mov	dl, al ; new color
  8122                              <1> m_pix_op_or_8_0:
  8123 0000FCB7 AC                  <1> 	lodsb 
  8124 0000FCB8 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  8125 0000FCBE 7408                <1> 	je	short m_pix_op_or_8_1 ; exclude
  8126 0000FCC0 0817                <1> 	or	[edi], dl
  8127 0000FCC2 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  8128                              <1> m_pix_op_or_8_1:
  8129 0000FCC8 47                  <1> 	inc	edi
  8130 0000FCC9 E2EC                <1> 	loop	m_pix_op_or_8_0
  8131 0000FCCB C3                  <1> 	retn
  8132                              <1> m_pix_op_or_1:
  8133 0000FCCC 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8134 0000FCD3 774A                <1> 	ja	short m_pix_op_or_3 ; 32bpp	
  8135 0000FCD5 722B                <1> 	jb	short m_pix_op_or_2 ; 16bpp
  8136                              <1> 	; 24 bit true colors
  8137                              <1> 	;jmp	short m_pix_op_or_24
  8138                              <1> m_pix_op_or_24:
  8139                              <1> 	; 24 bit true colors
  8140 0000FCD7 89C2                <1> 	mov	edx, eax ; new color
  8141                              <1> 	;and	edx, 0FFFFFFh
  8142                              <1> m_pix_op_or_24_0:
  8143 0000FCD9 66AD                <1> 	lodsw
  8144 0000FCDB C1E010              <1> 	shl	eax, 16
  8145 0000FCDE AC                  <1> 	lodsb
  8146 0000FCDF C1C010              <1> 	rol	eax, 16	
  8147 0000FCE2 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8148 0000FCE8 7412                <1> 	je	short m_pix_op_or_24_1 ; exclude
  8149 0000FCEA 09D0                <1> 	or	eax, edx
  8150 0000FCEC 668907              <1> 	mov	[edi], ax
  8151 0000FCEF C1E810              <1> 	shr	eax, 16
  8152 0000FCF2 884702              <1> 	mov	[edi+2], al
  8153 0000FCF5 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8154                              <1> m_pix_op_or_24_1:
  8155 0000FCFC 83C703              <1> 	add	edi, 3 ; +3
  8156 0000FCFF E2D8                <1> 	loop	m_pix_op_or_24_0
  8157 0000FD01 C3                  <1> 	retn
  8158                              <1> 	; 65536 colors (16bpp)
  8159                              <1> m_pix_op_or_2:
  8160                              <1> 	;jmp	short m_pix_op_or_16
  8161                              <1> m_pix_op_or_16:
  8162                              <1> 	; 16 bit colors (65536 colors)
  8163 0000FD02 89C2                <1> 	mov	edx, eax ; new color
  8164                              <1> 	;and	edx, 0FFFFh
  8165                              <1> m_pix_op_or_16_0:
  8166 0000FD04 66AD                <1> 	lodsw
  8167 0000FD06 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8168 0000FD0D 740A                <1> 	je	short m_pix_op_or_16_1 ; exclude
  8169 0000FD0F 660917              <1> 	or	[edi], dx
  8170 0000FD12 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8171                              <1> m_pix_op_or_16_1:
  8172 0000FD19 83C702              <1> 	add	edi, 2 ; +2
  8173 0000FD1C E2E6                <1> 	loop	m_pix_op_or_16_0
  8174 0000FD1E C3                  <1> 	retn
  8175                              <1> m_pix_op_or_3:
  8176                              <1> 	; 32 bit true colors
  8177                              <1> 	;jmp	short m_pix_op_or_32
  8178                              <1> m_pix_op_or_32:
  8179                              <1> 	; 32 bit true colors
  8180 0000FD1F 89C2                <1> 	mov	edx, eax ; new color
  8181                              <1> m_pix_op_or_32_0:
  8182 0000FD21 AD                  <1> 	lodsd 
  8183 0000FD22 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8184 0000FD28 7409                <1> 	je	short m_pix_op_or_32_1 ; exclude
  8185 0000FD2A 0917                <1> 	or	[edi], edx ; 25/02/2021	
  8186 0000FD2C 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8187                              <1> m_pix_op_or_32_1:
  8188 0000FD33 83C704              <1> 	add	edi, 4 ; +4
  8189 0000FD36 E2E9                <1> 	loop	m_pix_op_or_32_0
  8190 0000FD38 C3                  <1> 	retn
  8191                              <1> 
  8192                              <1> m_pix_op_or_w:
  8193                              <1> 	; 06/02/2021
  8194                              <1> 	; MIX COLOR (MASKED, window)
  8195                              <1> 	;
  8196                              <1> 	; jump from pix_op_or_w
  8197                              <1> 	;
  8198                              <1> 	; INPUT:
  8199                              <1> 	;   ecx = bytes per row (to be applied)
  8200                              <1> 	;   edx = screen width in bytes
  8201                              <1> 	;   ebx = row count
  8202                              <1> 	;   eax = color
  8203                              <1> 	;
  8204                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8205                              <1> 	;
  8206                              <1> 	; OUTPUT:
  8207                              <1> 	; 	[u.r0] will be > 0 if succesful
  8208                              <1> 
  8209                              <1> 	; window
  8210                              <1> 	;mov	edi, [v_str] ; LFB start address
  8211                              <1> 	;mov	esi, edi 
  8212                              <1> 
  8213 0000FD39 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8214 0000FD40 7707                <1> 	ja	short m_pix_op_or_w_1
  8215                              <1> 
  8216                              <1> 	; 256 colors (8bpp)
  8217 0000FD42 BD[B5FC0000]        <1> 	mov	ebp, m_pix_op_or_8
  8218 0000FD47 EB1E                <1> 	jmp	short m_pix_op_or_w_4
  8219                              <1> 			
  8220                              <1> m_pix_op_or_w_1:
  8221 0000FD49 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8222 0000FD50 7710                <1> 	ja	short m_pix_op_or_w_3 ; 32bpp
  8223 0000FD52 7207                <1> 	jb	short m_pix_op_or_w_2 ; 16bpp
  8224                              <1> 
  8225                              <1> 	; 24 bit true colors
  8226 0000FD54 BD[D7FC0000]        <1> 	mov	ebp, m_pix_op_or_24
  8227 0000FD59 EB0C                <1> 	jmp	short m_pix_op_or_w_4
  8228                              <1> 
  8229                              <1> 	; 65536 colors (16bpp)
  8230                              <1> m_pix_op_or_w_2:
  8231 0000FD5B BD[02FD0000]        <1> 	mov	ebp, m_pix_op_or_16
  8232 0000FD60 EB05                <1> 	jmp	short m_pix_op_or_w_4
  8233                              <1> 
  8234                              <1> 	; 32 bit true colors
  8235                              <1> m_pix_op_or_w_3:
  8236 0000FD62 BD[1FFD0000]        <1> 	mov	ebp, m_pix_op_or_32
  8237                              <1> m_pix_op_or_w_4:
  8238 0000FD67 E9CFFBFFFF          <1> 	jmp	m_pix_op_orc_w_x
  8239                              <1> 
  8240                              <1> m_pix_op_xor:
  8241                              <1> 	; 06/02/2021
  8242                              <1> 	; XOR COLOR (MASKED, full screen)
  8243                              <1> 	;
  8244                              <1> 	; jump from pix_op_xor
  8245                              <1> 	;
  8246                              <1> 	; INPUT:
  8247                              <1> 	;   eax = color (AL, AX, EAX)
  8248                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8249                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8250                              <1> 	;
  8251                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8252                              <1> 	;
  8253                              <1> 	; OUTPUT:
  8254                              <1> 	; 	[u.r0] will be > 0 if succesful
  8255                              <1> 	
  8256                              <1> 	; Full screen
  8257                              <1> m_pix_op_xor_0:
  8258 0000FD6C 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8259 0000FD73 7717                <1> 	ja	short m_pix_op_xor_1
  8260                              <1> 	; 256 colors (8bpp)
  8261                              <1> 	;jmp	short m_pix_op_xor_8
  8262                              <1> m_pix_op_xor_8:
  8263                              <1> 	; 8 bit colors (256 colors)
  8264 0000FD75 88C2                <1> 	mov	dl, al ; new color
  8265                              <1> m_pix_op_xor_8_0:
  8266 0000FD77 AC                  <1> 	lodsb 
  8267 0000FD78 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  8268 0000FD7E 7408                <1> 	je	short m_pix_op_xor_8_1 ; exclude
  8269 0000FD80 3017                <1> 	xor	[edi], dl
  8270 0000FD82 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  8271                              <1> m_pix_op_xor_8_1:
  8272 0000FD88 47                  <1> 	inc	edi
  8273 0000FD89 E2EC                <1> 	loop	m_pix_op_xor_8_0
  8274 0000FD8B C3                  <1> 	retn
  8275                              <1> m_pix_op_xor_1:
  8276 0000FD8C 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8277 0000FD93 774A                <1> 	ja	short m_pix_op_xor_3 ; 32bpp	
  8278 0000FD95 722B                <1> 	jb	short m_pix_op_xor_2 ; 16bpp
  8279                              <1> 	; 24 bit true colors
  8280                              <1> 	;jmp	short m_pix_op_xor_24
  8281                              <1> m_pix_op_xor_24:
  8282                              <1> 	; 24 bit true colors
  8283 0000FD97 89C2                <1> 	mov	edx, eax ; new color
  8284                              <1> 	;and	edx, 0FFFFFFh
  8285                              <1> m_pix_op_xor_24_0:
  8286 0000FD99 66AD                <1> 	lodsw
  8287 0000FD9B C1E010              <1> 	shl	eax, 16
  8288 0000FD9E AC                  <1> 	lodsb
  8289 0000FD9F C1C010              <1> 	rol	eax, 16	
  8290 0000FDA2 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8291 0000FDA8 7412                <1> 	je	short m_pix_op_xor_24_1 ; exclude
  8292 0000FDAA 31D0                <1> 	xor	eax, edx
  8293 0000FDAC 668907              <1> 	mov	[edi], ax
  8294 0000FDAF C1E810              <1> 	shr	eax, 16
  8295 0000FDB2 884702              <1> 	mov	[edi+2], al
  8296 0000FDB5 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8297                              <1> m_pix_op_xor_24_1:
  8298 0000FDBC 83C703              <1> 	add	edi, 3 ; +3
  8299 0000FDBF E2D8                <1> 	loop	m_pix_op_xor_24_0
  8300 0000FDC1 C3                  <1> 	retn
  8301                              <1> 	; 65536 colors (16bpp)
  8302                              <1> m_pix_op_xor_2:
  8303                              <1> 	;jmp	short m_pix_op_xor_16
  8304                              <1> m_pix_op_xor_16:
  8305                              <1> 	; 16 bit colors (65536 colors)
  8306 0000FDC2 89C2                <1> 	mov	edx, eax ; new color
  8307                              <1> 	;and	edx, 0FFFFh
  8308                              <1> m_pix_op_xor_16_0:
  8309 0000FDC4 66AD                <1> 	lodsw
  8310 0000FDC6 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8311 0000FDCD 740A                <1> 	je	short m_pix_op_xor_16_1 ; exclude
  8312 0000FDCF 663117              <1> 	xor	[edi], dx
  8313 0000FDD2 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8314                              <1> m_pix_op_xor_16_1:
  8315 0000FDD9 83C702              <1> 	add	edi, 2 ; +2
  8316 0000FDDC E2E6                <1> 	loop	m_pix_op_xor_16_0
  8317 0000FDDE C3                  <1> 	retn
  8318                              <1> m_pix_op_xor_3:
  8319                              <1> 	; 32 bit true colors
  8320                              <1> 	;jmp	short m_pix_op_xor_32
  8321                              <1> m_pix_op_xor_32:
  8322                              <1> 	; 32 bit true colors
  8323 0000FDDF 89C2                <1> 	mov	edx, eax ; new color
  8324                              <1> m_pix_op_xor_32_0:
  8325 0000FDE1 AD                  <1> 	lodsd 
  8326 0000FDE2 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8327 0000FDE8 7409                <1> 	je	short m_pix_op_xor_32_1 ; exclude
  8328 0000FDEA 3117                <1> 	xor	[edi], edx ; 25/02/2021	
  8329 0000FDEC 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8330                              <1> m_pix_op_xor_32_1:
  8331 0000FDF3 83C704              <1> 	add	edi, 4 ; +4
  8332 0000FDF6 E2E9                <1> 	loop	m_pix_op_xor_32_0
  8333 0000FDF8 C3                  <1> 	retn
  8334                              <1> 
  8335                              <1> m_pix_op_xor_w:
  8336                              <1> 	; 06/02/2021
  8337                              <1> 	; XOR COLOR (MASKED, window)
  8338                              <1> 	;
  8339                              <1> 	; jump from pix_op_xor_w
  8340                              <1> 	;
  8341                              <1> 	; INPUT:
  8342                              <1> 	;   ecx = bytes per row (to be applied)
  8343                              <1> 	;   edx = screen width in bytes
  8344                              <1> 	;   ebx = row count
  8345                              <1> 	;   eax = color
  8346                              <1> 	;
  8347                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8348                              <1> 	;
  8349                              <1> 	; OUTPUT:
  8350                              <1> 	; 	[u.r0] will be > 0 if succesful
  8351                              <1> 
  8352                              <1> 	; window
  8353                              <1> 	;mov	edi, [v_str] ; LFB start address
  8354                              <1> 	;mov	esi, edi 
  8355                              <1> 
  8356 0000FDF9 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8357 0000FE00 7707                <1> 	ja	short m_pix_op_xor_w_1
  8358                              <1> 
  8359                              <1> 	; 256 colors (8bpp)
  8360 0000FE02 BD[75FD0000]        <1> 	mov	ebp, m_pix_op_xor_8
  8361 0000FE07 EB1E                <1> 	jmp	short m_pix_op_xor_w_4
  8362                              <1> 			
  8363                              <1> m_pix_op_xor_w_1:
  8364 0000FE09 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8365 0000FE10 7710                <1> 	ja	short m_pix_op_xor_w_3 ; 32bpp
  8366 0000FE12 7207                <1> 	jb	short m_pix_op_xor_w_2 ; 16bpp
  8367                              <1> 
  8368                              <1> 	; 24 bit true colors
  8369 0000FE14 BD[97FD0000]        <1> 	mov	ebp, m_pix_op_xor_24
  8370 0000FE19 EB0C                <1> 	jmp	short m_pix_op_xor_w_4
  8371                              <1> 
  8372                              <1> 	; 65536 colors (16bpp)
  8373                              <1> m_pix_op_xor_w_2:
  8374 0000FE1B BD[C2FD0000]        <1> 	mov	ebp, m_pix_op_xor_16
  8375 0000FE20 EB05                <1> 	jmp	short m_pix_op_xor_w_4
  8376                              <1> 
  8377                              <1> 	; 32 bit true colors
  8378                              <1> m_pix_op_xor_w_3:
  8379 0000FE22 BD[DFFD0000]        <1> 	mov	ebp, m_pix_op_xor_32
  8380                              <1> m_pix_op_xor_w_4:
  8381 0000FE27 E90FFBFFFF          <1> 	jmp	m_pix_op_xor_w_x
  8382                              <1> 
  8383                              <1> m_pix_op_not:
  8384                              <1> 	; 06/02/2021
  8385                              <1> 	; NOT COLOR (MASKED, full screen)
  8386                              <1> 	;
  8387                              <1> 	; jump from pix_op_not
  8388                              <1> 	;
  8389                              <1> 	; INPUT:
  8390                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8391                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8392                              <1> 	;
  8393                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8394                              <1> 	;
  8395                              <1> 	; OUTPUT:
  8396                              <1> 	; 	[u.r0] will be > 0 if succesful
  8397                              <1> 	
  8398                              <1> 	; Full screen
  8399                              <1> m_pix_op_not_0:
  8400 0000FE2C 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8401 0000FE33 7715                <1> 	ja	short m_pix_op_not_1
  8402                              <1> 	; 256 colors (8bpp)
  8403                              <1> 	;jmp	short m_pix_op_not_8
  8404                              <1> m_pix_op_not_8:
  8405                              <1> 	; 8 bit colors (256 colors)
  8406 0000FE35 AC                  <1> 	lodsb 
  8407 0000FE36 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  8408 0000FE3C 7408                <1> 	je	short m_pix_op_not_8_1 ; exclude
  8409 0000FE3E F617                <1> 	not	byte [edi]
  8410 0000FE40 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  8411                              <1> m_pix_op_not_8_1:
  8412 0000FE46 47                  <1> 	inc	edi
  8413 0000FE47 E2EC                <1> 	loop	m_pix_op_not_8
  8414 0000FE49 C3                  <1> 	retn
  8415                              <1> m_pix_op_not_1:
  8416 0000FE4A 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8417 0000FE51 7746                <1> 	ja	short m_pix_op_not_3 ; 32bpp	
  8418 0000FE53 7229                <1> 	jb	short m_pix_op_not_2 ; 16bpp
  8419                              <1> 	; 24 bit true colors
  8420                              <1> 	;jmp	short m_pix_op_not_24
  8421                              <1> m_pix_op_not_24:
  8422                              <1> 	; 24 bit true colors
  8423 0000FE55 66AD                <1> 	lodsw
  8424 0000FE57 C1E010              <1> 	shl	eax, 16
  8425 0000FE5A AC                  <1> 	lodsb
  8426 0000FE5B C1C010              <1> 	rol	eax, 16	
  8427 0000FE5E 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8428 0000FE64 7412                <1> 	je	short m_pix_op_not_24_1 ; exclude
  8429 0000FE66 F7D0                <1> 	not	eax
  8430 0000FE68 668907              <1> 	mov	[edi], ax
  8431 0000FE6B C1E810              <1> 	shr	eax, 16
  8432 0000FE6E 884702              <1> 	mov	[edi+2], al
  8433 0000FE71 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8434                              <1> m_pix_op_not_24_1:
  8435 0000FE78 83C703              <1> 	add	edi, 3 ; +3
  8436 0000FE7B E2D8                <1> 	loop	m_pix_op_not_24
  8437 0000FE7D C3                  <1> 	retn
  8438                              <1> 	; 65536 colors (16bpp)
  8439                              <1> m_pix_op_not_2:
  8440                              <1> 	;jmp	short m_pix_op_not_16
  8441                              <1> m_pix_op_not_16:
  8442                              <1> 	; 16 bit colors (65536 colors)
  8443 0000FE7E 66AD                <1> 	lodsw
  8444 0000FE80 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8445 0000FE87 740A                <1> 	je	short m_pix_op_not_16_1 ; exclude
  8446 0000FE89 66F717              <1> 	not	word [edi]
  8447 0000FE8C 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8448                              <1> m_pix_op_not_16_1:
  8449 0000FE93 83C702              <1> 	add	edi, 2 ; +2
  8450 0000FE96 E2E6                <1> 	loop	m_pix_op_not_16
  8451 0000FE98 C3                  <1> 	retn
  8452                              <1> m_pix_op_not_3:
  8453                              <1> 	; 32 bit true colors
  8454                              <1> 	;jmp	short m_pix_op_not_32
  8455                              <1> m_pix_op_not_32:
  8456                              <1> 	; 32 bit true colors
  8457 0000FE99 AD                  <1> 	lodsd 
  8458 0000FE9A 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8459 0000FEA0 7409                <1> 	je	short m_pix_op_not_32_1 ; exclude
  8460 0000FEA2 F717                <1> 	not	dword [edi]	
  8461 0000FEA4 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8462                              <1> m_pix_op_not_32_1:
  8463 0000FEAB 83C704              <1> 	add	edi, 4 ; +4
  8464 0000FEAE E2E9                <1> 	loop	m_pix_op_not_32
  8465 0000FEB0 C3                  <1> 	retn
  8466                              <1> 
  8467                              <1> m_pix_op_not_w:
  8468                              <1> 	; 06/02/2021
  8469                              <1> 	; NOT COLOR (MASKED, window)
  8470                              <1> 	;
  8471                              <1> 	; jump from pix_op_not_w
  8472                              <1> 	;
  8473                              <1> 	; INPUT:
  8474                              <1> 	;   ecx = bytes per row (to be applied)
  8475                              <1> 	;   edx = screen width in bytes
  8476                              <1> 	;   ebx = row count
  8477                              <1> 	;
  8478                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8479                              <1> 	;
  8480                              <1> 	; OUTPUT:
  8481                              <1> 	; 	[u.r0] will be > 0 if succesful
  8482                              <1> 
  8483                              <1> 	; window
  8484                              <1> 	;mov	edi, [v_str] ; LFB start address
  8485                              <1> 	;mov	esi, edi 
  8486                              <1> 
  8487 0000FEB1 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8488 0000FEB8 7707                <1> 	ja	short m_pix_op_not_w_1
  8489                              <1> 
  8490                              <1> 	; 256 colors (8bpp)
  8491 0000FEBA BD[35FE0000]        <1> 	mov	ebp, m_pix_op_not_8
  8492 0000FEBF EB1E                <1> 	jmp	short m_pix_op_not_w_4
  8493                              <1> 			
  8494                              <1> m_pix_op_not_w_1:
  8495 0000FEC1 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8496 0000FEC8 7710                <1> 	ja	short m_pix_op_not_w_3 ; 32bpp
  8497 0000FECA 7207                <1> 	jb	short m_pix_op_not_w_2 ; 16bpp
  8498                              <1> 
  8499                              <1> 	; 24 bit true colors
  8500 0000FECC BD[55FE0000]        <1> 	mov	ebp, m_pix_op_not_24
  8501 0000FED1 EB0C                <1> 	jmp	short m_pix_op_not_w_4
  8502                              <1> 
  8503                              <1> 	; 65536 colors (16bpp)
  8504                              <1> m_pix_op_not_w_2:
  8505 0000FED3 BD[7EFE0000]        <1> 	mov	ebp, m_pix_op_not_16
  8506 0000FED8 EB05                <1> 	jmp	short m_pix_op_not_w_4
  8507                              <1> 
  8508                              <1> 	; 32 bit true colors
  8509                              <1> m_pix_op_not_w_3:
  8510 0000FEDA BD[99FE0000]        <1> 	mov	ebp, m_pix_op_not_32
  8511                              <1> m_pix_op_not_w_4:
  8512 0000FEDF E957FAFFFF          <1> 	jmp	m_pix_op_not_w_x
  8513                              <1> 
  8514                              <1> m_pix_op_neg:
  8515                              <1> 	; 06/02/2021
  8516                              <1> 	; NEGATIVE COLOR (MASKED, full screen)
  8517                              <1> 	;
  8518                              <1> 	; jump from pix_op_neg
  8519                              <1> 	;
  8520                              <1> 	; INPUT:
  8521                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8522                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8523                              <1> 	;
  8524                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8525                              <1> 	;
  8526                              <1> 	; OUTPUT:
  8527                              <1> 	; 	[u.r0] will be > 0 if succesful
  8528                              <1> 	
  8529                              <1> 	; Full screen
  8530                              <1> m_pix_op_neg_0:
  8531 0000FEE4 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8532 0000FEEB 7715                <1> 	ja	short m_pix_op_neg_1
  8533                              <1> 	; 256 colors (8bpp)
  8534                              <1> 	;jmp	short m_pix_op_neg_8
  8535                              <1> m_pix_op_neg_8:
  8536                              <1> 	; 8 bit colors (256 colors)
  8537 0000FEED AC                  <1> 	lodsb 
  8538 0000FEEE 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  8539 0000FEF4 7408                <1> 	je	short m_pix_op_neg_8_1 ; exclude
  8540 0000FEF6 F61F                <1> 	neg	byte [edi]
  8541 0000FEF8 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  8542                              <1> m_pix_op_neg_8_1:
  8543 0000FEFE 47                  <1> 	inc	edi
  8544 0000FEFF E2EC                <1> 	loop	m_pix_op_neg_8
  8545 0000FF01 C3                  <1> 	retn
  8546                              <1> m_pix_op_neg_1:
  8547 0000FF02 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8548 0000FF09 7746                <1> 	ja	short m_pix_op_neg_3 ; 32bpp	
  8549 0000FF0B 7229                <1> 	jb	short m_pix_op_neg_2 ; 16bpp
  8550                              <1> 	; 24 bit true colors
  8551                              <1> 	;jmp	short m_pix_op_neg_24
  8552                              <1> m_pix_op_neg_24:
  8553                              <1> 	; 24 bit true colors
  8554 0000FF0D 66AD                <1> 	lodsw
  8555 0000FF0F C1E010              <1> 	shl	eax, 16
  8556 0000FF12 AC                  <1> 	lodsb
  8557 0000FF13 C1C010              <1> 	rol	eax, 16	
  8558 0000FF16 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8559 0000FF1C 7412                <1> 	je	short m_pix_op_neg_24_1 ; exclude
  8560 0000FF1E F7D8                <1> 	neg	eax
  8561 0000FF20 668907              <1> 	mov	[edi], ax
  8562 0000FF23 C1E810              <1> 	shr	eax, 16
  8563 0000FF26 884702              <1> 	mov	[edi+2], al
  8564 0000FF29 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8565                              <1> m_pix_op_neg_24_1:
  8566 0000FF30 83C703              <1> 	add	edi, 3 ; +3
  8567 0000FF33 E2D8                <1> 	loop	m_pix_op_neg_24
  8568 0000FF35 C3                  <1> 	retn
  8569                              <1> 	; 65536 colors (16bpp)
  8570                              <1> m_pix_op_neg_2:
  8571                              <1> 	;jmp	short m_pix_op_neg_16
  8572                              <1> m_pix_op_neg_16:
  8573                              <1> 	; 16 bit colors (65536 colors)
  8574 0000FF36 66AD                <1> 	lodsw
  8575 0000FF38 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8576 0000FF3F 740A                <1> 	je	short m_pix_op_neg_16_1 ; exclude
  8577 0000FF41 66F71F              <1> 	neg	word [edi]
  8578 0000FF44 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8579                              <1> m_pix_op_neg_16_1:
  8580 0000FF4B 83C702              <1> 	add	edi, 2 ; +2
  8581 0000FF4E E2E6                <1> 	loop	m_pix_op_neg_16
  8582 0000FF50 C3                  <1> 	retn
  8583                              <1> m_pix_op_neg_3:
  8584                              <1> 	; 32 bit true colors
  8585                              <1> 	;jmp	short m_pix_op_neg_32
  8586                              <1> m_pix_op_neg_32:
  8587                              <1> 	; 32 bit true colors
  8588 0000FF51 AD                  <1> 	lodsd 
  8589 0000FF52 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8590 0000FF58 7409                <1> 	je	short m_pix_op_neg_32_1 ; exclude
  8591 0000FF5A F71F                <1> 	neg	dword [edi]	
  8592 0000FF5C 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8593                              <1> m_pix_op_neg_32_1:
  8594 0000FF63 83C704              <1> 	add	edi, 4 ; +4
  8595 0000FF66 E2E9                <1> 	loop	m_pix_op_neg_32
  8596 0000FF68 C3                  <1> 	retn
  8597                              <1> 
  8598                              <1> m_pix_op_neg_w:
  8599                              <1> 	; 06/02/2021
  8600                              <1> 	; NEGATIVE COLOR (MASKED, window)
  8601                              <1> 	;
  8602                              <1> 	; jump from pix_op_neg_w
  8603                              <1> 	;
  8604                              <1> 	; INPUT:
  8605                              <1> 	;   ecx = bytes per row (to be applied)
  8606                              <1> 	;   edx = screen width in bytes
  8607                              <1> 	;   ebx = row count
  8608                              <1> 	;
  8609                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8610                              <1> 	;
  8611                              <1> 	; OUTPUT:
  8612                              <1> 	; 	[u.r0] will be > 0 if succesful
  8613                              <1> 
  8614                              <1> 	; window
  8615                              <1> 	;mov	edi, [v_str] ; LFB start address
  8616                              <1> 	;mov	esi, edi 
  8617                              <1> 
  8618 0000FF69 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8619 0000FF70 7707                <1> 	ja	short m_pix_op_neg_w_1
  8620                              <1> 
  8621                              <1> 	; 256 colors (8bpp)
  8622 0000FF72 BD[EDFE0000]        <1> 	mov	ebp, m_pix_op_neg_8
  8623 0000FF77 EB1E                <1> 	jmp	short m_pix_op_neg_w_4
  8624                              <1> 			
  8625                              <1> m_pix_op_neg_w_1:
  8626 0000FF79 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8627 0000FF80 7710                <1> 	ja	short m_pix_op_neg_w_3 ; 32bpp
  8628 0000FF82 7207                <1> 	jb	short m_pix_op_neg_w_2 ; 16bpp
  8629                              <1> 
  8630                              <1> 	; 24 bit true colors
  8631 0000FF84 BD[0DFF0000]        <1> 	mov	ebp, m_pix_op_neg_24
  8632 0000FF89 EB0C                <1> 	jmp	short m_pix_op_neg_w_4
  8633                              <1> 
  8634                              <1> 	; 65536 colors (16bpp)
  8635                              <1> m_pix_op_neg_w_2:
  8636 0000FF8B BD[36FF0000]        <1> 	mov	ebp, m_pix_op_neg_16
  8637 0000FF90 EB05                <1> 	jmp	short m_pix_op_neg_w_4
  8638                              <1> 
  8639                              <1> 	; 32 bit true colors
  8640                              <1> m_pix_op_neg_w_3:
  8641 0000FF92 BD[51FF0000]        <1> 	mov	ebp, m_pix_op_neg_32
  8642                              <1> m_pix_op_neg_w_4:
  8643 0000FF97 E99FF9FFFF          <1> 	jmp	m_pix_op_neg_w_x
  8644                              <1> 
  8645                              <1> m_pix_op_inc:
  8646                              <1> 	; 06/02/2021
  8647                              <1> 	; INCREASE COLOR (MASKED, full screen)
  8648                              <1> 	;
  8649                              <1> 	; jump from pix_op_inc
  8650                              <1> 	;
  8651                              <1> 	; INPUT:
  8652                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8653                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8654                              <1> 	;
  8655                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8656                              <1> 	;
  8657                              <1> 	; OUTPUT:
  8658                              <1> 	; 	[u.r0] will be > 0 if succesful
  8659                              <1> 	
  8660                              <1> 	; Full screen
  8661                              <1> m_pix_op_inc_0:
  8662 0000FF9C 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8663 0000FFA3 7719                <1> 	ja	short m_pix_op_inc_1
  8664                              <1> 	; 256 colors (8bpp)
  8665                              <1> 	;jmp	short m_pix_op_inc_8
  8666                              <1> m_pix_op_inc_8:
  8667                              <1> 	; 8 bit colors (256 colors)
  8668 0000FFA5 AC                  <1> 	lodsb 
  8669 0000FFA6 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  8670 0000FFAC 740C                <1> 	je	short m_pix_op_inc_8_1 ; exclude
  8671 0000FFAE FE07                <1> 	inc	byte [edi]
  8672 0000FFB0 7502                <1> 	jnz	short m_pix_op_inc_8_0
  8673 0000FFB2 FE0F                <1> 	dec	byte [edi]
  8674                              <1> m_pix_op_inc_8_0:
  8675 0000FFB4 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  8676                              <1> m_pix_op_inc_8_1:
  8677 0000FFBA 47                  <1> 	inc	edi
  8678 0000FFBB E2E8                <1> 	loop	m_pix_op_inc_8
  8679 0000FFBD C3                  <1> 	retn
  8680                              <1> m_pix_op_inc_1:
  8681 0000FFBE 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8682 0000FFC5 7752                <1> 	ja	short m_pix_op_inc_3 ; 32bpp	
  8683 0000FFC7 7230                <1> 	jb	short m_pix_op_inc_2 ; 16bpp
  8684                              <1> 	; 24 bit true colors
  8685                              <1> 	;jmp	short m_pix_op_inc_24
  8686                              <1> m_pix_op_inc_24:
  8687                              <1> 	; 24 bit true colors
  8688 0000FFC9 66AD                <1> 	lodsw
  8689 0000FFCB C1E010              <1> 	shl	eax, 16
  8690 0000FFCE AC                  <1> 	lodsb
  8691 0000FFCF C1C010              <1> 	rol	eax, 16	
  8692 0000FFD2 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8693 0000FFD8 7419                <1> 	je	short m_pix_op_inc_24_1 ; exclude
  8694 0000FFDA 40                  <1> 	inc	eax
  8695 0000FFDB 3DFFFFFF00          <1> 	cmp	eax, 0FFFFFFh
  8696 0000FFE0 7601                <1> 	jna	short m_pix_op_inc_24_0
  8697 0000FFE2 48                  <1> 	dec	eax 
  8698                              <1> m_pix_op_inc_24_0:
  8699 0000FFE3 668907              <1> 	mov	[edi], ax
  8700 0000FFE6 C1E810              <1> 	shr	eax, 16
  8701 0000FFE9 884702              <1> 	mov	[edi+2], al
  8702 0000FFEC 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8703                              <1> m_pix_op_inc_24_1:
  8704 0000FFF3 83C703              <1> 	add	edi, 3 ; +3
  8705 0000FFF6 E2D1                <1> 	loop	m_pix_op_inc_24
  8706 0000FFF8 C3                  <1> 	retn
  8707                              <1> 	; 65536 colors (16bpp)
  8708                              <1> m_pix_op_inc_2:
  8709                              <1> 	;jmp	short m_pix_op_inc_16
  8710                              <1> m_pix_op_inc_16:
  8711                              <1> 	; 16 bit colors (65536 colors)
  8712 0000FFF9 66AD                <1> 	lodsw
  8713 0000FFFB 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8714 00010002 740F                <1> 	je	short m_pix_op_inc_16_1 ; exclude
  8715 00010004 66FF07              <1> 	inc	word [edi]
  8716 00010007 7503                <1> 	jnz	short m_pix_op_inc_16_0
  8717 00010009 66FF0F              <1> 	dec	word [edi]
  8718                              <1> m_pix_op_inc_16_0:
  8719 0001000C 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8720                              <1> m_pix_op_inc_16_1:
  8721 00010013 83C702              <1> 	add	edi, 2 ; +2
  8722 00010016 E2E1                <1> 	loop	m_pix_op_inc_16
  8723 00010018 C3                  <1> 	retn
  8724                              <1> m_pix_op_inc_3:
  8725                              <1> 	; 32 bit true colors
  8726                              <1> 	;jmp	short m_pix_op_inc_32
  8727                              <1> m_pix_op_inc_32:
  8728                              <1> 	; 32 bit true colors
  8729 00010019 AD                  <1> 	lodsd 
  8730 0001001A 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8731 00010020 740D                <1> 	je	short m_pix_op_inc_32_1 ; exclude
  8732 00010022 FF07                <1> 	inc	dword [edi]
  8733 00010024 7502                <1> 	jnz	short m_pix_op_inc_32_0
  8734 00010026 FF0F                <1> 	dec	dword [edi]
  8735                              <1> m_pix_op_inc_32_0:	
  8736 00010028 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8737                              <1> m_pix_op_inc_32_1:
  8738 0001002F 83C704              <1> 	add	edi, 4 ; +4
  8739 00010032 E2E5                <1> 	loop	m_pix_op_inc_32
  8740 00010034 C3                  <1> 	retn
  8741                              <1> 
  8742                              <1> m_pix_op_inc_w:
  8743                              <1> 	; 06/02/2021
  8744                              <1> 	; INCREASE COLOR (MASKED, window)
  8745                              <1> 	;
  8746                              <1> 	; jump from pix_op_inc_w
  8747                              <1> 	;
  8748                              <1> 	; INPUT:
  8749                              <1> 	;   ecx = bytes per row (to be applied)
  8750                              <1> 	;   edx = screen width in bytes
  8751                              <1> 	;   ebx = row count
  8752                              <1> 	;
  8753                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8754                              <1> 	;
  8755                              <1> 	; OUTPUT:
  8756                              <1> 	; 	[u.r0] will be > 0 if succesful
  8757                              <1> 
  8758                              <1> 	; window
  8759                              <1> 	;mov	edi, [v_str] ; LFB start address
  8760                              <1> 	;mov	esi, edi 
  8761                              <1> 
  8762 00010035 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8763 0001003C 7707                <1> 	ja	short m_pix_op_inc_w_1
  8764                              <1> 
  8765                              <1> 	; 256 colors (8bpp)
  8766 0001003E BD[A5FF0000]        <1> 	mov	ebp, m_pix_op_inc_8
  8767 00010043 EB1E                <1> 	jmp	short m_pix_op_inc_w_4
  8768                              <1> 			
  8769                              <1> m_pix_op_inc_w_1:
  8770 00010045 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8771 0001004C 7710                <1> 	ja	short m_pix_op_inc_w_3 ; 32bpp
  8772 0001004E 7207                <1> 	jb	short m_pix_op_inc_w_2 ; 16bpp
  8773                              <1> 
  8774                              <1> 	; 24 bit true colors
  8775 00010050 BD[C9FF0000]        <1> 	mov	ebp, m_pix_op_inc_24
  8776 00010055 EB0C                <1> 	jmp	short m_pix_op_inc_w_4
  8777                              <1> 
  8778                              <1> 	; 65536 colors (16bpp)
  8779                              <1> m_pix_op_inc_w_2:
  8780 00010057 BD[F9FF0000]        <1> 	mov	ebp, m_pix_op_inc_16
  8781 0001005C EB05                <1> 	jmp	short m_pix_op_inc_w_4
  8782                              <1> 
  8783                              <1> 	; 32 bit true colors
  8784                              <1> m_pix_op_inc_w_3:
  8785 0001005E BD[19000100]        <1> 	mov	ebp, m_pix_op_inc_32
  8786                              <1> m_pix_op_inc_w_4:
  8787 00010063 E9D3F8FFFF          <1> 	jmp	m_pix_op_inc_w_x
  8788                              <1> 
  8789                              <1> m_pix_op_dec:
  8790                              <1> 	; 06/02/2021
  8791                              <1> 	; DECREASE COLOR (MASKED, full screen)
  8792                              <1> 	;
  8793                              <1> 	; jump from pix_op_dec
  8794                              <1> 	;
  8795                              <1> 	; INPUT:
  8796                              <1> 	;   ecx = [v_siz] ; display page pixel count
  8797                              <1> 	;   esi = edi = [v_mem] ; LFB start address
  8798                              <1> 	;
  8799                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8800                              <1> 	;
  8801                              <1> 	; OUTPUT:
  8802                              <1> 	; 	[u.r0] will be > 0 if succesful
  8803                              <1> 	
  8804                              <1> 	; Full screen
  8805                              <1> m_pix_op_dec_0:
  8806 00010068 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8807 0001006F 7719                <1> 	ja	short m_pix_op_dec_1
  8808                              <1> 	; 256 colors (8bpp)
  8809                              <1> 	;jmp	short m_pix_op_dec_8
  8810                              <1> m_pix_op_dec_8:
  8811                              <1> 	; 8 bit colors (256 colors)
  8812 00010071 AC                  <1> 	lodsb 
  8813 00010072 3A05[9A120300]      <1> 	cmp	al, [maskcolor]
  8814 00010078 740C                <1> 	je	short m_pix_op_dec_8_1 ; exclude
  8815 0001007A FE0F                <1> 	dec	byte [edi]
  8816 0001007C 7902                <1> 	jns	short m_pix_op_dec_8_0
  8817 0001007E FE07                <1> 	inc	byte [edi]
  8818                              <1> m_pix_op_dec_8_0:
  8819 00010080 FF05[64030300]      <1> 	inc	dword [u.r0] ; +1
  8820                              <1> m_pix_op_dec_8_1:
  8821 00010086 47                  <1> 	inc	edi
  8822 00010087 E2E8                <1> 	loop	m_pix_op_dec_8
  8823 00010089 C3                  <1> 	retn
  8824                              <1> m_pix_op_dec_1:
  8825 0001008A 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8826 00010091 774D                <1> 	ja	short m_pix_op_dec_3 ; 32bpp	
  8827 00010093 722B                <1> 	jb	short m_pix_op_dec_2 ; 16bpp
  8828                              <1> 	; 24 bit true colors
  8829                              <1> 	;jmp	short m_pix_op_dec_24
  8830                              <1> m_pix_op_dec_24:
  8831                              <1> 	; 24 bit true colors
  8832 00010095 66AD                <1> 	lodsw
  8833 00010097 C1E010              <1> 	shl	eax, 16
  8834 0001009A AC                  <1> 	lodsb
  8835 0001009B C1C010              <1> 	rol	eax, 16	
  8836 0001009E 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8837 000100A4 7414                <1> 	je	short m_pix_op_dec_24_1 ; exclude
  8838 000100A6 48                  <1> 	dec	eax
  8839 000100A7 7901                <1> 	jns	short m_pix_op_dec_24_0
  8840 000100A9 40                  <1> 	inc	eax 
  8841                              <1> m_pix_op_dec_24_0:
  8842 000100AA 668907              <1> 	mov	[edi], ax
  8843 000100AD C1E810              <1> 	shr	eax, 16
  8844 000100B0 884702              <1> 	mov	[edi+2], al
  8845 000100B3 8305[64030300]03    <1> 	add	dword [u.r0], 3 ; +3
  8846                              <1> m_pix_op_dec_24_1:
  8847 000100BA 83C703              <1> 	add	edi, 3 ; +3
  8848 000100BD E2D6                <1> 	loop	m_pix_op_dec_24
  8849 000100BF C3                  <1> 	retn
  8850                              <1> 	; 65536 colors (16bpp)
  8851                              <1> m_pix_op_dec_2:
  8852                              <1> 	;jmp	short m_pix_op_dec_16
  8853                              <1> m_pix_op_dec_16:
  8854                              <1> 	; 16 bit colors (65536 colors)
  8855 000100C0 66AD                <1> 	lodsw
  8856 000100C2 663B05[9A120300]    <1> 	cmp	ax, [maskcolor]
  8857 000100C9 740F                <1> 	je	short m_pix_op_dec_16_1 ; exclude
  8858 000100CB 66FF0F              <1> 	dec	word [edi]
  8859 000100CE 7903                <1> 	jns	short m_pix_op_dec_16_0
  8860 000100D0 66FF07              <1> 	inc	word [edi]
  8861                              <1> m_pix_op_dec_16_0:
  8862 000100D3 8305[64030300]02    <1> 	add	dword [u.r0], 2 ; +2
  8863                              <1> m_pix_op_dec_16_1:
  8864 000100DA 83C702              <1> 	add	edi, 2 ; +2
  8865 000100DD E2E1                <1> 	loop	m_pix_op_dec_16
  8866 000100DF C3                  <1> 	retn
  8867                              <1> m_pix_op_dec_3:
  8868                              <1> 	; 32 bit true colors
  8869                              <1> 	;jmp	short m_pix_op_dec_32
  8870                              <1> m_pix_op_dec_32:
  8871                              <1> 	; 32 bit true colors
  8872 000100E0 AD                  <1> 	lodsd 
  8873 000100E1 3B05[9A120300]      <1> 	cmp	eax, [maskcolor]
  8874 000100E7 740D                <1> 	je	short m_pix_op_dec_32_1 ; exclude
  8875 000100E9 FF0F                <1> 	dec	dword [edi]
  8876 000100EB 7902                <1> 	jns	short m_pix_op_dec_32_0
  8877 000100ED FF07                <1> 	inc	dword [edi]
  8878                              <1> m_pix_op_dec_32_0:	
  8879 000100EF 8305[64030300]04    <1> 	add	dword [u.r0], 4 ; +4
  8880                              <1> m_pix_op_dec_32_1:
  8881 000100F6 83C704              <1> 	add	edi, 4 ; +4
  8882 000100F9 E2E5                <1> 	loop	m_pix_op_dec_32
  8883 000100FB C3                  <1> 	retn
  8884                              <1> 
  8885                              <1> m_pix_op_dec_w:
  8886                              <1> 	; 06/02/2021
  8887                              <1> 	; DECREASE COLOR (MASKED, window)
  8888                              <1> 	;
  8889                              <1> 	; jump from pix_op_dec_w
  8890                              <1> 	;
  8891                              <1> 	; INPUT:
  8892                              <1> 	;   ecx = bytes per row (to be applied)
  8893                              <1> 	;   edx = screen width in bytes
  8894                              <1> 	;   ebx = row count
  8895                              <1> 	;
  8896                              <1> 	;   [maskcolor] = mask color (to be excluded)
  8897                              <1> 	;
  8898                              <1> 	; OUTPUT:
  8899                              <1> 	; 	[u.r0] will be > 0 if succesful
  8900                              <1> 
  8901                              <1> 	; window
  8902                              <1> 	;mov	edi, [v_str] ; LFB start address
  8903                              <1> 	;mov	esi, edi 
  8904                              <1> 
  8905 000100FC 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  8906 00010103 7707                <1> 	ja	short m_pix_op_dec_w_1
  8907                              <1> 
  8908                              <1> 	; 256 colors (8bpp)
  8909 00010105 BD[71000100]        <1> 	mov	ebp, m_pix_op_dec_8
  8910 0001010A EB1E                <1> 	jmp	short m_pix_op_dec_w_4
  8911                              <1> 			
  8912                              <1> m_pix_op_dec_w_1:
  8913 0001010C 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  8914 00010113 7710                <1> 	ja	short m_pix_op_dec_w_3 ; 32bpp
  8915 00010115 7207                <1> 	jb	short m_pix_op_dec_w_2 ; 16bpp
  8916                              <1> 
  8917                              <1> 	; 24 bit true colors
  8918 00010117 BD[95000100]        <1> 	mov	ebp, m_pix_op_dec_24
  8919 0001011C EB0C                <1> 	jmp	short m_pix_op_dec_w_4
  8920                              <1> 
  8921                              <1> 	; 65536 colors (16bpp)
  8922                              <1> m_pix_op_dec_w_2:
  8923 0001011E BD[C0000100]        <1> 	mov	ebp, m_pix_op_dec_16
  8924 00010123 EB05                <1> 	jmp	short m_pix_op_dec_w_4
  8925                              <1> 
  8926                              <1> 	; 32 bit true colors
  8927                              <1> m_pix_op_dec_w_3:
  8928 00010125 BD[E0000100]        <1> 	mov	ebp, m_pix_op_dec_32
  8929                              <1> m_pix_op_dec_w_4:
  8930 0001012A E90CF8FFFF          <1> 	jmp	m_pix_op_dec_w_x
  8931                              <1> 
  8932                              <1> sysvideo_39:
  8933                              <1> 	; 15/02/2021
  8934                              <1> 	; 07/02/2021, 08/02/2021
  8935                              <1> 	; 03/01/2021, 04/01/2021
  8936                              <1> 	; 23/11/2020
  8937                              <1> 	; BH = 3
  8938                              <1> 	; PIXEL READ/WRITE
  8939                              <1> 	
  8940                              <1> 	; 07/02/2021
  8941                              <1> 	; 04/01/2021 (TRDOS 386 v2.0.3)
  8942 0001012F 80FB03              <1> 	cmp	bl, 3
  8943 00010132 761A                <1> 	jna	short sysvideo_39_1
  8944                              <1> 	; 07/02/2021
  8945 00010134 80FB06              <1> 	cmp	bl, 6
  8946 00010137 7705                <1> 	ja	short sysvideo_39_0
  8947 00010139 E91A010000          <1> 	jmp	sysvideo_39_31
  8948                              <1> sysvideo_39_0:
  8949                              <1> 	; error
  8950 0001013E B3FF                <1> 	mov	bl, 0FFh
  8951 00010140 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  8952 00010146 895D10              <1> 	mov	[ebp+16], ebx ; EBX
  8953 00010149 E9AED7FFFF          <1> 	jmp	sysret
  8954                              <1> sysvideo_39_1:
  8955 0001014E 803D[CA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh
  8956 00010155 7312                <1> 	jnb	short sysvideo_39_2 ; SVGA (VESA VBE) video mode
  8957                              <1> 
  8958                              <1> 	; Std VGA or CGA mode
  8959 00010157 81C200000A00        <1> 	add	edx, 0A0000h
  8960 0001015D 72DF                <1> 	jc	short sysvideo_39_0
  8961 0001015F 81FAFFFF0A00        <1> 	cmp	edx, 0AFFFFh
  8962 00010165 77D7                <1> 	ja	short sysvideo_39_0
  8963 00010167 EB1E                <1> 	jmp	short sysvideo_39_3 ; 8bpp
  8964                              <1> 
  8965                              <1> sysvideo_39_2:
  8966                              <1> 	; use current vbe (svga) video mode
  8967                              <1> 
  8968                              <1> 	; get LFB address
  8969 00010169 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  8970 0001016E 09C0                <1> 	or	eax, eax
  8971 00010170 74CC                <1> 	jz	short sysvideo_39_0
  8972 00010172 3B15[30120300]      <1> 	cmp	edx, [LFB_SIZE] 
  8973 00010178 73C4                <1> 	jnb	short sysvideo_39_0
  8974                              <1> 
  8975 0001017A 01C2                <1> 	add	edx, eax
  8976                              <1> 	;jc	short sysvideo_39_0
  8977                              <1> 
  8978                              <1> 	; Pixel read/write in VESA VBE (2/3) video mode
  8979                              <1> 	; Video memory at Linear Frame Buffer base address
  8980                              <1> 
  8981 0001017C 8A3D[38120300]      <1> 	mov	bh, [LFB_Info+LFBINFO.bpp]
  8982                              <1> 
  8983 00010182 80FF08              <1> 	cmp	bh, 8 ; 8bpp
  8984 00010185 775D                <1> 	ja	short sysvideo_39_17
  8985                              <1> 
  8986                              <1> 	; 8 bits per pixel
  8987                              <1> sysvideo_39_3:
  8988 00010187 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  8989 0001018A 7406                <1> 	je	short sysvideo_39_5
  8990 0001018C 7712                <1> 	ja	short sysvideo_39_8
  8991                              <1> sysvideo_39_4:
  8992                              <1> 	; read pixel (8bpp)
  8993 0001018E 8A02                <1> 	mov	al, [edx]
  8994                              <1> 	;mov	[u.r0], al
  8995                              <1> 	;jmp	sysret
  8996 00010190 EB04                <1> 	jmp	short sysvideo_39_7
  8997                              <1> sysvideo_39_5:
  8998                              <1> 	; write pixel (8bpp)
  8999 00010192 88C8                <1> 	mov	al, cl
  9000                              <1> sysvideo_39_6:
  9001 00010194 8802                <1> 	mov	[edx], al
  9002                              <1> sysvideo_39_7:
  9003 00010196 A2[64030300]        <1> 	mov	[u.r0], al
  9004 0001019B E95CD7FFFF          <1> 	jmp	sysret
  9005                              <1> sysvideo_39_8:
  9006 000101A0 80FB03              <1> 	cmp	bl, 3 ; mix
  9007 000101A3 7208                <1> 	jb	short sysvideo_39_9
  9008                              <1> 	; mix  pixel colors (8bpp)
  9009 000101A5 8A02                <1> 	mov	al, [edx]
  9010 000101A7 00C8                <1> 	add	al, cl
  9011 000101A9 D0D8                <1> 	rcr	al, 1
  9012 000101AB EBE7                <1> 	jmp	short sysvideo_39_6
  9013                              <1> sysvideo_39_9:
  9014                              <1> 	 ; swap pixel colors (8bpp)
  9015 000101AD 88C8                <1> 	mov	al, cl
  9016 000101AF 8602                <1> 	xchg	[edx], al
  9017 000101B1 EBE3                <1> 	jmp	short sysvideo_39_7
  9018                              <1> 
  9019                              <1> 	; 16 bits per pixel
  9020                              <1> sysvideo_39_10:
  9021 000101B3 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9022 000101B6 7406                <1> 	je	short sysvideo_39_12
  9023 000101B8 7714                <1> 	ja	short sysvideo_39_15
  9024                              <1> sysvideo_39_11:
  9025                              <1> 	; read pixel (16bpp)
  9026 000101BA 8B02                <1> 	mov	eax, [edx]
  9027                              <1> 	;mov	[u.r0], ax
  9028                              <1> 	;jmp	sysret
  9029 000101BC EB05                <1> 	jmp	short sysvideo_39_14
  9030                              <1> sysvideo_39_12:
  9031                              <1> 	; write pixel (16bpp)
  9032 000101BE 89C8                <1> 	mov	eax, ecx
  9033                              <1> sysvideo_39_13:
  9034 000101C0 668902              <1> 	mov	[edx], ax
  9035                              <1> sysvideo_39_14:
  9036 000101C3 66A3[64030300]      <1> 	mov	[u.r0], ax
  9037 000101C9 E92ED7FFFF          <1> 	jmp	sysret
  9038                              <1> sysvideo_39_15:
  9039 000101CE 80FB03              <1> 	cmp	bl, 3 ; mix
  9040 000101D1 720A                <1> 	jb	short sysvideo_39_16
  9041                              <1> 	; mix  pixel colors (16bpp)
  9042 000101D3 8B02                <1> 	mov	eax, [edx]
  9043 000101D5 6601C8              <1> 	add	ax, cx
  9044 000101D8 66D1D8              <1> 	rcr	ax, 1
  9045 000101DB EBE3                <1> 	jmp	short sysvideo_39_13
  9046                              <1> sysvideo_39_16:
  9047                              <1> 	 ; swap pixel colors (16bpp)
  9048 000101DD 89C8                <1> 	mov	eax, ecx
  9049 000101DF 668702              <1> 	xchg	[edx], ax
  9050 000101E2 EBDF                <1> 	jmp	short sysvideo_39_14
  9051                              <1> sysvideo_39_17:
  9052 000101E4 80FF18              <1> 	cmp	bh, 24
  9053 000101E7 7743                <1> 	ja	short sysvideo_39_24
  9054 000101E9 72C8                <1> 	jb	short sysvideo_39_10  
  9055                              <1> 	
  9056                              <1> 	; 24 bits per pixel
  9057 000101EB 81E1FFFFFF00        <1> 	and	ecx, 0FFFFFFh
  9058 000101F1 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9059 000101F4 7406                <1> 	je	short sysvideo_39_19
  9060 000101F6 7712                <1> 	ja	short sysvideo_39_22
  9061                              <1> sysvideo_39_18:
  9062                              <1> 	; read pixel (24bpp)
  9063 000101F8 8B02                <1> 	mov	eax, [edx]
  9064                              <1> 	;and	eax, 0FFFFFFh
  9065                              <1> 	;mov	[u.r0], eax
  9066                              <1> 	;jmp	sysret
  9067 000101FA EB04                <1> 	jmp	short sysvideo_39_21
  9068                              <1> sysvideo_39_19:
  9069                              <1> 	; write pixel (24bpp)
  9070 000101FC 89C8                <1> 	mov	eax, ecx
  9071                              <1> sysvideo_39_20:
  9072                              <1> 	;and	eax, 0FFFFFFh
  9073 000101FE 8902                <1> 	mov	[edx], eax
  9074                              <1> sysvideo_39_21:
  9075 00010200 A3[64030300]        <1> 	mov	[u.r0], eax
  9076 00010205 E9F2D6FFFF          <1> 	jmp	sysret
  9077                              <1> sysvideo_39_22:
  9078 0001020A 80FB03              <1> 	cmp	bl, 3 ; mix
  9079 0001020D 720D                <1> 	jb	short sysvideo_39_23
  9080                              <1> 	; mix  pixel colors (24bpp)
  9081 0001020F 8B02                <1> 	mov	eax, [edx]
  9082 00010211 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9083                              <1> 	;and	ecx, 0FFFFFFh
  9084 00010216 01C8                <1> 	add	eax, ecx
  9085 00010218 D1D8                <1> 	rcr	eax, 1
  9086 0001021A EBE2                <1> 	jmp	short sysvideo_39_20
  9087                              <1> sysvideo_39_23:
  9088                              <1> 	 ; swap pixel colors (24bpp)
  9089 0001021C 89C8                <1> 	mov	eax, ecx
  9090                              <1> 	;and	eax, 0FFFFFFh
  9091 0001021E 668702              <1> 	xchg	[edx], ax
  9092 00010221 C1C810              <1> 	ror	eax, 16
  9093 00010224 884202              <1> 	mov	[edx+2], al	
  9094 00010227 C1C010              <1> 	rol	eax, 16
  9095 0001022A EBD4                <1> 	jmp	short sysvideo_39_21
  9096                              <1> 
  9097                              <1> 	; 32 bits per pixel
  9098                              <1> sysvideo_39_24:
  9099 0001022C 80FB01              <1> 	cmp	bl, 1 ; 1 = write pixel
  9100 0001022F 7406                <1> 	je	short sysvideo_39_26
  9101 00010231 7712                <1> 	ja	short sysvideo_39_29
  9102                              <1> sysvideo_39_25:
  9103                              <1> 	; read pixel (32bpp)
  9104 00010233 8B02                <1> 	mov	eax, [edx]
  9105                              <1> 	;mov	[u.r0], eax
  9106                              <1> 	;jmp	sysret
  9107 00010235 EB04                <1> 	jmp	short sysvideo_39_28
  9108                              <1> sysvideo_39_26:
  9109                              <1> 	; write pixel (32bpp)
  9110 00010237 89C8                <1> 	mov	eax, ecx
  9111                              <1> sysvideo_39_27:
  9112 00010239 8902                <1> 	mov	[edx], eax
  9113                              <1> sysvideo_39_28:
  9114 0001023B A3[64030300]        <1> 	mov	[u.r0], eax
  9115 00010240 E9B7D6FFFF          <1> 	jmp	sysret
  9116                              <1> sysvideo_39_29:
  9117 00010245 80FB03              <1> 	cmp	bl, 3 ; mix
  9118 00010248 7208                <1> 	jb	short sysvideo_39_30
  9119                              <1> 	; mix  pixel colors (32bpp)
  9120 0001024A 8B02                <1> 	mov	eax, [edx]
  9121 0001024C 01C8                <1> 	add	eax, ecx
  9122 0001024E D1D8                <1> 	rcr	eax, 1
  9123 00010250 EBE7                <1> 	jmp	short sysvideo_39_27
  9124                              <1> sysvideo_39_30:
  9125                              <1> 	 ; swap pixel colors (32bpp)
  9126 00010252 89C8                <1> 	mov	eax, ecx
  9127 00010254 8702                <1> 	xchg	[edx], eax
  9128 00010256 EBE3                <1> 	jmp	short sysvideo_39_28
  9129                              <1> 
  9130                              <1> sysvideo_39_31:
  9131                              <1> 	; 08/02/2021
  9132                              <1> 	; 07/02/2021
  9133                              <1> 	; BL = 4 -> read pixels from user defined positions
  9134                              <1> 	; BL = 5 -> write single color pixels to user defined pos.
  9135                              <1> 	; BL = 6 -> write multi color pixels to user defined pos.
  9136                              <1> 	; ECX = color (CL, CX, ECX)
  9137                              <1> 	; EDX = number of pixels
  9138                              <1> 	; ESI = user buffer contains dword pixel positions
  9139                              <1> 	;	 (and dword colors for BL input = 6)
  9140                              <1> 	; EDI = user's pixel color buff (destination) for BL = 4
  9141                              <1> 
  9142 00010258 890D[9A120300]      <1> 	mov	[maskcolor], ecx
  9143 0001025E 89D5                <1> 	mov	ebp, edx ; number of pixels    
  9144 00010260 803D[CA6F0000]FF    <1> 	cmp	byte [CRT_MODE], 0FFh ; SVGA flag
  9145 00010267 7317                <1> 	jnb	short sysvideo_39_33 ; SVGA (VESA VBE mode)
  9146                              <1> 	; Standard VGA mode
  9147 00010269 B900000100          <1> 	mov	ecx, 65536 ; Video page size (maximum)
  9148 0001026E 39CA                <1> 	cmp	edx, ecx
  9149 00010270 7709                <1> 	ja	short sysvideo_39_32 ; abnormal value !
  9150 00010272 B800000A00          <1> 	mov	eax, 0A0000h ; Video page start address
  9151 00010277 B208                <1> 	mov	dl, 8  ; 8 bits per pixel (256 colors)
  9152 00010279 EB20                <1> 	jmp	short sysvideo_39_34
  9153                              <1> sysvideo_39_32:
  9154                              <1> 	; nonsense! (edx has abnormal value)
  9155 0001027B E97CD6FFFF          <1> 	jmp	sysret	
  9156                              <1> sysvideo_39_33:
  9157                              <1> 	; get LFB address
  9158 00010280 A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
  9159 00010285 09C0                <1> 	or	eax, eax
  9160 00010287 74F2                <1> 	jz	short sysvideo_39_32 ; LFB is not ready !
  9161 00010289 8B0D[30120300]      <1> 	mov	ecx, [LFB_SIZE]
  9162 0001028F 39CA                <1> 	cmp	edx, ecx 
  9163 00010291 77E8                <1> 	ja	short sysvideo_39_32 ; abnormal value !
  9164                              <1> 
  9165                              <1> 	; 08/02/2021
  9166 00010293 89D5                <1> 	mov	ebp, edx ; pixel count  
  9167                              <1> 	;shl	ebp, 2 ; byte count (pixel pos: 4 bytes)
  9168                              <1> 
  9169                              <1> 	; bits per pixel (pixel color size)
  9170 00010295 8A15[38120300]      <1> 	mov	dl, [LFB_Info+LFBINFO.bpp]	
  9171                              <1> sysvideo_39_34:
  9172 0001029B C1E502              <1> 	shl	ebp, 2 ; 15/02/2021 (byte count)	
  9173 0001029E A3[8A120300]        <1> 	mov	[v_mem], eax ; Save video page start address
  9174                              <1> 	;mov	[v_siz], ecx ; Video page size (limit)
  9175                              <1> 	;mov	ebx, [v_siz]
  9176 000102A3 88DE                <1> 	mov	dh, bl ; sub function
  9177 000102A5 89CB                <1> 	mov	ebx, ecx ; [v_siz] 
  9178 000102A7 8815[89120300]      <1> 	mov	[v_bpp], dl ; bits per pixel (color size)
  9179                              <1> 
  9180 000102AD B900080000          <1> 	mov	ecx, 2048
  9181 000102B2 39CD                <1> 	cmp	ebp, ecx
  9182 000102B4 7302                <1> 	jnb	short sysvideo_39_35 	
  9183 000102B6 89E9                <1> 	mov	ecx, ebp ; fix to requested byte count	
  9184                              <1> sysvideo_39_35:
  9185 000102B8 80FE04              <1> 	cmp	dh, 4 ; 08/02/2021
  9186                              <1> 	;cmp	bl, 4 ; read pixels from user defined positions 
  9187 000102BB 7605                <1> 	jna	short sysvideo_39_36
  9188 000102BD E9B2000000          <1> 	jmp	sysvideo_39_52
  9189                              <1> 	; 08/02/2021
  9190                              <1> 	;mov	[buffer8], edi  ; user's destination buff addr
  9191                              <1> sysvideo_39_36:
  9192                              <1> 	; 08/02/2021
  9193                              <1> 	; read pixel positions 
  9194                              <1> 	; as defined in user's source buffer 
  9195 000102C2 893D[A2120300]      <1> 	mov	[buffer8], edi  ; user's destination buff addr
  9196 000102C8 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9197                              <1> 					  ; 2028 byte data
  9198                              <1> 	; esi = user's source buffer for pixel positions
  9199                              <1> 	; ecx = byte count
  9200 000102CD E87C180000          <1> 	call	transfer_from_user_buffer
  9201 000102D2 72A7                <1> 	jc	short sysvideo_39_32 ; error
  9202                              <1> 	; ecx  = transfer count (bytes)
  9203                              <1> 
  9204 000102D4 57                  <1> 	push	edi ; *
  9205 000102D5 56                  <1> 	push	esi ; **
  9206 000102D6 51                  <1> 	push	ecx ; ***
  9207                              <1> 
  9208 000102D7 89FE                <1> 	mov	esi, edi ; kernel buffer
  9209 000102D9 8B15[8A120300]      <1> 	mov	edx, [v_mem] ; video memory
  9210 000102DF C1E902              <1> 	shr	ecx, 2 ; pixel count (within buffer capacity)
  9211                              <1> 
  9212 000102E2 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9213 000102E9 7753                <1> 	ja	short sysvideo_39_49
  9214                              <1> sysvideo_39_37:
  9215                              <1> 	; 8bpp
  9216 000102EB AD                  <1> 	lodsd
  9217 000102EC 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9218 000102EE 7309                <1> 	jnb	short sysvideo_39_39
  9219 000102F0 0FB60402            <1> 	movzx	eax, byte [edx+eax]
  9220                              <1> sysvideo_39_38:
  9221 000102F4 AB                  <1> 	stosd
  9222 000102F5 E2F4                <1> 	loop	sysvideo_39_37
  9223 000102F7 EB49                <1> 	jmp	short sysvideo_39_50
  9224                              <1> sysvideo_39_39:
  9225                              <1> 	; write black color for improper positions
  9226 000102F9 31C0                <1> 	xor	eax, eax
  9227 000102FB EBF7                <1> 	jmp	short sysvideo_39_38
  9228                              <1> sysvideo_39_40:
  9229 000102FD 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9230 00010304 772A                <1> 	ja	short sysvideo_39_47 ; 32bpp
  9231 00010306 7216                <1> 	jb	short sysvideo_39_44 ; 16bpp
  9232                              <1> sysvideo_39_41: 
  9233                              <1> 	; 24bpp
  9234 00010308 AD                  <1> 	lodsd
  9235 00010309 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9236 0001030B 730D                <1> 	jnb	short sysvideo_39_43
  9237 0001030D 8B0402              <1> 	mov	eax, [edx+eax]
  9238 00010310 25FFFFFF00          <1> 	and	eax, 0FFFFFFh
  9239                              <1> sysvideo_39_42:
  9240 00010315 AB                  <1> 	stosd
  9241 00010316 E2F0                <1> 	loop	sysvideo_39_41
  9242 00010318 EB28                <1> 	jmp	short sysvideo_39_50
  9243                              <1> sysvideo_39_43:
  9244                              <1> 	; write black color for improper positions
  9245 0001031A 31C0                <1> 	xor	eax, eax
  9246 0001031C EBF7                <1> 	jmp	short sysvideo_39_42
  9247                              <1> sysvideo_39_44:
  9248                              <1> 	; 16bpp
  9249 0001031E AD                  <1> 	lodsd
  9250 0001031F 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9251 00010321 7309                <1> 	jnb	short sysvideo_39_46
  9252 00010323 0FB70402            <1> 	movzx	eax, word [edx+eax]
  9253                              <1> sysvideo_39_45:
  9254 00010327 AB                  <1> 	stosd
  9255 00010328 E2F4                <1> 	loop	sysvideo_39_44
  9256 0001032A EB16                <1> 	jmp	short sysvideo_39_50
  9257                              <1> sysvideo_39_46:
  9258                              <1> 	; write black color for improper positions
  9259 0001032C 31C0                <1> 	xor	eax, eax
  9260 0001032E EBF7                <1> 	jmp	short sysvideo_39_45
  9261                              <1> sysvideo_39_47:
  9262                              <1> 	; 32bpp
  9263 00010330 AD                  <1> 	lodsd
  9264 00010331 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9265 00010333 7309                <1> 	jnb	short sysvideo_39_49
  9266 00010335 0FB70402            <1> 	movzx	eax, word [edx+eax]
  9267                              <1> sysvideo_39_48:
  9268 00010339 AB                  <1> 	stosd
  9269 0001033A E2F4                <1> 	loop	sysvideo_39_47
  9270 0001033C EB04                <1> 	jmp	short sysvideo_39_50
  9271                              <1> sysvideo_39_49:
  9272                              <1> 	; write black color for improper positions
  9273 0001033E 31C0                <1> 	xor	eax, eax
  9274 00010340 EBF7                <1> 	jmp	short sysvideo_39_48
  9275                              <1> sysvideo_39_50:
  9276 00010342 59                  <1> 	pop	ecx ; transfer count in bytes
  9277 00010343 5E                  <1> 	pop	esi ; ** ; kernel buffer
  9278                              <1>  	;mov	esi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9279                              <1> 					  ; 2028 byte data
  9280 00010344 8B3D[A2120300]      <1> 	mov	edi, [buffer8]
  9281                              <1> 	; edi = user's destination buffer for pixel colors
  9282                              <1> 	; ecx = byte count
  9283 0001034A E8B5170000          <1> 	call	transfer_to_user_buffer
  9284 0001034F 5E                  <1> 	pop	esi ; *
  9285 00010350 7260                <1> 	jc	short sysvideo_39_56 ; error
  9286                              <1> 	; ecx  = transfer count (bytes)
  9287 00010352 89C8                <1> 	mov	eax, ecx
  9288 00010354 C1E802              <1> 	shr	eax, 2
  9289 00010357 0105[64030300]      <1> 	add	[u.r0], eax ; transfer count (in pixels)
  9290                              <1> 		
  9291 0001035D 29CD                <1> 	sub	ebp, ecx
  9292 0001035F 7651                <1> 	jna	short sysvideo_39_56 ; completed/finished
  9293 00010361 01CE                <1> 	add	esi, ecx ; next position in source buffer
  9294                              <1> 	;add	[buffer8], ecx ; next pos in destination buff
  9295 00010363 01CF                <1> 	add	edi, ecx
  9296 00010365 66B90008            <1> 	mov	cx, 2048 ; new count, limit: kernel buff size
  9297 00010369 39CD                <1> 	cmp	ebp, ecx ; remain >= limit ?
  9298 0001036B 7302                <1> 	jnb	short sysvideo_39_51 ; yes
  9299 0001036D 89E9                <1> 	mov	ecx, ebp ; fix byte count to remain bytes
  9300                              <1> sysvideo_39_51:
  9301 0001036F E94EFFFFFF          <1> 	jmp	sysvideo_39_36 
  9302                              <1> 
  9303                              <1> sysvideo_39_52:
  9304 00010374 80FE05              <1> 	cmp	dh, 5 ; 08/02/2021
  9305                              <1> 	;cmp	bl, 5 ; write pixels to user defined positions 
  9306 00010377 7605                <1> 	jna	short sysvideo_39_53
  9307 00010379 E99B000000          <1> 	jmp	sysvideo_39_66
  9308                              <1> sysvideo_39_53:
  9309                              <1> 	; single color pixel writing
  9310 0001037E BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9311                              <1> 					  ; 2028 byte data
  9312                              <1> 	; esi = user's source buffer for pixel positions
  9313                              <1> 	; ecx = byte count
  9314 00010383 E8C6170000          <1> 	call	transfer_from_user_buffer
  9315 00010388 7228                <1> 	jc	short sysvideo_39_56 ; error
  9316                              <1> 	; ecx = transfer count (bytes)
  9317                              <1> 
  9318                              <1> 	; write pixels by using (user) defined positions
  9319                              <1> 	; ecx = byte count (1,2,3,4 times pixel count)	
  9320                              <1> 	; edi = system buffer address
  9321                              <1> 
  9322 0001038A 56                  <1> 	push	esi ; **
  9323 0001038B 51                  <1> 	push	ecx ; *
  9324                              <1> 
  9325 0001038C 89FE                <1> 	mov	esi, edi
  9326 0001038E 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  9327                              <1> 
  9328                              <1> 	; 08/02/2021
  9329 00010394 C1E902              <1> 	shr	ecx, 2 ; pixel count
  9330 00010397 8B15[9A120300]      <1> 	mov	edx, [maskcolor]
  9331                              <1> 	;mov	ebx, [v_siz]
  9332                              <1> 
  9333 0001039D 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9334 000103A4 7711                <1> 	ja	short sysvideo_39_57
  9335                              <1> sysvideo_39_54:
  9336                              <1> 	; 8bpp
  9337 000103A6 AD                  <1> 	lodsd
  9338 000103A7 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9339 000103A9 7303                <1> 	jnb	short sysvideo_39_55
  9340 000103AB 881407              <1> 	mov	[edi+eax], dl
  9341                              <1> sysvideo_39_55:
  9342 000103AE E2F6                <1> 	loop	sysvideo_39_54
  9343 000103B0 EB50                <1> 	jmp	short sysvideo_39_64
  9344                              <1> sysvideo_39_56:
  9345 000103B2 E945D5FFFF          <1> 	jmp	sysret
  9346                              <1> sysvideo_39_57:
  9347 000103B7 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9348 000103BE 7732                <1> 	ja	short sysvideo_39_62 ; 32bpp
  9349 000103C0 721D                <1> 	jb	short sysvideo_39_60 ; 16bpp
  9350                              <1> sysvideo_39_58: 
  9351                              <1> 	; 24bpp
  9352 000103C2 AD                  <1> 	lodsd
  9353 000103C3 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9354 000103C5 7314                <1> 	jnb	short sysvideo_39_59
  9355 000103C7 881407              <1> 	mov	[edi+eax], dl
  9356 000103CA 40                  <1> 	inc	eax
  9357 000103CB C1CA08              <1> 	ror	edx, 8
  9358 000103CE 66891407            <1> 	mov	[edi+eax], dx
  9359 000103D2 C1C208              <1> 	rol	edx, 8
  9360 000103D5 FF05[64030300]      <1> 	inc	dword [u.r0]
  9361                              <1> sysvideo_39_59:
  9362 000103DB E2E5                <1> 	loop	sysvideo_39_58
  9363 000103DD EB23                <1> 	jmp	short sysvideo_39_64
  9364                              <1> sysvideo_39_60:
  9365                              <1> 	; 16bpp
  9366 000103DF AD                  <1> 	lodsd
  9367 000103E0 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9368 000103E2 730A                <1> 	jnb	short sysvideo_39_61
  9369 000103E4 66891407            <1> 	mov	[edi+eax], dx
  9370 000103E8 FF05[64030300]      <1> 	inc	dword [u.r0]
  9371                              <1> sysvideo_39_61:	
  9372 000103EE E2EF                <1> 	loop	sysvideo_39_60
  9373 000103F0 EB10                <1> 	jmp	short sysvideo_39_64	
  9374                              <1> sysvideo_39_62:
  9375                              <1> 	; 32bpp
  9376 000103F2 AD                  <1> 	lodsd
  9377 000103F3 39D8                <1> 	cmp	eax, ebx ; < [v_siz]
  9378 000103F5 7309                <1> 	jnb	short sysvideo_39_63
  9379 000103F7 891407              <1> 	mov	[edi+eax], edx
  9380 000103FA FF05[64030300]      <1> 	inc	dword [u.r0]
  9381                              <1> sysvideo_39_63:	
  9382 00010400 E2F0                <1> 	loop	sysvideo_39_62
  9383                              <1> sysvideo_39_64:
  9384 00010402 59                  <1> 	pop	ecx ; **
  9385 00010403 5E                  <1> 	pop	esi ; *	
  9386 00010404 29CD                <1> 	sub	ebp, ecx
  9387 00010406 76AA                <1> 	jna	short sysvideo_39_56
  9388 00010408 01CE                <1> 	add	esi, ecx
  9389 0001040A 66B90008            <1> 	mov	cx, 2048
  9390 0001040E 39CD                <1> 	cmp	ebp, ecx
  9391 00010410 7302                <1> 	jnb	short sysvideo_39_65
  9392 00010412 89E9                <1> 	mov	ecx, ebp
  9393                              <1> sysvideo_39_65:
  9394 00010414 E965FFFFFF          <1> 	jmp	sysvideo_39_53
  9395                              <1> 
  9396                              <1> sysvideo_39_66:
  9397                              <1> 	; 15/02/2021
  9398 00010419 D1E5                <1> 	shl	ebp, 1 ; 8 bytes per pixel (position&color)
  9399                              <1> sysvideo_39_67: 	
  9400 0001041B 66B90008            <1> 	mov	cx, 2048
  9401 0001041F 39CD                <1> 	cmp	ebp, ecx
  9402 00010421 7302                <1> 	jnb	short sysvideo_39_68
  9403 00010423 89E9                <1> 	mov	ecx, ebp
  9404                              <1> sysvideo_39_68:
  9405                              <1> 	; multi colors pixel writing
  9406 00010425 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK ; kernel buffer for
  9407                              <1> 					  ; 2048 byte data
  9408                              <1> 	; esi = user's source buffer for pixel positions
  9409                              <1> 	; ecx = byte count
  9410 0001042A E81F170000          <1> 	call	transfer_from_user_buffer
  9411 0001042F 7281                <1> 	jc	short sysvideo_39_56 ; error
  9412                              <1> 	; ecx  = transfer count
  9413                              <1> 	
  9414                              <1> 	; write pixels & colors as defined in user buffer 
  9415                              <1> 	; ecx = byte count (2,4,6,8 times pixel count)	
  9416                              <1> 	; edi = system buffer address
  9417                              <1> 
  9418 00010431 56                  <1> 	push	esi ; **
  9419 00010432 51                  <1> 	push	ecx ; *
  9420                              <1> 
  9421 00010433 89FE                <1> 	mov	esi, edi
  9422 00010435 8B3D[8A120300]      <1> 	mov	edi, [v_mem]
  9423                              <1> 
  9424                              <1> 	; 08/02/2021
  9425 0001043B C1E903              <1> 	shr	ecx, 3 ; pixel count
  9426                              <1> 
  9427                              <1> 	;mov	ebx, [v_siz]
  9428                              <1> 
  9429 0001043E 803D[89120300]08    <1> 	cmp	byte [v_bpp], 8 ; 8bpp
  9430 00010445 770F                <1> 	ja	short sysvideo_39_71
  9431                              <1> sysvideo_39_69:
  9432                              <1> 	; 8bpp
  9433 00010447 AD                  <1> 	lodsd	; position
  9434 00010448 89C2                <1> 	mov	edx, eax
  9435 0001044A AD                  <1> 	lodsd	; color
  9436 0001044B 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9437 0001044D 7303                <1> 	jnb	short sysvideo_39_70
  9438 0001044F 880417              <1> 	mov	[edi+edx], al
  9439                              <1> sysvideo_39_70:
  9440 00010452 E2F3                <1> 	loop	sysvideo_39_69
  9441 00010454 EB51                <1> 	jmp	short sysvideo_39_78
  9442                              <1> sysvideo_39_71:
  9443 00010456 803D[89120300]18    <1> 	cmp	byte [v_bpp], 24 ; 24bpp
  9444 0001045D 7735                <1> 	ja	short sysvideo_39_76 ; 32bpp
  9445 0001045F 721D                <1> 	jb	short sysvideo_39_74 ; 16bpp
  9446                              <1> sysvideo_39_72:
  9447                              <1> 	; 24bpp 
  9448 00010461 AD                  <1> 	lodsd	; position
  9449 00010462 89C2                <1> 	mov	edx, eax
  9450 00010464 AD                  <1> 	lodsd	; color
  9451 00010465 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9452 00010467 7311                <1> 	jnb	short sysvideo_39_73
  9453 00010469 880417              <1> 	mov	[edi+edx], al
  9454 0001046C 42                  <1> 	inc	edx
  9455 0001046D C1E808              <1> 	shr	eax, 8
  9456 00010470 66890417            <1> 	mov	[edi+edx], ax
  9457 00010474 FF05[64030300]      <1> 	inc	dword [u.r0]
  9458                              <1> sysvideo_39_73:	
  9459 0001047A E2E5                <1> 	loop	sysvideo_39_72
  9460 0001047C EB29                <1> 	jmp	short sysvideo_39_78
  9461                              <1> sysvideo_39_74:
  9462                              <1> 	; 16bpp
  9463 0001047E AD                  <1> 	lodsd	; position
  9464 0001047F 89C2                <1> 	mov	edx, eax
  9465 00010481 AD                  <1> 	lodsd	; color
  9466 00010482 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9467 00010484 730A                <1> 	jnb	short sysvideo_39_75
  9468 00010486 66890417            <1> 	mov	[edi+edx], ax
  9469 0001048A FF05[64030300]      <1> 	inc	dword [u.r0]
  9470                              <1> sysvideo_39_75:	
  9471 00010490 E2EC                <1> 	loop	sysvideo_39_74
  9472 00010492 EB13                <1> 	jmp	short sysvideo_39_78
  9473                              <1> sysvideo_39_76:
  9474                              <1> 	; 32bpp
  9475 00010494 AD                  <1> 	lodsd	; position
  9476 00010495 89C2                <1> 	mov	edx, eax
  9477 00010497 AD                  <1> 	lodsd	; color
  9478 00010498 39DA                <1> 	cmp	edx, ebx ; < [v_siz]
  9479 0001049A 7309                <1> 	jnb	short sysvideo_39_77
  9480 0001049C 890417              <1> 	mov	[edi+edx], eax
  9481 0001049F FF05[64030300]      <1> 	inc	dword [u.r0]
  9482                              <1> sysvideo_39_77:	
  9483 000104A5 E2ED                <1> 	loop	sysvideo_39_76
  9484                              <1> sysvideo_39_78:
  9485 000104A7 59                  <1> 	pop	ecx ; *
  9486 000104A8 5E                  <1> 	pop	esi ; **	
  9487                              <1> 
  9488 000104A9 29CD                <1> 	sub	ebp, ecx
  9489 000104AB 762E                <1> 	jna	short sysvideo_39_79
  9490 000104AD 01CE                <1> 	add	esi, ecx
  9491 000104AF E967FFFFFF          <1> 	jmp	sysvideo_39_67
  9492                              <1> ;sysvideo_39_79:
  9493                              <1> ;	jmp	sysret
  9494                              <1> 		
  9495                              <1> sysvideo_16:
  9496                              <1> 	; 23/11/2020
  9497 000104B4 80FF04              <1> 	cmp	bh, 4
  9498 000104B7 0F8272FCFFFF        <1> 	jb	sysvideo_39 ; bh = 3, pixel r/w
  9499 000104BD 7721                <1> 	ja	short sysvideo_17
  9500                              <1> 	
  9501                              <1> 	; BH = 4
  9502                              <1> 	; Direct User Access for CGA video memory.
  9503                              <1> 	; Setup user's page tables for direct access to 0B8000h.
  9504                              <1> 	;
  9505                              <1> 	; Permission checks are not implemented yet !
  9506                              <1> 	; (11/07/2016)
  9507                              <1> 
  9508 000104BF B800800B00          <1> 	mov	eax, 0B8000h
  9509 000104C4 B908000000          <1> 	mov	ecx, 8 ; 8 pages (8*4K=32K)
  9510 000104C9 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
  9511 000104CB E82A62FFFF          <1> 	call	direct_memory_access	
  9512 000104D0 0F8226D4FFFF        <1> 	jc	sysret
  9513                              <1> 	; eax = 0B8000h if there is not an error
  9514 000104D6 A3[64030300]        <1> 	mov	[u.r0], eax
  9515                              <1> sysvideo_39_79: ; 08/01/2021
  9516 000104DB E91CD4FFFF          <1> 	jmp	sysret
  9517                              <1> 
  9518                              <1> sysvideo_17:
  9519                              <1> 	; 23/12/2020
  9520                              <1> 	; 11/12/2020
  9521                              <1> 	; 10/12/2020
  9522                              <1> 	; 23/11/2020
  9523 000104E0 80FF06              <1> 	cmp	bh, 6
  9524 000104E3 740B                <1> 	je	short sysvideo_17_0
  9525 000104E5 0F82B9000000        <1> 	jb	sysvideo_18
  9526 000104EB E913010000          <1> 	jmp	sysvideo_20 ; ja
  9527                              <1> 
  9528                              <1> sysvideo_17_0:
  9529                              <1> 	; BH = 6
  9530                              <1> 	; Direct User Access to Linear Frame Buffer.
  9531                              <1> 	; Setup user's page tables for direct access to LFB.
  9532                              <1> 	;
  9533                              <1> 	; Permission checks are not implemented yet !
  9534                              <1> 	; (10/12/2020)
  9535                              <1> 
  9536 000104F0 80FBFF              <1> 	cmp	bl, 0FFh ; current video mode
  9537 000104F3 722C                <1> 	jb	short sysvideo_17_2 ; for desired video mode
  9538                              <1> 
  9539 000104F5 381D[CA6F0000]      <1> 	cmp	[CRT_MODE], bl ; VESA VBE video mode ?
  9540 000104FB 750E                <1> 	jne	short sysvideo_17_1
  9541 000104FD 668B0D[1E120300]    <1> 	mov	cx, [video_mode]
  9542 00010504 6681E1FF01          <1> 	and	cx, 1FFh
  9543 00010509 EB29                <1> 	jmp	short sysvideo_17_3
  9544                              <1> sysvideo_17_1:
  9545                              <1> 	; 11/12/2020
  9546 0001050B 88DF                <1> 	mov	bh, bl ; 0FFh
  9547 0001050D 8A1D[CA6F0000]      <1> 	mov	bl, [CRT_MODE] ; VGA/CGA video mode
  9548 00010513 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  9549                              <1> 	; 23/12/2020
  9550 00010519 895D10              <1> 	mov	[ebp+16], ebx ; return to user with EBX value 
  9551 0001051C E9DBD3FFFF          <1> 	jmp	sysret ; return to user with EAX = 0
  9552                              <1> sysvideo_17_2:
  9553                              <1> 	; bl = VESA video mode - 100h
  9554 00010521 B701                <1> 	mov	bh, 1 ; bx = 1XXh
  9555 00010523 53                  <1> 	push	ebx ; requested vesa video mode
  9556 00010524 E88236FFFF          <1> 	call	vbe_biosfn_return_current_mode
  9557 00010529 59                  <1> 	pop	ecx ; requested vesa video mode
  9558 0001052A 6681E3FF01          <1> 	and	bx, 1FFh
  9559 0001052F 6639D9              <1> 	cmp	cx, bx
  9560 00010532 7564                <1> 	jne	short sysvideo_17_8
  9561                              <1> sysvideo_17_3:
  9562 00010534 663B0D[2A120300]    <1> 	cmp	cx, [LFB_Info+LFBINFO.mode]
  9563 0001053B 755B                <1> 	jne	short sysvideo_17_8
  9564                              <1> sysvideo_17_4:
  9565                              <1> 	; 11/12/2020
  9566 0001053D A1[2C120300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
  9567                              <1> 	; 21/12/2020
  9568 00010542 09C0                <1> 	or	eax, eax
  9569 00010544 744D                <1> 	jz	short sysvideo_17_7
  9570                              <1> 	;
  9571 00010546 8B0D[30120300]      <1> 	mov	ecx, [LFB_Info+LFBINFO.LFB_size] ; buff size
  9572 0001054C 89C3                <1> 	mov 	ebx, eax ; user's address = physical address
  9573                              <1> 	;push	ebx
  9574 0001054E 51                  <1> 	push	ecx
  9575                              <1> 	; 21/12/2020
  9576 0001054F 81C1FF0F0000        <1> 	add	ecx, 4095  ; PAGESIZE - 1
  9577                              <1> 	; 14/12/2020
  9578 00010555 C1E90C              <1> 	shr	ecx, 12  ; convert bytes to pages
  9579 00010558 E89D61FFFF          <1> 	call	direct_memory_access
  9580 0001055D 5A                  <1> 	pop	edx  ; linear frame buffer size in bytes
  9581                              <1> 	;pop	eax  ; linear frame buffer address (physical)
  9582 0001055E 7233                <1> 	jc	short sysvideo_17_7 ; [u.r0] = eax = 0
  9583                              <1> sysvideo_17_5:
  9584 00010560 668B0D[36120300]    <1> 	mov	cx, [LFB_Info+LFBINFO.Y_res] ; screen height
  9585 00010567 C1E110              <1> 	shl	ecx, 16
  9586 0001056A 668B0D[34120300]    <1> 	mov	cx,  [LFB_Info+LFBINFO.X_res] ; screen width
  9587 00010571 31DB                <1> 	xor	ebx, ebx
  9588 00010573 8A1D[38120300]      <1> 	mov	bl, [LFB_Info+LFBINFO.bpp] ; bits per pixel
  9589 00010579 8A3D[2A120300]      <1> 	mov	bh, [LFB_Info+LFBINFO.mode] ; XX part of 1XXh
  9590                              <1> sysvideo_26_4: ; 23/12/2020	
  9591 0001057F 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  9592 00010585 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
  9593 00010588 895D10              <1> 	mov	[ebp+16], ebx ; EBX
  9594 0001058B 894D18              <1> 	mov	[ebp+24], ecx ; ECX
  9595                              <1> sysvideo_17_6:
  9596 0001058E A3[64030300]        <1> 	mov	[u.r0], eax ; LFB address
  9597                              <1> sysvideo_17_7:
  9598 00010593 E964D3FFFF          <1> 	jmp	sysret 
  9599                              <1> sysvideo_17_8:
  9600                              <1> 	; cx = mode
  9601                              <1> 	; 21/12/2020
  9602 00010598 80CD40              <1> 	or	ch, 40h  ; Linear frame buffer flag	
  9603 0001059B E82D34FFFF          <1> 	call	_vbe_biosfn_return_mode_info
  9604 000105A0 72F1                <1> 	jc	short sysvideo_17_7
  9605 000105A2 EB99                <1> 	jmp	short sysvideo_17_4
  9606                              <1> 	
  9607                              <1> sysvideo_18:
  9608                              <1> 	; BH = 5
  9609                              <1> 	; Direct User Access for VGA video memory.
  9610                              <1> 	; Setup user's page tables for direct access to 0A0000h.
  9611                              <1> 	;
  9612                              <1> 	; Permission checks are not implemented yet !
  9613                              <1> 	; (11/07/2016)
  9614                              <1> 
  9615 000105A4 B800000A00          <1> 	mov	eax, 0A0000h
  9616 000105A9 B910000000          <1> 	mov	ecx, 16 ; 16 pages (16*4K=64K)
  9617 000105AE 89C3                <1> 	mov	ebx, eax ; 12/05/2017 ; virtual = physical
  9618 000105B0 E84561FFFF          <1> 	call	direct_memory_access	
  9619 000105B5 0F8241D3FFFF        <1> 	jc	sysret
  9620                              <1> 	; eax = 0A0000h if there is not an error
  9621 000105BB A3[64030300]        <1> 	mov	[u.r0], eax
  9622 000105C0 E937D3FFFF          <1> 	jmp	sysret
  9623                              <1> 
  9624                              <1> sysvideo_19:
  9625                              <1> 	; 22/01/2021
  9626                              <1> 	; 12/12/2020
  9627                              <1> 	; 11/12/2020
  9628                              <1> 	; 23/11/2020
  9629                              <1> 	; BH = 7
  9630                              <1> 	; Get (Super/Extended VGA) mode
  9631                              <1> 	; and Linear Frame Buffer info.
  9632                              <1> 	
  9633                              <1> 	; 22/01/2021
  9634 000105C5 B3FF                <1> 	mov	bl, 0FFh
  9635                              <1> 	; 11/12/2020
  9636                              <1> 	;cmp	byte [CRT_MODE], 0FFh ; (extended mode?)
  9637                              <1> 	; 22/01/2021
  9638 000105C7 381D[CA6F0000]      <1> 	cmp	[CRT_MODE], bl  ; 0FFh
  9639                              <1> 	;jb	sysvideo_17_1	; not a VESA VBE mode
  9640                              <1> 	; 12/12/2020
  9641 000105CD 7305                <1> 	jnb	short sysvideo_19_0
  9642 000105CF E937FFFFFF          <1> 	jmp	sysvideo_17_1
  9643                              <1> 
  9644                              <1> sysvideo_19_0:
  9645 000105D4 E8D235FFFF          <1> 	call	vbe_biosfn_return_current_mode
  9646 000105D9 6681E3FF01          <1> 	and	bx, 1FFh
  9647 000105DE 663B1D[2A120300]    <1> 	cmp	bx, [LFB_Info+LFBINFO.mode]
  9648 000105E5 7510                <1> 	jne	short sysvideo_19_2
  9649                              <1> sysvideo_19_1:
  9650 000105E7 A1[2C120300]        <1> 	mov	eax, [LFB_Info+LFBINFO.LFB_addr]
  9651 000105EC 8B15[30120300]      <1> 	mov	edx, [LFB_Info+LFBINFO.LFB_size]
  9652 000105F2 E969FFFFFF          <1> 	jmp	sysvideo_17_5
  9653                              <1> sysvideo_19_2:
  9654 000105F7 E8D133FFFF          <1> 	call	_vbe_biosfn_return_mode_info
  9655 000105FC 73E9                <1> 	jnc	short sysvideo_19_1
  9656 000105FE E9F9D2FFFF          <1> 	jmp	sysret
  9657                              <1> 
  9658                              <1> sysvideo_20:
  9659                              <1> 	; 11/12/2020
  9660                              <1> 	; 23/11/2020
  9661 00010603 80FF08              <1> 	cmp	bh, 8
  9662 00010606 72BD                <1> 	jb	short sysvideo_19 ; video mode & lfb info
  9663 00010608 0F8780000000        <1> 	ja	sysvideo_21 ; 12/12/2020
  9664                              <1> 
  9665                              <1> 	; BH = 8
  9666                              <1> 	; Set (Super/Extended VGA) mode & return LFB info
  9667                              <1> 	;
  9668                              <1> 	
  9669                              <1> 	; 11/12/2020
  9670 0001060E 80FBFF              <1> 	cmp	bl, 0FFh  ; CGA/VGA mode ?
  9671 00010611 7318                <1> 	jnb	short sysvideo_20_1
  9672                              <1> 
  9673                              <1> 	;xor	ah, ah
  9674 00010613 88D8                <1> 	mov	al, bl
  9675                              <1> sysvideo_20_0:
  9676 00010615 E84F11FFFF          <1> 	call	_int10h  ; uses vbe3 pmi32 option
  9677 0001061A 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
  9678 0001061D 7459                <1> 	je	short sysvideo_20_3 ; error
  9679                              <1> 	
  9680                              <1> 	; 11/12/2020
  9681                              <1> 	; alternative (it does not use vbe3 pmi32)
  9682                              <1> 	;push	eax
  9683                              <1> 	;call	_set_mode
  9684                              <1> 	;pop	eax
  9685                              <1> 	;jc	short sysvideo_20_3
  9686                              <1> 	
  9687                              <1> 	;inc	eax
  9688 0001061F FEC0                <1> 	inc	al
  9689                              <1> 	;mov	[u.r0], ax ; video mode + 1	
  9690 00010621 A2[64030300]        <1> 	mov	[u.r0], al
  9691 00010626 E9D1D2FFFF          <1> 	jmp	sysret
  9692                              <1> 
  9693                              <1> sysvideo_20_1:
  9694                              <1> 	; cx = vesa video mode
  9695 0001062B 6689C8              <1> 	mov	ax, cx
  9696 0001062E 663D0001            <1> 	cmp	ax, 100h
  9697 00010632 72E1                <1> 	jb	short sysvideo_20_0 ; VGA/CGA mode
  9698 00010634 663DFF01            <1> 	cmp	ax, 1FFh
  9699                              <1> 	;ja	short sysvideo_20_4 ; not valid
  9700 00010638 773E                <1> 	ja	short sysvideo_20_3
  9701 0001063A 50                  <1> 	push	eax
  9702 0001063B 6689C3              <1> 	mov	bx, ax
  9703 0001063E 66B8024F            <1> 	mov	ax, 4F02h
  9704                              <1> 
  9705                              <1> 	; simulate _int10h (int 31h) for func 4F02h
  9706                              <1> 	;pushfd
  9707                              <1> 	;push	cs
  9708                              <1> 	;push	sysvideo_20_1_retn 
  9709                              <1> 	;push	es ; *
  9710                              <1> 	;push	ds ; **	; SAVE WORK AND PARAMETER REGISTERS
  9711                              <1> 	;jmp	VBE_func
  9712                              <1> ;sysvideo_20_1_retn:	
  9713                              <1> 	
  9714 00010642 E82211FFFF          <1> 	call	_int10h ; simulate int 10h (int 31h)
  9715                              <1> 
  9716 00010647 6683F84F            <1> 	cmp	ax, 004Fh
  9717 0001064B 58                  <1> 	pop	eax
  9718 0001064C 752A                <1> 	jne	short sysvideo_20_3 ; error
  9719                              <1> 	;pop	eax
  9720 0001064E 40                  <1> 	inc	eax
  9721 0001064F A3[64030300]        <1> 	mov	[u.r0], eax ; video mode + 1
  9722 00010654 09D2                <1> 	or	edx, edx ; is LFBINFO requested by user ?	
  9723                              <1> 	;jz	short sysvideo_20_4
  9724 00010656 7420                <1> 	jz	short sysvideo_20_3 ; no
  9725                              <1> 
  9726                              <1> 	; 11/12/2020
  9727                              <1> 	; Check LFBINFO table/structure
  9728                              <1> 	; (it is set by vbe2 'vbe_biosfn_set_mode'
  9729                              <1> 	; but if vbe3 vbios pmi is in use,
  9730                              <1> 	; it will not set LFBINFO table)
  9731                              <1> 
  9732 00010658 52                  <1> 	push	edx
  9733 00010659 48                  <1> 	dec	eax  ; video mode
  9734 0001065A BE[2A120300]        <1> 	mov	esi, LFB_Info
  9735 0001065F 663B06              <1> 	cmp	ax, [esi+LFBINFO.mode]
  9736 00010662 7407                <1> 	je	short sysvideo_20_2
  9737                              <1> 
  9738 00010664 E86433FFFF          <1> 	call	_vbe_biosfn_return_mode_info
  9739                              <1> 	;jnc	short sysvideo_20_2
  9740 00010669 7212                <1> 	jc	short sysvideo_20_4 ; edx = 0	
  9741                              <1> 
  9742                              <1> 	;; clear LFBINFO table for invalidating	
  9743                              <1> 	;mov	ecx, LFBINFO.size ; 16
  9744                              <1> 	;mov	edi, esi ; LFB_Info table address
  9745                              <1> 	;xor	eax, eax
  9746                              <1> 	;rep	stosb
  9747                              <1> 
  9748                              <1> sysvideo_20_2:
  9749                              <1> 	;pop	ecx
  9750                              <1> 	;mov	edi, ecx ; user buffer
  9751 0001066B 5F                  <1> 	pop	edi
  9752 0001066C B910000000          <1> 	mov	ecx, LFBINFO.size ; 16
  9753 00010671 E88E140000          <1> 	call	transfer_to_user_buffer ; fast transfer
  9754 00010676 7206                <1> 	jc	short sysvideo_20_5
  9755                              <1> 	
  9756                              <1> 	;jmp	sysret
  9757                              <1> sysvideo_20_3:	
  9758                              <1> 	;pop	eax ; [u.r0] = 0		
  9759                              <1> ;sysvideo_20_4:
  9760 00010678 E97FD2FFFF          <1> 	jmp	sysret
  9761                              <1> 
  9762                              <1> sysvideo_20_4:
  9763 0001067D 5A                  <1> 	pop	edx
  9764                              <1> sysvideo_20_5:
  9765 0001067E 31D2                <1> 	xor	edx, edx ; 0
  9766                              <1> 	; edx = 0 -> invalid LFBINFO data
  9767 00010680 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  9768 00010686 895514              <1> 	mov	[ebp+20], edx ; return to user with EDX value 
  9769 00010689 E96ED2FFFF          <1> 	jmp	sysret
  9770                              <1> 
  9771                              <1> sysvideo_21:
  9772                              <1> 	; 04/01/2021
  9773                              <1> 	; 03/12/2020
  9774 0001068E 80FF0A              <1> 	cmp	bh, 10
  9775 00010691 0F82AA010000        <1> 	jb	sysvideo_22 ; VESA VBE3 pmi parms
  9776                              <1> 	; 23/12/2020
  9777 00010697 0F8434020000        <1> 	je	sysvideo_26 ; Video memory mapping	
  9778                              <1> 	
  9779                              <1> 	; 04/01/2020
  9780 0001069D 80FF0B              <1> 	cmp	bh, 11
  9781 000106A0 0F87B6020000        <1> 	ja	sysvideo_27
  9782                              <1> 		
  9783                              <1> 	; BH = 11
  9784                              <1> 	; set/read DAC color registers (for 8bpp)
  9785                              <1> 	
  9786 000106A6 80FB04              <1> 	cmp	bl, 4
  9787 000106A9 0F83AB000000        <1> 	jnb	sysvideo_21_7	; BMP file type palette
  9788                              <1> 				; handling	
  9789 000106AF F6C301              <1> 	test	bl, 1
  9790 000106B2 7555                <1> 	jnz	short sysvideo_21_4 ; set/write DAC colors
  9791                              <1> 		
  9792                              <1> 	; Read DAC color register or all DAC color registers
  9793 000106B4 F6C302              <1> 	test	bl, 2  ; read single DAC color register
  9794 000106B7 7424                <1> 	jz	short sysvideo_21_2 ; read all DAC color regs	
  9795                              <1> 
  9796                              <1> 	; read single DAC color register
  9797                              <1> 	; CL = DAC color register (index)
  9798                              <1>  	
  9799 000106B9 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  9800 000106BD 88C8                <1> 	mov	al, cl	; DAC color register
  9801 000106BF 31C9                <1> 	xor	ecx, ecx ; (this may not be necessary)
  9802 000106C1 EE                  <1> 	out	dx, al
  9803                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9804 000106C2 B2C9                <1> 	mov	dl, 0C9h
  9805 000106C4 EC                  <1> 	in	al, dx
  9806 000106C5 88C4                <1> 	mov	ah, al	; red
  9807 000106C7 EC                  <1> 	in	al, dx
  9808 000106C8 88C1                <1> 	mov	cl, al	; green
  9809 000106CA EC                  <1> 	in	al, dx
  9810 000106CB 88C5                <1> 	mov	ch, al	; blue
  9811 000106CD C1E108              <1> 	shl	ecx, 8
  9812 000106D0 88E1                <1> 	mov	cl, ah	; red	
  9813                              <1> 	; CL = Red, CH = Green, byte 3 = Blue, byte 4 = 0
  9814                              <1> sysvideo_21_0:
  9815 000106D2 890D[64030300]      <1> 	mov	[u.r0], ecx
  9816                              <1> sysvideo_21_1:
  9817 000106D8 E91FD2FFFF          <1> 	jmp	sysret
  9818                              <1> sysvideo_21_2:
  9819                              <1> 	; read all DAC color registers
  9820 000106DD 89CB                <1> 	mov	ebx, ecx ; user's buffer address
  9821 000106DF BF00600900          <1> 	mov	edi, VBE3STACKADDR
  9822 000106E4 89FE                <1> 	mov	esi, edi
  9823 000106E6 B900030000          <1> 	mov	ecx, 768 ; 256*3
  9824 000106EB 51                  <1> 	push	ecx
  9825 000106EC 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  9826 000106F0 28C0                <1> 	sub	al, al ; 0
  9827 000106F2 EE                  <1> 	out	dx, al
  9828                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9829 000106F3 B2C9                <1> 	mov	dl, 0C9h
  9830                              <1> sysvideo_21_3:
  9831 000106F5 EC                  <1> 	in	al, dx
  9832 000106F6 AA                  <1> 	stosb
  9833 000106F7 EC                  <1> 	in	al, dx
  9834 000106F8 AA                  <1> 	stosb
  9835 000106F9 EC                  <1> 	in	al, dx
  9836 000106FA AA                  <1> 	stosb
  9837 000106FB E2F8                <1> 	loop	sysvideo_21_3
  9838 000106FD 59                  <1> 	pop	ecx
  9839                              <1> 
  9840 000106FE 89DF                <1> 	mov	edi, ebx ; user's buffer address
  9841                              <1> 	;mov	esi, VBE3STACKADDR
  9842                              <1> 	;mov	ecx, 256*3 = 768
  9843 00010700 E8FF130000          <1> 	call	transfer_to_user_buffer
  9844 00010705 72D1                <1> 	jc	short sysvideo_21_1
  9845                              <1> 	;mov	[u.r0], ecx ; actual transfer count
  9846 00010707 EBC9                <1> 	jmp	short sysvideo_21_0
  9847                              <1> 
  9848                              <1> sysvideo_21_4:
  9849                              <1> 	; Set/Write DAC color register or all registers
  9850 00010709 F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
  9851 0001070C 741C                <1> 	jz	short sysvideo_21_5 ; set all DAC color regs
  9852                              <1> 
  9853                              <1> 	; set single DAC color register
  9854                              <1> 	; CL = DAC color register (index)
  9855                              <1> 	; (byte 1 = Red, byte 2 = Green, byte 3 = Blue) 
  9856                              <1> 
  9857 0001070E 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  9858 00010712 89C8                <1> 	mov	eax, ecx ; DAC color register (index)
  9859 00010714 C1E910              <1> 	shr	ecx, 16  ; CL = green, AH = Red
  9860 00010717 EE                  <1> 	out	dx, al
  9861                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9862 00010718 FEC2                <1> 	inc	dl
  9863 0001071A 88E0                <1> 	mov	al, ah	; Red
  9864 0001071C EE                  <1> 	out	dx, al
  9865 0001071D 88C8                <1> 	mov	al, cl	; Green
  9866 0001071F EE                  <1> 	out	dx, al
  9867 00010720 88E8                <1> 	mov	al, ch	; Blue
  9868 00010722 EE                  <1> 	out	dx, al	
  9869                              <1> 	;rol	ecx, 8
  9870 00010723 C1E108              <1> 	shl	ecx, 8	; 21/02/2021
  9871 00010726 88E1                <1> 	mov	cl, ah	; Red
  9872                              <1> 		; ecx = 00BBGGRRh	
  9873 00010728 EBA8                <1> 	jmp	short sysvideo_21_0
  9874                              <1> 
  9875                              <1> sysvideo_21_5:
  9876                              <1> 	; write/set all DAC color registers
  9877 0001072A 89CE                <1> 	mov	esi, ecx ; user's buffer address
  9878 0001072C BF00600900          <1> 	mov	edi, VBE3STACKADDR
  9879 00010731 89FB                <1> 	mov	ebx, edi
  9880 00010733 B900030000          <1> 	mov	ecx, 768 ; 256*3
  9881 00010738 E811140000          <1> 	call	transfer_from_user_buffer
  9882 0001073D 7299                <1> 	jc	short sysvideo_21_1
  9883 0001073F 890D[64030300]      <1> 	mov	[u.r0], ecx ; actual transfer count
  9884                              <1> 
  9885 00010745 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
  9886 00010747 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  9887 0001074B 28C0                <1> 	sub	al, al ; 0
  9888 0001074D EE                  <1> 	out	dx, al
  9889                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9890 0001074E FEC2                <1> 	inc	dl
  9891                              <1> sysvideo_21_6:
  9892 00010750 AC                  <1> 	lodsb
  9893 00010751 EE                  <1> 	out	dx, al
  9894 00010752 AC                  <1> 	lodsb
  9895 00010753 EE                  <1> 	out	dx, al
  9896 00010754 AC                  <1> 	lodsb
  9897 00010755 EE                  <1> 	out	dx, al
  9898 00010756 E2F8                <1> 	loop	sysvideo_21_6
  9899 00010758 EB30                <1> 	jmp	short sysvideo_21_9
  9900                              <1> 
  9901                              <1> sysvideo_21_7:	
  9902                              <1> 	; BMP file type palette handling	
  9903                              <1> 	
  9904 0001075A F6C301              <1> 	test	bl, 1
  9905 0001075D 756E                <1> 	jnz	short sysvideo_21_12 ; set/write DAC colors
  9906                              <1> 		
  9907                              <1> 	; Read DAC color register or all DAC color registers
  9908 0001075F F6C302              <1> 	test	bl, 2  ; read single DAC color register
  9909 00010762 742B                <1> 	jz	short sysvideo_21_10 ; read all DAC color regs	
  9910                              <1> 
  9911                              <1> 	; read single DAC color register
  9912                              <1> 	; CL = DAC color register (index)
  9913                              <1>  	
  9914 00010764 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  9915 00010768 88C8                <1> 	mov	al, cl	; DAC color register
  9916 0001076A 31C9                <1> 	xor	ecx, ecx
  9917 0001076C EE                  <1> 	out	dx, al
  9918                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9919 0001076D B2C9                <1> 	mov	dl, 0C9h
  9920 0001076F EC                  <1> 	in	al, dx
  9921 00010770 C0E002              <1> 	shl	al, 2
  9922 00010773 88C5                <1> 	mov	ch, al	; red
  9923 00010775 EC                  <1> 	in	al, dx
  9924 00010776 C0E002              <1> 	shl	al, 2
  9925 00010779 88C1                <1> 	mov	cl, al	; green
  9926 0001077B EC                  <1> 	in	al, dx
  9927 0001077C C0E002              <1> 	shl	al, 2
  9928                              <1> 	; 21/02/2021
  9929 0001077F C1E108              <1> 	shl	ecx, 8
  9930 00010782 88C1                <1> 	mov	cl, al	; blue
  9931                              <1> 	; CL = Blue, CH = Green, byte 3 = Red, byte 4 = 0
  9932                              <1> sysvideo_21_8:
  9933 00010784 890D[64030300]      <1> 	mov	[u.r0], ecx
  9934                              <1> sysvideo_21_9:
  9935 0001078A E96DD1FFFF          <1> 	jmp	sysret
  9936                              <1> sysvideo_21_10:
  9937                              <1> 	; read all DAC color registers
  9938 0001078F 89CD                <1> 	mov	ebp, ecx ; user's buffer address
  9939 00010791 BF00600900          <1> 	mov	edi, VBE3STACKADDR
  9940 00010796 89FE                <1> 	mov	esi, edi
  9941 00010798 B900040000          <1> 	mov	ecx, 1024 ; 256*4
  9942 0001079D 51                  <1> 	push	ecx
  9943 0001079E 66BAC703            <1> 	mov	dx, 3C7h ; VGAREG_DAC_READ_ADDRESS
  9944 000107A2 28C0                <1> 	sub	al, al ; 0
  9945 000107A4 EE                  <1> 	out	dx, al
  9946                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9947 000107A5 B2C9                <1> 	mov	dl, 0C9h
  9948                              <1> sysvideo_21_11:
  9949 000107A7 31DB                <1> 	xor	ebx, ebx
  9950 000107A9 EC                  <1> 	in	al, dx	; Red
  9951 000107AA C0E002              <1> 	shl	al, 2
  9952 000107AD 88C7                <1> 	mov	bh, al
  9953 000107AF EC                  <1> 	in	al, dx	; Green
  9954 000107B0 C0E002              <1> 	shl	al, 2
  9955 000107B3 88C3                <1> 	mov	bl, al
  9956 000107B5 EC                  <1> 	in	al, dx	; Blue
  9957 000107B6 C0E002              <1> 	shl	al, 2
  9958 000107B9 C1E308              <1> 	shl	ebx, 8
  9959 000107BC 89D8                <1> 	mov	eax, ebx ; 00RRGGBBh
  9960 000107BE AB                  <1> 	stosd	
  9961 000107BF E2E6                <1> 	loop	sysvideo_21_11
  9962 000107C1 59                  <1> 	pop	ecx
  9963                              <1> 
  9964 000107C2 89EF                <1> 	mov	edi, ebp ; user's buffer address
  9965                              <1> 	;mov	esi, VBE3STACKADDR
  9966                              <1> 	;mov	ecx, 1024 = 4*256
  9967 000107C4 E83B130000          <1> 	call	transfer_to_user_buffer
  9968 000107C9 72BF                <1> 	jc	short sysvideo_21_9
  9969                              <1> 	;mov	[u.r0], ecx ; actual transfer count
  9970 000107CB EBB7                <1> 	jmp	short sysvideo_21_8
  9971                              <1> 
  9972                              <1> sysvideo_21_12:
  9973                              <1> 	; Set/Write DAC color register or all registers
  9974 000107CD F6C302              <1> 	test	bl, 2 ; write/set single DAC color register
  9975 000107D0 7427                <1> 	jz	short sysvideo_21_13 ; set all DAC color regs
  9976                              <1> 
  9977                              <1> 	; set single DAC color register
  9978                              <1> 	; CL = DAC color register (index)
  9979                              <1> 	; (byte 1 = Blue, byte 2 = Green, byte 3 = Red) 
  9980                              <1> 
  9981 000107D2 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
  9982 000107D6 88C8                <1> 	mov	al, cl	; DAC color register (index)
  9983 000107D8 88EC                <1> 	mov	ah, ch	; Blue 
  9984 000107DA C1E910              <1> 	shr	ecx, 16
  9985 000107DD EE                  <1> 	out	dx, al
  9986                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
  9987 000107DE FEC2                <1> 	inc	dl
  9988 000107E0 88E8                <1> 	mov	al, ch	; Red
  9989 000107E2 C0E802              <1> 	shr	al, 2
  9990 000107E5 EE                  <1> 	out	dx, al
  9991 000107E6 88C8                <1> 	mov	al, cl	; Green
  9992 000107E8 C0E802              <1> 	shr	al, 2
  9993 000107EB EE                  <1> 	out	dx, al
  9994 000107EC 88E0                <1> 	mov	al, ah	; Blue
  9995 000107EE C0E802              <1> 	shr	al, 2
  9996 000107F1 EE                  <1> 	out	dx, al	
  9997                              <1> 	;rol	ecx, 8
  9998 000107F2 C1E108              <1> 	shl	ecx, 8 ; 21/02/2021 
  9999 000107F5 88E1                <1> 	mov	cl, ah
 10000 000107F7 EB8B                <1> 	jmp	short sysvideo_21_8
 10001                              <1> 
 10002                              <1> sysvideo_21_13:
 10003                              <1> 	; write/set all DAC color registers
 10004 000107F9 89CE                <1> 	mov	esi, ecx ; user's buffer address
 10005 000107FB BF00600900          <1> 	mov	edi, VBE3STACKADDR
 10006 00010800 89FB                <1> 	mov	ebx, edi
 10007 00010802 B900040000          <1> 	mov	ecx, 1024 ; 256*4
 10008 00010807 E842130000          <1> 	call	transfer_from_user_buffer
 10009 0001080C 722E                <1> 	jc	short sysvideo_21_15
 10010 0001080E 890D[64030300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 10011                              <1> 
 10012 00010814 89DE                <1> 	mov	esi, ebx ; VBE3STACKADDR
 10013 00010816 66BAC803            <1> 	mov	dx, 3C8h ; VGAREG_DAC_WRITE_ADDRESS
 10014 0001081A 28C0                <1> 	sub	al, al ; 0
 10015 0001081C EE                  <1> 	out	dx, al
 10016                              <1> 	;mov	dx, 3C9h ; VGAREG_DAC_DATA
 10017 0001081D FEC2                <1> 	inc	dl
 10018                              <1> sysvideo_21_14:
 10019 0001081F AD                  <1> 	lodsd
 10020                              <1> 	; byte 0 = Blue, byte 1 = Green, byte 2 = Red
 10021                              <1> 	; 21/02/2021
 10022 00010820 89C3                <1> 	mov	ebx, eax ; BL = Blue, BH = Green
 10023 00010822 C1CB08              <1> 	ror	ebx, 8 ; BL = Green, BH = Red
 10024 00010825 88F8                <1> 	mov	al, bh
 10025 00010827 C0E802              <1> 	shr	al, 2
 10026 0001082A EE                  <1> 	out	dx, al ; Red
 10027 0001082B 88D8                <1> 	mov	al, bl
 10028 0001082D C0E802              <1> 	shr	al, 2	
 10029 00010830 EE                  <1> 	out	dx, al ; Green
 10030 00010831 C1C308              <1> 	rol	ebx, 8 ; BL = Blue
 10031 00010834 88D8                <1> 	mov	al, bl
 10032 00010836 C0E802              <1> 	shr	al, 2
 10033 00010839 EE                  <1> 	out	dx, al ; Blue 
 10034 0001083A E2E3                <1> 	loop	sysvideo_21_14
 10035                              <1> sysvideo_21_15:
 10036 0001083C E9BBD0FFFF          <1> 	jmp	sysret
 10037                              <1> 
 10038                              <1> sysvideo_22:
 10039                              <1> 	; 22/01/2021
 10040                              <1> 	; 17/01/2021
 10041                              <1> 	; 04/12/2020
 10042                              <1> 	; 03/12/2020
 10043                              <1> 	; BH = 9
 10044                              <1> 	; Set/Get VESA VBE3 protected mode interface params
 10045                              <1> 
 10046                              <1> 	; 22/01/2021
 10047                              <1> 	;cmp	byte [vbe3], 3
 10048                              <1> 	;jne	short sysvideo_25 ; not applicable if
 10049                              <1> 				; vbe3 compatible video bios
 10050                              <1> 				; is not detected by kernel	
 10051 00010841 80FB02              <1> 	cmp	bl, 2
 10052                              <1> 	;ja	short sysvideo_25 ; bl > 2 not implemented
 10053                              <1> 	; 17/01/2021
 10054 00010844 7716                <1> 	ja	short sysvideo_22_0 ; srvs flag sub function
 10055                              <1> 	;jb	short sysvideo_23
 10056                              <1> 
 10057                              <1> 	; 21/01/2021
 10058 00010846 803D[54090000]03    <1> 	cmp	byte [vbe3], 3
 10059 0001084D 757D                <1> 	jne	short sysvideo_25 ; not applicable if
 10060                              <1> 				; vbe3 compatible video bios
 10061                              <1> 				; is not detected by kernel
 10062 0001084F 80FB01              <1> 	cmp	bl, 1
 10063 00010852 7663                <1> 	jna	short sysvideo_23
 10064                              <1> 
 10065 00010854 8A1D[1C120300]      <1> 	mov	bl, [pmi32] ; Video bios 32 bit PMI functions
 10066 0001085A EB68                <1> 	jmp	short sysvideo_24
 10067                              <1> 
 10068                              <1> sysvideo_22_0:
 10069                              <1> 	; 17/01/2021
 10070                              <1> 	; save/restore video state user permission
 10071 0001085C 80FB05              <1> 	cmp	bl, 5
 10072 0001085F 771E                <1> 	ja	short sysvideo_22_2
 10073 00010861 7208                <1> 	jb	short sysvideo_22_1
 10074                              <1> 	; get srvs flag value/status
 10075 00010863 8A1D[80120300]      <1> 	mov	bl, [srvsf] ; 0 = disabled, 1 = enabled
 10076 00010869 EB2C                <1> 	jmp	short sysvideo_22_3
 10077                              <1> 
 10078                              <1> sysvideo_22_1:
 10079                              <1> 	; permission (root and multi tasking) check
 10080 0001086B E836000000          <1> 	call	sysvideo_22_4
 10081 00010870 735A                <1> 	jnc	short sysvideo_25 ; not permitted !
 10082                              <1> 	; cf = 1
 10083 00010872 80EB03              <1> 	sub	bl, 3 ; disable = 0, enable = 1
 10084                              <1> 	; 22/01/2021
 10085 00010875 881D[80120300]      <1> 	mov	[srvsf], bl
 10086 0001087B FEC3                <1> 	inc	bl ; 1 = disabled, 2 = enabled
 10087 0001087D EB18                <1> 	jmp	short sysvideo_22_3
 10088                              <1> 
 10089                              <1> sysvideo_22_2:
 10090 0001087F 80FB06              <1> 	cmp	bl, 6
 10091 00010882 7748                <1> 	ja	short sysvideo_25 ; invalid/unimplemented
 10092                              <1> 	; get VESA VBE number/status
 10093 00010884 8A25[54090000]      <1> 	mov	ah, [vbe3] ; vbe3 = 3, vbe2 = 2, others = 0
 10094 0001088A A0[55090000]        <1> 	mov	al, [vbe2bios] ; bochs/qemu/vbox emulator status
 10095 0001088F 66A3[64030300]      <1> 	mov	[u.r0], ax
 10096 00010895 EB35                <1> 	jmp	short sysvideo_25
 10097                              <1> 
 10098                              <1> sysvideo_22_3:
 10099                              <1> 	; 22/01/2021
 10100 00010897 8A3D[81120300]      <1> 	mov	bh, [srvso] ; state options (> 80h -> svga)
 10101 0001089D 66891D[64030300]    <1> 	mov	[u.r0], bx ; function result is return value 
 10102 000108A4 EB26                <1> 	jmp	short sysvideo_25 
 10103                              <1> 
 10104                              <1> sysvideo_22_4:
 10105                              <1> 	; 17/01/2021 - permission will be given by root only
 10106 000108A6 803D[62960100]00    <1> 	cmp	byte [multi_tasking], 0 ; in single user mode
 10107 000108AD 7707                <1> 	ja	short sysvideo_22_5
 10108                              <1> 	; 19/01/2021
 10109 000108AF 803D[B0030300]01    <1>  	cmp	byte [u.uid], 1 ; ([u.uid] = 0 -> root)
 10110                              <1> sysvideo_22_5:
 10111                              <1> 	; [multi_tasking] = 0 & [u.uid] = 0 -> CF = 1
 10112                              <1> 	; otherwise -> CF = 0 
 10113 000108B6 C3                  <1> 	retn
 10114                              <1> 
 10115                              <1> sysvideo_23:
 10116                              <1> 	; 17/01/2021
 10117                              <1> 	; permission (root and multi tasking) check
 10118 000108B7 E8EAFFFFFF          <1> 	call	sysvideo_22_4
 10119 000108BC 730E                <1> 	jnc	short sysvideo_25 ; not permitted !
 10120                              <1> 
 10121 000108BE 881D[1C120300]      <1> 	mov	[pmi32], bl ; 1 = enabled, 0 = disabled 
 10122                              <1> sysvideo_24:
 10123 000108C4 FEC3                <1> 	inc	bl
 10124 000108C6 881D[64030300]      <1> 	mov	[u.r0], bl ; function result is return value 
 10125                              <1> sysvideo_25:
 10126 000108CC E92BD0FFFF          <1> 	jmp	sysret	
 10127                              <1> 
 10128                              <1> sysvideo_26:
 10129                              <1> 	; 23/12/2020
 10130                              <1> 	; BH = 10
 10131                              <1> 	; Map video memory to user's buffer
 10132                              <1> 	; (multiuser/owner r/w permisions are ignored
 10133                              <1> 	;  for current TRDOS 386 version !)
 10134                              <1> 
 10135 000108D1 6681E100F0          <1> 	and	cx, ~4095  ; clear low 12 bits
 10136 000108D6 09C9                <1> 	or	ecx, ecx ; start address of user's buffer
 10137 000108D8 74F2                <1> 	jz	short sysvideo_25 ; error !
 10138                              <1> 	
 10139 000108DA 80FB01              <1> 	cmp	bl, 1  ; VGA memory mapping ?
 10140 000108DD 740E                <1> 	je	short sysvideo_26_1
 10141 000108DF 7718                <1> 	ja	short sysvideo_26_2
 10142                              <1> sysvideo_26_0:
 10143                              <1> 	; BL = 0 : CGA memory (0B8000h) map (32K)
 10144 000108E1 B800800B00          <1> 	mov	eax, 0B8000h	
 10145 000108E6 BB00800000          <1> 	mov	ebx, 32768
 10146 000108EB EB37                <1> 	jmp	short sysvideo_26_3
 10147                              <1> sysvideo_26_1:
 10148                              <1> 	; BL = 1 : VGA memory (0A0000h) map (64K)
 10149 000108ED B800000A00          <1> 	mov	eax, 0A0000h	
 10150 000108F2 BB00000100          <1> 	mov	ebx, 65536
 10151 000108F7 EB2B                <1> 	jmp	short sysvideo_26_3
 10152                              <1> sysvideo_26_2:
 10153                              <1> 	; BL = 2 : SVGA memory (LFB) map to user's buffer
 10154 000108F9 803D[54090000]02    <1> 	cmp	byte [vbe3], 2  ; VESA VBE 2/3 vbios ready ?
 10155 00010900 72CA                <1> 	jb	short sysvideo_25  ; no, error !
 10156 00010902 6681E200F0          <1> 	and	dx, ~4095 ; clear low 12 bits
 10157 00010907 09D2                <1> 	or	edx, edx  ; buffer size in bytes	
 10158 00010909 74C1                <1> 	jz	short sysvideo_25  ; error
 10159 0001090B 89D3                <1> 	mov	ebx, edx
 10160 0001090D A1[2C120300]        <1> 	mov	eax, [LFB_ADDR] ; [LFB_Info+LFBINFO.LFB_addr]
 10161 00010912 21C0                <1> 	and	eax, eax
 10162 00010914 7425                <1> 	jz	short sysvideo_26_5
 10163                              <1> 				; (LFB parms are not set yet)
 10164 00010916 3B1D[30120300]      <1> 	cmp	ebx, [LFB_SIZE] ; [LFB_Info+LFBINFO.LFB_size]
 10165 0001091C 7606                <1> 	jna	short sysvideo_26_3
 10166 0001091E 8B1D[30120300]      <1> 	mov	ebx, [LFB_SIZE]
 10167                              <1> sysvideo_26_3: 
 10168 00010924 52                  <1> 	push	edx
 10169 00010925 53                  <1> 	push	ebx	; buffer size in bytes
 10170 00010926 51                  <1> 	push	ecx	; user's buffer address
 10171 00010927 87D9                <1> 	xchg	ebx, ecx
 10172 00010929 C1E90C              <1> 	shr	ecx, 12 ; convert buffer size to page count
 10173 0001092C E8C95DFFFF          <1> 	call	direct_memory_access
 10174 00010931 59                  <1> 	pop	ecx	; user's buffer address
 10175 00010932 5B                  <1> 	pop	ebx	; buffer size
 10176 00010933 5A                  <1> 	pop	edx
 10177 00010934 7296                <1> 	jc	short sysvideo_25 ; error !
 10178                              <1> 				  ; [u.r0] = 0
 10179                              <1> ;sysvideo_26_4:
 10180                              <1> 	;mov	ebp, [u.usp] ; ebp points to user's registers
 10181                              <1> 	;mov	[ebp+20], edx ; return to user with EDX value 
 10182                              <1> 	;mov	[ebp+16], ebx ; EBX
 10183                              <1> 	;mov	[ebp+24], ecx ; ECX
 10184                              <1> 	; eax = physical address of video memory (LFB)
 10185                              <1> 	;mov	[u.r0], eax
 10186                              <1> 	;jmp	sysret
 10187 00010936 E944FCFFFF          <1> 	jmp	sysvideo_26_4
 10188                              <1> 
 10189                              <1> sysvideo_26_5:
 10190 0001093B 66A1[E30E0000]      <1> 	mov	ax, [def_LFB_addr] ; default LFB for mode 118h
 10191                              <1> 	; ah must be 0C0h or 0D0h or E0h
 10192                              <1> 	; others are nonsence !?
 10193 00010941 08E4                <1>  	or	ah, ah
 10194 00010943 7487                <1> 	jz	short sysvideo_25 ; invalid lfb addr or
 10195                              <1> 			  	; it is not a vbe2 -bochs emu- 
 10196                              <1> 			  	; or vbe3 -real- video bios 
 10197 00010945 80FCF0              <1> 	cmp	ah, 0F0h  
 10198 00010948 7382                <1> 	jnb	short sysvideo_25 ; nonsence !?
 10199 0001094A C1E010              <1> 	shl	eax, 16
 10200                              <1> 	;jz	short sysvideo_25 ; eax = 0 
 10201                              <1> 
 10202 0001094D 81FB00907E00        <1> 	cmp	ebx, 1920*1080*4 ; maximum value of possible
 10203                              <1> 				 ; buffer sizes
 10204 00010953 76CF                <1> 	jna	short sysvideo_26_3  ; buffer size is proper
 10205                              <1> 	; resize buffer to fit 4GB limit
 10206 00010955 BB00907E00          <1> 	mov	ebx, 1920*1080*4
 10207 0001095A EBC8                <1> 	jmp	short sysvideo_26_3
 10208                              <1> 
 10209                              <1> sysvideo_27:
 10210                              <1> 	; 16/02/2021
 10211                              <1> 	; 18/01/2021
 10212 0001095C 80FF0C              <1> 	cmp	bh, 12
 10213 0001095F 0F8778010000        <1> 	ja	sysvideo_28 ; 19/01/2021
 10214                              <1> 
 10215                              <1> 	; BH = 12
 10216                              <1> 	; Font sub functions.
 10217                              <1> 	; 12/02/2021
 10218                              <1> 	; 11/01/2021
 10219                              <1> 	; 10/01/2021
 10220                              <1> 	;   BL = 0 : Disable system font overwrite
 10221                              <1> 	;   BL = 1 : Enable system font overwrite
 10222                              <1> 	;   BL = 2 : Read system font 8x8
 10223                              <1> 	;   BL = 3 : Read system font 8x14
 10224                              <1> 	;   BL = 4 : Read system font 8x16
 10225                              <1> 	;   BL = 5 : Read user defined font 8x8
 10226                              <1> 	;   BL = 6 : Read user defined font 8x16
 10227                              <1> 	;   BL = 7 : Write system font 8x8
 10228                              <1> 	;   BL = 8 : Write system font 8x14
 10229                              <1> 	;   BL = 9 : Write system font 8x16
 10230                              <1> 	;   BL = 10 : Write user defined font 8x8
 10231                              <1> 	;   BL = 11 : Write user defined font 8x16
 10232                              <1> 	;
 10233                              <1> 	;  BL > 11 : invalid (not implemented)
 10234                              <1> 	;
 10235                              <1> 	; For BL = 1 to 11
 10236                              <1> 	;   ECX = number of characters (<= 256)
 10237                              <1> 	;   EDX = first character (ascii code in DL)
 10238                              <1> 	;   ESI = user's buffer address
 10239                              <1> 	;
 10240                              <1> 	; Return: EAX = character count 
 10241                              <1> 
 10242 00010965 80FB0B              <1> 	cmp	bl, 11
 10243 00010968 7605                <1> 	jna	short sysvideo_27_1
 10244                              <1> sysvideo_27_0:
 10245 0001096A E98DCFFFFF          <1> 	jmp	sysret ; not implemented yet !		
 10246                              <1> sysvideo_27_1:
 10247 0001096F 66B80001            <1> 	mov	ax, 256
 10248 00010973 08DB                <1> 	or	bl, bl
 10249 00010975 750E                <1>  	jnz	short sysvideo_27_3
 10250                              <1> 	
 10251                              <1> 	; bl = 0
 10252                              <1> 	; disable system font overwrite 
 10253                              <1> 
 10254 00010977 8025[7E120300]7F    <1> 	and	byte [ufont], 7Fh ; clear bit 7
 10255                              <1> sysvideo_27_2:
 10256                              <1> 	;mov	word [u.r0], 256  ; > 0 -> successful
 10257 0001097E A3[64030300]        <1> 	mov	[u.r0], eax ; 256
 10258 00010983 EBE5                <1> 	jmp	short sysvideo_27_0
 10259                              <1> sysvideo_27_3:
 10260 00010985 80FB01              <1> 	cmp	bl, 1
 10261 00010988 7710                <1> 	ja	short sysvideo_27_4
 10262                              <1> 
 10263                              <1> 	; bl = 1
 10264                              <1> 	; enable system font overwrite 
 10265                              <1> 	;	if [multi_tasking]= 0 and [u.uid] = 0
 10266                              <1> 
 10267                              <1> 	;cmp	byte [multi_tasking], 0 
 10268                              <1> 	;			; multi tasking enabled ?
 10269                              <1> 	;ja	short sysvideo_27_0 ; yes
 10270                              <1> 	;; 19/01/2021 
 10271                              <1> 	;; system maintenance or single user mode
 10272                              <1> 	;cmp	byte [u.uid], 0  ; root ?
 10273                              <1> 	;ja	short sysvideo_27_0 ; no
 10274                              <1> 
 10275                              <1> 	; 19/01/2021
 10276                              <1> 	; multi tasking & root check
 10277 0001098A E817FFFFFF          <1> 	call	sysvideo_22_4
 10278 0001098F 73D9                <1> 	jnc	short sysvideo_27_0 ; not permitted
 10279                              <1> 
 10280                              <1> 	; [multi_tasking]= 0 and [u.uid] = 0
 10281                              <1> 
 10282 00010991 800D[7E120300]80    <1> 	or	byte [ufont], 80h ; set bit 7
 10283                              <1> 		
 10284 00010998 EBE4                <1>  	jmp	short sysvideo_27_2
 10285                              <1> 
 10286                              <1> sysvideo_27_4:
 10287 0001099A 09C9                <1> 	or	ecx, ecx
 10288 0001099C 74CC                <1> 	jz	short sysvideo_27_0
 10289 0001099E 21D2                <1> 	and	edx, edx
 10290 000109A0 7410                <1> 	jz	short sysvideo_27_4_0
 10291                              <1> 	;mov	ax, 256
 10292 000109A2 39C1                <1> 	cmp	ecx, eax ; 256
 10293 000109A4 77C4                <1> 	ja	short sysvideo_27_0
 10294 000109A6 48                  <1> 	dec	eax
 10295 000109A7 39C2                <1> 	cmp	edx, eax ; 255
 10296 000109A9 77BF                <1> 	ja	short sysvideo_27_0
 10297 000109AB 40                  <1> 	inc	eax
 10298 000109AC 29D0                <1> 	sub	eax, edx ; 256 - DX
 10299 000109AE 39C8                <1> 	cmp	eax, ecx
 10300 000109B0 72B8                <1> 	jb	short sysvideo_27_0
 10301                              <1> 
 10302                              <1> sysvideo_27_4_0:
 10303 000109B2 89F5                <1> 	mov	ebp, esi
 10304                              <1> 
 10305 000109B4 80FB06              <1> 	cmp	bl, 6
 10306 000109B7 776C                <1> 	ja	short sysvideo_27_13
 10307 000109B9 7210                <1> 	jb	short sysvideo_27_5
 10308                              <1> 	; bl = 6
 10309 000109BB F605[7E120300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 10310 000109C2 74A6                <1> 	jz	short sysvideo_27_0
 10311                              <1> 	; read 8x16 user defined font
 10312 000109C4 BE00400900          <1> 	mov	esi, VGAFONT16USER
 10313 000109C9 EB0C                <1> 	jmp	short sysvideo_27_6
 10314                              <1> sysvideo_27_5:
 10315 000109CB 80FB04              <1> 	cmp	bl, 4
 10316 000109CE 723D                <1> 	jb	short sysvideo_27_11
 10317 000109D0 7723                <1> 	ja	short sysvideo_27_9
 10318                              <1> 	; bl = 4
 10319                              <1> 	; read 8x16 system font
 10320 000109D2 BE[64760100]        <1> 	mov	esi, vgafont16
 10321                              <1> sysvideo_27_6:
 10322                              <1> 	; read 8x16 font
 10323 000109D7 66C1E204            <1> 	shl	dx, 4 ; * 16
 10324 000109DB 66C1E104            <1> 	shl	cx, 4 ; * 16 ; 16 bytes per char
 10325                              <1> sysvideo_27_7:
 10326 000109DF 89EF                <1> 	mov	edi, ebp
 10327                              <1> 	;add	edi, edx ; 16/02/2021
 10328 000109E1 01D6                <1> 	add	esi, edx
 10329                              <1> 	; ecx = byte count
 10330                              <1> 	; esi = source (in system memory)
 10331                              <1> 	; edi = destination (in user memory)
 10332 000109E3 E81C110000          <1> 	call	transfer_to_user_buffer
 10333 000109E8 7206                <1> 	jc	short sysvideo_27_8
 10334 000109EA 890D[64030300]      <1> 	mov	[u.r0], ecx	
 10335                              <1> sysvideo_27_8:
 10336 000109F0 E907CFFFFF          <1> 	jmp	sysret
 10337                              <1> sysvideo_27_9:
 10338                              <1> 	; bl = 5
 10339 000109F5 F605[7E120300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 10340 000109FC 74F2                <1> 	jz	short sysvideo_27_8
 10341                              <1> 	; read 8x8 user defined font
 10342 000109FE BE00500900          <1> 	mov	esi, VGAFONT8USER
 10343                              <1> sysvideo_27_10:
 10344                              <1> 	; read 8x8 font
 10345 00010A03 66C1E203            <1> 	shl	dx, 3 ; * 8
 10346 00010A07 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 8 bytes per char
 10347 00010A0B EBD2                <1> 	jmp	short sysvideo_27_7
 10348                              <1> 
 10349                              <1> sysvideo_27_11:
 10350 00010A0D 80FB03              <1> 	cmp	bl, 3  ; 8x14 system font
 10351 00010A10 720C                <1> 	jb	short sysvideo_27_12 ; 8x8 system font
 10352                              <1> 	; bl = 3
 10353                              <1> 	; read 8x14 system font 
 10354                              <1> 	;mov	al, 14
 10355                              <1> 	;mul	dl
 10356                              <1> 	;mov	dx, ax
 10357                              <1> 	;push	edx
 10358                              <1> 	;mov	ax, 14
 10359                              <1> 	;mul	cx
 10360                              <1> 	;mov	cx, ax
 10361                              <1> 	;pop	edx
 10362 00010A12 E8A9000000          <1> 	call	sysvideo_27_14
 10363 00010A17 BE[64680100]        <1> 	mov	esi, vgafont14
 10364 00010A1C EBC1                <1> 	jmp	short sysvideo_27_7	
 10365                              <1> 	
 10366                              <1> sysvideo_27_12:
 10367                              <1> 	; bl = 2
 10368                              <1> 	; read 8x8 system font 
 10369 00010A1E BE[64600100]        <1> 	mov	esi, vgafont8
 10370 00010A23 EBDE                <1> 	jmp	short sysvideo_27_10
 10371                              <1> 
 10372                              <1> sysvideo_27_13:
 10373                              <1> 	; overwrite font
 10374 00010A25 80FB0A              <1> 	cmp	bl, 10
 10375 00010A28 7772                <1> 	ja	short sysvideo_27_22 ; 8x16 user font
 10376 00010A2A 7224                <1> 	jb	short sysvideo_27_15
 10377                              <1> 	; bl = 10
 10378 00010A2C BF00500900          <1> 	mov	edi, VGAFONT8USER
 10379 00010A31 F605[7E120300]08    <1> 	test	byte [ufont], 8 ; 8x8 user font loaded ?
 10380 00010A38 7558                <1> 	jnz	short sysvideo_27_21 ; yes
 10381 00010A3A 08ED                <1> 	or	ch, ch ; cx = 256
 10382                              <1> 	;jnz	short sysvideo_27_21 ; 256 chars
 10383 00010A3C 7406                <1> 	jz	short sysvideo_27_13_0
 10384 00010A3E 66B90008            <1> 	mov	cx, 8*256
 10385 00010A42 EB37                <1> 	jmp	short sysvideo_27_18_0
 10386                              <1> sysvideo_27_13_0:
 10387                              <1> 	; copy system font to user font before overwrite
 10388 00010A44 BE[64600100]        <1> 	mov	esi, vgafont8
 10389                              <1> 	;push	edi
 10390                              <1> 	;push	ecx
 10391                              <1> 	;mov	cl, 64
 10392                              <1> 	;rep	movsd
 10393                              <1> 	;pop	ecx
 10394                              <1> 	;pop	edi
 10395                              <1> 	;mov	esi, ebp ; user's font buffer
 10396 00010A49 E884000000          <1> 	call	sysvideo_27_23
 10397 00010A4E EB42                <1> 	jmp	short sysvideo_27_21
 10398                              <1> 
 10399                              <1> sysvideo_27_15:
 10400                              <1> 	; check system font overwrite permission
 10401 00010A50 F605[7E120300]80    <1> 	test	byte [ufont], 80h
 10402 00010A57 7497                <1> 	jz	short sysvideo_27_8
 10403                              <1> 
 10404 00010A59 80FB08              <1> 	cmp	bl, 8
 10405 00010A5C 773E                <1> 	ja	short sysvideo_27_22 ; 8x16 system font
 10406 00010A5E 722D                <1> 	jb	short sysvideo_27_20 ; 8x8 system font
 10407                              <1> 	; bl = 8
 10408                              <1> 	; overwrite 8x14 system font 
 10409                              <1> 	;mov	al, 14
 10410                              <1> 	;mul	dl
 10411                              <1> 	;mov	dx, ax
 10412                              <1> 	;push	edx
 10413                              <1> 	;mov	ax, 14
 10414                              <1> 	;mul	cx
 10415                              <1> 	;mov	cx, ax
 10416                              <1> 	;pop	edx
 10417 00010A60 E85B000000          <1> 	call	sysvideo_27_14
 10418 00010A65 BF[64680100]        <1> 	mov	edi, vgafont14
 10419 00010A6A EB0D                <1> 	jmp	short sysvideo_27_18
 10420                              <1> sysvideo_27_16:
 10421                              <1> 	; bl = 9
 10422                              <1> 	; overwrite 8x16 system font
 10423 00010A6C BF[64760100]        <1> 	mov	edi, vgafont16
 10424                              <1> sysvideo_27_17:
 10425                              <1> 	; overwrite 8x16 font
 10426 00010A71 66C1E204            <1> 	shl	dx, 4 ; * 16
 10427 00010A75 66C1E104            <1> 	shl	cx, 4 ; * 16 ; 16 bytes per char
 10428                              <1> sysvideo_27_18:
 10429 00010A79 01D7                <1> 	add	edi, edx
 10430                              <1> 	;add	esi, edx ; 16/02/2021
 10431                              <1> sysvideo_27_18_0:
 10432                              <1> 	; ecx = byte count
 10433                              <1> 	; esi = source (in user memory)
 10434                              <1> 	; edi = destination (in system memory)
 10435 00010A7B E8CE100000          <1> 	call	transfer_from_user_buffer
 10436 00010A80 7206                <1> 	jc	short sysvideo_27_19
 10437 00010A82 890D[64030300]      <1> 	mov	[u.r0], ecx	
 10438                              <1> sysvideo_27_19:
 10439 00010A88 E96FCEFFFF          <1> 	jmp	sysret
 10440                              <1> sysvideo_27_20:
 10441                              <1> 	; bl = 7
 10442                              <1> 	; overwrite 8x8 system font
 10443 00010A8D BF[64600100]        <1> 	mov	edi, vgafont8
 10444                              <1> sysvideo_27_21:
 10445                              <1> 	; write 8x8 font
 10446 00010A92 66C1E203            <1> 	shl	dx, 3 ; * 8
 10447 00010A96 66C1E103            <1> 	shl	cx, 3 ; * 8 ; 8 bytes per char
 10448 00010A9A EBDD                <1> 	jmp	short sysvideo_27_18
 10449                              <1> sysvideo_27_22:
 10450                              <1> 	; bl = 11
 10451                              <1> 	; overwrite 8x16 user defined font
 10452 00010A9C BF00400900          <1> 	mov	edi, VGAFONT16USER
 10453 00010AA1 F605[7E120300]10    <1> 	test	byte [ufont], 16 ; 8x16 user font loaded ?
 10454 00010AA8 75C7                <1> 	jnz	short sysvideo_27_17 ; yes
 10455 00010AAA 08ED                <1> 	or	ch, ch ; cx = 256
 10456                              <1> 	;jnz	short sysvideo_27_17 ; 256 chars
 10457 00010AAC 7406                <1> 	jz	short sysvideo_27_22_0
 10458 00010AAE 66B90010            <1> 	mov	cx, 16*256
 10459 00010AB2 EBC7                <1> 	jmp	short sysvideo_27_18_0
 10460                              <1> sysvideo_27_22_0:
 10461                              <1> 	; copy system font to user font before overwrite
 10462 00010AB4 BE[64760100]        <1> 	mov	esi, vgafont16
 10463                              <1> 	;push	edi
 10464                              <1> 	;push	ecx
 10465                              <1> 	;mov	cl, 64
 10466                              <1> 	;rep	movsd
 10467                              <1> 	;pop	ecx
 10468                              <1> 	;pop	edi
 10469                              <1> 	;mov	esi, ebp ; user's font buffer
 10470 00010AB9 E814000000          <1> 	call	sysvideo_27_23
 10471 00010ABE EBB1                <1> 	jmp	short sysvideo_27_17
 10472                              <1> 
 10473                              <1> sysvideo_27_14:
 10474                              <1> 	; 16/02/2021
 10475 00010AC0 52                  <1> 	push	edx
 10476 00010AC1 66B80E00            <1> 	mov	ax, 14	
 10477 00010AC5 66F7E1              <1> 	mul	cx
 10478 00010AC8 89C1                <1> 	mov	ecx, eax
 10479 00010ACA 5A                  <1> 	pop	edx
 10480 00010ACB B00E                <1> 	mov	al, 14
 10481 00010ACD F6E2                <1> 	mul	dl
 10482 00010ACF 89C2                <1> 	mov	edx, eax
 10483 00010AD1 C3                  <1> 	retn
 10484                              <1> 
 10485                              <1> 	;mov	al, 14
 10486                              <1> 	;mul	dl
 10487                              <1> 	;mov	dx, ax
 10488                              <1> 	;push	edx
 10489                              <1> 	;; 12/02/2021
 10490                              <1> 	;mov	ax, 14
 10491                              <1> 	;;mov	eax, 14
 10492                              <1> 	;;mul	cx
 10493                              <1> 	;mul	ecx
 10494                              <1> 	;;mov	cx, ax
 10495                              <1> 	;mov	ecx, eax
 10496                              <1> 	;pop	edx
 10497                              <1> 	;retn	
 10498                              <1> 
 10499                              <1> sysvideo_27_23:
 10500 00010AD2 57                  <1> 	push	edi
 10501 00010AD3 51                  <1> 	push	ecx
 10502 00010AD4 B140                <1> 	mov	cl, 64
 10503 00010AD6 F3A5                <1> 	rep	movsd
 10504 00010AD8 59                  <1> 	pop	ecx
 10505 00010AD9 5F                  <1> 	pop	edi
 10506 00010ADA 89EE                <1> 	mov	esi, ebp ; user's font buffer
 10507 00010ADC C3                  <1> 	retn
 10508                              <1> 
 10509                              <1> sysvideo_28:
 10510                              <1> 	; 24/01/2021
 10511                              <1> 	; 23/01/2021
 10512                              <1> 	; 18/01/2021
 10513 00010ADD 80FF0E              <1> 	cmp	bh, 14
 10514 00010AE0 0F8275010000        <1> 	jb	sysvideo_29
 10515 00010AE6 0F8754020000        <1> 	ja	sysvideo_30
 10516                              <1> 
 10517                              <1> 	; BH = 14
 10518                              <1> 	; Save/Restore Super VGA video state
 10519                              <1> 	
 10520                              <1> 	; BL = options
 10521                              <1> 	;	bit 0 - Save (0) or Restore (1)	
 10522                              <1> 	;	bit 1 - controller hardware state
 10523                              <1> 	;	bit 2 - BIOS data state
 10524                              <1> 	;	bit 3 - DAC state
 10525                              <1> 	;	bit 4 - (extended) Register state
 10526                              <1> 	;	bit 5 - system (0) or user (1) memory
 10527                              <1> 	;	bit 6 - verify without transfer
 10528                              <1> 	;	bit 7 - not used (must be 0)
 10529                              <1> 
 10530                              <1> 	; ECX = Buffer address or VideoStateID
 10531                              <1> 
 10532 00010AEC 803D[54090000]02    <1> 	cmp	byte [vbe3], 2 ;  VESA VBE2 or VBE3 ?
 10533 00010AF3 7717                <1> 	ja	short sysvideo_28_0 ; yes
 10534 00010AF5 7210                <1> 	jb	short sysvideo_28_16 ; not a SVGA sys !
 10535                              <1> 
 10536                              <1> 	; == VBE2 ==
 10537                              <1> 	; Check Bochs/Qemu/VirtualBox PC emulator
 10538                              <1> 	; (vbe2 is usable only for emulator's vbios)
 10539 00010AF7 8A25[55090000]      <1> 	mov	ah, [vbe2bios]
 10540 00010AFD 80FCC0              <1> 	cmp	ah, 0C0h	
 10541 00010B00 7205                <1> 	jb	short sysvideo_28_16 ; unknown vbios !
 10542 00010B02 80FCC5              <1> 	cmp	ah, 0C5h
 10543 00010B05 7605                <1> 	jna	short sysvideo_28_0
 10544                              <1> 		; Use kernel's vbios functions (video.s)
 10545                              <1> sysvideo_28_16:
 10546                              <1> 	; unknown vbios !
 10547 00010B07 E9F0CDFFFF          <1> 	jmp	sysret	
 10548                              <1> 
 10549                              <1> sysvideo_28_0:
 10550 00010B0C 80FB7F              <1> 	cmp	bl, 7Fh
 10551 00010B0F 77F6                <1> 	ja	short sysvideo_28_16 ; unknown options
 10552                              <1> 
 10553 00010B11 88DA                <1> 	mov	dl, bl
 10554 00010B13 80E21F              <1> 	and	dl, 1Fh 
 10555 00010B16 D0EA                <1> 	shr	dl, 1
 10556 00010B18 74ED                <1> 	jz	short sysvideo_28_16 ; invalid !
 10557                              <1> 	; DL = VBE Function 4F04h Save/Restore options 	
 10558                              <1> 	;  bit 0 : controller hardware state
 10559                              <1> 	;  bit 1 : BIOS data state
 10560                              <1> 	;  bit 2 : DAC state
 10561                              <1> 	;  bit 3 : (extended) Register state
 10562                              <1> 	
 10563 00010B1A F6C320              <1> 	test	bl, 32 ; bit 5
 10564 00010B1D 0F85B1000000        <1> 	jnz	sysvideo_28_7 ; user buffer
 10565                              <1> 
 10566                              <1> 	; source or destination is kernel/system buffer
 10567                              <1> 
 10568 00010B23 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 10569 00010B2A 76DB                <1> 	jna	short sysvideo_28_16 ; not permitted
 10570                              <1> 
 10571 00010B2C F6C301              <1> 	test	bl, 1
 10572 00010B2F 743A                <1> 	jz	short sysvideo_28_4 ; Save
 10573                              <1> 
 10574                              <1> 	; Restore
 10575 00010B31 3B0D[82120300]      <1> 	cmp	ecx, [VideoStateID]
 10576 00010B37 75CE                <1> 	jne	short sysvideo_28_16 ; not correct ID !
 10577                              <1> 		
 10578 00010B39 0FB6CA              <1> 	movzx	ecx, dl
 10579 00010B3C 80CA80              <1> 	or	dl, 80h
 10580 00010B3F 3A15[81120300]      <1> 	cmp	dl, [srvso]
 10581 00010B45 75C0                <1> 	jne	short sysvideo_28_16 ; not correct !
 10582                              <1> 
 10583 00010B47 88DA                <1> 	mov	dl, bl
 10584                              <1> 
 10585                              <1> 	; ecx = cl = options
 10586 00010B49 E82131FFFF          <1> 	call	vbe_srs_gbs
 10587                              <1> 	; ebx = state buffer size (data size)
 10588                              <1> 
 10589 00010B4E 891D[64030300]      <1> 	mov	[u.r0], ebx
 10590                              <1> 
 10591 00010B54 F6C240              <1> 	test	dl, 64 ; verify without transfer
 10592 00010B57 75AE                <1> 	jnz	short sysvideo_28_16 ; yes
 10593                              <1> 
 10594 00010B59 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE	
 10595 00010B5E BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 10596 00010B63 87CB                <1> 	xchg	ecx, ebx
 10597 00010B65 F3A4                <1> 	rep	movsb
 10598                              <1> 	
 10599 00010B67 88D9                <1> 	mov	cl, bl
 10600                              <1> 
 10601                              <1> 	; 23/01/2021
 10602 00010B69 EB44                <1> 	jmp	short sysvideo_28_10
 10603                              <1> 
 10604                              <1> sysvideo_28_4:
 10605 00010B6B 53                  <1> 	push	ebx	
 10606                              <1> 	; 24/01/2021
 10607 00010B6C 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 10608 00010B6E 881D[81120300]      <1> 	mov	[srvso], bl ; 0 ; invalidate
 10609 00010B74 891D[82120300]      <1> 	mov	[VideoStateID], ebx ; 0 ; invalidate
 10610 00010B7A 0FB6CA              <1> 	movzx	ecx, dl ; options
 10611 00010B7D B201                <1> 	mov	dl, 1 ; save state		
 10612 00010B7F E890000000          <1> 	call	sysvideo_28_11 ; 23/01/2021
 10613                              <1> 	; Note: VBE3 BIOS data save option will be
 10614                              <1> 	;	disabled.. ; 24/01/2021
 10615 00010B84 89CA                <1> 	mov	edx, ecx ; state (save) options
 10616 00010B86 5B                  <1> 	pop	ebx
 10617                              <1> 	
 10618 00010B87 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 10619 00010B8B 7536                <1> 	jne	short sysvideo_28_3 ; no !
 10620                              <1> 
 10621 00010B8D F6C340              <1> 	test	bl, 64 ; verify without transfer
 10622 00010B90 7536                <1> 	jnz	short sysvideo_28_6 ; yes
 10623                              <1> 
 10624                              <1> 	; ecx = cl = options
 10625 00010B92 E8D830FFFF          <1> 	call	vbe_srs_gbs
 10626                              <1> 	; ebx = state buffer size (data size)
 10627                              <1> 
 10628 00010B97 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 10629 00010B9C BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE	
 10630 00010BA1 89D9                <1> 	mov	ecx, ebx
 10631 00010BA3 F3A4                <1> 	rep	movsb
 10632                              <1> 
 10633 00010BA5 88D1                <1> 	mov	cl, dl
 10634 00010BA7 80C980              <1> 	or	cl, 80h ; SVGA (VESA VBE) flag
 10635                              <1> 	;mov	[srvso], dl
 10636                              <1> 
 10637 00010BAA E908010000          <1> 	jmp	sysvideo_28_15
 10638                              <1> 
 10639                              <1> 	; 23/01/2021
 10640                              <1> sysvideo_28_10:
 10641                              <1> 	; CL = VESA VBE3 Save/Restore options
 10642                              <1> 
 10643 00010BAF B202                <1> 	mov	dl, 2 ; restore state
 10644                              <1> 
 10645 00010BB1 E85C000000          <1> 	call	sysvideo_28_1
 10646                              <1> 
 10647 00010BB6 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 10648 00010BBA 7407                <1> 	je	short sysvideo_28_3
 10649                              <1> 	;jmp	short sysvideo_28_9 
 10650                              <1> 
 10651                              <1> sysvideo_28_9:
 10652                              <1> 	; return zero size (error) to user
 10653 00010BBC 29C0                <1> 	sub	eax, eax
 10654                              <1> sysvideo_28_5:
 10655 00010BBE A3[64030300]        <1> 	mov	[u.r0], eax
 10656                              <1> sysvideo_28_3:
 10657 00010BC3 E934CDFFFF          <1> 	jmp	sysret
 10658                              <1> 
 10659                              <1> sysvideo_28_6:
 10660                              <1> 	; use timer ticks as VideoStateID
 10661 00010BC8 A1[508A0100]        <1> 	mov	eax, [TIMER_LH]
 10662 00010BCD 09C0                <1> 	or 	eax, eax
 10663 00010BCF 75ED                <1> 	jnz	short sysvideo_28_5
 10664 00010BD1 40                  <1> 	inc	eax
 10665 00010BD2 EBEA                <1> 	jmp	short sysvideo_28_5
 10666                              <1> 
 10667                              <1> sysvideo_28_7:
 10668                              <1> 	; save/restore to/from user buffer
 10669                              <1> 
 10670                              <1> 	; 23/01/2021
 10671 00010BD4 89CE                <1> 	mov	esi, ecx ; user's vstate buffer
 10672 00010BD6 BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 10673                              <1> 
 10674 00010BDB 0FB6CA              <1> 	movzx	ecx, dl ; VESA VBE func 4F04h options
 10675                              <1> 
 10676                              <1> 	; source or destination is user buffer
 10677 00010BDE F6C301              <1> 	test	bl, 1
 10678 00010BE1 7444                <1> 	jz	short sysvideo_28_12  ; Save
 10679                              <1> 
 10680                              <1> 	; Restore
 10681 00010BE3 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 10682 00010BEA 766A                <1> 	jna	short sysvideo_28_14 ; not permitted
 10683                              <1> 
 10684 00010BEC 88DA                <1> 	mov	dl, bl ; 'sysvideo' options
 10685                              <1> 
 10686                              <1> 	; ecx = cl = options
 10687 00010BEE E87C30FFFF          <1> 	call	vbe_srs_gbs
 10688                              <1> 	; ebx = state buffer size (data size)
 10689                              <1> 
 10690 00010BF3 891D[64030300]      <1> 	mov	[u.r0], ebx ; transfer count
 10691                              <1> 
 10692 00010BF9 F6C240              <1> 	test	dl, 64 ; verify without transfer
 10693 00010BFC 7558                <1> 	jnz	short sysvideo_28_14 ; yes
 10694                              <1>  
 10695 00010BFE 6681FB0008          <1> 	cmp	bx, 2048
 10696 00010C03 73B7                <1> 	jnb	short sysvideo_28_9 ; invalid
 10697                              <1> 
 10698 00010C05 87CB                <1> 	xchg	ecx, ebx
 10699                              <1> 	; esi = user buffer
 10700                              <1> 	; edi = VBE3SAVERESTOREBLOCK
 10701                              <1> 
 10702 00010C07 E8420F0000          <1> 	call	transfer_from_user_buffer
 10703 00010C0C 72AE                <1> 	jc	short sysvideo_28_9 ; error 
 10704                              <1> 
 10705 00010C0E 89D9                <1> 	mov	ecx, ebx ; Function 4F04h options
 10706 00010C10 EB9D                <1> 	jmp	short sysvideo_28_10 ; 23/01/2021
 10707                              <1> 
 10708                              <1> sysvideo_28_1:
 10709 00010C12 31DB                <1> 	xor	ebx, ebx ; 0 ; use kernel's buffer
 10710                              <1> sysvideo_28_11:
 10711                              <1> 	; 24/01/2021
 10712 00010C14 803D[54090000]03    <1> 	cmp	byte [vbe3], 3
 10713 00010C1B 7405                <1> 	je	short sysvideo_28_2
 10714                              <1> 
 10715                              <1> 	; VESA VBE2 (BOCHS/QEMU/VBOX) video bios
 10716 00010C1D E9B62FFFFF          <1> 	jmp	_vbe_biosfn_save_restore_state
 10717                              <1> sysvideo_28_2:
 10718                              <1> 	;24/01/2021
 10719                              <1> 	;mov	eax, 4F04h  ; Save/Restore vstate
 10720                              <1> 	; VESA VBE3 video bios
 10721 00010C22 E90F0EFFFF          <1> 	jmp	_vbe3_pmfn_save_restore_state
 10722                              <1> 	
 10723                              <1> sysvideo_28_12:
 10724                              <1> 	; Save
 10725                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 10726                              <1> 
 10727                              <1> 	;movzx	ecx, dl ; options
 10728 00010C27 56                  <1> 	push	esi
 10729 00010C28 53                  <1> 	push	ebx
 10730                              <1> 	; 23/01/2021
 10731 00010C29 B201                <1> 	mov	dl, 1 ; save state
 10732 00010C2B E8E2FFFFFF          <1> 	call	sysvideo_28_1
 10733 00010C30 5A                  <1> 	pop	edx ; 'sysvideo' options
 10734 00010C31 5F                  <1> 	pop	edi ; user's video state buffer
 10735                              <1> 
 10736 00010C32 6683F84F            <1> 	cmp	ax, 4Fh ; successful ?
 10737 00010C36 751E                <1> 	jne	short sysvideo_28_14 ; no !
 10738                              <1> 
 10739                              <1> 	; ecx = cl = options
 10740 00010C38 E83230FFFF          <1> 	call	vbe_srs_gbs
 10741                              <1> 	; ebx = state buffer size (data size)
 10742                              <1> 
 10743 00010C3D 89D9                <1> 	mov	ecx, ebx ; transfer count
 10744                              <1> 
 10745 00010C3F F6C240              <1> 	test	dl, 64 ; verify without transfer
 10746 00010C42 750C                <1> 	jnz	short sysvideo_28_13 ; yes
 10747                              <1> 		
 10748                              <1> 	;mov	edi, esi
 10749 00010C44 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 10750 00010C49 E8B60E0000          <1> 	call	transfer_to_user_buffer
 10751 00010C4E 7206                <1> 	jc	short sysvideo_28_14
 10752                              <1> sysvideo_28_13:
 10753 00010C50 890D[64030300]      <1> 	mov	[u.r0], ecx
 10754                              <1> sysvideo_28_14:
 10755 00010C56 E9A1CCFFFF          <1> 	jmp	sysret
 10756                              <1> 
 10757                              <1> sysvideo_29:
 10758                              <1> 	; 18/01/2021
 10759                              <1> 	; BH = 13
 10760                              <1> 	; Save/Restore std VGA video state
 10761                              <1> 
 10762                              <1> 	; bl = 0..3
 10763                              <1> 	;	save to or restore from
 10764                              <1> 	;	system buffer, VBE3VIDEOSTATE
 10765                              <1> 	;	ECX = VideoStateID for restoring	
 10766                              <1> 	; bl = 4..7
 10767                              <1> 	;	save to or restore from
 10768                              <1> 	;	user buffer pointed by ECX
 10769                              <1> 		   	
 10770 00010C5B 80FB03              <1> 	cmp	bl, 3
 10771 00010C5E 7776                <1> 	ja	short sysvideo_29_6
 10772                              <1> 
 10773                              <1> 	; source or destination is kernel/system buffer
 10774                              <1> 
 10775 00010C60 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 10776 00010C67 7668                <1> 	jna	short sysvideo_29_5 ; not permitted
 10777                              <1> 
 10778 00010C69 F6C301              <1> 	test	bl, 1
 10779 00010C6C 7437                <1> 	jz	short sysvideo_29_2  ; Save
 10780                              <1> 
 10781                              <1> 	; Restore
 10782 00010C6E 3B0D[82120300]      <1> 	cmp	ecx, [VideoStateID]
 10783 00010C74 755B                <1> 	jne	short sysvideo_29_5 ; not correct ID !
 10784 00010C76 80FB01              <1> 	cmp	bl, 1
 10785 00010C79 7709                <1> 	ja	short sysvideo_29_0
 10786                              <1> 	; bl = 1
 10787 00010C7B BB6E000000          <1> 	mov	ebx, 110 
 10788 00010C80 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 10789 00010C82 EB07                <1> 	jmp	short sysvideo_29_1
 10790                              <1> sysvideo_29_0:
 10791                              <1>  	; bl  = 3
 10792 00010C84 BB72030000          <1> 	mov	ebx, 882 
 10793 00010C89 B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 10794                              <1> sysvideo_29_1:
 10795 00010C8B 3A0D[81120300]      <1> 	cmp	cl, [srvso]
 10796 00010C91 753E                <1> 	jne	short sysvideo_29_5 ; not correct !
 10797                              <1> 
 10798 00010C93 BE00580900          <1> 	mov	esi, VBE3VIDEOSTATE ; 22/01/2021
 10799 00010C98 E86C31FFFF          <1> 	call	biosfn_restore_video_state
 10800 00010C9D 891D[64030300]      <1> 	mov	[u.r0], ebx ; video state size (bytes)
 10801                              <1> 	;jmp	sysret
 10802 00010CA3 EB2C                <1> 	jmp	short sysvideo_29_5	
 10803                              <1> sysvideo_29_2:
 10804                              <1> 	;mov	esi, ecx
 10805 00010CA5 BF00580900          <1> 	mov	edi, VBE3VIDEOSTATE
 10806                              <1> 	
 10807 00010CAA B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 10808 00010CAC 08DB                <1> 	or	bl, bl
 10809 00010CAE 7502                <1> 	jnz	short sysvideo_29_3 ; bl = 2
 10810                              <1> 	; bl = 0 
 10811 00010CB0 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 10812                              <1> sysvideo_29_3:
 10813 00010CB2 E8E42FFFFF          <1> 	call	biosfn_save_video_state
 10814                              <1> sysvideo_28_15:
 10815                              <1> 	; use timer ticks as VideoStateID
 10816 00010CB7 A1[508A0100]        <1> 	mov	eax, [TIMER_LH]
 10817 00010CBC 21C0                <1> 	and 	eax, eax
 10818 00010CBE 7501                <1> 	jnz	short sysvideo_29_4
 10819 00010CC0 40                  <1> 	inc	eax
 10820                              <1> sysvideo_29_4:
 10821 00010CC1 880D[81120300]      <1> 	mov	[srvso], cl
 10822 00010CC7 A3[82120300]        <1> 	mov	[VideoStateID], eax
 10823 00010CCC A3[64030300]        <1> 	mov	[u.r0], eax
 10824                              <1> sysvideo_29_5:
 10825 00010CD1 E926CCFFFF          <1> 	jmp	sysret
 10826                              <1> 
 10827                              <1> sysvideo_29_6:
 10828 00010CD6 80FB07              <1> 	cmp	bl, 7
 10829 00010CD9 77F6                <1> 	ja	short sysvideo_29_5 ; invalid sub function 
 10830                              <1> 
 10831 00010CDB 89CE                <1> 	mov	esi, ecx
 10832 00010CDD BF00760900          <1> 	mov	edi, VBE3SAVERESTOREBLOCK
 10833                              <1> 
 10834                              <1> 	; source or destination is user buffer
 10835 00010CE2 F6C301              <1> 	test	bl, 1
 10836 00010CE5 7434                <1> 	jz	short sysvideo_29_9  ; Save
 10837                              <1> 
 10838                              <1> 	; Restore
 10839 00010CE7 803D[80120300]00    <1> 	cmp	byte [srvsf], 0 ; srs permission flag
 10840 00010CEE 76E1                <1> 	jna	short sysvideo_29_5 ; not permitted
 10841                              <1> 	
 10842                              <1> 	;mov	esi, ecx
 10843                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 10844                              <1> 	
 10845 00010CF0 80FB07              <1> 	cmp	bl, 7
 10846 00010CF3 7409                <1> 	je	short sysvideo_29_7
 10847                              <1> 	; bl = 5 
 10848 00010CF5 B303                <1> 	mov	bl, 3
 10849 00010CF7 B96E000000          <1> 	mov	ecx, 110
 10850 00010CFC EB05                <1> 	jmp	short sysvideo_29_8
 10851                              <1> sysvideo_29_7:
 10852                              <1> 	; bl = 7
 10853 00010CFE B972030000          <1> 	mov	ecx, 882
 10854                              <1> sysvideo_29_8:
 10855 00010D03 E8460E0000          <1> 	call	transfer_from_user_buffer
 10856 00010D08 72C7                <1> 	jc	short sysvideo_29_5
 10857 00010D0A 890D[64030300]      <1> 	mov	[u.r0], ecx
 10858 00010D10 88D9                <1> 	mov	cl, bl ; mov cl,7 (mov cl,3)
 10859 00010D12 89FE                <1> 	mov	esi, edi ; VBE3SAVERESTOREBLOCK
 10860                              <1> 	; cl = 3 or 7  	
 10861 00010D14 E8F030FFFF          <1> 	call	biosfn_restore_video_state
 10862 00010D19 EBB6                <1> 	jmp	sysvideo_29_5
 10863                              <1> 	;jmp	sysret
 10864                              <1> sysvideo_29_9:
 10865                              <1> 	; Save
 10866                              <1> 	;mov	edi, VBE3SAVERESTOREBLOCK
 10867                              <1> 
 10868 00010D1B 80FB06              <1> 	cmp	bl, 6
 10869 00010D1E 7409                <1> 	je	short sysvideo_29_10
 10870                              <1> 	; bl = 4
 10871 00010D20 BB6E000000          <1> 	mov	ebx, 110
 10872 00010D25 B103                <1> 	mov	cl, 3 ; ctrl, vbios data
 10873 00010D27 EB07                <1> 	jmp	short sysvideo_29_11
 10874                              <1> sysvideo_29_10:
 10875                              <1> 	; bl = 6
 10876 00010D29 BB72030000          <1> 	mov	ebx, 882
 10877 00010D2E B107                <1> 	mov	cl, 7 ; ctrl, vbios data, dac
 10878                              <1> sysvideo_29_11:
 10879 00010D30 E8662FFFFF          <1> 	call	biosfn_save_video_state
 10880                              <1> 
 10881 00010D35 89D9                <1> 	mov	ecx, ebx ; transfer count
 10882 00010D37 89F7                <1> 	mov	edi, esi
 10883 00010D39 BE00760900          <1> 	mov	esi, VBE3SAVERESTOREBLOCK
 10884                              <1> 
 10885                              <1> 	;call	transfer_to_user_buffer
 10886                              <1> 	;jc	short sysvideo_29_5
 10887                              <1> 	;mov	[u.r0], ecx ; transfer count
 10888                              <1> 	;;jmp	sysret
 10889                              <1> 	;jmp	short sysvideo_29_5
 10890                              <1>  
 10891 00010D3E EB1A                <1> 	jmp	short sysvideo_29_12
 10892                              <1> 
 10893                              <1> sysvideo_30:	 
 10894 00010D40 80FF0F              <1> 	cmp	bh, 15
 10895 00010D43 7722                <1> 	ja	short sysvideo_31 ; invalid function
 10896                              <1> 	
 10897                              <1> 	; BH = 15
 10898                              <1> 	; Copy VESA EDID to user's buffer
 10899                              <1> 	
 10900 00010D45 803D[2F430000]4F    <1> 	cmp	byte [edid], 4Fh
 10901 00010D4C 7519                <1> 	jne	short sysvideo_31 ; not ready ! 
 10902                              <1> 
 10903                              <1> 	;and	ecx, ecx
 10904                              <1> 	;jz	short sysvideo_31
 10905                              <1> 
 10906                              <1> 	; ecx = user's buffer address
 10907 00010D4E 89CF                <1> 	mov	edi, ecx
 10908 00010D50 BE[9C110300]        <1> 	mov	esi, edid_info
 10909 00010D55 B980000000          <1> 	mov	ecx, 128 ; 128 bytes
 10910                              <1> sysvideo_29_12:
 10911 00010D5A E8A50D0000          <1> 	call	transfer_to_user_buffer
 10912 00010D5F 7206                <1> 	jc	short sysvideo_31
 10913                              <1> 
 10914 00010D61 890D[64030300]      <1> 	mov	[u.r0], ecx ; EDID size, 128 bytes
 10915                              <1> sysvideo_31:
 10916 00010D67 E990CBFFFF          <1> 	jmp	sysret
 10917                              <1> 
 10918                              <1> mkdir:
 10919                              <1> 	; 04/12/2015 (14 byte directory names)
 10920                              <1> 	; 12/10/2015
 10921                              <1> 	; 17/06/2015 (Retro UNIX 386 v1 - Beginning)
 10922                              <1> 	; 29/04/2013 - 01/08/2013 (Retro UNIX 8086 v1)
 10923                              <1> 	;
 10924                              <1> 	; 'mkdir' makes a directory entry from the name pointed to
 10925                              <1> 	; by u.namep into the current directory.
 10926                              <1> 	;
 10927                              <1> 	; INPUTS ->
 10928                              <1> 	;    u.namep - points to a file name 
 10929                              <1> 	;	           that is about to be a directory entry.
 10930                              <1> 	;    ii - current directory's i-number.	
 10931                              <1> 	; OUTPUTS ->
 10932                              <1> 	;    u.dirbuf+2 - u.dirbuf+10 - contains file name. 
 10933                              <1> 	;    u.off - points to entry to be filled 
 10934                              <1> 	;	     in the current directory		
 10935                              <1> 	;    u.base - points to start of u.dirbuf.
 10936                              <1> 	;    r1 - contains i-number of current directory 
 10937                              <1> 	;	
 10938                              <1> 	; ((AX = R1)) output
 10939                              <1> 	;
 10940                              <1> 	;    (Retro UNIX Prototype : 11/11/2012, UNIXCOPY.ASM)
 10941                              <1>         ;    ((Modified registers: eAX, eDX, eBX, eCX, eSI, eDI, eBP))  
 10942                              <1> 	;
 10943                              <1> 
 10944                              <1> 	; 17/06/2015 - 32 bit modifications (Retro UNIX 386 v1)
 10945 00010D6C 31C0                <1> 	xor 	eax, eax
 10946 00010D6E BF[9A030300]        <1> 	mov     edi, u.dirbuf+2
 10947 00010D73 89FE                <1> 	mov	esi, edi
 10948 00010D75 AB                  <1> 	stosd
 10949 00010D76 AB                  <1> 	stosd
 10950                              <1> 	; 04/12/2015 (14 byte directory names)
 10951 00010D77 AB                  <1> 	stosd
 10952 00010D78 66AB                <1> 	stosw
 10953                              <1> 		; jsr r0,copyz; u.dirbuf+2; u.dirbuf+10. / clear this
 10954 00010D7A 89F7                <1> 	mov	edi, esi ; offset to u.dirbuf
 10955                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 10956                              <1> 	;mov 	ebp, [u.namep]
 10957 00010D7C E80D030000          <1> 	call	trans_addr_nmbp ; convert virtual address to physical
 10958                              <1> 		; esi = physical address (page start + offset)
 10959                              <1> 		; ecx = byte count in the page (1 - 4096)
 10960                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 10961                              <1> 		; mov u.namep,r2 / r2 points to name of directory entry
 10962                              <1> 		; mov $u.dirbuf+2,r3 / r3 points to u.dirbuf+2
 10963                              <1> mkdir_1: ; 1: 
 10964 00010D81 45                  <1> 	inc	ebp ; 12/10/2015
 10965                              <1> 	;
 10966                              <1> 	; / put characters in the directory name in u.dirbuf+2 - u.dirbuf+10
 10967                              <1> 	 ; 01/08/2013
 10968 00010D82 AC                  <1> 	lodsb
 10969                              <1> 		; movb (r2)+,r1 / move character in name to r1
 10970 00010D83 20C0                <1> 	and 	al, al
 10971 00010D85 7427                <1> 	jz 	short mkdir_3 	  
 10972                              <1> 		; beq 1f / if null, done
 10973 00010D87 3C2F                <1> 	cmp	al, '/'
 10974                              <1> 		; cmp r1,$'/ / is it a "/"?
 10975 00010D89 7414                <1> 	je	short mkdir_err
 10976                              <1> 	;je	error
 10977                              <1> 		; beq error9 / yes, error
 10978                              <1> 	; 12/10/2015
 10979 00010D8B 6649                <1> 	dec	cx
 10980 00010D8D 7505                <1> 	jnz	short mkdir_2
 10981                              <1> 	; 12/10/2015 ([u.namep] -> ebp)
 10982 00010D8F E800030000          <1> 	call	trans_addr_nm ; convert virtual address to physical
 10983                              <1> 		; esi = physical address (page start + offset)
 10984                              <1> 		; ecx = byte count in the page
 10985                              <1> 	; edi = offset to u.dirbuf (edi is not modified in trans_addr_nm)
 10986                              <1> mkdir_2:
 10987 00010D94 81FF[A8030300]      <1> 	cmp     edi, u.dirbuf+16 ; ; 04/12/2015 (10 -> 16) 
 10988                              <1> 		; cmp r3,$u.dirbuf+10. / have we reached the last slot for
 10989                              <1> 				     ; / a char?
 10990 00010D9A 74E5                <1> 	je	short mkdir_1
 10991                              <1> 		; beq 1b / yes, go back
 10992 00010D9C AA                  <1> 	stosb
 10993                              <1> 		; movb r1,(r3)+ / no, put the char in the u.dirbuf
 10994 00010D9D EBE2                <1> 	jmp 	short mkdir_1
 10995                              <1> 		; br 1b / get next char
 10996                              <1> mkdir_err:
 10997                              <1> 	; 17/06/2015
 10998 00010D9F C705[C8030300]1300- <1> 	mov	dword [u.error], ERR_NOT_DIR ; 'not a valid directory !'
 10998 00010DA7 0000                <1>
 10999 00010DA9 E92ECBFFFF          <1> 	jmp	error
 11000                              <1> 
 11001                              <1> mkdir_3: ; 1:
 11002 00010DAE A1[78030300]        <1> 	mov	eax, [u.dirp]
 11003 00010DB3 A3[80030300]        <1> 	mov	[u.off], eax
 11004                              <1> 		; mov u.dirp,u.off / pointer to empty current directory
 11005                              <1> 				 ; / slot to u.off
 11006                              <1> wdir: ; 29/04/2013
 11007 00010DB8 C705[84030300]-     <1>         mov     dword [u.base], u.dirbuf
 11007 00010DBE [98030300]          <1>
 11008                              <1> 		; mov $u.dirbuf,u.base / u.base points to created file name
 11009 00010DC2 C705[88030300]1000- <1>         mov     dword [u.count], 16 ; 04/12/2015 (10 -> 16) 
 11009 00010DCA 0000                <1>
 11010                              <1> 		; mov $10.,u.count / u.count = 10
 11011 00010DCC 66A1[51040300]      <1> 	mov	ax, [ii] 
 11012                              <1> 		; mov ii,r1 / r1 has i-number of current directory
 11013 00010DD2 B201                <1> 	mov	dl, 1 ; owner flag mask ; RETRO UNIX 8086 v1 modification !
 11014 00010DD4 E8741D0000          <1> 	call 	access
 11015                              <1> 		; jsr r0,access; 1 / get i-node and set its file up 
 11016                              <1> 				 ; / for writing
 11017                              <1> 	; AX = i-number of current directory
 11018                              <1> 	; 01/08/2013
 11019 00010DD9 FE05[C6030300]      <1> 	inc     byte [u.kcall] ; the caller is 'mkdir' sign	
 11020 00010DDF E8820F0000          <1> 	call	writei
 11021                              <1> 		; jsr r0,writei / write into directory
 11022 00010DE4 C3                  <1> 	retn	
 11023                              <1> 		; rts r0
 11024                              <1> 
 11025                              <1> sysexec:
 11026                              <1> 	; 18/11/2017
 11027                              <1> 	; 14/11/2017
 11028                              <1> 	; 13/11/2017
 11029                              <1> 	; 24/10/2016, 04/01/2017
 11030                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 11031                              <1> 	; 23/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 11032                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 11033                              <1> 	;
 11034                              <1> 	; 'sysexec' initiates execution of a file whose path name if
 11035                              <1> 	; pointed to by 'name' in the sysexec call. 
 11036                              <1> 	; 'sysexec' performs the following operations:
 11037                              <1> 	;    1. obtains i-number of file to be executed via 'namei'.
 11038                              <1> 	;    2. obtains i-node of file to be exceuted via 'iget'.
 11039                              <1> 	;    3. sets trap vectors to system routines.
 11040                              <1> 	;    4. loads arguments to be passed to executing file into
 11041                              <1> 	;	highest locations of user's core
 11042                              <1> 	;    5. puts pointers to arguments in locations immediately
 11043                              <1> 	;	following arguments.
 11044                              <1> 	;    6.	saves number of arguments in next location.
 11045                              <1> 	;    7. intializes user's stack area so that all registers
 11046                              <1> 	;	will be zeroed and the PS is cleared and the PC set
 11047                              <1> 	;	to core when 'sysret' restores registers 
 11048                              <1> 	;	and does an rti.
 11049                              <1> 	;    8. inializes u.r0 and u.sp
 11050                              <1> 	;    9. zeros user's core down to u.r0
 11051                              <1> 	;   10.	reads executable file from storage device into core
 11052                              <1> 	;	starting at location 'core'.
 11053                              <1> 	;   11.	sets u.break to point to end of user's code with
 11054                              <1> 	;	data area appended.
 11055                              <1> 	;   12.	calls 'sysret' which returns control at location
 11056                              <1> 	;	'core' via 'rti' instruction. 		  		
 11057                              <1> 	;
 11058                              <1> 	; Calling sequence:
 11059                              <1> 	;	sysexec; namep; argp
 11060                              <1> 	; Arguments:
 11061                              <1> 	;	namep - points to pathname of file to be executed
 11062                              <1> 	;	argp  - address of table of argument pointers
 11063                              <1> 	;	argp1... argpn - table of argument pointers
 11064                              <1> 	;	argp1:<...0> ... argpn:<...0> - argument strings
 11065                              <1> 	; Inputs: (arguments)
 11066                              <1> 	; Outputs: -	
 11067                              <1> 	; ...............................................................
 11068                              <1> 	;
 11069                              <1> 	; Retro UNIX 386 v1 modification: 
 11070                              <1> 	;	User application runs in it's own virtual space 
 11071                              <1> 	;	which is izolated from kernel memory (and other
 11072                              <1> 	;	memory pages) via 80386	paging in ring 3 
 11073                              <1> 	;	privilige mode. Virtual start address is always 0.
 11074                              <1> 	;	User's core memory starts at linear address 400000h
 11075                              <1> 	;	(the end of the 1st 4MB).
 11076                              <1> 	;
 11077                              <1> 	; Retro UNIX 8086 v1 modification: 
 11078                              <1> 	;	user/application segment and system/kernel segment
 11079                              <1> 	;	are different and sysenter/sysret/sysrele routines
 11080                              <1> 	;	are different (user's registers are saved to 
 11081                              <1> 	;	and then restored from system's stack.)
 11082                              <1> 	;
 11083                              <1> 	;	NOTE: Retro UNIX 8086 v1 'arg2' routine gets these
 11084                              <1> 	;	      arguments which were in these registers;
 11085                              <1> 	;	      but, it returns by putting the 1st argument
 11086                              <1> 	;	      in 'u.namep' and the 2nd argument
 11087                              <1> 	;	      on top of stack. (1st argument is offset of the
 11088                              <1> 	;	      file/path name in the user's program segment.)		 	
 11089                              <1> 	
 11090                              <1> 	;call	arg2
 11091                              <1> 	; * name - 'u.namep' points to address of file/path name
 11092                              <1> 	;          in the user's program segment ('u.segmnt')
 11093                              <1> 	;          with offset in BX register (as sysopen argument 1).
 11094                              <1> 	; * argp - sysexec argument 2 is in CX register 
 11095                              <1> 	;          which is on top of stack.
 11096                              <1> 	;
 11097                              <1> 		; jsr r0,arg2 / arg0 in u.namep,arg1 on top of stack
 11098                              <1> 
 11099                              <1> 	; 23/06/2015 (32 bit modifications)
 11100                              <1> 
 11101                              <1> 	;; 13/11/2017
 11102                              <1> 	;;mov	[u.namep], ebx ; argument 1
 11103                              <1>         ; 18/10/2015
 11104 00010DE5 890D[4C040300]      <1> 	mov     [argv], ecx  ; * ; argument 2
 11105                              <1> 
 11106                              <1> 	; 13/11/2017
 11107 00010DEB 89DE                <1> 	mov	esi, ebx
 11108 00010DED E88E210000          <1> 	call	set_working_path_x
 11109 00010DF2 7319                <1> 	jnc	short sysexec_0
 11110                              <1> 
 11111                              <1> 	;; 'bad command or file name'
 11112                              <1> 	;mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 11113                              <1> 	
 11114                              <1> 	; 'file not found !' error
 11115 00010DF4 B802000000          <1> 	mov	eax, ERR_NOT_FOUND ; 02h ; TRDOS 8086
 11116                              <1> sysexec_not_found_err:
 11117                              <1> sysexec_access_error:
 11118                              <1> sysexec_ext_error:
 11119 00010DF9 A3[64030300]        <1> 	mov	[u.r0], eax
 11120 00010DFE A3[C8030300]        <1> 	mov	[u.error], eax
 11121 00010E03 E84D220000          <1> 	call 	reset_working_path
 11122 00010E08 E9CFCAFFFF          <1> 	jmp	error
 11123                              <1> 
 11124                              <1> sysexec_0:
 11125                              <1> 	; 13/11/2017
 11126                              <1> 	;mov	esi, FindFile_Name
 11127 00010E0D 66B80018            <1>         mov	ax, 1800h ; Only files 
 11128 00010E11 E86B86FFFF          <1> 	call	find_first_file
 11129 00010E16 72E1                <1> 	jc	short sysexec_not_found_err ; eax = 2
 11130                              <1> 
 11131                              <1> 	; check_ file attributes
 11132                              <1> 	; (attribute bits = 00ADVSHR) ; 18h = Directory+Volume
 11133                              <1> 	; BL = Attributes byte
 11134                              <1> 	
 11135 00010E18 F6C306              <1>         test	bl, 6  ; system file or hidden file (S+H) 
 11136                              <1> 	;jz	short sysexec_0ext
 11137 00010E1B 7417                <1> 	jz	short sysexec_1 ; yes
 11138                              <1> 
 11139                              <1> 	; 13/11/2017 
 11140                              <1> 	; /// TRDOS386 permission check for multiuser mode ///
 11141                              <1> 	; SYSTEM file or HIDDEN file !!
 11142                              <1> 	; (Only super user has permission to run this file.)
 11143                              <1> 	
 11144                              <1> 	; ([u.uid]=0 for super user or root in multiuser mode)  
 11145                              <1> 	; ([u.uid]=0 for any users in singleuser mode) 
 11146 00010E1D 803D[B0030300]00    <1> 	cmp 	byte [u.uid], 0 ; Super User ([u.uid]=0) ?
 11147                              <1> 	;jna	short sysexec_0ext
 11148 00010E24 760E                <1> 	jna	short sysexec_1 ; yes 
 11149                              <1> 
 11150                              <1> 	; 'permission denied !' error  
 11151 00010E26 B80B000000          <1>         mov	eax, ERR_FILE_ACCESS  ; 11 = ERR_PERM_DENIED
 11152 00010E2B EBCC                <1>         jmp	short sysexec_access_error
 11153                              <1> 
 11154                              <1> sysexec_not_exf:
 11155                              <1> 	; 'not executable file !' error
 11156 00010E2D B816000000          <1> 	mov	eax, ERR_NOT_EXECUTABLE
 11157 00010E32 EBC5                <1> 	jmp	sysexec_ext_error
 11158                              <1> 
 11159                              <1> ;sysexec_0ext:
 11160                              <1> sysexec_1:
 11161                              <1> 	; 18/11/2017
 11162 00010E34 BE[78930100]        <1> 	mov	esi, FindFile_Name
 11163                              <1> 	; 13/11/2017
 11164                              <1> 	; check program file name extension
 11165                              <1> 	; ('.PRG' for current TRDOS version)
 11166 00010E39 E8E6A0FFFF          <1> 	call	check_prg_filename_ext
 11167 00010E3E 72ED                <1> 	jc	short sysexec_not_exf
 11168                              <1> 	
 11169                              <1> 	; 18/11/2017
 11170 00010E40 3C50                <1> 	cmp	al, 'P'
 11171 00010E42 75E9                <1> 	jne	short sysexec_not_exf	
 11172                              <1> 
 11173                              <1> 	; '.PRG' extension is OK.
 11174                              <1> 	; Only '.PRG' files are valid program files
 11175                              <1> 	; for current TRDOS 386 version.
 11176                              <1> 
 11177 00010E44 8B15[A4930100]      <1> 	mov	edx, [FindFile_DirEntry+DirEntry_FileSize]
 11178 00010E4A 66A1[9C930100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusHI]
 11179 00010E50 C1E010              <1> 	shl	eax, 16
 11180 00010E53 66A1[A2930100]      <1> 	mov	ax, [FindFile_DirEntry+DirEntry_FstClusLO]
 11181                              <1> 	; EAX = First Cluster number
 11182                              <1> 	; EDX = File Size
 11183                              <1> 
 11184 00010E59 A3[51040300]        <1> 	mov	[ii], eax
 11185 00010E5E 8915[55040300]      <1> 	mov	[i.size], edx
 11186                              <1> 
 11187                              <1> ;sysexec_1:
 11188                              <1> 	; 13/11/2017 - TRDOS 386 (TRDOS v2.0)
 11189                              <1> 	; 24/06/2015 - 23/10/2015 (Retro UNIX 386 v1)
 11190                              <1>         ; Moving arguments to the end of [u.upage]
 11191                              <1> 	; (by regarding page borders in user's memory space)
 11192                              <1> 	;
 11193                              <1> 	; 10/10/2015
 11194                              <1> 	; 21/07/2015
 11195 00010E64 89E5                <1> 	mov	ebp, esp ; (**)
 11196                              <1> 	; 18/10/2015
 11197 00010E66 89EF                <1> 	mov 	edi, ebp
 11198 00010E68 B900010000          <1> 	mov 	ecx, MAX_ARG_LEN ; 256
 11199                              <1> 	;sub	edi, MAX_ARG_LEN ; 256
 11200 00010E6D 29CF                <1> 	sub	edi, ecx
 11201 00010E6F 89FC                <1> 	mov	esp, edi ; *!*
 11202 00010E71 31C0                <1> 	xor	eax, eax
 11203 00010E73 A3[8C030300]        <1> 	mov 	[u.nread], eax ; 0
 11204 00010E78 66A3[4A040300]      <1> 	mov	[argc], ax ; 0 ; 13/11/2017
 11205 00010E7E 49                  <1> 	dec	ecx ; 256 - 1
 11206 00010E7F 890D[88030300]      <1> 	mov 	[u.count], ecx ; MAX_ARG_LEN - 1 ; 255
 11207                              <1> 	;mov 	dword [u.count], MAX_ARG_LEN - 1 ; 255
 11208                              <1> sysexec_2:
 11209 00010E85 8B35[4C040300]      <1> 	mov	esi, [argv] ; 18/10/2015 
 11210 00010E8B E866000000          <1> 	call	get_argp
 11211 00010E90 B904000000          <1> 	mov	ecx, 4 ; mov ecx, 4
 11212                              <1> sysexec_3:
 11213 00010E95 21C0                <1> 	and	eax, eax
 11214 00010E97 0F846F050000        <1>         jz      sysexec_6
 11215                              <1> 	; 18/10/2015
 11216 00010E9D 010D[4C040300]      <1> 	add	[argv], ecx ; 4
 11217 00010EA3 66FF05[4A040300]    <1> 	inc	word [argc]
 11218                              <1> 	;
 11219 00010EAA A3[84030300]        <1> 	mov	[u.base], eax
 11220                              <1>  	; 23/10/2015
 11221 00010EAF 66C705[C4030300]00- <1> 	mov	word [u.pcount], 0
 11221 00010EB7 00                  <1>
 11222                              <1> sysexec_4:
 11223 00010EB8 E8E70B0000          <1> 	call	cpass ; get a character from user's core memory
 11224 00010EBD 750E                <1>         jnz	short sysexec_5
 11225                              <1> 		; (max. 255 chars + null)
 11226                              <1> 	; 18/10/2015
 11227 00010EBF 28C0                <1> 	sub 	al, al
 11228 00010EC1 AA                  <1> 	stosb
 11229 00010EC2 FF05[8C030300]      <1> 	inc	dword [u.nread]
 11230 00010EC8 E93F050000          <1> 	jmp	sysexec_6 ; 24/04/2016
 11231                              <1> sysexec_5:
 11232 00010ECD AA                  <1> 	stosb
 11233 00010ECE 20C0                <1> 	and 	al, al
 11234 00010ED0 75E6                <1> 	jnz	short sysexec_4
 11235 00010ED2 B904000000          <1> 	mov	ecx, 4
 11236 00010ED7 390D[48040300]      <1> 	cmp	[ncount], ecx ; 4
 11237 00010EDD 72A6                <1> 	jb	short sysexec_2
 11238 00010EDF 8B35[44040300]      <1> 	mov	esi, [nbase]
 11239 00010EE5 010D[44040300]      <1> 	add	[nbase], ecx ; 4	
 11240 00010EEB 66290D[48040300]    <1> 	sub	[ncount], cx 
 11241 00010EF2 8B06                <1> 	mov	eax, [esi]
 11242 00010EF4 EB9F                <1> 	jmp	short sysexec_3
 11243                              <1> 
 11244                              <1> get_argp:
 11245                              <1> 	; 14/11/2017 - TRDOS 386 (TRDOS v2.0)
 11246                              <1> 	; 18/10/2015 (nbase, ncount)
 11247                              <1> 	; 21/07/2015
 11248                              <1> 	; 24/06/2015 (Retro UNIX 386 v1)
 11249                              <1> 	; Get (virtual) address of argument from user's core memory
 11250                              <1> 	;
 11251                              <1> 	; INPUT:
 11252                              <1> 	;	esi = virtual address of argument pointer
 11253                              <1> 	; OUTPUT:
 11254                              <1> 	;	eax = virtual address of argument
 11255                              <1> 	;
 11256                              <1> 	; Modified registers: EAX, EBX, ECX, EDX, ESI 
 11257                              <1> 	;
 11258 00010EF6 833D[BC030300]00    <1>  	cmp     dword [u.ppgdir], 0 ; /etc/init ?
 11259                              <1> 				    ; (the caller is kernel)
 11260 00010EFD 7667                <1>         jna     short get_argpk 
 11261                              <1> 	;
 11262 00010EFF 89F3                <1>      	mov	ebx, esi
 11263 00010F01 E8E253FFFF          <1> 	call	get_physical_addr ; get physical address
 11264 00010F06 0F8289000000        <1>         jc      get_argp_err
 11265 00010F0C A3[44040300]        <1> 	mov 	[nbase], eax ; physical address	
 11266 00010F11 66890D[48040300]    <1> 	mov	[ncount], cx ; remain byte count in page (1-4096)
 11267 00010F18 B804000000          <1> 	mov	eax, 4 ; 21/07/2015
 11268 00010F1D 6639C1              <1> 	cmp	cx, ax ; 4
 11269 00010F20 735D                <1> 	jnb	short get_argp2
 11270 00010F22 89F3                <1> 	mov	ebx, esi
 11271 00010F24 01CB                <1> 	add	ebx, ecx
 11272 00010F26 E8BD53FFFF          <1> 	call	get_physical_addr ; get physical address
 11273 00010F2B 7268                <1> 	jc	short get_argp_err
 11274                              <1> 	;push	esi
 11275 00010F2D 89C6                <1> 	mov	esi, eax
 11276 00010F2F 66870D[48040300]    <1> 	xchg	cx, [ncount]
 11277 00010F36 8735[44040300]      <1> 	xchg	esi, [nbase]
 11278 00010F3C B504                <1> 	mov	ch, 4
 11279 00010F3E 28CD                <1> 	sub	ch, cl
 11280                              <1> get_argp0:
 11281 00010F40 AC                  <1> 	lodsb
 11282 00010F41 6650                <1> 	push	ax
 11283 00010F43 FEC9                <1> 	dec	cl
 11284 00010F45 75F9                <1>         jnz     short get_argp0
 11285 00010F47 8B35[44040300]      <1> 	mov	esi, [nbase]
 11286                              <1> 	; 21/07/2015
 11287 00010F4D 0FB6C5              <1> 	movzx	eax, ch
 11288 00010F50 0105[44040300]      <1> 	add	[nbase], eax
 11289 00010F56 662905[48040300]    <1> 	sub	[ncount], ax
 11290                              <1> get_argp1:
 11291 00010F5D AC                  <1> 	lodsb
 11292 00010F5E FECD                <1> 	dec	ch
 11293 00010F60 7447                <1>         jz      short get_argp3
 11294 00010F62 6650                <1>         push	ax
 11295 00010F64 EBF7                <1> 	jmp     short get_argp1
 11296                              <1> get_argpk:
 11297                              <1> 	; Argument is in kernel's memory space
 11298 00010F66 66C705[48040300]00- <1> 	mov	word [ncount], PAGE_SIZE ; 4096
 11298 00010F6E 10                  <1>
 11299 00010F6F 8935[44040300]      <1> 	mov	[nbase], esi
 11300 00010F75 8305[44040300]04    <1> 	add	dword [nbase], 4
 11301 00010F7C 8B06                <1> 	mov	eax, [esi] ; virtual addr. = physical addr.
 11302 00010F7E C3                  <1> 	retn
 11303                              <1> get_argp2:
 11304                              <1> 	; 21/07/2015
 11305                              <1> 	;mov	eax, 4
 11306 00010F7F 8B15[44040300]      <1> 	mov 	edx, [nbase] ; 18/10/2015
 11307 00010F85 0105[44040300]      <1> 	add	[nbase], eax
 11308 00010F8B 662905[48040300]    <1> 	sub	[ncount], ax
 11309                              <1> 	;
 11310 00010F92 8B02                <1> 	mov	eax, [edx]
 11311 00010F94 C3                  <1> 	retn
 11312                              <1> get_argp_err:
 11313 00010F95 A3[C8030300]        <1> 	mov	[u.error], eax
 11314                              <1> 	; 14/11/2017
 11315 00010F9A B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 01h ; TRDOS 8086
 11316 00010F9F A3[64030300]        <1> 	mov	[u.r0], eax
 11317 00010FA4 E933C9FFFF          <1> 	jmp	error
 11318                              <1> get_argp3:
 11319 00010FA9 B103                <1> 	mov	cl, 3
 11320                              <1> get_argp4:
 11321 00010FAB C1E008              <1> 	shl	eax, 8
 11322 00010FAE 665A                <1> 	pop	dx
 11323 00010FB0 88D0                <1> 	mov 	al, dl
 11324 00010FB2 E2F7                <1>         loop    get_argp4
 11325                              <1> 	;pop	esi
 11326 00010FB4 C3                  <1> 	retn	
 11327                              <1> 
 11328                              <1> sysstat: 
 11329                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 11330                              <1> 	; temporary !
 11331 00010FB5 B801000000          <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 11332 00010FBA A3[C8030300]        <1>         mov     [u.error], eax
 11333 00010FBF A3[64030300]        <1>         mov     [u.r0], eax 
 11334 00010FC4 E913C9FFFF          <1> 	jmp	error
 11335                              <1> 
 11336                              <1> sysfstat: 
 11337                              <1> 	; 13/01/2017 - TRDOS 386 (TRDOS v2.0)
 11338                              <1> 	; temporary !
 11339 00010FC9 B801000000          <1> 	mov	eax, ERR_INV_FNUMBER ; 'invalid function number !'
 11340 00010FCE A3[C8030300]        <1>         mov     [u.error], eax
 11341 00010FD3 A3[64030300]        <1>         mov     [u.r0], eax 
 11342 00010FD8 E9FFC8FFFF          <1> 	jmp	error
 11343                              <1> 
 11344                              <1> fclose:
 11345                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 11346                              <1> 	;
 11347                              <1> 	; 18/06/2015 (Retro UNIX 386 v1 - Beginning)
 11348                              <1> 	;            (32 bit offset pointer modification)
 11349                              <1> 	; 19/04/2013 - 12/01/2014 (Retro UNIX 8086 v1)
 11350                              <1> 	;
 11351                              <1> 	; Given the file descriptor (index to the u.fp list)
 11352                              <1> 	; 'fclose' first gets the i-number of the file via 'getf'.
 11353                              <1> 	; If i-node is active (i-number > 0) the entry in 
 11354                              <1> 	; u.fp list is cleared. If all the processes that opened
 11355                              <1> 	; that file close it, then fsp etry is freed and the file
 11356                              <1> 	; is closed. If not a return is taken. 
 11357                              <1> 	; If the file has been deleted while open, 'anyi' is called
 11358                              <1> 	; to see anyone else has it open, i.e., see if it is appears
 11359                              <1> 	; in another entry in the fsp table. Upon return from 'anyi'
 11360                              <1> 	; a check is made to see if the file is special.	
 11361                              <1> 	;
 11362                              <1> 	; INPUTS ->
 11363                              <1> 	;    r1 - contains the file descriptor (value=0,1,2...)
 11364                              <1> 	;    u.fp - list of entries in the fsp table
 11365                              <1> 	;    fsp - table of entries (4 words/entry) of open files.	 
 11366                              <1> 	; OUTPUTS ->
 11367                              <1> 	;    r1 - contains the same file descriptor
 11368                              <1> 	;    r2 - contains i-number
 11369                              <1> 	;
 11370                              <1> 	; ((AX = R1))
 11371                              <1> 	; ((Modified registers: eDX, eBX, eCX, eSI, eDI, eBP))
 11372                              <1> 	;
 11373                              <1> 	; Retro UNIX 8086 v1 modification : CF = 1
 11374                              <1> 	;              if i-number of the file is 0. (error)  	
 11375                              <1> 	;
 11376                              <1> 	; TRDOS 386 (06/10/2016)
 11377                              <1> 	; 
 11378                              <1> 	; INPUT:
 11379                              <1> 	;	EAX = File Handle (File Descriptor, File Index)
 11380                              <1> 	;
 11381                              <1> 	; OUTPUT:
 11382                              <1> 	;	CF = 1 -> File not open !
 11383                              <1> 	;	CF = 0 -> OK!
 11384                              <1> 	;	     EBX = File Number (System)
 11385                              <1> 	;	     [cdev] = Logical DOS Drive Number
 11386                              <1> 	;	     EAX = File Handle/Number (user) 	
 11387                              <1> 	;
 11388                              <1> 	; Modified Registers: EBX
 11389                              <1> 
 11390 00010FDD 50                  <1> 	push	eax ; File handle
 11391                              <1> 	
 11392 00010FDE E846000000          <1> 	call	getf
 11393 00010FE3 0F8245240000        <1> 	jc	device_close ; eax = device number
 11394                              <1> 
 11395 00010FE9 80BB[F6990100]01    <1> 	cmp	byte [ebx+OF_MODE], 1 ; open mode ; 0 = empty entry
 11396 00010FF0 722E                <1> 	jb	short fclose_1	      ; 1 = read, 2 = write
 11397                              <1> 	
 11398 00010FF2 83F801              <1> 	cmp	eax, 1 ; is the first cluster number > 0
 11399 00010FF5 7229                <1> 	jb	short fclose_1 ; no, this is empty entry
 11400                              <1> 
 11401                              <1> fclose_0:
 11402 00010FF7 FE8B[0A9A0100]      <1> 	dec	byte [ebx+OF_OPENCOUNT] ; decrement the number of processes 
 11403                              <1> 			                ; that have opened the file
 11404 00010FFD 7921                <1> 	jns	short fclose_1 ; jump if not negative (jump if bit 7 is 0)	 
 11405                              <1> 			; if all processes haven't closed the file, return
 11406                              <1> 	;
 11407                              <1> 	; eax ; First cluster
 11408 00010FFF 31C0                <1> 	xor	eax, eax ; 0
 11409 00011001 8883[F6990100]      <1> 	mov	[ebx+OF_MODE], al ; 0 = empty entry
 11410                              <1> 	;mov	[ebx+OF_STATUS], al ; 0 = empty entry
 11411 00011007 66C1E302            <1> 	shl	bx, 2 
 11412 0001100B 8983[C4990100]      <1> 	mov	[ebx+OF_FCLUSTER], eax ; 0
 11413 00011011 8983[DC9A0100]      <1> 	mov	[ebx+OF_CCLUSTER], eax ; 0
 11414                              <1> 	;mov	[ebx+OF_CCINDEX], eax ; 0
 11415 00011017 A3[74030300]        <1> 	mov	[u.fofp], eax ; 0
 11416 0001101C 66C1EB02            <1> 	shr	bx, 2
 11417                              <1> fclose_1: ; 1:
 11418 00011020 58                  <1> 	pop	eax ; File handle (File Descriptor, File Index)
 11419 00011021 C680[6A030300]00    <1> 	mov	byte [eax+u.fp], 0 ; clear that entry in the u.fp list
 11420 00011028 C3                  <1> 	retn
 11421                              <1> 
 11422                              <1> getf:
 11423                              <1> 	; 12/10/2016
 11424                              <1> 	; 11/10/2016
 11425                              <1> 	; 08/10/2016
 11426                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 11427                              <1> 	; / get the device number and the i-number of an open file
 11428                              <1> 	; 13/05/2015
 11429                              <1> 	; 11/05/2015 (Retro UNIX 386 v1 - Beginning)
 11430                              <1> 	; 19/04/2013 - 18/11/2013 (Retro UNIX 8086 v1)
 11431                              <1> 	;
 11432 00011029 89C3                <1> 	mov	ebx, eax
 11433                              <1> getf1: 
 11434 0001102B 83FB0A              <1> 	cmp	ebx, 10
 11435 0001102E 730A                <1>         jnb	short getf2
 11436 00011030 8A9B[6A030300]      <1> 	mov	bl, [ebx+u.fp]
 11437 00011036 08DB                <1> 	or	bl, bl
 11438 00011038 7503                <1> 	jnz	short getf3
 11439                              <1> getf2:
 11440                              <1> 	; 'File not open !' error (ax=0)
 11441 0001103A 29C0                <1> 	sub	eax, eax
 11442 0001103C C3                  <1> 	retn
 11443                              <1> getf3:	
 11444 0001103D F6C380              <1> 	test	bl, 80h
 11445 00011040 7530                <1> 	jnz	short getf5 ; device
 11446 00011042 FECB                <1> 	dec	bl ; 0 based
 11447 00011044 8A83[EC990100]      <1> 	mov	al, [ebx+OF_DRIVE]
 11448 0001104A A2[46030300]        <1> 	mov	[cdev], al
 11449 0001104F C0E302              <1> 	shl	bl, 2 ; *4 (dword offset)
 11450 00011052 8B83[3C9A0100]      <1> 	mov	eax, [ebx+OF_SIZE]
 11451 00011058 A3[55040300]        <1> 	mov	[i.size], eax ; file size
 11452 0001105D 8D83[149A0100]      <1> 	lea	eax, [ebx+OF_POINTER] ;12/10/2016
 11453 00011063 A3[74030300]        <1> 	mov	[u.fofp], eax
 11454 00011068 8B83[C4990100]      <1> 	mov	eax, [ebx+OF_FCLUSTER]
 11455 0001106E C0EB02              <1> 	shr	bl, 2 ; /4 (byte offset) 
 11456                              <1> getf4:
 11457 00011071 C3                  <1> 	retn
 11458                              <1> getf5: 
 11459                              <1> 	; get device number
 11460 00011072 80E37F              <1> 	and	bl, 7Fh ; 1 to 7Fh
 11461 00011075 FECB                <1> 	dec	bl ; 0 based (0 to 7Eh)
 11462 00011077 8A83[1E980100]      <1> 	mov	al, [ebx+DEV_DRIVER]
 11463 0001107D 8AAB[88970100]      <1> 	mov	ch, [ebx+DEV_ACCESS]
 11464 00011083 8A8B[3C980100]      <1> 	mov	cl, [ebx+DEV_OPENMODE]
 11465 00011089 80E5FE              <1> 	and	ch, 0FEh ; reset bit 0 ; dev_close
 11466 0001108C F9                  <1> 	stc ; cf = 1 
 11467 0001108D C3                  <1> 	retn	
 11468                              <1> 
 11469                              <1> trans_addr_nmbp:
 11470                              <1> 	; 18/10/2015
 11471                              <1> 	; 12/10/2015
 11472 0001108E 8B2D[7C030300]      <1> 	mov 	ebp, [u.namep]
 11473                              <1> trans_addr_nm: 
 11474                              <1> 	; Convert virtual (pathname) address to physical address
 11475                              <1> 	; (Retro UNIX 386 v1 feature only !)
 11476                              <1> 	; 18/10/2015
 11477                              <1> 	; 12/10/2015 (u.pnbase & u.pncount has been removed from code)
 11478                              <1> 	; 02/07/2015
 11479                              <1> 	; 17/06/2015
 11480                              <1> 	; 16/06/2015
 11481                              <1> 	;
 11482                              <1> 	; INPUTS: 
 11483                              <1> 	;	ebp = pathname address (virtual) ; [u.namep]
 11484                              <1> 	;	[u.pgdir] = user's page directory
 11485                              <1> 	; OUTPUT:
 11486                              <1> 	;       esi = physical address of the pathname
 11487                              <1> 	;	ecx = remain byte count in the page
 11488                              <1> 	;
 11489                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX, ESI)
 11490                              <1> 	;
 11491 00011094 833D[BC030300]00    <1>         cmp     dword [u.ppgdir], 0  ; /etc/init ? (sysexec)
 11492 0001109B 7618                <1> 	jna	short trans_addr_nmk ; the caller is os kernel;
 11493                              <1> 				     ; it is already physical address
 11494 0001109D 50                  <1>    	push	eax	
 11495 0001109E 89EB                <1> 	mov	ebx, ebp ; [u.namep] ; pathname address (virtual)
 11496 000110A0 E84352FFFF          <1>        	call	get_physical_addr ; get physical address
 11497 000110A5 7204                <1> 	jc	short tr_addr_nm_err
 11498                              <1> 	; 18/10/2015
 11499                              <1> 	; eax = physical address 
 11500                              <1> 	; cx = remain byte count in page (1-4096) 
 11501                              <1> 		; 12/10/2015 (cx = [u.pncount])
 11502 000110A7 89C6                <1> 	mov	esi, eax ; 12/10/2015 (esi=[u.pnbase])
 11503 000110A9 58                  <1> 	pop	eax 
 11504 000110AA C3                  <1> 	retn
 11505                              <1> 
 11506                              <1> tr_addr_nm_err:
 11507 000110AB A3[C8030300]        <1> 	mov	[u.error], eax
 11508                              <1> 	;pop 	eax
 11509 000110B0 E927C8FFFF          <1> 	jmp	error
 11510                              <1> 
 11511                              <1> trans_addr_nmk:
 11512                              <1> 	; 12/10/2015
 11513                              <1> 	; 02/07/2015
 11514 000110B5 8B35[7C030300]      <1> 	mov	esi, [u.namep]  ; [u.pnbase]
 11515 000110BB 66B90010            <1> 	mov	cx, PAGE_SIZE ; 4096 ; [u.pncount]
 11516 000110BF C3                  <1> 	retn
 11517                              <1> 
 11518                              <1> sysbreak:
 11519                              <1> 	; 18/10/2015
 11520                              <1> 	; 07/10/2015
 11521                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 11522                              <1> 	; 20/06/2013 - 24/03/2014 (Retro UNIX 8086 v1)
 11523                              <1> 	;
 11524                              <1> 	; 'sysbreak' sets the programs break points. 
 11525                              <1> 	; It checks the current break point (u.break) to see if it is
 11526                              <1> 	; between "core" and the stack (sp). If it is, it is made an
 11527                              <1> 	; even address (if it was odd) and the area between u.break
 11528                              <1> 	; and the stack is cleared. The new breakpoint is then put
 11529                              <1> 	; in u.break and control is passed to 'sysret'.
 11530                              <1> 	;
 11531                              <1> 	; Calling sequence:
 11532                              <1> 	;	sysbreak; addr
 11533                              <1> 	; Arguments: -
 11534                              <1> 	;	
 11535                              <1> 	; Inputs: u.break - current breakpoint
 11536                              <1> 	; Outputs: u.break - new breakpoint 
 11537                              <1> 	;	area between old u.break and the stack (sp) is cleared.
 11538                              <1> 	; ...............................................................
 11539                              <1> 	;	
 11540                              <1> 	; Retro UNIX 8086 v1 modification:
 11541                              <1> 	;	The user/application program puts breakpoint address
 11542                              <1> 	;       in BX register as 'sysbreak' system call argument.
 11543                              <1> 	; 	(argument transfer method 1)
 11544                              <1> 	;
 11545                              <1> 	;  NOTE: Beginning of core is 0 in Retro UNIX 8086 v1 !
 11546                              <1> 	; 	((!'sysbreak' is not needed in Retro UNIX 8086 v1!))
 11547                              <1> 	;  NOTE:
 11548                              <1> 	; 	'sysbreak' clears extended part (beyond of previous
 11549                              <1> 	;	'u.break' address) of user's memory for original unix's
 11550                              <1> 	;	'bss' compatibility with Retro UNIX 8086 v1 (19/11/2013)
 11551                              <1> 
 11552                              <1> 		; mov u.break,r1 / move users break point to r1
 11553                              <1> 		; cmp r1,$core / is it the same or lower than core?
 11554                              <1> 		; blos 1f / yes, 1f
 11555                              <1> 	; 23/06/2015
 11556 000110C0 8B2D[90030300]      <1> 	mov	ebp, [u.break] ; virtual address (offset)
 11557                              <1> 	;and	ebp, ebp
 11558                              <1> 	;jz	short sysbreak_3 
 11559                              <1> 	; Retro UNIX 386 v1 NOTE: u.break points to virtual address !!!
 11560                              <1> 	; (Even break point address is not needed for Retro UNIX 386 v1)
 11561 000110C6 8B15[5C030300]      <1> 	mov	edx, [u.sp] ; kernel stack at the beginning of sys call
 11562 000110CC 83C20C              <1> 	add	edx, 12 ; EIP -4-> CS -4-> EFLAGS -4-> ESP (user) 
 11563                              <1> 	; 07/10/2015
 11564 000110CF 891D[90030300]      <1> 	mov	[u.break], ebx ; virtual address !!!
 11565                              <1> 	;
 11566 000110D5 3B1A                <1> 	cmp	ebx, [edx] ; compare new break point with 
 11567                              <1> 			   ; with top of user's stack (virtual!)
 11568 000110D7 7323                <1> 	jnb	short sysbreak_3
 11569                              <1> 		; cmp r1,sp / is it the same or higher 
 11570                              <1> 			  ; / than the stack?
 11571                              <1> 		; bhis 1f / yes, 1f
 11572 000110D9 89DE                <1> 	mov	esi, ebx
 11573 000110DB 29EE                <1> 	sub	esi, ebp ; new break point - old break point
 11574 000110DD 761D                <1> 	jna	short sysbreak_3 
 11575                              <1> 	;push	ebx
 11576                              <1> sysbreak_1:
 11577 000110DF 89EB                <1> 	mov	ebx, ebp  
 11578 000110E1 E80252FFFF          <1> 	call	get_physical_addr ; get physical address
 11579 000110E6 72C3                <1> 	jc	tr_addr_nm_err
 11580                              <1> 	; 18/10/2015
 11581 000110E8 89C7                <1> 	mov	edi, eax 
 11582 000110EA 29C0                <1> 	sub	eax, eax ; 0
 11583                              <1> 		 ; ECX = remain byte count in page (1-4096)
 11584 000110EC 39CE                <1> 	cmp	esi, ecx
 11585 000110EE 7302                <1> 	jnb	short sysbreak_2
 11586 000110F0 89F1                <1> 	mov	ecx, esi
 11587                              <1> sysbreak_2:
 11588 000110F2 29CE                <1> 	sub	esi, ecx
 11589 000110F4 01CD                <1> 	add	ebp, ecx
 11590 000110F6 F3AA                <1> 	rep 	stosb
 11591 000110F8 09F6                <1> 	or	esi, esi
 11592 000110FA 75E3                <1> 	jnz	short sysbreak_1
 11593                              <1> 	;
 11594                              <1> 		; bit $1,r1 / is it an odd address
 11595                              <1> 		; beq 2f / no, its even
 11596                              <1> 		; clrb (r1)+ / yes, make it even
 11597                              <1> 	; 2: / clear area between the break point and the stack
 11598                              <1> 		; cmp r1,sp / is it higher or same than the stack
 11599                              <1> 		; bhis 1f / yes, quit
 11600                              <1> 		; clr (r1)+ / clear word
 11601                              <1> 		; br 2b / go back
 11602                              <1> 	;pop	ebx
 11603                              <1> sysbreak_3: ; 1:
 11604                              <1> 	;mov	[u.break], ebx ; virtual address !!!
 11605                              <1> 		; jsr r0,arg; u.break / put the "address" 
 11606                              <1> 			; / in u.break (set new break point)
 11607                              <1> 		; br sysret4 / br sysret
 11608 000110FC E9FBC7FFFF          <1> 	jmp	sysret
 11609                              <1> 
 11610                              <1> sysseek: ; / moves read write pointer in an fsp entry
 11611                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 11612                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 11613                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 11614                              <1> 	;
 11615                              <1> 	; 'sysseek' changes the r/w pointer of (3rd word of in an
 11616                              <1> 	; fsp entry) of an open file whose file descriptor is in u.r0.
 11617                              <1> 	; The file descriptor refers to a file open for reading or
 11618                              <1> 	; writing. The read (or write) pointer is set as follows:
 11619                              <1> 	;	* if 'ptrname' is 0, the pointer is set to offset.
 11620                              <1> 	;	* if 'ptrname' is 1, the pointer is set to its
 11621                              <1> 	;	  current location plus offset.
 11622                              <1> 	;	* if 'ptrname' is 2, the pointer is set to the
 11623                              <1> 	;	  size of file plus offset.
 11624                              <1> 	; The error bit (e-bit) is set for an undefined descriptor.
 11625                              <1> 	;
 11626                              <1> 	; Calling sequence:
 11627                              <1> 	;	sysseek; offset; ptrname
 11628                              <1> 	; Arguments:
 11629                              <1> 	;	offset - number of bytes desired to move 
 11630                              <1> 	;		 the r/w pointer
 11631                              <1> 	;	ptrname - a switch indicated above
 11632                              <1> 	;
 11633                              <1> 	; Inputs: r0 - file descriptor 
 11634                              <1> 	; Outputs: -
 11635                              <1> 	; ...............................................................
 11636                              <1> 	;	
 11637                              <1> 	; Retro UNIX 8086 v1 modification: 
 11638                              <1> 	;       'sysseek' system call has three arguments; so,
 11639                              <1> 	;	* 1st argument, file descriptor is in BX (BL) register
 11640                              <1> 	;	* 2nd argument, offset is in CX register
 11641                              <1> 	;	* 3rd argument, ptrname/switch is in DX (DL) register	
 11642                              <1> 
 11643 00011101 E821000000          <1> 	call	seektell
 11644                              <1> 	; EAX = Current R/W pointer of the file
 11645                              <1> 	; EBX = [u.fofp]
 11646                              <1> 	; [u.base] = offset (ECX input)
 11647                              <1> 
 11648 00011106 0305[84030300]      <1> 	add	eax, [u.base]
 11649 0001110C 8903                <1> 	mov	[ebx], eax
 11650 0001110E E9E9C7FFFF          <1> 	jmp	sysret
 11651                              <1> 
 11652                              <1> systell: ; / get the r/w pointer
 11653                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0) - temporary !-
 11654                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 11655                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 11656                              <1> 	;
 11657                              <1> 	; Retro UNIX 8086 v1 modification:
 11658                              <1> 	; ! 'systell' does not work in original UNIX v1,
 11659                              <1> 	; 	    it returns with error !
 11660                              <1> 	; Inputs: r0 - file descriptor 
 11661                              <1> 	; Outputs: r0 - file r/w pointer
 11662                              <1> 
 11663                              <1> 	;xor	ecx, ecx ; 0
 11664 00011113 BA01000000          <1> 	mov	edx, 1 ; 05/08/2013
 11665                              <1> 	;call 	seektell
 11666 00011118 E810000000          <1> 	call 	seektell0 ; 05/08/2013
 11667                              <1> 	;; 06/11/2016
 11668                              <1> 	;; mov	eax, [ebx]
 11669 0001111D A3[64030300]        <1> 	mov	[u.r0], eax
 11670 00011122 E9D5C7FFFF          <1> 	jmp	sysret
 11671                              <1> 
 11672                              <1> ; Original unix v1 'systell' system call:
 11673                              <1> 		; jsr r0,seektell
 11674                              <1> 		; br error4
 11675                              <1> 
 11676                              <1> seektell:
 11677                              <1> 	; 06/11/2016 - TRDOS 386 (TRDOS v2.0)
 11678                              <1> 	; 03/01/2016
 11679                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 11680                              <1> 	; 07/07/2013 - 05/08/2013 (Retro UNIX 8086 v1)
 11681                              <1> 	;
 11682                              <1> 	; 'seektell' puts the arguments from sysseek and systell
 11683                              <1> 	; call in u.base and u.count. It then gets the i-number of
 11684                              <1> 	; the file from the file descriptor in u.r0 and by calling
 11685                              <1> 	; getf. The i-node is brought into core and then u.count
 11686                              <1> 	; is checked to see it is a 0, 1, or 2.
 11687                              <1> 	; If it is 0 - u.count stays the same
 11688                              <1> 	;          1 - u.count = offset (u.fofp)
 11689                              <1> 	;	   2 - u.count = i.size (size of file)
 11690                              <1> 	; 	 		
 11691                              <1> 	; !! Retro UNIX 8086 v1 modification:
 11692                              <1> 	;	Argument 1, file descriptor is in BX;
 11693                              <1> 	;	Argument 2, offset is in CX;
 11694                              <1> 	;	Argument 3, ptrname/switch is in DX register.	
 11695                              <1> 	;
 11696                              <1> 	; ((Return -> eax = base for offset (position= base+offset))
 11697                              <1> 	;
 11698 00011127 890D[84030300]      <1> 	mov 	[u.base], ecx ; offset
 11699                              <1> seektell0:
 11700 0001112D 8915[88030300]      <1> 	mov 	[u.count], edx
 11701                              <1> 	; EBX = file descriptor (file number)
 11702 00011133 E8F3FEFFFF          <1> 	call	getf1
 11703                              <1> 	; EAX = First cluster of the file
 11704                              <1> 	; EBX = File number (Open file number)
 11705                              <1> 	; [u.fofp] = Pointer to File pointer
 11706                              <1> 	; [i.size] = File size
 11707                              <1> 
 11708 00011138 09C0                <1> 	or	eax, eax
 11709 0001113A 7514                <1> 	jnz	short seektell1
 11710                              <1> 
 11711 0001113C B80A000000          <1> 	mov	eax, ERR_FILE_NOT_OPEN
 11712 00011141 A3[64030300]        <1> 	mov	[u.r0], eax 
 11713 00011146 A3[C8030300]        <1> 	mov	dword [u.error], eax ; 'file not open !'
 11714 0001114B E98CC7FFFF          <1> 	jmp	error
 11715                              <1> 
 11716                              <1> seektell1:
 11717 00011150 8B1D[74030300]      <1>         mov     ebx, [u.fofp]
 11718 00011156 803D[88030300]01    <1> 	cmp	byte [u.count], 1
 11719 0001115D 7705                <1> 	ja	short seektell2
 11720 0001115F 7409                <1> 	je	short seektell3
 11721 00011161 31C0                <1> 	xor	eax, eax
 11722 00011163 C3                  <1> 	retn
 11723                              <1> 
 11724                              <1> seektell2:
 11725 00011164 A1[55040300]        <1>         mov   	eax, [i.size]
 11726 00011169 C3                  <1> 	retn
 11727                              <1> 
 11728                              <1> seektell3:
 11729 0001116A 8B03                <1> 	mov	eax, [ebx]
 11730 0001116C C3                  <1> 	retn
 11731                              <1> 
 11732                              <1> sysintr: ; / set interrupt handling
 11733                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 11734                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 11735                              <1> 	;
 11736                              <1> 	; 'sysintr' sets the interrupt handling value. It puts
 11737                              <1> 	; argument of its call in u.intr then branches into 'sysquit'
 11738                              <1> 	; routine. u.tty is checked if to see if a control tty exists.
 11739                              <1> 	; If one does the interrupt character in the tty buffer is
 11740                              <1> 	; cleared and 'sysret'is called. If one does not exits
 11741                              <1> 	; 'sysret' is just called.	
 11742                              <1> 	;
 11743                              <1> 	; Calling sequence:
 11744                              <1> 	;	sysintr; arg
 11745                              <1> 	; Argument:
 11746                              <1> 	;	arg - if 0, interrupts (ASCII DELETE) are ignored.
 11747                              <1> 	;	    - if 1, intterupts cause their normal result
 11748                              <1> 	;		 i.e force an exit.
 11749                              <1> 	;	    - if arg is a location within the program,
 11750                              <1> 	;		control is passed to that location when
 11751                              <1> 	;		an interrupt occurs.	
 11752                              <1> 	; Inputs: -
 11753                              <1> 	; Outputs: -
 11754                              <1> 	; ...............................................................
 11755                              <1> 	;	
 11756                              <1> 	; Retro UNIX 8086 v1 modification: 
 11757                              <1> 	;       'sysintr' system call sets u.intr to value of BX
 11758                              <1> 	;	then branches into sysquit.
 11759                              <1> 	;
 11760 0001116D 66891D[AA030300]    <1> 	mov	[u.intr], bx
 11761                              <1> 		; jsr r0,arg; u.intr / put the argument in u.intr
 11762                              <1> 		; br 1f / go into quit routine
 11763 00011174 E983C7FFFF          <1> 	jmp	sysret
 11764                              <1> 
 11765                              <1> sysquit:
 11766                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 11767                              <1> 	; 07/07/2013 (Retro UNIX 8086 v1)
 11768                              <1> 	;
 11769                              <1> 	; 'sysquit' turns off the quit signal. it puts the argument of
 11770                              <1> 	; the call in u.quit. u.tty is checked if to see if a control 
 11771                              <1> 	; tty exists. If one does the interrupt character in the tty
 11772                              <1> 	; buffer is cleared and 'sysret'is called. If one does not exits
 11773                              <1> 	; 'sysret' is just called.	
 11774                              <1> 	;
 11775                              <1> 	; Calling sequence:
 11776                              <1> 	;	sysquit; arg
 11777                              <1> 	; Argument:
 11778                              <1> 	;	arg - if 0, this call diables quit signals from the
 11779                              <1> 	;		typewriter (ASCII FS)
 11780                              <1> 	;	    - if 1, quits are re-enabled and cause execution to
 11781                              <1> 	;		cease and a core image to be produced.
 11782                              <1> 	;		 i.e force an exit.
 11783                              <1> 	;	    - if arg is an addres in the program,
 11784                              <1> 	;		a quit causes control to sent to that
 11785                              <1> 	;		location.	
 11786                              <1> 	; Inputs: -
 11787                              <1> 	; Outputs: -
 11788                              <1> 	; ...............................................................
 11789                              <1> 	;	
 11790                              <1> 	; Retro UNIX 8086 v1 modification: 
 11791                              <1> 	;       'sysquit' system call sets u.quit to value of BX
 11792                              <1> 	;	then branches into 'sysret'.
 11793                              <1> 	;
 11794 00011179 66891D[AC030300]    <1> 	mov	[u.quit], bx
 11795 00011180 E977C7FFFF          <1> 	jmp	sysret
 11796                              <1> 		; jsr r0,arg; u.quit / put argument in u.quit
 11797                              <1> 	;1:
 11798                              <1> 		; mov u.ttyp,r1 / move pointer to control tty buffer
 11799                              <1> 			      ; / to r1
 11800                              <1> 		; beq sysret4 / return to user
 11801                              <1> 		; clrb 6(r1) / clear the interrupt character 
 11802                              <1> 			   ; / in the tty buffer
 11803                              <1> 		; br sysret4 / return to user
 11804                              <1> 
 11805                              <1> anyi: 
 11806                              <1> 	; 06/10/2016 (TRDOS 386 = TRDOS v2.0)
 11807                              <1> 	; Major Modification!
 11808                              <1> 	; TRDOS 386 does not permit to delete a file while it is open 
 11809                              <1> 	; The role of 'anyi' procedure has beeen changed to ensure that.
 11810                              <1> 	; 	
 11811                              <1> 	; 22/06/2015 (Retro UNIX 386 v1 - Beginning)
 11812                              <1> 	; 25/04/2013 (Retro UNIX 8086 v1)
 11813                              <1> 	;
 11814                              <1> 	; 'anyi' is called if a file deleted while open.
 11815                              <1> 	; "anyi" checks to see if someone else has opened this file.
 11816                              <1> 	;
 11817                              <1> 	; INPUTS ->
 11818                              <1> 	;    r1 - contains an i-number
 11819                              <1> 	;    fsp - start of table containing open files
 11820                              <1> 	;
 11821                              <1> 	; OUTPUTS ->
 11822                              <1> 	;    "deleted" flag set in fsp entry of another occurrence of
 11823                              <1> 	;	   this file and r2 points 1st word of this fsp entry.
 11824                              <1> 	;    if file not found - bit in i-node map is cleared
 11825                              <1> 	;    			 (i-node is freed)
 11826                              <1> 	;               all blocks related to i-node are freed
 11827                              <1> 	;	        all flags in i-node are cleared
 11828                              <1> 	; ((AX = R1)) input
 11829                              <1> 	;
 11830                              <1> 	;    (Retro UNIX Prototype : 02/12/2012, UNIXCOPY.ASM)
 11831                              <1>         ;    ((Modified registers: eDX, eCX, eBX, eSI, eDI, eBP))  
 11832                              <1> 	;
 11833                              <1> 	; / r1 contains an i-number
 11834                              <1> 
 11835                              <1> 	; TRDOS 386 (06/10/2016)
 11836                              <1> 	; 
 11837                              <1> 	; INPUT:
 11838                              <1> 	;	EAX = First Cluster
 11839                              <1> 	;	 DL = Logical DOS Drive Number
 11840                              <1> 	;
 11841                              <1> 	; OUTPUT:
 11842                              <1> 	;	CF = 1 -> EBX = File Handle/Number/Index
 11843                              <1> 	;	CF = 0 -> EBX = 0
 11844                              <1> 	;
 11845                              <1> 	; Modified Registers: EBX
 11846                              <1> 
 11847 00011185 31DB                <1> 	xor	ebx, ebx
 11848                              <1> anyi_0: 
 11849 00011187 80BB[F6990100]00    <1> 	cmp	byte [ebx+OF_MODE], 0 ; 0 = empty entry
 11850 0001118E 770A                <1> 	ja	short anyi_2 ; 1 (r), 2 (w) or 3 (r&w)
 11851                              <1> anyi_1:
 11852 00011190 FEC3                <1> 	inc	bl
 11853 00011192 80FB0A              <1> 	cmp	bl, OPENFILES ; max. count of open files
 11854 00011195 72F0                <1> 	jb	short anyi_0
 11855 00011197 31C0                <1> 	xor	eax, eax
 11856 00011199 C3                  <1> 	retn 
 11857                              <1> anyi_2:
 11858 0001119A 3A93[EC990100]      <1> 	cmp	dl, [ebx+OF_DRIVE]
 11859 000111A0 75EE                <1> 	jne	short anyi_1
 11860 000111A2 66C1E302            <1> 	shl	bx, 2 ; *4 (dword offset)
 11861 000111A6 3B83[C4990100]      <1> 	cmp	eax, [ebx+OF_FCLUSTER]
 11862 000111AC 7406                <1> 	je	short anyi_3
 11863 000111AE 66C1EB02            <1> 	shr	bx, 2 ; /4 (byte offset)
 11864 000111B2 EBDC                <1> 	jmp	short anyi_1 	
 11865                              <1> anyi_3:
 11866 000111B4 66C1EB02            <1> 	shr	bx, 2 ; /4 (bytes offset) (index)
 11867 000111B8 F9                  <1> 	stc
 11868 000111B9 C3                  <1> 	retn
 11869                              <1> 
 11870                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS9.INC
 11871                              <1> ; Last Modification: 09/12/2015
 11872                              <1> 
 11873                              <1> syssleep:
 11874                              <1> 	; 29/06/2015 - (Retro UNIX 386 v1)
 11875                              <1> 	; 11/06/2014 - (Retro UNIX 8086 v1)
 11876                              <1> 	;
 11877                              <1> 	; Retro UNIX 8086 v1 feature only
 11878                              <1> 	; (INPUT -> none)
 11879                              <1> 	;
 11880 000111BA 0FB61D[B3030300]    <1> 	movzx	ebx, byte [u.uno] ; process number
 11881 000111C1 8AA3[7F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; current/console tty
 11882 000111C7 E881190000          <1> 	call	sleep
 11883 000111CC E92BC7FFFF          <1> 	jmp	sysret
 11884                              <1> 
 11885                              <1> _vp_clr:
 11886                              <1> 	; Reset/Clear Video Page
 11887                              <1> 	;
 11888                              <1> 	; 30/06/2015 - (Retro UNIX 386 v1)
 11889                              <1> 	; 21/05/2013 - 30/10/2013(Retro UNIX 8086 v1) (U0.ASM)
 11890                              <1> 	;
 11891                              <1> 	; Retro UNIX 8086 v1 feature only !
 11892                              <1> 	;
 11893                              <1> 	; INPUTS -> 
 11894                              <1> 	;   BH = video page number	 
 11895                              <1> 	;
 11896                              <1> 	; OUTPUT ->
 11897                              <1> 	;   none
 11898                              <1> 	; ((Modified registers: eAX, BH, eCX, eDX, eSI, eDI))
 11899                              <1> 	;
 11900                              <1> 	; 04/12/2013
 11901 000111D1 28C0                <1> 	sub	al, al
 11902                              <1> 	; al = 0 (clear video page)
 11903                              <1> 	; bh = video page ; 13/05/2016
 11904 000111D3 B407                <1> 	mov	ah, 07h
 11905                              <1> 	; ah = 7 (attribute/color)
 11906 000111D5 6631C9              <1> 	xor 	cx, cx ; 0, left upper column (cl) & row (cl)
 11907 000111D8 66BA4F18            <1> 	mov	dx, 184Fh ; right lower column & row (dl=24, dh=79)
 11908 000111DC E85C0EFFFF          <1> 	call	_scroll_up
 11909                              <1> 	; bh = video page
 11910 000111E1 6631D2              <1> 	xor	dx, dx ; 0 (cursor position) 
 11911 000111E4 E9AE11FFFF          <1> 	jmp 	_set_cpos
 11912                              <1> 
 11913                              <1> sysmsg:
 11914                              <1> 	; 07/12/2020
 11915                              <1> 	; 05/12/2020
 11916                              <1> 	; 13/05/2016
 11917                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 11918                              <1> 	; 01/07/2015 - 11/11/2015 (Retro UNIX 386 v1)
 11919                              <1> 	; Print user-application message on user's console tty
 11920                              <1> 	;
 11921                              <1> 	; Input -> EBX = Message address
 11922                              <1> 	;	   ECX = Message length (max. 255)
 11923                              <1> 	;	   DL = Color (IBM PC Rombios color attributes)
 11924                              <1> 	;
 11925 000111E9 81F9FF000000        <1> 	cmp	ecx, MAX_MSG_LEN ; 255
 11926 000111EF 0F8707C7FFFF        <1> 	ja	sysret ; nothing to do with big message size
 11927 000111F5 08C9                <1> 	or	cl, cl
 11928 000111F7 0F84FFC6FFFF        <1> 	jz	sysret
 11929 000111FD 20D2                <1> 	and	dl, dl
 11930 000111FF 7502                <1> 	jnz	short sysmsg0
 11931 00011201 B207                <1> 	mov	dl, 07h ; default color
 11932                              <1> 		; (black background, light gray character) 
 11933                              <1> sysmsg0:
 11934 00011203 891D[84030300]      <1> 	mov	[u.base], ebx
 11935 00011209 8815[FF890100]      <1> 	mov	[ccolor], dl ; color attributes
 11936 0001120F 89E5                <1> 	mov	ebp, esp
 11937 00011211 31DB                <1> 	xor	ebx, ebx ; 0
 11938 00011213 891D[8C030300]      <1> 	mov	[u.nread], ebx ; 0
 11939                              <1> 	;
 11940 00011219 381D[C6030300]      <1> 	cmp	[u.kcall], bl ; 0
 11941 0001121F 776F                <1> 	ja	short sysmsgk ; Temporary (01/07/2015)
 11942                              <1> 	;
 11943 00011221 890D[88030300]      <1> 	mov	[u.count], ecx
 11944                              <1> 	;inc	ecx ; + 00h ; ASCIIZ
 11945                              <1> 	;
 11946                              <1> 	; 07/12/2020
 11947                              <1> 	;add	ecx, 3
 11948 00011227 6683C103            <1> 	add	cx, 3
 11949 0001122B 80E1FC              <1> 	and	cl, ~3  ; not 3
 11950                              <1> 	;
 11951 0001122E 29CC                <1> 	sub	esp, ecx
 11952 00011230 89E7                <1> 	mov	edi, esp
 11953 00011232 89E6                <1> 	mov	esi, esp
 11954 00011234 66891D[C4030300]    <1> 	mov	[u.pcount], bx ; reset page (phy. addr.) counter
 11955                              <1> 	; 11/11/2015
 11956 0001123B 8A25[94030300]      <1> 	mov 	ah, [u.ttyp] ; recent open tty
 11957                              <1> 	; 0 = none
 11958 00011241 FECC                <1> 	dec	ah
 11959 00011243 790C                <1> 	jns	short sysmsg1 
 11960 00011245 8A1D[B3030300]      <1> 	mov	bl, [u.uno] ; process number	
 11961 0001124B 8AA3[7F000300]      <1> 	mov	ah, [ebx+p.ttyc-1] ; user's (process's) console tty
 11962                              <1> sysmsg1:
 11963 00011251 8825[96030300]      <1> 	mov	[u.ttyn], ah
 11964                              <1> sysmsg2:
 11965 00011257 E848080000          <1> 	call	cpass
 11966 0001125C 7416                <1> 	jz	short sysmsg5
 11967 0001125E AA                  <1> 	stosb
 11968 0001125F 20C0                <1> 	and	al, al
 11969 00011261 75F4                <1> 	jnz	short sysmsg2
 11970                              <1> sysmsg3:
 11971 00011263 80FC07              <1> 	cmp	ah, 7 ; tty number
 11972 00011266 7711                <1> 	ja	short sysmsg6 ; serial port
 11973 00011268 E83E000000          <1> 	call	print_cmsg ; 05/12/2020
 11974                              <1> sysmsg4:
 11975 0001126D 89EC                <1> 	mov	esp, ebp	
 11976 0001126F E988C6FFFF          <1> 	jmp	sysret
 11977                              <1> sysmsg5:
 11978 00011274 C60700              <1> 	mov	byte [edi], 0
 11979 00011277 EBEA                <1> 	jmp	short sysmsg3
 11980                              <1> sysmsg6:
 11981 00011279 8A06                <1> 	mov	al, [esi]
 11982 0001127B E8CD180000          <1> 	call	sndc
 11983 00011280 72EB                <1> 	jc	short sysmsg4
 11984 00011282 803E00              <1> 	cmp	byte [esi], 0  ; 0 is stop character
 11985 00011285 76E6                <1> 	jna	short sysmsg4
 11986 00011287 46                  <1> 	inc 	esi
 11987 00011288 8A25[96030300]      <1> 	mov	ah, [u.ttyn]
 11988 0001128E EBE9                <1> 	jmp	short sysmsg6
 11989                              <1> 
 11990                              <1> sysmsgk: ; Temporary (01/07/2015)
 11991                              <1> 	; The message has been sent by Kernel (ASCIIZ string)
 11992                              <1> 	; (ECX -character count- will not be considered)
 11993 00011290 8B35[84030300]      <1> 	mov	esi, [u.base]
 11994 00011296 8A25[FE890100]      <1> 	mov	ah, [ptty] ; present/current screen (video page)
 11995 0001129C 8825[96030300]      <1> 	mov	[u.ttyn], ah
 11996 000112A2 C605[C6030300]00    <1> 	mov	byte [u.kcall], 0
 11997 000112A9 EBB8                <1> 	jmp	short sysmsg3
 11998                              <1> 	
 11999                              <1> print_cmsg: 
 12000                              <1> 	; 08/12/2020
 12001                              <1> 	; 07/12/2020
 12002                              <1> 	; 05/12/2020
 12003                              <1> 	; 18/11/2017
 12004                              <1> 	; 13/05/2016 - TRDOS 386 (TRDOS v2.0)
 12005                              <1> 	; 01/07/2015 (Retro UNIX 386 v1)
 12006                              <1> 	;
 12007                              <1> 	; print message (on user's console tty) 
 12008                              <1> 	;	with requested color
 12009                              <1> 	;
 12010                              <1> 	; INPUTS:
 12011                              <1> 	;	esi = message address
 12012                              <1> 	;	[u.ttyn] = tty number (0 to 7)
 12013                              <1> 	;	[ccolor] = color attributes (IBM PC BIOS colors)
 12014                              <1> 	;
 12015                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi
 12016                              <1> 	; (ebp must be preserved)
 12017                              <1> 
 12018                              <1> 	;mov	bh, ah
 12019 000112AB 8A3D[96030300]      <1> 	mov	bh, [u.ttyn]
 12020 000112B1 8A1D[FF890100]      <1> 	mov	bl, [ccolor] ; * ; 05/12/2020
 12021                              <1> 
 12022                              <1> 	; 05/12/2020
 12023 000112B7 803D[1C120300]00    <1> 	cmp	byte [pmi32], 0 ; is vbios's 32 bit pmi enabled ?
 12024 000112BE 772E                <1> 	ja	short pcmsg5 ; yes
 12025                              <1> pcmsg1:
 12026                              <1> 	; 08/12/2020
 12027 000112C0 8A1D[FF890100]      <1> 	mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 12028                              <1> 	
 12029 000112C6 AC                  <1> 	lodsb
 12030 000112C7 20C0                <1> 	and 	al, al  ; 0
 12031 000112C9 743A                <1> 	jz 	short pcmsg2
 12032                              <1> pcmsg7:
 12033 000112CB 56                  <1> 	push 	esi
 12034                              <1> 	;mov	bl, [ccolor] ; * (video.s 'u11'&'beep' change BL)
 12035                              <1> 	; 05/12/2020
 12036                              <1> 	;;mov	bh, [u.ttyn]
 12037                              <1> 	;call 	_write_tty
 12038                              <1> 	;pop	esi
 12039                              <1> 	;jmp	short pcmsg1
 12040                              <1> ;pcmsg2:
 12041                              <1> 	;retn
 12042                              <1> 
 12043                              <1> 	; 07/12/2020
 12044 000112CC 803D[CA6F0000]03    <1> 	cmp     byte [CRT_MODE], 3
 12045 000112D3 7708                <1> 	ja 	short pcmsg4
 12046                              <1> pcmsg3:
 12047 000112D5 E83610FFFF          <1> 	call	_write_tty_m3
 12048 000112DA 5E                  <1> 	pop	esi
 12049 000112DB EBE3                <1> 	jmp	short pcmsg1
 12050                              <1> pcmsg4:
 12051 000112DD 803D[CA6F0000]07    <1>         cmp     byte [CRT_MODE], 7
 12052 000112E4 76EF                <1> 	jna 	short pcmsg3
 12053 000112E6 E8491DFFFF          <1> 	call	vga_write_teletype
 12054 000112EB 5E                  <1> 	pop	esi
 12055 000112EC EBD2                <1> 	jmp	short pcmsg1
 12056                              <1> pcmsg5:
 12057                              <1> 	; 07/12/2020
 12058 000112EE 803D[CA6F0000]07    <1>         cmp     byte [CRT_MODE], 7
 12059 000112F5 76C9                <1> 	jna 	short pcmsg1
 12060                              <1> 
 12061                              <1> 	; 05/12/2020
 12062                              <1> 	; writing message by using
 12063                              <1> 	; VESA VBE3 video bios protected mode interface
 12064                              <1> 	
 12065 000112F7 B40E                <1> 	mov	ah, 0Eh
 12066                              <1> pcmsg6:
 12067 000112F9 AC                  <1> 	lodsb
 12068 000112FA 20C0                <1> 	and 	al, al  ; 0
 12069 000112FC 7407                <1> 	jz 	short pcmsg2
 12070                              <1> 	; bh = video page
 12071                              <1> 	; ah = 0Eh 
 12072                              <1> 	; al = character
 12073                              <1> 	; bl = color
 12074 000112FE E80707FFFF          <1> 	call	int10h_32bit_pmi
 12075 00011303 EBF4                <1> 	jmp	short pcmsg6
 12076                              <1> pcmsg2:
 12077 00011305 C3                  <1> 	retn
 12078                              <1> 
 12079                              <1> sysgeterr:
 12080                              <1> 	; 09/12/2015
 12081                              <1> 	; 21/09/2015 - (Retro UNIX 386 v1 feature only!)
 12082                              <1> 	; Get last error number or page fault count
 12083                              <1> 	; (for debugging)
 12084                              <1> 	;
 12085                              <1> 	; Input -> EBX = return type
 12086                              <1> 	;	   0 = last error code (which is in 'u.error')	
 12087                              <1> 	;	   FFFFFFFFh = page fault count for running process
 12088                              <1> 	;	   FFFFFFFEh = total page fault count
 12089                              <1> 	;	   1 .. FFFFFFFDh = undefined 
 12090                              <1> 	;
 12091                              <1> 	; Output -> EAX = last error number or page fault count
 12092                              <1> 	;	   (depending on EBX input)
 12093                              <1> 	; 	
 12094 00011306 21DB                <1> 	and 	ebx, ebx
 12095 00011308 750B                <1> 	jnz	short glerr_2
 12096                              <1> glerr_0:
 12097 0001130A A1[C8030300]        <1> 	mov	eax, [u.error]
 12098                              <1> glerr_1:
 12099 0001130F A3[64030300]        <1> 	mov	[u.r0], eax
 12100 00011314 C3                  <1>  	retn
 12101                              <1> glerr_2:
 12102 00011315 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0, FFFFFFFEh -> FFFFFFFFh
 12103 00011316 74FD                <1> 	jz	short glerr_2 ; page fault count for process
 12104 00011318 43                  <1> 	inc	ebx ; FFFFFFFFh -> 0	
 12105 00011319 75EF                <1> 	jnz	short glerr_0
 12106 0001131B A1[80050300]        <1> 	mov	eax, [PF_Count] ; total page fault count
 12107 00011320 EBED                <1>         jmp     short glerr_1
 12108                              <1> glerr_3:
 12109 00011322 A1[CC030300]        <1> 	mov 	eax, [u.pfcount]
 12110 00011327 EBE6                <1> 	jmp	short glerr_1
 12111                              <1> 
 12112                              <1> load_and_run_file:
 12113                              <1> 	; 18/11/2017
 12114                              <1> 	; 22/01/2017
 12115                              <1> 	; 04/01/2017, 07/01/2017
 12116                              <1> 	; 24/10/2016
 12117                              <1> 	; 24/04/2016, 02/05/2016, 03/05/2016, 06/05/2016
 12118                              <1> 	; 23/04/2016 (TRDOS 386 = TRDOS v2.0)
 12119                              <1> 	; 23/10/2015 (Retro UNIX 386 v1, 'sysexec')
 12120                              <1> 	; 23/06/2015 (Retro UNIX 386 v1 - Beginning)
 12121                              <1> 	; 03/06/2013 - 06/12/2013 (Retro UNIX 8086 v1)
 12122                              <1> 	; EAX = First Cluster number
 12123                              <1> 	; EDX = File Size
 12124                              <1> 	; ESI = Argument list address
 12125                              <1> 	; [argc] = argument count
 12126                              <1> 	; [u.nread] = argument list length
 12127                              <1> 	; [esp] = return address to the caller (*)
 12128                              <1> 	;
 12129 00011329 8935[4C040300]      <1> 	mov	[argv], esi
 12130 0001132F 8915[55040300]      <1> 	mov	[i.size], edx
 12131 00011335 A3[51040300]        <1> 	mov	[ii], eax
 12132                              <1> 
 12133                              <1> 	;sti	; 07/01/2017
 12134                              <1> 	;mov	eax, [k_page_dir]
 12135                              <1> 	;mov	[u.pgdir], eax
 12136 0001133A 31C0                <1> 	xor 	eax, eax ; clc ; *** ; 04/01/2017
 12137                              <1> 	;mov	[u.r0], eax ; 0 ; 07/01/2017
 12138                              <1> 
 12139                              <1> 	; 06/05/2016
 12140                              <1> 	; Set 'sysexit' return order to MainProg
 12141                              <1> 	;
 12142 0001133C 58                  <1> 	pop	eax ; * 'loc_load_and_run_file_8:' address
 12143                              <1> 	;; 22/01/2017
 12144                              <1> 	;;cli ; 07/01/2017
 12145 0001133D 8B25[6C890100]      <1> 	mov	esp, [tss.esp0]
 12146                              <1> 	;
 12147                              <1> 	; 'loc_load_run_file_8' address has 
 12148                              <1> 	; 'jmp loc_file_rw_restore_retn' instruction
 12149                              <1> 	; 'loc_file_rw_restore_retn:' will return to
 12150                              <1> 	; [mainprog_return_addr] 
 12151                              <1> 	; just after 'call command_interpreter'
 12152                              <1> 	;
 12153 00011343 68[33750000]        <1> 	push	_end_of_mainprog ; we must not return to here !
 12154 00011348 FF35[50960100]      <1> 	push	dword [mainprog_return_addr]
 12155 0001134E 89E5                <1> 	mov	ebp, esp ; **
 12156                              <1> 	;	
 12157 00011350 9C                  <1> 	pushfd  ; EFLAGS      ; IRETD ; ***
 12158 00011351 6A08                <1> 	push	KCODE ; cs    ; IRETD
 12159 00011353 50                  <1> 	push	eax ; * (eip) ; IRETD
 12160 00011354 8925[5C030300]      <1> 	mov	[u.sp], esp
 12161                              <1> 	;mov	byte [u.quant], time_count
 12162 0001135A 1E                  <1> 	push	ds
 12163 0001135B 06                  <1> 	push	es
 12164 0001135C 0FA0                <1> 	push	fs
 12165 0001135E 0FA8                <1> 	push	gs	
 12166                              <1> 	;mov	eax, [u.r0]
 12167 00011360 29C0                <1> 	sub	eax, eax
 12168 00011362 60                  <1> 	pushad
 12169 00011363 68[FCD80000]        <1> 	push	sysret
 12170                              <1> 	;push	sysrel1 ; 07/01/2017
 12171 00011368 8925[60030300]      <1> 	mov	[u.usp], esp
 12172                              <1> 	;
 12173 0001136E E845060000          <1> 	call	wswap ; Save MainProg (process 1) 'u' structure
 12174                              <1> 		      ; and registers for return (from program)	
 12175 00011373 89EC                <1> 	mov	esp, ebp ; **
 12176                              <1> 	;;22/01/2017
 12177                              <1> 	;;sti ; 07/01/2017
 12178 00011375 50                  <1> 	push	eax  ; * 'loc_load_and_run_file_8:' address
 12179                              <1> 	;
 12180                              <1> 	;;; 02/05/2016
 12181                              <1> 	;;; Create a new process (parent: MainProg)	
 12182 00011376 31F6                <1> 	xor 	esi, esi
 12183                              <1> cnpm_1: ; search p.stat table for unused process number
 12184 00011378 46                  <1> 	inc	esi
 12185 00011379 80BE[AF000300]00    <1> 	cmp	byte [esi+p.stat-1], 0 ; SFREE
 12186                              <1> 				; is process active, unused, dead
 12187 00011380 760B                <1> 	jna	short cnpm_2	; it's unused so branch
 12188 00011382 6683FE10            <1> 	cmp	si, nproc 	; all processes checked
 12189 00011386 72F0                <1> 	jb	short cnpm_1    ; no, branch back
 12190 00011388 E92E62FFFF          <1> 	jmp	panic 
 12191                              <1> cnpm_2:
 12192 0001138D A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; page directory of MainProg
 12193 00011392 A3[BC030300]        <1> 	mov	[u.ppgdir], eax ; parent's page directory
 12194 00011397 E83748FFFF          <1> 	call	allocate_page
 12195 0001139C 0F821962FFFF        <1> 	jc	panic
 12196                              <1> 	; EAX = UPAGE (user structure page) address
 12197 000113A2 A3[B4030300]        <1> 	mov	[u.upage], eax ; memory page for 'user' struct (child)
 12198 000113A7 89F7                <1> 	mov	edi, esi
 12199 000113A9 66C1E702            <1> 	shl	di, 2
 12200 000113AD 8987[BC000300]      <1> 	mov	[edi+p.upage-4], eax ; memory page for 'user' struct
 12201 000113B3 E89548FFFF          <1> 	call	clear_page ; 03/05/2016
 12202                              <1> 	;movzx	eax, byte [p.ttyc] ; console tty (for MainProg)
 12203 000113B8 6629C0              <1> 	sub	ax, ax ; 0
 12204 000113BB 668986[7F000300]    <1> 	mov     [esi+p.ttyc-1], ax ; al - set child's console tty
 12205                              <1> 				   ; ah - reset child's wait channel	
 12206 000113C2 89F0                <1> 	mov	eax, esi
 12207 000113C4 A2[B3030300]        <1> 	mov	[u.uno], al ; child process number
 12208 000113C9 FE86[AF000300]      <1>         inc     byte [esi+p.stat-1] ; 1, SRUN
 12209 000113CF 66D1E6              <1> 	shl	si, 1 ; multiply si by 2 to get index into p.pid table
 12210 000113D2 66FF05[4E030300]    <1> 	inc	word [mpid] ; increment m.pid; get a new process name
 12211 000113D9 66A1[4E030300]      <1> 	mov	ax, [mpid]
 12212 000113DF 668986[1E000300]    <1> 	mov	[esi+p.pid-2], ax ; put new process name 
 12213                              <1> 				  ; in child process' name slot
 12214                              <1> 	;mov	ax, [p.pid]  ; get process name of MainProg
 12215 000113E6 66B80100            <1> 	mov	ax, 1
 12216 000113EA 668986[3E000300]    <1> 	mov	[esi+p.ppid-2], ax ; put parent process name 
 12217                              <1> 			           ; in parent process slot for child
 12218 000113F1 6648                <1> 	dec	ax ; 0
 12219 000113F3 66A3[94030300]      <1> 	mov 	[u.ttyp], ax ; 0
 12220                              <1> 	;;;
 12221 000113F9 A1[51040300]        <1> 	mov 	eax,  [ii]
 12222                              <1> 	; Retro UNIX 386 v1, 'sysexec' (u2.s)
 12223 000113FE E84A170000          <1> 	call	iopen
 12224                              <1> 	; 06/06/2016
 12225 00011403 C605[A9030300]01    <1> 	mov	byte [u.pri], 1 ; normal priority
 12226                              <1> 	;
 12227 0001140A EB16                <1> 	jmp	short sysexec_7 ; 02/05/2016
 12228                              <1> 
 12229                              <1> sysexec_6:
 12230                              <1> 	; 19/11/2017
 12231                              <1> 	; 18/11/2017
 12232                              <1> 	; 14/11/2017
 12233                              <1> 	; 13/11/2017
 12234 0001140C 8925[4C040300]      <1> 	mov	[argv], esp ; *!* ; start address of argument list 
 12235                              <1> 
 12236                              <1> 	; 04/01/2017
 12237                              <1> 	; 24/10/2016
 12238                              <1> 	;;02/05/2016
 12239                              <1> 	; 23/04/2016 (TRDOS 386)
 12240                              <1> 	; 18/10/2015 ('sysexec_6')
 12241                              <1> 	; 23/06/2015
 12242 00011412 A1[B8030300]        <1> 	mov	eax, [u.pgdir] ; physical address of page directory
 12243                              <1> 	;cmp 	eax, [k_page_dir] ; TRDOS MainProg ? 
 12244                              <1> 	;je	short sysexec_7
 12245                              <1> 	; 19/11/2017
 12246 00011417 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; phy addr of the parent's page dir
 12247 0001141D E8EA48FFFF          <1> 	call	deallocate_page_dir
 12248                              <1> sysexec_7:
 12249 00011422 E81A48FFFF          <1> 	call	make_page_dir
 12250 00011427 0F828E61FFFF        <1> 	jc	panic  ; allocation error 
 12251                              <1> 		       ; after a deallocation would be nonsence !?
 12252                              <1> 	; 24/07/2015
 12253                              <1> 	; map kernel pages (1st 4MB) to PDE 0
 12254                              <1> 	;     of the user's page directory
 12255                              <1> 	;     (It is needed for interrupts!)
 12256                              <1> 	; 18/10/2015
 12257 0001142D 8B15[D0890100]      <1> 	mov	edx, [k_page_dir] ; Kernel's page directory
 12258 00011433 8B02                <1> 	mov	eax, [edx] ; physical address of
 12259                              <1> 			   ; kernel's first page table (1st 4 MB)
 12260                              <1> 			   ; (PDE 0 of kernel's page directory)
 12261 00011435 8B15[B8030300]      <1> 	mov 	edx, [u.pgdir]
 12262 0001143B 8902                <1> 	mov	[edx], eax ; PDE 0 (1st 4MB)
 12263                              <1> 	;
 12264                              <1> 	; 20/07/2015
 12265 0001143D BB00004000          <1> 	mov	ebx, CORE ; start address = 0 (virtual) + CORE
 12266                              <1> 	; 18/10/2015
 12267 00011442 BE[3C040300]        <1> 	mov	esi, pcore ; physical start address
 12268                              <1> sysexec_8:	
 12269 00011447 B907000000          <1> 	mov	ecx, PDE_A_USER + PDE_A_WRITE + PDE_A_PRESENT
 12270 0001144C E80E48FFFF          <1> 	call	make_page_table
 12271 00011451 0F826461FFFF        <1> 	jc	panic
 12272                              <1> 	;mov	ecx, PTE_A_USER + PTE_A_WRITE + PTE_A_PRESENT
 12273 00011457 E81148FFFF          <1> 	call	make_page ; make new page, clear and set the pte 
 12274 0001145C 0F825961FFFF        <1> 	jc	panic
 12275                              <1> 	;
 12276 00011462 8906                <1> 	mov	[esi], eax ; 24/06/2015
 12277                              <1> 	; ebx = virtual address (24/07/2015)
 12278 00011464 E8A94DFFFF          <1> 	call 	add_to_swap_queue
 12279                              <1> 	; 18/10/2015
 12280 00011469 81FE[40040300]      <1> 	cmp	esi, ecore ; user's stack (last) page ?
 12281 0001146F 740C                <1> 	je	short sysexec_9 ; yes
 12282 00011471 BE[40040300]        <1> 	mov	esi, ecore  ; physical address of the last page 
 12283                              <1> 	; 20/07/2015
 12284 00011476 BB00F0FFFF          <1> 	mov	ebx, (ECORE - PAGE_SIZE) + CORE
 12285                              <1> 	; ebx = virtual end address + segment base address - 4K
 12286 0001147B EBCA                <1>         jmp     short sysexec_8
 12287                              <1> sysexec_9:
 12288                              <1> 	; 19/11/2017 
 12289                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 12290                              <1> 	; 25/06/2015, 26/08/2015, 18/10/2015
 12291                              <1> 	; move arguments from kernel stack to [ecore]
 12292                              <1> 	; (argument list/line will be copied from kernel stack
 12293                              <1> 	; frame to the last (stack) page of user's core memory)
 12294                              <1> 	; 18/10/2015
 12295 0001147D 8B3D[40040300]      <1> 	mov	edi, [ecore]
 12296 00011483 81C700100000        <1> 	add	edi, PAGE_SIZE
 12297                              <1> 	; 19/11/2017
 12298 00011489 83EF04              <1> 	sub	edi, 4
 12299 0001148C C70700000000        <1> 	mov	dword [edi], 0 
 12300 00011492 89FB                <1> 	mov	ebx, edi
 12301                              <1> 	;
 12302 00011494 0FB705[4A040300]    <1> 	movzx	eax, word [argc]
 12303 0001149B 09C0                <1> 	or	eax, eax
 12304 0001149D 7445                <1> 	jz	short sysexec_13 ; 19/11/2017
 12305                              <1> 	;jnz	short sysexec_10
 12306                              <1> 	;mov 	ebx, edi
 12307                              <1> 	;sub	ebx, 4 
 12308                              <1> 	;mov	[ebx], eax ; 0
 12309                              <1> 	;jmp 	short sysexec_13
 12310                              <1> sysexec_10:
 12311 0001149F 8B0D[8C030300]      <1> 	mov	ecx, [u.nread]
 12312                              <1> 	; 13/11/2017
 12313                              <1> 	;mov	esi, TextBuffer ; 'load_and_execute_file'
 12314                              <1> 	;mov	esi, esp  	; 'sysexec'
 12315 000114A5 8B35[4C040300]      <1> 	mov	esi, [argv] ; 24/04/2016 (TRDOS 386  = TRDOS v2.0)
 12316                              <1> 	;sub	edi, ecx ; page end address - argument list length
 12317 000114AB 29CB                <1> 	sub	ebx, ecx ; 19/11/2017
 12318 000114AD 89C2                <1> 	mov	edx, eax
 12319 000114AF FEC2                <1> 	inc	dl ; argument count + 1 for argc value  
 12320 000114B1 C0E202              <1> 	shl 	dl, 2  ; 4 * (argument count + 1)
 12321                              <1> 	;mov	ebx, edi
 12322 000114B4 89DF                <1> 	mov	edi, ebx ; 19//11/2017
 12323 000114B6 80E3FC              <1> 	and	bl, 0FCh ; 32 bit (dword) alignment
 12324 000114B9 29D3                <1> 	sub 	ebx, edx
 12325 000114BB 89FA                <1> 	mov	edx, edi
 12326 000114BD F3A4                <1> 	rep	movsb
 12327 000114BF 89D6                <1> 	mov 	esi, edx
 12328 000114C1 89DF                <1> 	mov 	edi, ebx
 12329 000114C3 BA00F0BFFF          <1> 	mov	edx, ECORE - PAGE_SIZE ; virtual addr. of the last page
 12330 000114C8 2B15[40040300]      <1> 	sub 	edx, [ecore] ; difference (virtual - physical) 
 12331 000114CE AB                  <1> 	stosd	; eax = argument count	
 12332                              <1> sysexec_11:
 12333 000114CF 89F0                <1> 	mov	eax, esi
 12334 000114D1 01D0                <1> 	add	eax, edx
 12335 000114D3 AB                  <1> 	stosd  ; eax = virtual address
 12336                              <1> 	;dec	byte [argc]
 12337 000114D4 66FF0D[4A040300]    <1> 	dec	word [argc] ; 14/11/2017
 12338 000114DB 7407                <1> 	jz	short sysexec_13
 12339                              <1> sysexec_12:
 12340 000114DD AC                  <1> 	lodsb
 12341 000114DE 20C0                <1> 	and	al, al
 12342 000114E0 75FB                <1> 	jnz	short sysexec_12
 12343 000114E2 EBEB                <1> 	jmp	short sysexec_11
 12344                              <1> sysexec_13:
 12345                              <1> 	; 24/10/2016
 12346                              <1> 	; 24/04/2016 - TRDOS 386 (TRDOS v2.0)
 12347                              <1> 	; 23/06/2015 - 19/10/2015 (Retro UNIX 386 v1, 'sysexec_13')
 12348                              <1> 	;
 12349                              <1> 	; moving arguments to [ecore] is OK here..
 12350                              <1> 	;
 12351                              <1> 	; ebx = beginning addres of argument list pointers
 12352                              <1> 		;	in user's stack
 12353 000114E4 2B1D[40040300]      <1> 	sub 	ebx, [ecore]
 12354 000114EA 81C300F0BFFF        <1> 	add     ebx, (ECORE - PAGE_SIZE)
 12355                              <1> 			; end of core - 4096 (last page)
 12356                              <1> 			; (virtual address)
 12357 000114F0 891D[4C040300]      <1> 	mov	[argv], ebx
 12358 000114F6 891D[90030300]      <1> 	mov	[u.break], ebx ; available user memory
 12359                              <1> 	;
 12360 000114FC 29C0                <1> 	sub	eax, eax
 12361 000114FE C705[88030300]2000- <1> 	mov	dword [u.count], 32 ; Executable file header size
 12361 00011506 0000                <1>
 12362 00011508 C705[74030300]-     <1> 	mov	dword [u.fofp], u.off
 12362 0001150E [80030300]          <1>
 12363 00011512 A3[80030300]        <1> 	mov	[u.off], eax ; 0
 12364 00011517 A3[84030300]        <1> 	mov	[u.base], eax ; 0, start of user's core (virtual)
 12365                              <1> 	; 24/10/2016
 12366 0001151C A0[968A0100]        <1> 	mov	al, [Current_Drv]
 12367 00011521 A2[46030300]        <1> 	mov	[cdev], al
 12368                              <1> 	;
 12369 00011526 A1[51040300]        <1> 	mov	eax, [ii] ; Fist Cluster of the Program (PRG) file
 12370                              <1> 	; EAX = First cluster of the executable file
 12371 0001152B E80A010000          <1> 	call	readi
 12372                              <1> 
 12373 00011530 8B0D[90030300]      <1> 	mov	ecx, [u.break] ; top of user's stack (physical addr.)
 12374 00011536 890D[88030300]      <1> 	mov	[u.count], ecx ; save for overrun check
 12375                              <1> 	;
 12376 0001153C 8B0D[8C030300]      <1> 	mov	ecx, [u.nread]
 12377 00011542 890D[90030300]      <1> 	mov	[u.break], ecx ; virtual address (offset from start)
 12378 00011548 80F920              <1> 	cmp	cl, 32
 12379 0001154B 7540                <1>         jne     short sysexec_15
 12380                              <1> 	;:
 12381                              <1> 	; Retro UNIX 386 v1 (32 bit) executable file header format
 12382 0001154D 8B35[3C040300]      <1> 	mov	esi, [pcore] ; start address of user's core memory 
 12383                              <1> 		             ; (phys. start addr. of the exec. file)
 12384 00011553 AD                  <1> 	lodsd
 12385 00011554 663DEB1E            <1> 	cmp	ax, 1EEBh ; EBH, 1Eh -> jump to +32
 12386 00011558 7533                <1> 	jne	short sysexec_15
 12387 0001155A AD                  <1> 	lodsd
 12388 0001155B 89C1                <1> 	mov	ecx, eax ; text (code) section size
 12389 0001155D AD                  <1> 	lodsd
 12390 0001155E 01C1                <1> 	add	ecx, eax ; + data section size (initialized data)
 12391 00011560 89CB                <1> 	mov	ebx, ecx
 12392 00011562 AD                  <1> 	lodsd	
 12393 00011563 01C3                <1> 	add	ebx, eax ; + bss section size (for overrun checking)
 12394 00011565 3B1D[88030300]      <1> 	cmp	ebx, [u.count]
 12395 0001156B 7711                <1> 	ja	short sysexec_14  ; program overruns stack !
 12396                              <1> 	;
 12397                              <1> 	; add bss section size to [u.break]
 12398 0001156D 0105[90030300]      <1> 	add 	[u.break], eax
 12399                              <1> 	;
 12400 00011573 83E920              <1> 	sub	ecx, 32  ; header size (already loaded)
 12401                              <1> 	;cmp	ecx, [u.count]
 12402                              <1> 	;jnb	short sysexec_16
 12403 00011576 890D[88030300]      <1> 	mov	[u.count], ecx ; required read count
 12404 0001157C EB29                <1> 	jmp	short sysexec_16
 12405                              <1> sysexec_14:
 12406                              <1> 	; insufficient (out of) memory
 12407 0001157E C705[C8030300]0400- <1> 	mov	dword [u.error], ERR_MINOR_IM ; 1
 12407 00011586 0000                <1>
 12408 00011588 E94FC3FFFF          <1> 	jmp	error
 12409                              <1> sysexec_15:
 12410 0001158D 8B15[55040300]      <1>         mov	edx, [i.size] ; file size
 12411 00011593 29CA                <1> 	sub	edx, ecx ; file size - loaded bytes
 12412 00011595 7626                <1> 	jna	short sysexec_17 ; no need to next read
 12413 00011597 01D1                <1> 	add	ecx, edx ; [i.size]
 12414 00011599 3B0D[88030300]      <1> 	cmp	ecx, [u.count] ; overrun check (!)
 12415 0001159F 77DD                <1> 	ja	short sysexec_14
 12416 000115A1 8915[88030300]      <1> 	mov	[u.count], edx
 12417                              <1> sysexec_16:
 12418 000115A7 A1[51040300]        <1> 	mov	eax, [ii] ; first cluster
 12419 000115AC E889000000          <1> 	call	readi
 12420 000115B1 8B0D[8C030300]      <1> 	mov	ecx, [u.nread]
 12421 000115B7 010D[90030300]      <1> 	add	[u.break], ecx
 12422                              <1> sysexec_17:
 12423 000115BD A1[51040300]        <1> 	mov	eax, [ii] ; first cluster
 12424 000115C2 E886150000          <1> 	call	iclose
 12425 000115C7 31C0                <1> 	xor     eax, eax
 12426 000115C9 FEC0                <1> 	inc	al
 12427 000115CB 66A3[AA030300]      <1> 	mov	[u.intr], ax ; 1 (interrupt/time-out is enabled)
 12428 000115D1 66A3[AC030300]      <1> 	mov	[u.quit], ax ; 1 ('crtl+brk' signal is enabled) 
 12429 000115D7 833D[BC030300]00    <1>         cmp	dword [u.ppgdir], 0  ; is the caller MainProg (kernel) ?
 12430 000115DE 770C                <1> 	ja	short sysexec_18 ; no, the caller is user process
 12431                              <1> 	; If the caller is kernel (MainProg), 'sysexec' will come here
 12432 000115E0 8B15[D0890100]      <1> 	mov	edx, [k_page_dir] ; kernel's page directory
 12433 000115E6 8915[BC030300]      <1> 	mov	[u.ppgdir], edx ; next time 'sysexec' must not come here 
 12434                              <1> sysexec_18:
 12435                              <1> 	; 02/05/2016
 12436                              <1> 	; 24/04/2016 (TRDOS 386 = TRDOS v2.0)
 12437                              <1> 	; 18/10/2015 (Retro UNIX 386 v1)
 12438                              <1> 	; 05/08/2015
 12439                              <1> 	; 29/07/2015
 12440                              <1> 
 12441                              <1> ;	; **** arguments list test start - 19/11/2017
 12442                              <1> ;	mov	ebp, [argv]
 12443                              <1> ;	sub	ebp, ECORE - 4096
 12444                              <1> ;	add	ebp, [ecore]
 12445                              <1> ;
 12446                              <1> ;	mov	ebx, [ebp]
 12447                              <1> ;	mov	[argc], bx
 12448                              <1> ;	add	ebp, 4
 12449                              <1> ;	mov	byte [ccolor], 1Fh
 12450                              <1> ;_zx0:
 12451                              <1> ;	cmp	word [argc], 0
 12452                              <1> ;	jna	short _zx2	
 12453                              <1> ;_zx1:
 12454                              <1> ;	push	ebp
 12455                              <1> ;	mov	esi, [ebp]
 12456                              <1> ;
 12457                              <1> ;	sub	esi, ECORE - 4096
 12458                              <1> ;	add	esi, [ecore]
 12459                              <1> ;
 12460                              <1> ;	call	print_cmsg
 12461                              <1> ;
 12462                              <1> ;	dec	word [argc]
 12463                              <1> ;	jz	short _zx2
 12464                              <1> ;
 12465                              <1> ;	mov	al, '.'
 12466                              <1> ;	mov	bl, 07h
 12467                              <1> ;	mov	bh, [u.ttyn]
 12468                              <1> ;	call 	_write_tty 
 12469                              <1> ;
 12470                              <1> ;	pop	ebp
 12471                              <1> ;	add	ebp, 4
 12472                              <1> ;	jmp	short _zx1			
 12473                              <1> ;_zx2:
 12474                              <1> ;	pop	ebp
 12475                              <1> ;	mov	byte [ccolor], 07h
 12476                              <1> ;	mov	eax, 1
 12477                              <1> ;	; **** arguments list test stop
 12478                              <1> ;	Test result is OK! (there is not a wrong thing) - 19/11/2017
 12479                              <1> 
 12480 000115EC 8B2D[4C040300]      <1> 	mov	ebp, [argv] ; user's stack pointer must point to argument
 12481                              <1> 			    ; list pointers (argument count)
 12482 000115F2 FA                  <1> 	cli
 12483 000115F3 8B25[6C890100]      <1>         mov     esp, [tss.esp0] ; ring 0 (kernel) stack pointer
 12484                              <1> 	;mov   	esp, [u.sp] ; Restore Kernel stack
 12485                              <1> 			    ; for this process	 
 12486                              <1> 	;add	esp, 20 ; --> EIP, CS, EFLAGS, ESP, SS
 12487                              <1> 	;xor	eax, eax ; 0
 12488 000115F9 FEC8                <1> 	dec	al ; eax = 0
 12489                              <1> 	;mov	edx, UDATA
 12490                              <1> 	; 18/11/2017
 12491 000115FB 6A23                <1> 	push	UDATA ; user's stack segment
 12492                              <1> 	;push	edx
 12493 000115FD 55                  <1> 	push	ebp ; user's stack pointer
 12494                              <1> 		    ; (points to number of arguments)
 12495                              <1> 	
 12496                              <1> 	; 04/01/2017
 12497                              <1> 	; MainProg comes here while [sysflg]= 0FFh
 12498                              <1> 	; (but sysexec comes here while [sysflg]= 0)
 12499 000115FE C605[5B030300]00    <1> 	mov	byte [sysflg], 0 ; 04/01/2017
 12500                              <1> 				 ; (timer_int sysflg control)
 12501 00011605 FB                  <1> 	sti
 12502 00011606 9C                  <1> 	pushfd	; EFLAGS
 12503                              <1> 		; Set IF for enabling interrupts in user mode	
 12504                              <1> 	;or	dword [esp], 200h 
 12505                              <1> 	;
 12506                              <1> 	;mov	bx, UCODE
 12507                              <1> 	;push	bx ; user's code segment
 12508 00011607 6A1B                <1> 	push	UCODE
 12509                              <1> 	;push	0
 12510 00011609 50                  <1> 	push	eax ; EIP (=0) - start address -	
 12511 0001160A 8925[5C030300]      <1> 	mov	[u.sp], esp ; 29/07/2015
 12512                              <1> 	; 05/08/2015
 12513                              <1> 	; Remedy of a General Protection Fault during 'iretd' is here !
 12514                              <1> 	; ('push dx' would cause to general protection fault, 
 12515                              <1> 	; after 'pop ds' etc.)
 12516                              <1> 	;
 12517                              <1> 	;; push dx ; ds (UDATA)
 12518                              <1> 	;; push dx ; es (UDATA)
 12519                              <1> 	;; push dx ; fs (UDATA)
 12520                              <1> 	;; push dx ; gs (UDATA)
 12521                              <1> 	;
 12522                              <1> 	; This is a trick to prevent general protection fault
 12523                              <1> 	; during 'iretd' intruction at the end of 'sysrele' (in u1.s):
 12524 00011610 66BA2300            <1> 	mov	dx, UDATA ; 19/11/2017
 12525 00011614 8EC2                <1> 	mov 	es, dx ; UDATA
 12526 00011616 06                  <1> 	push 	es ; ds (UDATA)
 12527 00011617 06                  <1> 	push 	es ; es (UDATA)
 12528 00011618 06                  <1> 	push 	es ; fs (UDATA)
 12529 00011619 06                  <1> 	push	es ; gs (UDATA)
 12530 0001161A 66BA1000            <1> 	mov	dx, KDATA
 12531 0001161E 8EC2                <1> 	mov	es, dx
 12532                              <1> 	;
 12533                              <1> 	;; pushad simulation
 12534 00011620 89E5                <1> 	mov	ebp, esp ; esp before pushad
 12535 00011622 50                  <1> 	push	eax ; eax (0)
 12536 00011623 50                  <1> 	push	eax ; ecx (0)
 12537 00011624 50                  <1> 	push	eax ; edx (0)
 12538 00011625 50                  <1> 	push	eax ; ebx (0)
 12539 00011626 55                  <1> 	push	ebp ; esp before pushad
 12540 00011627 50                  <1> 	push	eax ; ebp (0)
 12541 00011628 50                  <1> 	push	eax ; esi (0)		
 12542 00011629 50                  <1> 	push	eax ; edi (0)	
 12543                              <1> 	;
 12544 0001162A A3[64030300]        <1> 	mov	[u.r0], eax ; eax = 0
 12545 0001162F 8925[60030300]      <1> 	mov	[u.usp], esp
 12546                              <1> 
 12547                              <1> 	; 14/11/2017
 12548 00011635 E9C4C2FFFF          <1> 	jmp	sysret0
 12549                              <1> 
 12550                              <1> ;	; 02/05/2016
 12551                              <1> ;	;inc	byte [sysflg] ; 0FFh -> 0
 12552                              <1> ;	;mov	byte [sysflg], 0 ; 04/01/2017
 12553                              <1> ;	movzx	ebx, byte [u.uno]
 12554                              <1> ;	shl	bl, 1 ; 13/11/2017 	
 12555                              <1> ;	cmp	word [ebx+p.ppid-2], 1 ; MainProg
 12556                              <1> ;	ja	sysret0 ; 03/05/2016
 12557                              <1> ;	push	sysret ; * 
 12558                              <1> ;	mov	[u.usp], esp
 12559                              <1> ;	call	wswap ; save child process 'u' structure and
 12560                              <1> ;		      ; registers
 12561                              <1> ;	add	dword [u.usp], 4 ; 03/05/2016 
 12562                              <1> ;sysexec_19: ; 02/05/2016
 12563                              <1> ;	retn ; * 'sysret' ; byte [sysflg] -> 0FFh
 12564                              <1> 
 12565                              <1> readi:
 12566                              <1> 	; 01/05/2016
 12567                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 12568                              <1> 	; 20/05/2015 - Retro UNIX 386 v1
 12569                              <1> 	; 11/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 12570                              <1> 	;
 12571                              <1> 	; Reads from a file whose the first cluster number in EAX
 12572                              <1> 	; 
 12573                              <1> 	; INPUTS ->
 12574                              <1> 	;    EAX - First cluster number of the file
 12575                              <1> 	;    u.count - byte count user desires
 12576                              <1> 	;    u.base - points to user buffer
 12577                              <1> 	;    u.fofp - points to dword with current file offset
 12578                              <1> 	;    i.size - file size
 12579                              <1> 	;    cdev - logical dos drive number of the file
 12580                              <1> 	; OUTPUTS ->
 12581                              <1> 	;    u.count - cleared
 12582                              <1> 	;    u.nread - accumulates total bytes passed back
 12583                              <1> 	;
 12584                              <1> 	; ((EAX)) input/output
 12585                              <1> 	; (Retro UNIX Prototype : 14/12/2012 - 01/03/2013, UNIXCOPY.ASM)
 12586                              <1>         ; ((Modified registers: edx, ebx, ecx, esi, edi))  
 12587                              <1> 
 12588 0001163A 31D2                <1> 	xor	edx, edx ; 0
 12589 0001163C 8915[8C030300]      <1> 	mov 	[u.nread], edx ; 0
 12590 00011642 668915[C4030300]    <1> 	mov	[u.pcount], dx ; 19/05/2015
 12591 00011649 3915[88030300]      <1> 	cmp 	[u.count], edx ; 0
 12592 0001164F 7701                <1> 	ja 	short readi_1
 12593 00011651 C3                  <1> 	retn
 12594                              <1> readi_1:
 12595                              <1> dskr:
 12596                              <1> 	; 01/05/2016
 12597                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 12598                              <1> 	; 24/05/2015 - 12/10/2015 (Retro UNIX 386 v1)
 12599                              <1> 	; 26/04/2013 - 03/08/2013 (Retro UNIX 8086 v1)
 12600                              <1> dskr_0:
 12601 00011652 8B15[55040300]      <1>         mov	edx, [i.size]
 12602 00011658 8B1D[74030300]      <1> 	mov	ebx, [u.fofp]
 12603 0001165E 2B13                <1> 	sub	edx, [ebx]
 12604 00011660 7647                <1> 	jna	short dskr_4
 12605                              <1> 	;
 12606 00011662 50                  <1> 	push	eax ; 01/05/2016
 12607 00011663 3B15[88030300]      <1> 	cmp     edx, [u.count] 
 12608 00011669 7306                <1> 	jnb	short dskr_1
 12609 0001166B 8915[88030300]      <1> 	mov	[u.count], edx
 12610                              <1> dskr_1:
 12611                              <1> 	; EAX = First Cluster
 12612                              <1> 	; [Current_Drv] = Physical drive number 
 12613 00011671 E83B000000          <1> 	call	mget_r
 12614                              <1> 	; NOTE: in 'mget_r', relevant sector will be read in buffer
 12615                              <1> 	; if it is not already in buffer !
 12616 00011676 BB[8C050300]        <1> 	mov	ebx, readi_buffer
 12617 0001167B 803D[C6030300]00    <1> 	cmp	byte [u.kcall], 0 ; the caller is 'namei' sign (=1)
 12618 00011682 770F                <1> 	ja	short dskr_3	  ; zf=0 -> the caller is 'namei'
 12619 00011684 66833D[C4030300]00  <1> 	cmp	word [u.pcount], 0
 12620 0001168C 7705                <1> 	ja	short dskr_3
 12621                              <1> dskr_2:
 12622                              <1> 	; [u.base] = virtual address to transfer (as destination address)
 12623 0001168E E894010000          <1> 	call	trans_addr_w ; translate virtual address to physical (w)
 12624                              <1> dskr_3:
 12625                              <1> 	; EBX (r5) = system (I/O) buffer address -physical-
 12626 00011693 E8F7010000          <1> 	call	sioreg
 12627 00011698 87F7                <1> 	xchg	esi, edi
 12628                              <1> 	; EDI = file (user data) offset
 12629                              <1> 	; ESI = sector (I/O) buffer offset
 12630                              <1> 	; ECX = byte count
 12631 0001169A F3A4                <1> 	rep	movsb
 12632                              <1> 	; eax = remain bytes in buffer
 12633                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 12634 0001169C 09C0                <1> 	or	eax, eax
 12635 0001169E 75EE                <1> 	jnz	short dskr_2 ; (page end before system buffer end!)		
 12636 000116A0 58                  <1> 	pop	eax  ; (first cluster number)
 12637 000116A1 390D[88030300]      <1> 	cmp	[u.count], ecx ; 0
 12638 000116A7 77A9                <1> 	ja	short dskr_0
 12639                              <1> dskr_4:
 12640 000116A9 C605[C6030300]00    <1> 	mov	byte [u.kcall], 0
 12641 000116B0 C3                  <1> 	retn
 12642                              <1> 
 12643                              <1> mget_r:
 12644                              <1> 	; 24/10/2016
 12645                              <1> 	; 22/10/2016
 12646                              <1> 	; 12/10/2016
 12647                              <1> 	; 29/04/2016
 12648                              <1> 	; 25/04/2016 - TRDOS 386 (TRDOS v2.0)
 12649                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 12650                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 12651                              <1> 	;
 12652                              <1> 	; Get existing or (allocate) a new disk block for file
 12653                              <1> 	; 
 12654                              <1> 	; INPUTS ->
 12655                              <1> 	;    [u.fofp] = file offset pointer
 12656                              <1> 	;    EAX = First Cluster
 12657                              <1> 	;    [cdev] = Logical dos drive number 	  
 12658                              <1> 	;    ([u.off] = file offset)
 12659                              <1> 	; OUTPUTS ->
 12660                              <1> 	;    EAX = logical sector number
 12661                              <1> 	;    ESI = Logical Dos Drive Description Table address	
 12662                              <1> 	;
 12663                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI
 12664                              <1> 
 12665 000116B1 8B35[74030300]      <1> 	mov     esi, [u.fofp]
 12666 000116B7 8B1E                <1> 	mov	ebx, [esi] ; (u.off)
 12667                              <1> 
 12668 000116B9 29C9                <1> 	sub	ecx, ecx
 12669 000116BB 8A2D[46030300]      <1> 	mov	ch, [cdev]
 12670                              <1> 
 12671 000116C1 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 12672 000116C6 01CE                <1> 	add	esi, ecx
 12673                              <1> 
 12674 000116C8 380D[04960100]      <1> 	cmp	[readi.valid], cl ; 0
 12675 000116CE 7649                <1> 	jna	short mget_r_0
 12676                              <1> 	
 12677 000116D0 3A2D[05960100]      <1> 	cmp	ch, [readi.drv]
 12678 000116D6 7541                <1> 	jne	short mget_r_0
 12679                              <1> 
 12680 000116D8 3B05[18960100]      <1> 	cmp	eax, [readi.fclust]
 12681 000116DE 7565                <1> 	jne	short mget_r_3
 12682                              <1> 	
 12683 000116E0 89D8                <1> 	mov	eax, ebx ; file offset
 12684 000116E2 668B0D[0C960100]    <1> 	mov	cx, [readi.bpc]
 12685 000116E9 41                  <1> 	inc	ecx ; <= 65536
 12686 000116EA 29D2                <1> 	sub	edx, edx
 12687 000116EC F7F1                <1> 	div	ecx
 12688                              <1> 
 12689 000116EE 8B3D[14960100]      <1> 	mov	edi, [readi.c_index] ; cluster index
 12690                              <1> 
 12691 000116F4 39F8                <1> 	cmp	eax, edi
 12692 000116F6 757A                <1>         jne     short mget_r_4  ; (*)
 12693                              <1> 
 12694                              <1> 	; edx = byte offset in cluster (<= 65535)
 12695 000116F8 668915[0E960100]    <1> 	mov	[readi.offset], dx
 12696 000116FF 66C1EA09            <1> 	shr	dx, 9 ; / 512
 12697 00011703 8815[07960100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 12698                              <1> 	
 12699 00011709 A1[10960100]        <1> 	mov	eax, [readi.cluster]  ; > 0 if [readi.valid] = 1
 12700 0001170E 8B15[1C960100]      <1> 	mov	edx, [readi.fs_index]
 12701 00011714 E99A000000          <1>         jmp     mget_r_7
 12702                              <1> 	
 12703                              <1> mget_r_0:
 12704 00011719 882D[05960100]      <1> 	mov	[readi.drv], ch ; physical drive number
 12705 0001171F 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 12706 00011723 7707                <1> 	ja	short mget_r_1
 12707 00011725 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 12708 00011728 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 12709 0001172A EB03                <1> 	jmp	short mget_r_2	
 12710                              <1> mget_r_1:
 12711 0001172C 8A4E13              <1> 	mov	cl, [esi+LD_BPB+BPB_SecPerClust]
 12712                              <1> mget_r_2:
 12713 0001172F 880D[06960100]      <1> 	mov	[readi.spc], cl  ; sectors per cluster
 12714                              <1> 	; NOTE: readi bytes per sector value is always 512 ! 
 12715 00011735 66C1E109            <1> 	shl	cx, 9 ; * 512
 12716 00011739 6649                <1> 	dec	cx ; bytes per cluster - 1
 12717 0001173B 66890D[0C960100]    <1> 	mov	[readi.bpc], cx
 12718 00011742 6629C9              <1> 	sub	cx, cx
 12719                              <1> mget_r_3:
 12720 00011745 A3[18960100]        <1> 	mov	[readi.fclust], eax ; first cluster (or FDT address)
 12721 0001174A 880D[04960100]      <1> 	mov	[readi.valid], cl ; 0 
 12722                              <1> 	;mov	[readi.s_index], cl ; 0
 12723                              <1> 	;mov	[readi.offset], cx ; 0
 12724 00011750 890D[14960100]      <1> 	mov	[readi.c_index], ecx ; 0
 12725 00011756 890D[10960100]      <1> 	mov	[readi.cluster], ecx ; 0
 12726 0001175C 890D[08960100]      <1> 	mov	[readi.sector], ecx ; 0
 12727                              <1> 	
 12728 00011762 89D8                <1> 	mov	eax, ebx ; file offset
 12729 00011764 668B0D[0C960100]    <1> 	mov	cx, [readi.bpc]
 12730 0001176B 41                  <1> 	inc	ecx ; <= 65536
 12731 0001176C 29D2                <1> 	sub	edx, edx
 12732 0001176E F7F1                <1> 	div	ecx
 12733                              <1> 	;mov	edi, [readi.c_index] ; previous cluster index
 12734 00011770 29FF                <1> 	sub	edi, edi
 12735                              <1> mget_r_4:
 12736 00011772 A3[14960100]        <1> 	mov	[readi.c_index], eax ; cluster index
 12737                              <1> 	; edx = byte offset in cluster (<= 65535)
 12738 00011777 668915[0E960100]    <1> 	mov	[readi.offset], dx
 12739 0001177E 66C1EA09            <1> 	shr	dx, 9 ; / 512
 12740 00011782 8815[07960100]      <1> 	mov	[readi.s_index], dl ; sector index in cluster (0 to spc -1)
 12741                              <1> 
 12742 00011788 89C1                <1> 	mov	ecx, eax ; current cluster index
 12743 0001178A A1[18960100]        <1> 	mov	eax, [readi.fclust]
 12744 0001178F 09C9                <1> 	or	ecx, ecx ; cluster index
 12745 00011791 741B                <1> 	jz	short mget_r_6
 12746                              <1> 
 12747 00011793 39CF                <1> 	cmp	edi, ecx
 12748 00011795 7710                <1> 	ja	short mget_r_5 ; old cluster index is higher
 12749 00011797 8B15[10960100]      <1> 	mov	edx, [readi.cluster]
 12750 0001179D 21D2                <1> 	and	edx, edx
 12751 0001179F 7406                <1> 	jz	short mget_r_5
 12752                              <1> 	; valid 'readi' parameters (*)
 12753 000117A1 89D0                <1> 	mov	eax, edx
 12754 000117A3 29F9                <1> 	sub	ecx, edi
 12755 000117A5 740C                <1> 	jz	short mget_r_7
 12756                              <1> mget_r_5:
 12757                              <1> 	; EAX = Beginning cluster
 12758                              <1> 	; EDX = Sector index in disk/file section
 12759                              <1> 	;	(Only for SINGLIX file system!)
 12760                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 12761                              <1> 	; ESI = Logical DOS Drive Description Table address
 12762 000117A7 E8C9BFFFFF          <1> 	call	get_cluster_by_index
 12763 000117AC 724E                <1> 	jc	short mget_r_err
 12764                              <1> 	; EAX = Cluster number		
 12765                              <1> mget_r_6:
 12766 000117AE A3[10960100]        <1> 	mov	[readi.cluster], eax ; FDT number for Singlix File System
 12767                              <1> mget_r_7:
 12768 000117B3 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 12769 000117B7 765F                <1> 	jna	short mget_r_12
 12770                              <1> 
 12771 000117B9 83E802              <1> 	sub	eax, 2
 12772 000117BC 0FB615[06960100]    <1> 	movzx	edx, byte [readi.spc]
 12773 000117C3 F7E2                <1> 	mul	edx
 12774                              <1> 
 12775 000117C5 034668              <1> 	add	eax, [esi+LD_DATABegin]
 12776 000117C8 8A15[07960100]      <1> 	mov	dl, [readi.s_index]
 12777 000117CE 01D0                <1> 	add	eax, edx
 12778                              <1> mget_r_8:
 12779                              <1> 	; eax = logical sector number
 12780 000117D0 803D[04960100]00    <1> 	cmp	byte [readi.valid], 0
 12781 000117D7 7608                <1> 	jna	short mget_r_9
 12782 000117D9 3B05[08960100]      <1> 	cmp	eax, [readi.sector]
 12783 000117DF 7436                <1> 	je	short mget_r_11 ; sector is already in 'readi' buffer
 12784                              <1> mget_r_9:
 12785 000117E1 A3[08960100]        <1> 	mov	[readi.sector], eax
 12786 000117E6 BB[8C050300]        <1> 	mov	ebx, readi_buffer ; buffer address
 12787 000117EB B901000000          <1> 	mov	ecx, 1
 12788                              <1> 	; 29/04/2016
 12789                              <1> 	;xor	dl, dl
 12790                              <1> 
 12791                              <1> 	; EAX = Logical sector number
 12792                              <1> 	; ECX = Sector count
 12793                              <1> 	; EBX = Buffer address
 12794                              <1> 	; (EDX = 0)
 12795                              <1> 	; ESI = Logical DOS drive description table address	
 12796                              <1> 
 12797 000117F0 E868130000          <1> 	call	disk_read
 12798 000117F5 7314                <1> 	jnc	short mget_r_10
 12799                              <1> 
 12800                              <1> 	; 22/10/2016 (15h -> 17)
 12801 000117F7 B811000000          <1> 	mov	eax, 17 ; Drive not ready or read error !
 12802                              <1> mget_r_err:
 12803 000117FC A3[C8030300]        <1> 	mov	[u.error], eax
 12804                              <1> 	; 12/10/2016
 12805 00011801 A3[64030300]        <1> 	mov	[u.r0], eax
 12806 00011806 E9D1C0FFFF          <1> 	jmp	error
 12807                              <1> mget_r_10:
 12808 0001180B C605[04960100]01    <1> 	mov	byte [readi.valid], 1 ; 24/10/2016
 12809 00011812 A1[08960100]        <1> 	mov	eax, [readi.sector]
 12810                              <1> mget_r_11:
 12811 00011817 C3                  <1> 	retn
 12812                              <1> mget_r_12:
 12813                              <1> 	; EAX = FDT number
 12814                              <1> 	; EDX = Sector index from FDT sector (0,1,2,3,4...)
 12815 00011818 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 12816 00011819 8915[1C960100]      <1> 	mov	[readi.fs_index], edx
 12817 0001181F 01D0                <1> 	add	eax, edx
 12818 00011821 EBAD                <1> 	jmp	short mget_r_8
 12819                              <1> 
 12820                              <1> trans_addr_r:
 12821                              <1> 	; 12/10/2016
 12822                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 12823                              <1> 	; Translate virtual address to physical address 
 12824                              <1> 	; for reading from user's memory space
 12825                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 12826                              <1> 
 12827 00011823 31D2                <1> 	xor	edx, edx ; 0 (read access sign)
 12828 00011825 EB04                <1> 	jmp 	short trans_addr_rw
 12829                              <1> 
 12830                              <1> trans_addr_w:
 12831                              <1> 	; 12/10/2016
 12832                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 12833                              <1> 	; Translate virtual address to physical address 
 12834                              <1> 	; for writing to user's memory space
 12835                              <1> 	; 04/06/2015 - 18/10/2015 (Retro UNIX 386 v1)
 12836                              <1> 	
 12837 00011827 29D2                <1> 	sub	edx, edx
 12838 00011829 FEC2                <1> 	inc	dl ; 1 (write access sign)
 12839                              <1> trans_addr_rw:
 12840 0001182B 50                  <1> 	push	eax
 12841 0001182C 53                  <1> 	push	ebx
 12842 0001182D 52                  <1> 	push 	edx ; r/w sign (in DL)
 12843                              <1> 	;
 12844 0001182E 8B1D[84030300]      <1> 	mov	ebx, [u.base]
 12845 00011834 E8AF4AFFFF          <1> 	call	get_physical_addr ; get physical address
 12846 00011839 730F                <1> 	jnc	short passc_0
 12847 0001183B A3[C8030300]        <1> 	mov	[u.error], eax
 12848 00011840 A3[64030300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 12849                              <1> 	;pop	edx
 12850                              <1> 	;pop 	ebx
 12851                              <1> 	;pop	eax
 12852 00011845 E992C0FFFF          <1> 	jmp	error
 12853                              <1> passc_0:
 12854 0001184A F6C202              <1> 	test	dl, PTE_A_WRITE ; writable page
 12855 0001184D 5A                  <1> 	pop	edx
 12856 0001184E 751C                <1> 	jnz	short passc_1
 12857                              <1> 	
 12858 00011850 20D2                <1> 	and 	dl, dl
 12859 00011852 7418                <1> 	jz	short passc_1
 12860                              <1> 	; read only (duplicated) page -must be copied to a new page-
 12861                              <1> 	; EBX = linear address
 12862 00011854 51                  <1> 	push 	ecx
 12863 00011855 E82747FFFF          <1> 	call 	copy_page
 12864 0001185A 59                  <1> 	pop	ecx
 12865 0001185B 721E                <1> 	jc	short passc_2
 12866 0001185D 50                  <1> 	push	eax ; physical address of the new/allocated page
 12867 0001185E E8AF49FFFF          <1> 	call	add_to_swap_queue	
 12868 00011863 58                  <1> 	pop	eax
 12869 00011864 81E3FF0F0000        <1> 	and 	ebx, PAGE_OFF ; 0FFFh
 12870                              <1> 	;mov 	ecx, PAGE_SIZE
 12871                              <1> 	;sub	ecx, ebx 
 12872 0001186A 01D8                <1> 	add	eax, ebx  
 12873                              <1> passc_1: 
 12874 0001186C A3[C0030300]        <1> 	mov 	[u.pbase], eax ; physical address	
 12875 00011871 66890D[C4030300]    <1> 	mov	[u.pcount], cx ; remain byte count in page (1-4096)
 12876 00011878 5B                  <1> 	pop	ebx
 12877 00011879 58                  <1> 	pop	eax
 12878 0001187A C3                  <1> 	retn
 12879                              <1> passc_2:
 12880 0001187B B804000000          <1> 	mov	eax, ERR_MINOR_IM ; "Insufficient memory !" error
 12881 00011880 A3[64030300]        <1> 	mov	[u.r0], eax ; 12/10/2016
 12882 00011885 A3[C8030300]        <1> 	mov	dword [u.error], eax
 12883                              <1> 	;pop 	ebx
 12884                              <1> 	;pop	eax
 12885 0001188A E94DC0FFFF          <1> 	jmp	error
 12886                              <1> 
 12887                              <1> sioreg: 
 12888                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 12889                              <1> 	; 19/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 12890                              <1> 	; 12/03/2013 - 22/07/2013 (Retro UNIX 8086 v1)
 12891                              <1> 	; INPUTS -> 
 12892                              <1> 	;     EBX = system buffer (data) address (r5)
 12893                              <1> 	;     [u.fofp] = pointer to file offset pointer
 12894                              <1> 	;     [u.base] = virtual address of the user buffer
 12895                              <1> 	;     [u.pbase] = physical address of the user buffer
 12896                              <1> 	;     [u.count] = byte count
 12897                              <1> 	;     [u.pcount] = byte count within page frame 			
 12898                              <1> 	; OUTPUTS -> 
 12899                              <1> 	;     ESI = user data offset (r1)
 12900                              <1> 	;     EDI = system (I/O) buffer offset (r2)
 12901                              <1> 	;     ECX = byte count (r3)
 12902                              <1> 	;     EAX = remain bytes after byte count within page frame
 12903                              <1> 	;	(If EAX > 0, transfer will continue from the next page)
 12904                              <1>         ;
 12905                              <1> 	; ((Modified registers:  EDX))
 12906                              <1>  
 12907 0001188F 8B35[74030300]      <1>         mov     esi, [u.fofp]
 12908 00011895 8B3E                <1>         mov     edi, [esi]
 12909 00011897 89F9                <1> 	mov	ecx, edi
 12910 00011899 81C900FEFFFF        <1> 	or	ecx, 0FFFFFE00h
 12911 0001189F 81E7FF010000        <1> 	and	edi, 1FFh
 12912 000118A5 01DF                <1> 	add	edi, ebx ; EBX = system buffer (data) address
 12913 000118A7 F7D9                <1> 	neg	ecx
 12914 000118A9 3B0D[88030300]      <1> 	cmp	ecx, [u.count]
 12915 000118AF 7606                <1> 	jna	short sioreg_0
 12916 000118B1 8B0D[88030300]      <1> 	mov	ecx, [u.count]
 12917                              <1> sioreg_0:
 12918 000118B7 803D[C6030300]00    <1> 	cmp	byte [u.kcall], 0 
 12919 000118BE 7613                <1> 	jna	short sioreg_1
 12920                              <1> 	 ; the caller is 'mkdir' or 'namei'
 12921 000118C0 A1[84030300]        <1> 	mov	eax, [u.base]
 12922 000118C5 A3[C0030300]        <1> 	mov 	[u.pbase], eax ; physical address = virtual address
 12923 000118CA 66890D[C4030300]    <1> 	mov	word [u.pcount], cx ; remain bytes in buffer (1 sector)
 12924 000118D1 EB0B                <1> 	jmp	short sioreg_2
 12925                              <1> sioreg_1:
 12926 000118D3 0FB715[C4030300]    <1> 	movzx	edx, word [u.pcount]
 12927 000118DA 39D1                <1> 	cmp	ecx, edx	
 12928 000118DC 772A                <1> 	ja	short sioreg_4 ; transfer count > [u.pcount]
 12929                              <1> sioreg_2: ; 2:
 12930 000118DE 31C0                <1> 	xor 	eax, eax
 12931                              <1> sioreg_3:
 12932 000118E0 010D[8C030300]      <1> 	add 	[u.nread], ecx
 12933 000118E6 290D[88030300]      <1> 	sub 	[u.count], ecx
 12934 000118EC 010D[84030300]      <1> 	add 	[u.base], ecx
 12935 000118F2 010E                <1>         add 	[esi], ecx 
 12936 000118F4 8B35[C0030300]      <1> 	mov	esi, [u.pbase]
 12937 000118FA 66290D[C4030300]    <1> 	sub	[u.pcount], cx
 12938 00011901 010D[C0030300]      <1> 	add	[u.pbase], ecx
 12939 00011907 C3                  <1>         retn
 12940                              <1> sioreg_4:
 12941                              <1> 	; transfer count > [u.pcount] 
 12942                              <1> 	; (ecx > edx)
 12943 00011908 89C8                <1> 	mov	eax, ecx
 12944 0001190A 29D0                <1> 	sub	eax, edx ; remain bytes for 1 sector (block) transfer 
 12945 0001190C 89D1                <1> 	mov	ecx, edx ; current transfer count = [u.pcount]
 12946 0001190E EBD0                <1> 	jmp	short sioreg_3
 12947                              <1> 
 12948                              <1> tswitch: ; Retro UNIX 386 v1
 12949                              <1> tswap:
 12950                              <1> 	; 16/01/2017
 12951                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0)
 12952                              <1> 	; 10/05/2015 - 01/09/2015 (Retro UNIX 386 v1)
 12953                              <1> 	; 14/04/2013 - 14/02/2014 (Retro UNIX 8086 v1)
 12954                              <1> 	; time out swap, called when a user times out.
 12955                              <1> 	; the user is put on the low priority queue.
 12956                              <1> 	; This is done by making a link from the last user
 12957                              <1> 	; on the low priority queue to him via a call to 'putlu'.
 12958                              <1> 	; then he is swapped out.
 12959                              <1> 
 12960                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 21/05/2016 **
 12961                              <1> 	;     * when a high priority (event) process will be stopped
 12962                              <1> 	;	(swapped out, swithched out/off), 'tswap/tswitch' will
 12963                              <1> 	;	not add it to a run queue. 
 12964                              <1> 	;	/// What for: Process may be already in a run queue, 
 12965                              <1> 	;	it is unspeficied state because process might be started
 12966                              <1> 	;	by a timer event which does not regard previous priority
 12967                              <1> 	;	level and run queue of the process (for fast executing!).
 12968                              <1> 	;	After the 'run for event', process will be sequenced
 12969                              <1> 	;	to run by it's actual run queue. ///
 12970                              <1> 	;
 12971                              <1> 	; Retro UNIX 386 v1 modification ->
 12972                              <1> 	;       swap (software task switch) is performed by changing
 12973                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 12974                              <1> 	;	as in Retro UNIX 8086 v1.
 12975                              <1> 	;
 12976                              <1> 	; RETRO UNIX 8086 v1 modification ->
 12977                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 12978                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 12979                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 12980                              <1> 	;	compatibles was using 1MB segmented memory 
 12981                              <1> 	;	in 8086/8088 times.
 12982                              <1> 	;
 12983                              <1> 	; INPUTS ->
 12984                              <1> 	;    u.uno - users process number
 12985                              <1> 	;    runq+4 - lowest priority queue
 12986                              <1> 	; OUTPUTS ->
 12987                              <1> 	;    r0 - users process number
 12988                              <1> 	;    r2 - lowest priority queue address
 12989                              <1> 	;
 12990                              <1> 	; ((AX = R0, BX = R2)) output
 12991                              <1> 	; ((Modified registers: EDX, EBX, ECX, ESI, EDI))  	
 12992                              <1> 	;
 12993                              <1> 
 12994                              <1> 	NOTE:
 12995                              <1> 	;* [u.pri] priority level is specified by run queue which is process 
 12996                              <1> 	;  comes to run from.
 12997                              <1> 	;* Initial [u.pri] is 1 ('normal/regular') for programs 
 12998                              <1> 	;  (which are launched by MainProg or 'sysexec'), it is changed
 12999                              <1> 	;  to 2 ('high') by timer event, if program uses 'systimer' system call.
 13000                              <1> 	;* Program (Process) also can change it's running priority 
 13001                              <1> 	;  from 1 to 0 or up to 2 by using 'syspri' system call; but,
 13002                              <1> 	;  if program selects priority level 2 (high) for running, next time 
 13003                              <1> 	;  it is reduced to 1 (normal/regular) because 'syspri' adds this
 13004                              <1> 	;  program to 'run for normal' queue while running duration is a bit
 13005                              <1> 	;  protected from swap/switch out immediate, behalf of other high 
 13006                              <1> 	;  priority process in sequence. Program (with high priority) will not 
 13007                              <1> 	;  be swapped/switched out (by timer event) before it's time quantum 
 13008                              <1> 	;  will be elapsed, but, this will be temporary if program is not using 
 13009                              <1> 	;  timer event function.	  			 	
 13010                              <1> 
 13011                              <1> 	;For example:
 13012                              <1> 	;If a process frequently gets a timer event, it runs at high priority
 13013                              <1> 	;level but when it returns from running it returns to actual run queue,
 13014                              <1> 	;not to 'run for event' queue again.
 13015                              <1> 	;'tswap' will not change the sequence at return/stop(swap out) stage.
 13016                              <1> 	;But if priority level not high (=2, 'run for event'), 'tswap/tswitch'
 13017                              <1> 	;will add the stopping process to relevant run queue according to
 13018                              <1> 	;[u.pri] priority level.
 13019                              <1> 
 13020                              <1> 	; 16/01/2017
 13021 00011910 BB[54030300]        <1> 	mov	ebx, runq+2 	; 'runq_normal' ; normal/regular priority
 13022                              <1> 	; 21/05/2016
 13023                              <1> 	;cmp	byte [u.pri], 2	; high priority (run for event) ?
 13024                              <1> 	;jnb	short swap
 13025                              <1> 	; 16/01/2017
 13026                              <1> 	; (Normal and also high/event priority processes will be added to
 13027                              <1> 	; normal priority run queue for ensuring circular running sequence!)
 13028                              <1> 	; (Timer interrupt or 'syspri' system call may change priority and run
 13029                              <1> 	; queue to high/event level.)
 13030 00011915 803D[A9030300]00    <1> 	cmp	byte [u.pri], 0
 13031 0001191C 7702                <1> 	ja	short tswap_1	; normal priority run queue
 13032                              <1> 	;
 13033 0001191E 43                  <1> 	inc	ebx
 13034 0001191F 43                  <1> 	inc	ebx		; runq+4, 'runq_background', low priority
 13035                              <1> tswap_1:
 13036 00011920 A0[B3030300]        <1> 	mov 	al, [u.uno]
 13037                              <1> 	       	; movb u.uno,r1 / move users process number to r1
 13038                              <1> 		; mov  $runq+4,r2 
 13039                              <1> 			; / move lowest priority queue address to r2
 13040                              <1>       	; ebx = run queue
 13041 00011925 E8FE000000          <1> 	call 	putlu
 13042                              <1> 		; jsr r0,putlu / create link from last user on Q to 
 13043                              <1> 		             ; / u.uno's user
 13044                              <1> 
 13045                              <1> switch: ; Retro UNIX 386 v1
 13046                              <1> swap:
 13047                              <1> 	; 02/01/2017
 13048                              <1> 	; 21/05/2016
 13049                              <1> 	; 20/05/2016
 13050                              <1> 	; 02/05/2016
 13051                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13052                              <1> 	; 10/05/2015 - 02/09/2015 (Retro UNIX 386 v1)
 13053                              <1> 	; 14/04/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 13054                              <1> 	;
 13055                              <1> 	; 'swap' is routine that controls the swapping of processes
 13056                              <1> 	; in and out of core.
 13057                              <1> 	;
 13058                              <1> 	; TRDOS 386 (TRDOS v2.0) modification ->  ** 20/05/2016 **
 13059                              <1> 	;     * 3 different priority level is applied 
 13060                              <1> 	;	(just as original unix v1)
 13061                              <1> 	;	1) high priority (event) run queue, 'runq_event'
 13062                              <1> 	;	2) normal priority (regular) run queue, 'runq_normal'
 13063                              <1> 	;	3) low priority (background) run queue, 'runq_backgroud'
 13064                              <1> 	;	'swap' code will run a process which has max. priority
 13065                              <1>         ;       (for earliest event at first)
 13066                              <1> 	;
 13067                              <1> 	; Retro UNIX 386 v1 modification ->
 13068                              <1> 	;       swap (software task switch) is performed by changing
 13069                              <1> 	;	user's page directory (u.pgdir) instead of segment change
 13070                              <1> 	;	as in Retro UNIX 8086 v1.
 13071                              <1> 	;
 13072                              <1> 	; RETRO UNIX 8086 v1 modification ->
 13073                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13074                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13075                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13076                              <1> 	;	compatibles was using 1MB segmented memory 
 13077                              <1> 	;	in 8086/8088 times.
 13078                              <1> 	;
 13079                              <1> 	; INPUTS ->
 13080                              <1> 	;    runq table - contains processes to run.
 13081                              <1> 	;    p.link - contains next process in line to be run.
 13082                              <1> 	;    u.uno - process number of process in core	
 13083                              <1> 	;    s.stack - swap stack used as an internal stack for swapping.	
 13084                              <1> 	; OUTPUTS ->
 13085                              <1> 	;    (original unix v1 -> present process to its disk block)
 13086                              <1> 	;    (original unix v1 -> new process into core -> 
 13087                              <1> 	;	   Retro Unix 8086 v1 -> segment registers changed 
 13088                              <1> 	;	   for new process)
 13089                              <1> 	;    u.quant = 3 (Time quantum for a process)
 13090                              <1> 	; 	((INT 1Ch count down speed -> 18.2 times per second)	 	
 13091                              <1> 	;    RETRO UNIX 8086 v1 will use INT 1Ch (18.2 times per second)
 13092                              <1> 	;	 for now, it will swap the process if there is not
 13093                              <1> 	;	 a keyboard event (keystroke) (Int 15h, function 4Fh)
 13094                              <1> 	;	 or will count down from 3 to 0 even if there is a
 13095                              <1> 	;        keyboard event locking due to repetitive key strokes.
 13096                              <1> 	;	 u.quant will be reset to 3 for RETRO UNIX 8086 v1.
 13097                              <1> 	;
 13098                              <1> 	; ((Modified registers: EAX, EDX, EBX, ECX, ESI, EDI))  	
 13099                              <1> 
 13100                              <1> 	;NOTE:
 13101                              <1> 	;High priority queue is the first for selecting a process to run.
 13102                              <1> 	;If there is not a process in high priority level run queue,
 13103                              <1> 	;a process in normal priority run queue will be selected
 13104                              <1> 	;or a proces in low priority run queue will be selected if normal
 13105                              <1> 	;priority level run queue is empty.
 13106                              <1> 	
 13107                              <1> 	; 21/05/2016 -(3 priority levels, 3 run queues)
 13108 0001192A BE[52030300]        <1> 	mov	esi, runq ; 'runq_event' ; high priority, 'run for event'
 13109 0001192F C605[60960100]03    <1> 	mov	byte [priority], 3 ; high priority + 1
 13110 00011936 31DB                <1> 	xor	ebx, ebx ; 02/01/2017
 13111                              <1> swap_0: ; 1: / search runq table for highest priority process
 13112 00011938 66AD                <1> 	lodsw  ; mov ax, [esi], add esi+2
 13113                              <1> 	;xor	ebx, ebx ; 02/05/2016
 13114 0001193A 6621C0              <1> 	and 	ax, ax ; are there any processes to run in this Q entry
 13115 0001193D 750E                <1> 	jnz	short swap_2 
 13116                              <1> 	; 21/05/2026
 13117                              <1> 	; runq_normal = runq+2, runq_background = runq+4
 13118 0001193F FE0D[60960100]      <1> 	dec	byte [priority] ; 3 -> 3, 2 -> 1, 1-> 0
 13119 00011945 75F1                <1> 	jnz	short swap_0	
 13120                              <1> 	;cmp	esi, runq+6  ; if zero compare address to end of table
 13121                              <1> 	;jb	short swap_0 ; if not at end, go back
 13122                              <1> swap_1:
 13123                              <1> 	; 02/05/2016
 13124                              <1> 	; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
 13125                              <1> 	; No user process to run...
 13126                              <1> 	; Run the kernel process... MainProg: Internal Command Interpreter  
 13127 00011947 FEC0                <1> 	inc	al ; mov al, 1  ; process number of MainProg
 13128 00011949 FEC3                <1> 	inc	bl ; mov bl, al ; 1
 13129 0001194B EB1E                <1> 	jmp	short swap_4
 13130                              <1> swap_2:
 13131                              <1> 	; 21/05/2016
 13132 0001194D FE0D[60960100]      <1> 	dec	byte [priority] ; priority level of present user/process
 13133                              <1> 			        ; 0, 1, 2	   
 13134 00011953 4E                  <1> 	dec	esi
 13135 00011954 4E                  <1>         dec     esi
 13136                              <1> 	;
 13137 00011955 88C3                <1> 	mov	bl, al
 13138 00011957 38E0                <1> 	cmp	al, ah ; is there only 1 process in the queue to be run
 13139 00011959 740A                <1> 	je	short swap_3 ; yes
 13140 0001195B 8AA3[9F000300]      <1> 	mov	ah, [ebx+p.link-1] 
 13141 00011961 8826                <1>        	mov	[esi], ah ; move next process in line into run queue
 13142 00011963 EB06                <1> 	jmp	short swap_4
 13143                              <1> swap_3: 
 13144 00011965 6631D2              <1> 	xor	dx, dx
 13145 00011968 668916              <1> 	mov	[esi], dx ; zero the entry; no processes on the Q
 13146                              <1> swap_4: 
 13147 0001196B 8A25[B3030300]      <1> 	mov 	ah, [u.uno]
 13148 00011971 38C4                <1> 	cmp	ah, al ; is this process the same as the process in core?
 13149 00011973 743B                <1>        	je	short swap_8 ; yes, don't have to swap
 13150 00011975 08E4                <1> 	or	ah, ah  ; is the process # = 0
 13151 00011977 740D                <1>        	jz	short swap_6 ; 'sysexit'
 13152                              <1> 	;cmp	ah, al ;is this process the same as the process in core?
 13153                              <1>        	;je	short swap_8 ; yes, don't have to swap
 13154 00011979 8925[60030300]      <1> 	mov	[u.usp], esp ; return  address for 'syswait' & 'sleep'
 13155 0001197F E834000000          <1> 	call	wswap   ; write out core to disk
 13156 00011984 EB1C                <1> 	jmp 	short swap_7
 13157                              <1> swap_6:
 13158                              <1> 	; Deallocate memory pages belong to the process
 13159                              <1> 	; which is being terminated.
 13160                              <1> 	; (Retro UNIX 386 v1 modification !)
 13161                              <1> 	;
 13162 00011986 53                  <1> 	push	ebx
 13163 00011987 A1[B8030300]        <1> 	mov 	eax, [u.pgdir]  ; page directory of the process
 13164 0001198C 8B1D[BC030300]      <1> 	mov	ebx, [u.ppgdir] ; page directory of the parent process
 13165 00011992 E87543FFFF          <1> 	call	deallocate_page_dir
 13166 00011997 A1[B4030300]        <1> 	mov	eax, [u.upage] ; 'user' structure page of the process
 13167 0001199C E81044FFFF          <1> 	call	deallocate_page
 13168 000119A1 5B                  <1> 	pop	ebx
 13169                              <1> swap_7: 
 13170 000119A2 C0E302              <1> 	shl	bl, 2 ; * 4 
 13171 000119A5 8B83[BC000300]      <1> 	mov	eax, [ebx+p.upage-4] ; the 'u' page of the new process
 13172 000119AB E840000000          <1> 	call	rswap ; read new process into core
 13173                              <1> swap_8: 
 13174                              <1> 	; Retro UNIX  8086 v1 modification !
 13175 000119B0 C605[A8030300]04    <1> 	mov	byte [u.quant], time_count 
 13176 000119B7 C3                  <1> 	retn
 13177                              <1> 
 13178                              <1> wswap:  ; < swap out, swap to disk >
 13179                              <1> 	; 28/02/2017 (fnsave)
 13180                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13181                              <1> 	; 09/05/2015 (Retro UNIX 386 v1)
 13182                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 13183                              <1> 	; 'wswap' writes out the process that is in core onto its 
 13184                              <1> 	; appropriate disk area.
 13185                              <1> 	;
 13186                              <1> 	; Retro UNIX 386 v1 modification ->
 13187                              <1> 	;       User (u) structure content and the user's register content
 13188                              <1> 	;	will be copied to the process's/user's UPAGE (a page for
 13189                              <1> 	;	saving 'u' structure and user registers for task switching).
 13190                              <1> 	;	u.usp - points to kernel stack address which contains
 13191                              <1> 	;		user's registers while entering system call.  
 13192                              <1> 	;	u.sp  - points to kernel stack address 
 13193                              <1> 	;		to return from system call -for IRET-.
 13194                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 13195                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 13196                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 13197                              <1> 	;
 13198                              <1> 	; Retro UNIX 8086 v1 modification ->
 13199                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13200                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13201                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13202                              <1> 	;	compatibles was using 1MB segmented memory 
 13203                              <1> 	;	in 8086/8088 times.
 13204                              <1> 	;
 13205                              <1> 	; INPUTS ->
 13206                              <1> 	;    u.break - points to end of program
 13207                              <1> 	;    u.usp - stack pointer at the moment of swap
 13208                              <1> 	;    core - beginning of process program		
 13209                              <1> 	;    ecore - end of core 	
 13210                              <1> 	;    user - start of user parameter area		
 13211                              <1> 	;    u.uno - user process number	
 13212                              <1> 	;    p.dska - holds block number of process	
 13213                              <1> 	; OUTPUTS ->
 13214                              <1> 	;    swp I/O queue
 13215                              <1> 	;    p.break - negative word count of process 
 13216                              <1> 	;    r1 - process disk address	
 13217                              <1> 	;    r2 - negative word count
 13218                              <1> 	;
 13219                              <1> 	; RETRO UNIX 8086 v1 input/output:
 13220                              <1> 	;
 13221                              <1> 	; INPUTS ->
 13222                              <1> 	;    u.uno - process number (to be swapped out)
 13223                              <1> 	; OUTPUTS ->
 13224                              <1> 	;    none
 13225                              <1> 	;
 13226                              <1> 	;   ((Modified registers: ECX, ESI, EDI))  
 13227                              <1> 	;
 13228                              <1> 
 13229                              <1> 	; 28/02/2017
 13230                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 13231                              <1> 	;jna	short wswp
 13232 000119B8 803D[DA030300]00    <1> 	cmp	byte [u.fpsave], 0 ; 28/02/2017
 13233 000119BF 7606                <1> 	jna	short wswp
 13234 000119C1 DD35[DC030300]      <1> 	fnsave	[u.fpregs] ; save floating point registers (94 bytes)
 13235                              <1> wswp:
 13236 000119C7 8B3D[B4030300]      <1> 	mov	edi, [u.upage] ; process's user (u) structure page addr
 13237 000119CD B938000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 13238 000119D2 BE[5C030300]        <1> 	mov	esi, user ; active user (u) structure	
 13239 000119D7 F3A5                <1> 	rep	movsd
 13240                              <1> 	;
 13241 000119D9 8B35[60030300]      <1> 	mov	esi, [u.usp] ; esp (system stack pointer, 
 13242                              <1> 			     ;      points to user registers)
 13243 000119DF 8B0D[5C030300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 13244                              <1> 			     ; (for IRET)
 13245                              <1> 			     ; [u.sp] -> EIP (user)
 13246                              <1> 			     ; [u.sp+4]-> CS (user)
 13247                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 13248                              <1> 			     ; [u.sp+12] -> ESP (user)
 13249                              <1> 			     ; [u.sp+16] -> SS (user)	
 13250 000119E5 29F1                <1> 	sub	ecx, esi     ; required space for user registers
 13251 000119E7 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 13252                              <1> 			     ; (for IRET) 	
 13253 000119EA C1E902              <1> 	shr	ecx, 2	     		
 13254 000119ED F3A5                <1> 	rep	movsd
 13255 000119EF C3                  <1> 	retn
 13256                              <1> 
 13257                              <1> rswap:  ; < swap in, swap from disk >
 13258                              <1> 	; 28/02/2017 (frstor)
 13259                              <1> 	; 15/01/2017
 13260                              <1> 	; 14/01/2017
 13261                              <1> 	; 21/05/2016
 13262                              <1> 	; 03/05/2016
 13263                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13264                              <1> 	; 09/05/2015 - 15/09/2015 (Retro UNIX 386 v1)
 13265                              <1> 	; 26/05/2013 - 08/03/2014 (Retro UNIX 8086 v1)
 13266                              <1> 	; 'rswap' reads a process whose number is in r1, 
 13267                              <1> 	; from disk into core.
 13268                              <1> 	;
 13269                              <1> 	; Retro UNIX 386 v1 modification ->
 13270                              <1> 	;       User (u) structure content and the user's register content
 13271                              <1> 	;	will be restored from process's/user's UPAGE (a page for
 13272                              <1> 	;	saving 'u' structure and user registers for task switching).
 13273                              <1> 	;	u.usp - points to kernel stack address which contains
 13274                              <1> 	;		user's registers while entering system call.  
 13275                              <1> 	;	u.sp  - points to kernel stack address 
 13276                              <1> 	;		to return from system call -for IRET-.
 13277                              <1> 	;	[u.usp]+32+16 = [u.sp] 
 13278                              <1> 	;	[u.usp] -> edi, esi, ebp, esp (= [u.usp]+32), ebx, 
 13279                              <1> 	;		edx, ecx, eax, gs, fs, es, ds, -> [u.sp].
 13280                              <1> 	;
 13281                              <1> 	; RETRO UNIX 8086 v1 modification ->
 13282                              <1> 	;       'swap to disk' is replaced with 'change running segment'
 13283                              <1> 	;	according to 8086 cpu (x86 real mode) architecture.
 13284                              <1> 	;	pdp-11 was using 64KB uniform memory while IBM PC
 13285                              <1> 	;	compatibles was using 1MB segmented memory 
 13286                              <1> 	;	in 8086/8088 times.
 13287                              <1> 	;
 13288                              <1> 	; INPUTS ->
 13289                              <1> 	;    r1 - process number of process to be read in
 13290                              <1> 	;    p.break - negative of word count of process 
 13291                              <1> 	;    p.dska - disk address of the process		
 13292                              <1> 	;    u.emt - determines handling of emt's 	
 13293                              <1> 	;    u.ilgins - determines handling of illegal instructions		
 13294                              <1> 	; OUTPUTS ->
 13295                              <1> 	;    8 = (u.ilgins)
 13296                              <1> 	;    24 = (u.emt)
 13297                              <1> 	;    swp - bit 10 is set to indicate read 
 13298                              <1> 	;		(bit 15=0 when reading is done)	
 13299                              <1> 	;    swp+2 - disk block address
 13300                              <1> 	;    swp+4 - negative word count 	
 13301                              <1> 	;      ((swp+6 - address of user structure)) 
 13302                              <1> 	;
 13303                              <1> 	; RETRO UNIX 8086 v1 input/output:
 13304                              <1> 	;
 13305                              <1> 	; INPUTS ->
 13306                              <1> 	;    AL	- new process number (to be swapped in)	 
 13307                              <1> 	; OUTPUTS ->
 13308                              <1> 	;    none
 13309                              <1> 	;
 13310                              <1> 	;   ((Modified registers: EAX, ECX, ESI, EDI, ESP)) 
 13311                              <1> 	;
 13312                              <1> 	; Retro UNIX 386 v1 - modification ! 14/05/2015
 13313 000119F0 89C6                <1> 	mov	esi, eax  ; process's user (u) structure page addr
 13314 000119F2 B938000000          <1> 	mov	ecx, (U_SIZE + 3) / 4
 13315 000119F7 BF[5C030300]        <1> 	mov	edi, user ; active user (u) structure	
 13316 000119FC F3A5                <1> 	rep	movsd
 13317 000119FE 58                  <1> 	pop	eax	; 'rswap' return address
 13318                              <1> 	; 
 13319                              <1> 	;cli
 13320 000119FF 8B3D[60030300]      <1> 	mov	edi, [u.usp] ; esp (system stack pointer, 
 13321                              <1> 			     ;     points to user registers)
 13322 00011A05 89FC                <1> 	mov	esp, edi     ; 14/01/2017
 13323 00011A07 8B0D[5C030300]      <1> 	mov	ecx, [u.sp]  ; return address from the system call
 13324                              <1> 			     ; (for IRET)
 13325                              <1> 			     ; [u.sp] -> EIP (user)
 13326                              <1> 			     ; [u.sp+4]-> CS (user)
 13327                              <1> 			     ; [u.sp+8] -> EFLAGS (user)
 13328                              <1> 			     ; [u.sp+12] -> ESP (user)
 13329                              <1> 			     ; [u.sp+16] -> SS (user)		
 13330 00011A0D 29F9                <1> 	sub	ecx, edi     ; required space for user registers
 13331 00011A0F 83C114              <1> 	add	ecx, 20	     ; +5 dwords to return from system call
 13332                              <1> 			     ; (for IRET) 	
 13333 00011A12 C1E902              <1> 	shr	ecx, 2	       		
 13334 00011A15 F3A5                <1> 	rep	movsd
 13335                              <1> 	;mov	esp, [u.usp] ; 15/09/2015
 13336                              <1> 	;sti
 13337                              <1> 	; 28/02/2017
 13338                              <1> 	;cmp	byte [multi_tasking], 0  ; Musti tasking mode ?
 13339                              <1> 	;jna	short rswp_retn
 13340 00011A17 803D[DA030300]00    <1> 	cmp	byte [u.fpsave], 0
 13341 00011A1E 7606                <1> 	jna	short rswp_retn
 13342 00011A20 DD25[DC030300]      <1> 	frstor	[u.fpregs] ; restore floating point regs (94 bytes)
 13343                              <1> rswp_retn:
 13344 00011A26 50                  <1> 	push	eax	; 'rswap' return address
 13345 00011A27 C3                  <1> 	retn
 13346                              <1> 
 13347                              <1> putlu: 
 13348                              <1> 	; 20/05/2016
 13349                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13350                              <1> 	; 10/05/2015 - 12/09/2015 (Retro UNIX 386 v1)
 13351                              <1> 	; 15/04/2013 - 23/02/2014 (Retro UNIX 8086 v1)
 13352                              <1> 	; 'putlu' is called with a process number in r1 and a pointer
 13353                              <1> 	; to lowest priority Q (runq+4) in r2. A link is created from
 13354                              <1> 	; the last process on the queue to process in r1 by putting
 13355                              <1> 	; the process number in r1 into the last process's link.
 13356                              <1> 	;
 13357                              <1> 	; INPUTS ->
 13358                              <1> 	;    r1 - user process number
 13359                              <1> 	;    r2 - points to lowest priority queue 
 13360                              <1> 	;    p.dska - disk address of the process		
 13361                              <1> 	;    u.emt - determines handling of emt's 	
 13362                              <1> 	;    u.ilgins - determines handling of illegal instructions		
 13363                              <1> 	; OUTPUTS ->
 13364                              <1> 	;    r3 - process number of last process on the queue upon
 13365                              <1> 	;	  entering putlu
 13366                              <1> 	;    p.link-1 + r3 - process number in r1
 13367                              <1> 	;    r2 - points to lowest priority queue
 13368                              <1> 	;
 13369                              <1> 	; ((Modified registers: EDX, EBX)) 
 13370                              <1> 	;
 13371                              <1> 	; / r1 = user process no.; r2 points to lowest priority queue
 13372                              <1> 
 13373                              <1> 	; EBX = r2
 13374                              <1> 	; EAX = r1 (AL=r1b)
 13375                              <1> 
 13376                              <1> 	; 20/05/2016
 13377                              <1> 	; AL = process number (1 to 16) // Retro UNIX 8086, 386 v1 // 
 13378                              <1> 	;     (max. 16 processes available for current kernel version) 
 13379                              <1> 	; EBX = run queue address ; 20/05/2016 (TRDOS 386)
 13380                              <1> 		; which is one of following addresses:
 13381                              <1> 		;  1) 'runq_event' high priority run queue	 	
 13382                              <1> 		;  2) 'runq_normal' normal/regular priority run queue
 13383                              <1> 		;  3) 'runq_background' low priority run queue
 13384                              <1> 
 13385                              <1> 	;mov	ebx, runq
 13386 00011A28 0FB613              <1> 	movzx  	edx, byte [ebx]
 13387 00011A2B 43                  <1> 	inc	ebx
 13388 00011A2C 20D2                <1> 	and	dl, dl
 13389                              <1> 		; tstb (r2)+ / is queue empty?
 13390 00011A2E 740A                <1>        	jz	short putlu_1
 13391                              <1> 		; beq 1f / yes, branch
 13392 00011A30 8A13                <1> 	mov 	dl, [ebx] ; 12/09/2015
 13393                              <1> 		; movb (r2),r3 / no, save the "last user" process number
 13394                              <1> 			     ; / in r3
 13395 00011A32 8882[9F000300]      <1>        	mov	[edx+p.link-1], al
 13396                              <1> 		; movb r1,p.link-1(r3) / put pointer to user on 
 13397                              <1> 			     ; / "last users" link
 13398 00011A38 EB03                <1> 	jmp	short putlu_2
 13399                              <1> 		; br 2f /
 13400                              <1> putlu_1: ; 1:
 13401 00011A3A 8843FF              <1> 	mov	[ebx-1], al
 13402                              <1>        		; movb r1,-1(r2) / user is only user; 
 13403                              <1> 			    ; / put process no. at beginning and at end
 13404                              <1> putlu_2: ; 2: 
 13405 00011A3D 8803                <1> 	mov	[ebx], al
 13406                              <1>        		; movb r1,(r2) / user process in r1 is now the last entry
 13407                              <1> 			     ; / on the queue
 13408 00011A3F 88C2                <1> 	mov	dl, al
 13409 00011A41 88B2[9F000300]      <1>         mov     [edx+p.link-1], dh ; 0
 13410                              <1> 		; dec r2 / restore r2
 13411 00011A47 C3                  <1>         retn
 13412                              <1> 		; rts r0
 13413                              <1> 
 13414                              <1> sysver:
 13415                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
 13416 00011A48 C705[64030300]0002- <1> 	mov	dword [u.r0], 200h ; AH = major version, AL = minor version 
 13416 00011A50 0000                <1>
 13417 00011A52 E9A5BEFFFF          <1> 	jmp	sysret
 13418                              <1> 
 13419                              <1> 
 13420                              <1> syspri: ; change running priority (of the process)
 13421                              <1> 	; 21/05/2016
 13422                              <1> 	; 20/05/2026 - TRDOS 386 (TRDOS v2.0)
 13423                              <1> 	; INPUT ->
 13424                              <1> 	;	BL = priority level
 13425                              <1> 	;	   0 = low running priority (running on background)
 13426                              <1> 	;	   1 = normal/regular priority (running as regular)
 13427                              <1> 	;	   2 = high/event priority (running for event)
 13428                              <1> 	;	   >2 = invalid, it will accepted as 2 (event)
 13429                              <1> 	;	   0FFh = get/return current running priority only	
 13430                              <1> 	; OUTPUT -> 	
 13431                              <1> 	;	* if current [u.pri] < 2
 13432                              <1> 	;	  if BL input < 0FFh ->
 13433                              <1> 	;	     [u.pri] is updated as in BL input (0,1,2)
 13434                              <1> 	;	  if BL input = 0FFh -> AL = [u.pri] (current)
 13435                              <1> 	;	      
 13436                              <1> 	;	* if current [u.pri] = 2
 13437                              <1> 	;	  if BL input < 0FFh -> cf = 1 & AL = 2
 13438                              <1> 	;	  if BL input = 0FFh -> cf = 0 & AL = 2  
 13439                              <1> 	;	
 13440                              <1> 	;	NOTE: 	
 13441                              <1> 	;	If [u.pri] = 2, it can not be changed to 1 or 0;
 13442                              <1> 	;	because, run queue of the running process is unspecified
 13443                              <1> 	;	at this	stage. Process might be started by a timer event
 13444                              <1> 	;	or priority might be changed to high by previous
 13445                              <1> 	;	'syspri' system	call. In both cases, the process is in
 13446                              <1> 	;	'runq_normal' or 'runq_background' queue.
 13447                              <1> 	;	As result of this fact, when the [u.quant] time quantum
 13448                              <1> 	;	of the process is elapsed or 'sysrele' system call is
 13449                              <1> 	;	instructed by the process, 'tswap' ('tswitch') procedure
 13450                              <1> 	;	will be called (to 'swap' or 'switch' out the procedure)
 13451                              <1> 	;	and it will not call 'putlu' to add the (stopping)
 13452                              <1> 	;	process to relevant run queue when [u.pri] = 2.
 13453                              <1> 	;	(Otherwise, it would be possible to add process to
 13454                              <1> 	;	a run queue while it is already in a run queue, wrongly.)
 13455                              <1>   	;
 13456                              <1> 	;	If [u.pri]< 2, 'tswap/tswitch' procedure will call 
 13457                              <1> 	;	'putlu' to add process to relevant run queue
 13458                              <1> 	;	according to [u.pri] value. ('runq_normal' for 1, 
 13459                              <1> 	;	'runq_background' for 0).
 13460                              <1> 	;
 13461                              <1> 	;	If BL input >= 2 and < 0FFh while [u.pri] < 2,
 13462                              <1> 	;	process will be added to 'runq_normal' queue and
 13463                              <1> 	;	[u.pri] will be set to 2. (in 'syspri' system call)
 13464                              <1> 	;
 13465                              <1> 
 13466 00011A57 29C0                <1> 	sub	eax, eax ; 0
 13467 00011A59 A3[C8030300]        <1> 	mov	[u.error], eax
 13468                              <1> 
 13469 00011A5E A0[A9030300]        <1> 	mov	al, [u.pri]
 13470 00011A63 A3[64030300]        <1> 	mov	[u.r0], eax
 13471                              <1> 
 13472 00011A68 FEC3                <1> 	inc	bl
 13473 00011A6A 0F848CBEFFFF        <1> 	jz	sysret ; 0FFh -> 0, get priority level
 13474                              <1> 	
 13475 00011A70 3C02                <1> 	cmp	al, 2
 13476 00011A72 0F8364BEFFFF        <1> 	jnb	error ; CF = 1 & AL = 2 (& last error = 0)
 13477                              <1> 
 13478 00011A78 FECB                <1> 	dec	bl
 13479 00011A7A 80FB02              <1> 	cmp	bl, 2
 13480 00011A7D 7602                <1> 	jna	short syspri_1
 13481 00011A7F B302                <1> 	mov	bl, 2
 13482                              <1> syspri_1:
 13483 00011A81 881D[A9030300]      <1> 	mov	[u.pri], bl
 13484 00011A87 80FB02              <1> 	cmp	bl, 2
 13485 00011A8A 0F826CBEFFFF        <1>         jb      sysret
 13486                              <1> 
 13487                              <1> 	; here...
 13488                              <1> 	; Priority of current process has been changed to high
 13489                              <1> 	; ('run for event') but current process will be added to
 13490                              <1> 	; 'run as normal' queue. ('run for event' high priority
 13491                              <1> 	; queue is under control of timer -& RTC- interrupt only!) 
 13492                              <1> 	;
 13493                              <1> 	; (Otherwise, process can fall into black hole!
 13494                              <1> 	; e.g. if it is not in waiting list and it has not got 
 13495                              <1> 	; a timer event and it is not in a run queue!
 13496                              <1> 	; Because, when [u.pri] is 2, 'tswap/tswitch' will not 
 13497                              <1> 	; add the stopping process to a run queue.)
 13498                              <1> 
 13499 00011A90 A0[B3030300]        <1> 	mov	al, [u.uno]
 13500 00011A95 BB[54030300]        <1> 	mov	ebx, runq_normal ; normal priority !
 13501                              <1> 				 ; [u.pri] is set to high
 13502                              <1> 				 ; but 'runq_event' queue is set
 13503                              <1> 				 ; only by the kernel's timer
 13504                              <1> 				 ; event function (timer interrupt). 
 13505 00011A9A E889FFFFFF          <1> 	call	putlu
 13506 00011A9F E958BEFFFF          <1> 	jmp	sysret
 13507                              <1> 
 13508                              <1> cpass: ; / get next character from user area of core and put it in AL (r1)
 13509                              <1> 	; 02/05/2016 - TRDOS 386 (TRDOS v2.0)
 13510                              <1> 	; 19/05/2015 - 18/10/2015 (Retro UNIX 386 v1)
 13511                              <1> 	; 14/08/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 13512                              <1> 	; INPUTS -> 
 13513                              <1> 	;     [u.base] = virtual address in user area
 13514                              <1> 	;     [u.count] = byte count (max.)
 13515                              <1> 	;     [u.pcount] = byte count in page (0 = reset)		
 13516                              <1> 	; OUTPUTS -> 
 13517                              <1> 	;     AL = the character which is pointed by [u.base]
 13518                              <1> 	;     zf = 1 -> transfer count has been completed	
 13519                              <1>         ;
 13520                              <1> 	; ((Modified registers:  EAX, EDX, ECX))
 13521                              <1> 	;
 13522 00011AA4 833D[88030300]00    <1> 	cmp 	dword [u.count], 0  ; have all the characters been transferred
 13523                              <1> 			    	    ; i.e., u.count, # of chars. left
 13524 00011AAB 763F                <1> 	jna	short cpass_3	    ; to be transferred = 0?) yes, branch
 13525 00011AAD FF0D[88030300]      <1> 	dec	dword [u.count]	    ; no, decrement u.count
 13526                              <1>         ; 19/05/2015 
 13527                              <1> 	;(Retro UNIX 386 v1 - translation from user's virtual address
 13528                              <1> 	;		      to physical address
 13529 00011AB3 66833D[C4030300]00  <1> 	cmp	word [u.pcount], 0 ; byte count in page = 0 (initial value)
 13530                              <1> 			     ; 1-4095 --> use previous physical base address
 13531                              <1> 			     ; in [u.pbase]
 13532 00011ABB 770E                <1> 	ja	short cpass_1
 13533 00011ABD 833D[BC030300]00    <1> 	cmp     dword [u.ppgdir], 0 ; is the caller os kernel
 13534 00011AC4 7427                <1>         je      short cpass_k       ; (sysexec, '/etc/init') ?  (MainProg)
 13535 00011AC6 E858FDFFFF          <1> 	call	trans_addr_r
 13536                              <1> cpass_1:
 13537 00011ACB 66FF0D[C4030300]    <1> 	dec	word [u.pcount]
 13538                              <1> cpass_2: 
 13539 00011AD2 8B15[C0030300]      <1> 	mov	edx, [u.pbase]
 13540 00011AD8 8A02                <1> 	mov	al, [edx]	; take the character pointed to 
 13541                              <1> 				; by u.base and put it in r1
 13542 00011ADA FF05[8C030300]      <1> 	inc	dword [u.nread] ; increment no. of bytes transferred
 13543 00011AE0 FF05[84030300]      <1> 	inc	dword [u.base]  ; increment the buffer address to point to the
 13544                              <1> 			        ; next byte
 13545 00011AE6 FF05[C0030300]      <1> 	inc	dword [u.pbase]
 13546                              <1> cpass_3:
 13547 00011AEC C3                  <1> 	retn
 13548                              <1> cpass_k:
 13549                              <1> 	; 02/07/2015
 13550                              <1> 	; The caller is os kernel 
 13551                              <1> 	; (get sysexec arguments from kernel's memory space)
 13552 00011AED 8B1D[84030300]      <1> 	mov	ebx, [u.base]
 13553 00011AF3 66C705[C4030300]00- <1>         mov     word [u.pcount], PAGE_SIZE ; 4096
 13553 00011AFB 10                  <1>
 13554 00011AFC 891D[C0030300]      <1> 	mov	[u.pbase], ebx
 13555 00011B02 EBCE                <1> 	jmp	short cpass_2
 13556                              <1> 
 13557                              <1> transfer_to_user_buffer: ; fast transfer
 13558                              <1> 	; 27/05/2016
 13559                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 13560                              <1> 	;
 13561                              <1> 	; INPUT ->
 13562                              <1> 	;	ESI = source address in system space
 13563                              <1> 	;	EDI = user's buffer address
 13564                              <1> 	;	ECX = transfer (byte) count
 13565                              <1> 	;	[u.pgdir] = user's page directory
 13566                              <1> 	; OUTPUT ->
 13567                              <1> 	;	ECX = actual transfer count
 13568                              <1> 	;	cf = 1 -> error
 13569                              <1> 	;	[u.count] = remain byte count
 13570                              <1> 	;
 13571                              <1> 	; Modified registers: eax, ecx
 13572                              <1> 	;
 13573                              <1> 
 13574 00011B04 21C9                <1> 	and	ecx, ecx
 13575 00011B06 743B                <1> 	jz	short ttub_4
 13576                              <1> 
 13577 00011B08 890D[88030300]      <1> 	mov	[u.count], ecx
 13578                              <1> 	
 13579 00011B0E 57                  <1> 	push	edi
 13580 00011B0F 56                  <1> 	push	esi
 13581 00011B10 53                  <1> 	push	ebx
 13582 00011B11 52                  <1> 	push	edx
 13583 00011B12 51                  <1> 	push	ecx
 13584                              <1> 
 13585 00011B13 89FB                <1> 	mov	ebx, edi
 13586 00011B15 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 13587                              <1> ttub_1:
 13588                              <1> 	; ebx = virtual (linear) address
 13589                              <1> 	; [u.pgdir] = user's page directory
 13590 00011B1B E8CE47FFFF          <1>        	call	get_physical_addr_x ; get physical address
 13591 00011B20 7222                <1> 	jc	short ttub_5
 13592                              <1> 	; eax = physical address 
 13593                              <1> 	; ecx = remain byte count in page (1-4096)
 13594 00011B22 89C7                <1> 	mov	edi, eax
 13595 00011B24 A1[88030300]        <1> 	mov	eax, [u.count]
 13596 00011B29 39C1                <1> 	cmp	ecx, eax
 13597 00011B2B 7602                <1> 	jna	short ttub_2
 13598 00011B2D 89C1                <1> 	mov	ecx, eax
 13599                              <1> ttub_2:	
 13600 00011B2F 29C8                <1> 	sub	eax, ecx
 13601 00011B31 01CB                <1> 	add	ebx, ecx
 13602 00011B33 F3A4                <1> 	rep	movsb
 13603 00011B35 A3[88030300]        <1> 	mov	[u.count], eax
 13604 00011B3A 09C0                <1> 	or	eax, eax
 13605 00011B3C 75DD                <1> 	jnz	short ttub_1
 13606                              <1> ttub_retn:
 13607                              <1> tfub_retn:
 13608 00011B3E 59                  <1> 	pop	ecx ; transfer count = actual transfer count
 13609                              <1> ttub_3:
 13610 00011B3F 5A                  <1> 	pop	edx
 13611 00011B40 5B                  <1> 	pop	ebx
 13612 00011B41 5E                  <1> 	pop	esi
 13613 00011B42 5F                  <1> 	pop	edi
 13614                              <1> ttub_4:
 13615 00011B43 C3                  <1> 	retn
 13616                              <1> ttub_5:
 13617 00011B44 59                  <1> 	pop	ecx
 13618 00011B45 2B0D[88030300]      <1> 	sub	ecx, [u.count] ; actual transfer count
 13619 00011B4B F9                  <1> 	stc
 13620 00011B4C EBF1                <1> 	jmp	short ttub_3
 13621                              <1> 
 13622                              <1> transfer_from_user_buffer: ; fast transfer
 13623                              <1> 	; 27/05/2016
 13624                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
 13625                              <1> 	;
 13626                              <1> 	; INPUT ->
 13627                              <1> 	;	ESI = user's buffer address
 13628                              <1> 	;	EDI = destination address in system space
 13629                              <1> 	;	ECX = transfer (byte) count
 13630                              <1> 	;	[u.pgdir] = user's page directory
 13631                              <1> 	; OUTPUT ->
 13632                              <1> 	;	ecx = actual transfer count
 13633                              <1> 	;	cf = 1 -> error
 13634                              <1> 	;	[u.count] = remain byte count
 13635                              <1> 	;
 13636                              <1> 	; Modified registers: eax, ecx
 13637                              <1> 	;
 13638                              <1> 
 13639 00011B4E 21C9                <1> 	and	ecx, ecx
 13640                              <1> 	;jz	short tfub_4
 13641 00011B50 74F1                <1> 	jz	short ttub_4
 13642                              <1> 
 13643 00011B52 890D[88030300]      <1> 	mov	[u.count], ecx
 13644                              <1> 	
 13645 00011B58 57                  <1> 	push	edi
 13646 00011B59 56                  <1> 	push	esi
 13647 00011B5A 53                  <1> 	push	ebx
 13648 00011B5B 52                  <1> 	push	edx
 13649 00011B5C 51                  <1> 	push	ecx
 13650                              <1> 
 13651 00011B5D 89F3                <1> 	mov	ebx, esi
 13652 00011B5F 81C300004000        <1> 	add	ebx, CORE ; 27/05/2016
 13653                              <1> tfub_1:
 13654                              <1> 	; ebx = virtual (linear) address
 13655                              <1> 	; [u.pgdir] = user's page directory
 13656 00011B65 E88447FFFF          <1>        	call	get_physical_addr_x ; get physical address
 13657                              <1> 	;jc	short tfub_5
 13658 00011B6A 72D8                <1> 	jc	short ttub_5
 13659                              <1> 	; eax = physical address 
 13660                              <1> 	; ecx = remain byte count in page (1-4096)
 13661 00011B6C 89C6                <1> 	mov	esi, eax
 13662 00011B6E A1[88030300]        <1> 	mov	eax, [u.count]
 13663 00011B73 39C1                <1> 	cmp	ecx, eax
 13664 00011B75 7602                <1> 	jna	short tfub_2
 13665 00011B77 89C1                <1> 	mov	ecx, eax
 13666                              <1> tfub_2:	
 13667 00011B79 29C8                <1> 	sub	eax, ecx
 13668 00011B7B 01CB                <1> 	add	ebx, ecx
 13669 00011B7D F3A4                <1> 	rep	movsb
 13670 00011B7F A3[88030300]        <1> 	mov	[u.count], eax
 13671 00011B84 09C0                <1> 	or	eax, eax
 13672 00011B86 75DD                <1> 	jnz	short tfub_1
 13673                              <1> 
 13674 00011B88 EBB4                <1> 	jmp	short tfub_retn
 13675                              <1> 
 13676                              <1> ;tfub_retn:
 13677                              <1> ;	pop	ecx ; transfer count = actual transfer count
 13678                              <1> ;tfub_3:
 13679                              <1> ;	pop	edx
 13680                              <1> ;	pop	ebx
 13681                              <1> ;	pop	esi
 13682                              <1> ;	pop	edi
 13683                              <1> ;tfub_4:
 13684                              <1> ;	retn
 13685                              <1> ;tfub_5:
 13686                              <1> ;	pop	ecx
 13687                              <1> ;	sub	ecx, [u.count] ; actual transfer count
 13688                              <1> ;	stc
 13689                              <1> ;	jmp	short tfub_3
 13690                              <1> 
 13691                              <1> sysfff: ; <Find First File>
 13692                              <1> 	; 17/10/2016
 13693                              <1> 	; 16/10/2016
 13694                              <1> 	; 15/10/2016 TRDOS 386 (TRDOS v2.0) feature only ! 
 13695                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 13696                              <1> 	;            ("loc_INT21h_find_first_file")
 13697                              <1> 	; TRDOS 8086 (v1.0)
 13698                              <1>         ; 	07/08/2011 
 13699                              <1>         ;	Find First File
 13700                              <1> 	;	INPUT:
 13701                              <1>         ;	    CX= Attributes
 13702                              <1>         ;	    DS:DX= Pointer to filename
 13703                              <1> 	;	MSDOS OUTPUT:
 13704                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 13705                              <1> 	;	    Offset  Descrription
 13706                              <1> 	;	    0	    Reserved for use find next file
 13707                              <1> 	;	    21	    Attribute of file found
 13708                              <1> 	;	    22	    Time stamp of file
 13709                              <1> 	;	    24	    Date stamp of file
 13710                              <1> 	;	    26	    File size in bytes
 13711                              <1> 	;	    30	    Filename and extension (zero terminated)
 13712                              <1> 	;	If cf = 1:
 13713                              <1> 	;	    Error Codes: (in AX)
 13714                              <1> 	;	    	2 - File not found
 13715                              <1> 	;	       18 - No more files  			
 13716                              <1>         ;
 13717                              <1> 	; TRDOS 386 (v2.0) 
 13718                              <1> 	; 15/10/2016
 13719                              <1> 	;	
 13720                              <1>         ; INPUT ->
 13721                              <1>         ;	   CL = File attributes
 13722                              <1> 	;     	      bit 0 (1) - Read only file (R)
 13723                              <1> 	;             bit 1 (1) - Hidden file (H)
 13724                              <1>         ;             bit 2 (1) - System file (R)
 13725                              <1> 	;             bit 3 (1) - Volume label/name (V)
 13726                              <1>         ;             bit 4 (1) - Subdirectory (D)
 13727                              <1> 	;	      bit 5 (1) - File has been archived (A)
 13728                              <1> 	;	   CH = 0 -> Return basic parameters (24 bytes)
 13729                              <1> 	;	   CH > 0 -> Return FindFile structure/table (128 bytes)
 13730                              <1>         ;          EBX = Pointer to filename (ASCIIZ) -path-
 13731                              <1> 	;	   EDX = File parameters buffer address
 13732                              <1> 	;		(buffer size = 24 bytes if CH input = 0)
 13733                              <1> 	;		(buffer size = 128 bytes if CH input > 0)
 13734                              <1> 	;		 
 13735                              <1> 	; OUTPUT ->
 13736                              <1> 	;	   EAX = 0 if CH input > 0
 13737                              <1> 	;	   EAX = First cluster number of file if CH input = 0	
 13738                              <1> 	;	   EDX = File parameters table/structure address
 13739                              <1> 	;	   Basic Parameters:
 13740                              <1> 	;		Offset  Description
 13741                              <1> 	;		------	---------------
 13742                              <1> 	;		0	File Attributes
 13743                              <1> 	;		1	Ambiguous filename chars are used sign
 13744                              <1> 	;			(0 = filename fits exactly with request)
 13745                              <1> 	;			(>0 = ambiguous filename chars are used)
 13746                              <1> 	;	      	2	Time stamp of file
 13747                              <1> 	;		4	Date stamp of file
 13748                              <1> 	;		6	File size in bytes
 13749                              <1> 	;		10	Short Filename (ASCIIZ, max. 13 bytes)
 13750                              <1> 	;		23	Longname Length (1-255) if existing 
 13751                              <1> 	;  
 13752                              <1> 	;          cf = 1 -> Error code in AL
 13753                              <1> 	;
 13754                              <1> 	; Modified Registers: EAX (at the return of system call)
 13755                              <1> 	;  
 13756                              <1> 	; TR-DOS FindFile (FFF) Structure (128 bytes):
 13757                              <1> 	; 09/10/2011 (DIR.ASM) - 10/02/2016 (trdoskx.s)
 13758                              <1> 	;	
 13759                              <1> 	; Offset	Parameter		Size
 13760                              <1> 	; ------	------------------	-------- 
 13761                              <1> 	; 0		FindFile_Drv		1 byte
 13762                              <1> 	; 1		FindFile_Directory	65 bytes
 13763                              <1> 	; 66		FindFile_Name		13 bytes
 13764                              <1> 	; 79		FindFile_LongNameEntryLength 1 byte
 13765                              <1> 	;Above 80 bytes form
 13766                              <1> 	;TR-DOS Source/Destination File FullName Format/Structure
 13767                              <1> 	; 80		FindFile_AttributesMask 1 word
 13768                              <1> 	; 82		FindFile_DirEntry	32 bytes (*)
 13769                              <1> 	; 114		FindFile_DirFirstCluster 1 double word
 13770                              <1> 	; 118		FindFile_DirCluster	1 double word
 13771                              <1> 	; 122		FindFile_DirEntryNumber 1 word
 13772                              <1> 	; 124		FindFile_MatchCounter	1 word
 13773                              <1> 	; 126		FindFile_Reserved	1 word
 13774                              <1>    	; (*) MS-DOS, FAT 12-16-32 classic directory entry (32 bytes)
 13775                              <1> 
 13776                              <1> 	;mov	[u.namep], ebx
 13777                              <1> 	; 16/10/2016
 13778 00011B8A 8915[80960100]      <1> 	mov	[FFF_UBuffer], edx
 13779 00011B90 66890D[85960100]    <1> 	mov	[FFF_Attrib], cx ; [FFF_RType] = ch
 13780                              <1> 		    ; Attributes in CL, return data type in CH
 13781 00011B97 89DE                <1> 	mov	esi, ebx
 13782                              <1> 	; file name is forced, change directory as temporary
 13783                              <1> 	;mov	ax, 1
 13784                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
 13785                              <1> 	;call	set_working_path 
 13786 00011B99 E8E2130000          <1> 	call	set_working_path_x ; 17/10/2016	
 13787 00011B9E 731D                <1> 	jnc	short sysfff_0
 13788                              <1>  
 13789 00011BA0 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 13790 00011BA2 7505                <1> 	jnz	short sysfff_err
 13791                              <1> 
 13792                              <1> 	; eax = 0
 13793 00011BA4 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 13794                              <1> sysfff_err:
 13795 00011BA9 A3[64030300]        <1> 	mov	[u.r0], eax
 13796 00011BAE A3[C8030300]        <1> 	mov	[u.error], eax
 13797 00011BB3 E89D140000          <1>         call 	reset_working_path
 13798 00011BB8 E91FBDFFFF          <1> 	jmp	error
 13799                              <1> 
 13800                              <1> sysfff_0:
 13801                              <1> 	;sub	ah, ah ; ah = 0
 13802 00011BBD 8A0424              <1> 	mov	al, [esp]
 13803 00011BC0 08C0                <1> 	or	al, al
 13804 00011BC2 7412                <1> 	jz	short sysfff_2
 13805 00011BC4 B410                <1> 	mov	ah, 10h
 13806 00011BC6 A808                <1> 	test	al, 08h
 13807 00011BC8 7503                <1> 	jnz	short sysfff_1
 13808 00011BCA 80CC08              <1> 	or	ah, 08h
 13809                              <1> sysfff_1:
 13810 00011BCD 2410                <1> 	and	al, 10h ; Directory
 13811 00011BCF 7405                <1> 	jz	short sysfff_2
 13812 00011BD1 80E408              <1> 	and	ah, 08h
 13813 00011BD4 30C0                <1> 	xor	al, al ; When a directory is searched,
 13814                              <1> 		       ; filename will be returned even if
 13815                              <1> 		       ; it is not a directory!
 13816                              <1> 		       ; Because: (in order to prevent
 13817                              <1> 		       ; creating a dir with existing file name)
 13818                              <1> 		       ; Dir and file names must not be same!
 13819                              <1> 		       ; (return attribute must be checked)  	  	 	
 13820                              <1> sysfff_2:
 13821                              <1> 	; AX = Attributes mask 
 13822                              <1> 		; AL = AND mask (result must be equal to AL)
 13823                              <1> 		; AH = Negative AND mask (result must be ZERO)			
 13824                              <1>  	; ESI = FindFile_Name address
 13825                              <1> 
 13826 00011BD6 E8A678FFFF          <1> 	call	find_first_file
 13827 00011BDB 72CC                <1> 	jc	short sysfff_err ; eax = 2 (File not found !)
 13828                              <1> 
 13829                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 13830                              <1> 	; EDI = Directory Buffer Directory Entry Location
 13831                              <1> 	; EAX = File Size
 13832                              <1> 	;  BL = Attributes of The File/Directory
 13833                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 13834                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 13835                              <1> 
 13836                              <1> sysfff_3:
 13837                              <1> 	; 16/10/2016
 13838 00011BDD 668B0D[85960100]    <1> 	mov	cx, [FFF_Attrib]
 13839                              <1> 	; Attribs in CL, return data type in CH
 13840                              <1> 
 13841                              <1> 	;or	cl, cl
 13842                              <1> 	;jz	short sysfff_4 ; 0 = No filter
 13843 00011BE4 80F1FF              <1> 	xor	cl, 0FFh
 13844 00011BE7 20D9                <1> 	and	cl, bl
 13845 00011BE9 7409                <1> 	jz	short sysfff_4
 13846                              <1> 
 13847                              <1> 	;mov	eax, 2 ; 'file not found !' error
 13848                              <1> 	;jmp	short sysfff_err_1
 13849                              <1> 
 13850                              <1> 	; 16/10/2016
 13851 00011BEB E84079FFFF          <1> 	call	find_next_file
 13852 00011BF0 72B7                <1> 	jc	short sysfff_err ; eax = 12 (no more files !)
 13853 00011BF2 EBE9                <1> 	jmp	short sysfff_3
 13854                              <1> 
 13855                              <1> sysfff_4:
 13856 00011BF4 20ED                <1> 	and	ch, ch ; [FFF_RType]
 13857 00011BF6 7412                <1> 	jz	short sysfff_5
 13858 00011BF8 B980000000          <1> 	mov	ecx, 128 ; ; transfer length
 13859 00011BFD 880D[84960100]      <1> 	mov	[FFF_Valid], cl
 13860                              <1> sysfnf_11:
 13861 00011C03 BE[36930100]        <1> 	mov	esi, FindFile_Drv
 13862 00011C08 EB44                <1> 	jmp	short sysfff_6	
 13863                              <1> sysfff_5:
 13864                              <1> 	;mov	esi, FindFile_DirEntry
 13865 00011C0A B918000000          <1> 	mov	ecx, 24  ; transfer length
 13866 00011C0F 880D[84960100]      <1> 	mov	[FFF_Valid], cl
 13867                              <1> sysfnf_12:
 13868 00011C15 BF[409B0100]        <1> 	mov	edi, DTA ; FFF data transfer address
 13869                              <1> 	;mov	al, [esi+DirEntry_Attr] ; 11
 13870 00011C1A 88D8                <1> 	mov	al, bl ; File/Dir Attributes
 13871 00011C1C 887F17              <1> 	mov	[edi+23], bh ; Longname length (0= none)
 13872 00011C1F AA                  <1> 	stosb
 13873 00011C20 88D0                <1> 	mov	al, dl ; DL is for '?'
 13874 00011C22 00F0                <1> 	add	al, dh ; DH is for '*'
 13875                              <1> 	; AL > 0 if ambiguous file name wildcards are used
 13876 00011C24 AA                  <1> 	stosb
 13877 00011C25 8B4616              <1> 	mov	eax, [esi+DirEntry_WrtTime] ; 22	
 13878 00011C28 AB                  <1>         stosd	; DirEntry_WrtTime & DirEntry_WrtDate
 13879 00011C29 8B461C              <1>         mov	eax, [esi+DirEntry_FileSize] ; 28
 13880 00011C2C AB                  <1>         stosd
 13881 00011C2D 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI] ; 20
 13882 00011C31 66C1E010            <1> 	shl	ax, 16
 13883 00011C35 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO] ; 26 
 13884 00011C39 A3[64030300]        <1> 	mov	[u.r0], eax ; First Cluster
 13885                              <1> 
 13886                              <1>         ;mov	esi, FindFile_DirEntry
 13887 00011C3E E84F140000          <1> 	call	get_file_name
 13888                              <1> 
 13889 00011C43 8A0D[84960100]      <1> 	mov	cl, [FFF_Valid]
 13890 00011C49 BE[409B0100]        <1>        	mov	esi, DTA ; FFF data transfer address
 13891                              <1> sysfff_6:
 13892 00011C4E 8B3D[80960100]      <1> 	mov	edi, [FFF_UBuffer] ; user's buffer address (edx)
 13893 00011C54 E8ABFEFFFF          <1> 	call	transfer_to_user_buffer
 13894                              <1> 
 13895 00011C59 890D[64030300]      <1> 	mov	[u.r0], ecx ; actual transfer count
 13896 00011C5F E8F1130000          <1>         call 	reset_working_path
 13897 00011C64 E993BCFFFF          <1> 	jmp	sysret
 13898                              <1> 
 13899                              <1> sysfnf: ; <Find Next File>
 13900                              <1> 	; 16/10/2016 TRDOS 386 (TRDOS v2.0) feature only ! 
 13901                              <1> 	;           -derived from TRDOS v1.0, INT_21H.ASM-
 13902                              <1> 	;            ("loc_INT21h_find_next_file")
 13903                              <1> 	; TRDOS 8086 (v1.0)
 13904                              <1>         ; 	07/08/2011 
 13905                              <1>         ;	Find First File
 13906                              <1> 	;	INPUT:
 13907                              <1>         ;	    none
 13908                              <1> 	;	MSDOS OUTPUT:
 13909                              <1> 	;	    DTA: (Default address: PSP offset 80h)
 13910                              <1> 	;	    Offset  Descrription
 13911                              <1> 	;	    0	    Reserved for use find next file
 13912                              <1> 	;	    21	    Attribute of file found
 13913                              <1> 	;	    22	    Time stamp of file
 13914                              <1> 	;	    24	    Date stamp of file
 13915                              <1> 	;	    26	    File size in bytes
 13916                              <1> 	;	    30	    Filename and extension (zero terminated)
 13917                              <1> 	;	If cf = 1:
 13918                              <1> 	;	    Error Codes: (in AX)
 13919                              <1> 	;	       18 - No more files  			
 13920                              <1>         ;
 13921                              <1> 	; TRDOS 386 (v2.0) 
 13922                              <1> 	; 16/10/2016
 13923                              <1> 	;	
 13924                              <1>         ; INPUT ->
 13925                              <1>        	; 	   none
 13926                              <1> 	; OUTPUT ->
 13927                              <1> 	;	   EAX = 0 if CH input of 'Find First File' > 0
 13928                              <1> 	;	   EAX = First cluster number of file
 13929                              <1> 	;		 if CH input of 'Find First File' = 0	
 13930                              <1> 	;	   EDX = File parameters table/structure address
 13931                              <1> 	;
 13932                              <1> 	;          cf = 1 -> Error code in AL
 13933                              <1> 	;
 13934                              <1>  	; Modified Registers: EAX (at the return of system call)	
 13935                              <1> 
 13936                              <1> 	;	
 13937                              <1> 	; Note: If byte [FFF_Valid] = 0
 13938                              <1> 	;	'sysfnf' will return with 'no more files' error.
 13939                              <1> 	;	If byte [FFF_Valid] = 24
 13940                              <1> 	;	'sysfnf' will return with 32 bytes basic parameters
 13941                              <1> 	;	at the address which is in EDX.
 13942                              <1> 	;	If byte [FFF_Valid] = 128
 13943                              <1> 	;	'sysfnf' will return with 128 bytes Find File 
 13944                              <1> 	;	Structure/Table at the address which is in EDX.
 13945                              <1> 	
 13946 00011C69 803D[84960100]00    <1> 	cmp	byte [FFF_Valid], 0
 13947 00011C70 7714                <1> 	ja	short stsfnf_0
 13948                              <1>  	; 'no more files !' error 
 13949 00011C72 B80C000000          <1> 	mov	eax, ERR_NO_MORE_FILES ; 12
 13950 00011C77 A3[64030300]        <1> 	mov	[u.r0], eax
 13951 00011C7C A3[C8030300]        <1> 	mov	[u.error], eax
 13952 00011C81 E956BCFFFF          <1> 	jmp	error
 13953                              <1> stsfnf_0:
 13954                              <1> 	;cmp	byte [FFF_Valid], 128
 13955                              <1> 	;je	short stsfnf_1
 13956                              <1> 	;cmp	byte [FFF_Valid], 24
 13957                              <1> 	;je	short stsfnf_1
 13958                              <1> 	;mov	[FFF_Valid], 24 ; Default
 13959                              <1> stsfnf_1:
 13960 00011C86 0FB61D[968A0100]    <1> 	movzx	ebx, byte [Current_Drv]
 13961 00011C8D 66891D[8A960100]    <1> 	mov	[SWP_DRV], bx
 13962 00011C94 8A15[36930100]      <1> 	mov	dl, [FindFile_Drv]
 13963 00011C9A 38DA                <1> 	cmp	dl, bl
 13964 00011C9C 750B                <1> 	jne	short stsfnf_2
 13965 00011C9E 86FB                <1> 	xchg	bh, bl
 13966 00011CA0 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 13967 00011CA5 01DE                <1> 	add	esi, ebx
 13968 00011CA7 EB0D                <1> 	jmp	short sysfnf_3
 13969                              <1> 
 13970                              <1> stsfnf_2:
 13971 00011CA9 FE05[8B960100]      <1> 	inc	byte [SWP_DRV_chg]
 13972                              <1> 
 13973 00011CAF E82A64FFFF          <1> 	call	change_current_drive
 13974 00011CB4 7245                <1> 	jc	short sysfnf_err_1 ; read error ! 
 13975                              <1> 				   ; (do not stop, because
 13976                              <1> 				   ; we don't have a
 13977                              <1> 				   ; 'no more files'
 13978                              <1> 				   ; -file not found- error,	
 13979                              <1> 				   ; next sysfnf system call
 13980                              <1> 				   ; may solve the problem,
 13981                              <1> 				   ; after re-placing the disk)				
 13982                              <1> sysfnf_3:
 13983 00011CB6 A1[AC930100]        <1> 	mov	eax, [FindFile_DirCluster]
 13984 00011CBB 21C0                <1> 	and	eax, eax
 13985 00011CBD 7550                <1> 	jnz	short sysfnf_6
 13986                              <1>         
 13987 00011CBF 803D[958A0100]02    <1> 	cmp	byte [Current_FATType], 2
 13988 00011CC6 772C                <1> 	ja	short sysfnf_err_0 ; invalid, we neeed to stop !?
 13989 00011CC8 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
 13990 00011CCF 7223                <1> 	jb	short sysfnf_err_0 ; invalid, we neeed to stop !?
 13991                              <1> 
 13992 00011CD1 3805[BC910100]      <1> 	cmp	byte [DirBuff_ValidData], al ; 0
 13993 00011CD7 7608                <1> 	jna	short sysfnf_4 
 13994                              <1> 
 13995 00011CD9 3B05[C1910100]      <1> 	cmp	eax, [DirBuff_Cluster] ; 0 ?
 13996 00011CDF 745E                <1> 	je	short sysfnf_9
 13997                              <1> 
 13998                              <1> 	;cmp	byte [Current_Dir_Level], 0
 13999                              <1>         ;ja	short sysfnf_4  
 14000                              <1>         ;jna	short sysfnf_9 
 14001                              <1> 
 14002                              <1> sysfnf_4:
 14003 00011CE1 FE05[8B960100]      <1> 	inc	byte [SWP_DRV_chg]
 14004 00011CE7 E8D5B1FFFF          <1> 	call 	load_FAT_root_directory
 14005 00011CEC 7351                <1> 	jnc	short sysfnf_9
 14006                              <1> 	; eax = error code (17, 'drv not ready or read error')
 14007 00011CEE EB0B                <1> 	jmp	short sysfnf_err_1 ; read error ! (no FNF stop)
 14008                              <1> 				   ; (if you want, try again, 
 14009                              <1> 				   ;  after re-placing the disk)
 14010                              <1> sysfnf_5:	
 14011 00011CF0 3C0C                <1> 	cmp	al, 12 ; 'no more files' error
 14012 00011CF2 7507                <1> 	jne	short sysfnf_err_1 ; (no FNF stop -sysfnf will try
 14013                              <1> 				   ;  to read the directory again,
 14014                              <1> 				   ;  if the user calls sysfnf
 14015                              <1> 				   ;  just after this error return-)
 14016                              <1> 	; (FNF stop -sysfnf will not try
 14017                              <1> 	;  to read the directory again-)	
 14018                              <1> 
 14019                              <1> sysfnf_err_0:
 14020 00011CF4 C605[84960100]00    <1> 	mov	byte [FFF_Valid], 0 ; FNF stop sign
 14021                              <1> sysfnf_err_1:
 14022 00011CFB A3[64030300]        <1> 	mov	[u.r0], eax
 14023 00011D00 A3[C8030300]        <1> 	mov	[u.error], eax
 14024 00011D05 E84B130000          <1> 	call	reset_working_path
 14025 00011D0A E9CDBBFFFF          <1> 	jmp	error
 14026                              <1> 	  
 14027                              <1> sysfnf_6:
 14028 00011D0F 803D[BC910100]00    <1> 	cmp	byte [DirBuff_ValidData], 0
 14029 00011D16 7608                <1> 	jna	short sysfnf_7
 14030                              <1> 
 14031 00011D18 3B05[C1910100]      <1> 	cmp	eax, [DirBuff_Cluster]
 14032 00011D1E 741F                <1> 	je	short sysfnf_9
 14033                              <1> 
 14034                              <1> sysfnf_7:
 14035 00011D20 FE05[8B960100]      <1> 	inc	byte [SWP_DRV_chg]
 14036 00011D26 803D[958A0100]01    <1> 	cmp	byte [Current_FATType], 1
 14037 00011D2D 7309                <1> 	jnb	short sysfnf_8
 14038                              <1> 
 14039                              <1> 	; Singlix (TRFS) File System 
 14040                              <1> 	; (access via compatibility buffer)
 14041 00011D2F E855B2FFFF          <1> 	call	load_FS_sub_directory
 14042 00011D34 7309                <1> 	jnc	short sysfnf_9
 14043                              <1> 
 14044 00011D36 EBC3                <1> 	jmp	short sysfnf_err_1 ; read error (no FNF stop)
 14045                              <1> 
 14046                              <1> sysfnf_8:
 14047 00011D38 E80FB2FFFF          <1> 	call	load_FAT_sub_directory	 
 14048 00011D3D 72BC                <1> 	jc	short sysfnf_err_1 ; read error (no FNF stop)
 14049                              <1> 
 14050                              <1> sysfnf_9:
 14051 00011D3F E8EC77FFFF          <1> 	call	find_next_file
 14052 00011D44 72AA                <1> 	jc	short sysfnf_5
 14053                              <1> 
 14054 00011D46 A0[85960100]        <1> 	mov	al, [FFF_Attrib]
 14055                              <1> 	;or	al, al
 14056                              <1> 	;jz	short sysfnf_10 ; 0 = No filter
 14057 00011D4B 34FF                <1> 	xor	al, 0FFh
 14058 00011D4D 20D8                <1> 	and	al, bl
 14059 00011D4F 75EE                <1> 	jnz	short sysfnf_9 ; search for next file until
 14060                              <1> 			       ; an error return from
 14061                              <1> 			       ; find_next_file procedure	
 14062                              <1> sysfnf_10:
 14063 00011D51 0FB60D[84960100]    <1>         movzx	ecx, byte [FFF_Valid]
 14064 00011D58 80F980              <1> 	cmp	cl, 128 ; complete FindFile structure/table 
 14065 00011D5B 0F84A2FEFFFF        <1> 	je	sysfnf_11
 14066                              <1> 	;cmp	cl, 24  ; basic parameters
 14067                              <1> 	;je	sysfnf_12       
 14068 00011D61 E9AFFEFFFF          <1> 	jmp	sysfnf_12
 14069                              <1> 
 14070                              <1> writei:
 14071                              <1> 	; 26/10/2016
 14072                              <1> 	; 25/10/2016
 14073                              <1> 	; 23/10/2016
 14074                              <1> 	; 22/10/2016
 14075                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 14076                              <1> 	; 19/05/2015 - 20/05/2015 (Retro UNIX 386 v1)
 14077                              <1> 	; 12/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 14078                              <1> 	;
 14079                              <1> 	; Write data to file with first cluster number in EAX
 14080                              <1> 	; 
 14081                              <1> 	; INPUTS ->
 14082                              <1> 	;    EAX - First cluster number of the file
 14083                              <1> 	;    EBX - File number (Open file index number)
 14084                              <1> 	;    u.count - byte count to be written
 14085                              <1> 	;    u.base - points to user buffer
 14086                              <1> 	;    u.fofp - points to dword with current file offset
 14087                              <1> 	;    i.size - file size
 14088                              <1> 	;    cdev - logical dos drive number of the file
 14089                              <1> 	; OUTPUTS ->
 14090                              <1> 	;    u.count - cleared
 14091                              <1> 	;    u.nread - accumulates total bytes passed back
 14092                              <1> 	;    i.size - new file size (if file byte offset overs file size)
 14093                              <1> 	;    u.fofp - points to u.off (with new offset value)	
 14094                              <1> 	;
 14095                              <1> 	; (Retro UNIX Prototype : 11/11/2012 - 18/11/2012, UNIXCOPY.ASM)
 14096                              <1> 	; ((Modified registers: eax, edx, ebx, ecx, esi, edi, ebp)) 	
 14097                              <1> 
 14098 00011D66 31C9                <1> 	xor	ecx, ecx
 14099 00011D68 890D[8C030300]      <1> 	mov 	[u.nread], ecx  ; 0
 14100 00011D6E 66890D[C4030300]    <1> 	mov	[u.pcount], cx ; 19/05/2015
 14101 00011D75 390D[88030300]      <1> 	cmp 	[u.count], ecx
 14102 00011D7B 7701                <1> 	ja 	short writei_1 
 14103 00011D7D C3                  <1> 	retn
 14104                              <1> writei_1:
 14105 00011D7E 881D[44960100]      <1> 	mov	[writei.ofn], bl ; Open file number
 14106 00011D84 880D[7F960100]      <1> 	mov	[setfmod], cl ; 0 ; reset 'update lm date&time' sign
 14107                              <1> dskw_0: 
 14108                              <1> 	; 26/10/2016
 14109                              <1> 	; 22/10/2016, 23/10/2016, 25/10/2016
 14110                              <1> 	; 19/10/2016 - TRDOS 386 (TRDOS v2.0)
 14111                              <1> 	; 31/05/2015 - 25/07/2015 (Retro UNIX 386 v1)
 14112                              <1> 	; 26/04/2013 - 20/09/2013 (Retro UNIX 8086 v1)
 14113                              <1> 	;
 14114                              <1> 	; 01/08/2013 (mkdir_w check)
 14115 00011D8A E8D7000000          <1>  	call	mget_w
 14116                              <1> 	; eax = sector/block number
 14117                              <1> 
 14118 00011D8F 8B1D[74030300]      <1> 	mov     ebx, [u.fofp]
 14119 00011D95 8B13                <1> 	mov	edx, [ebx]
 14120 00011D97 81E2FF010000        <1> 	and	edx, 1FFh  ; / test the lower 9 bits of the file offset
 14121 00011D9D 750C                <1> 	jnz	short dskw_1 ; / if its non-zero, branch
 14122                              <1> 			     ; if zero, file offset = 0,
 14123                              <1> 		       	     ; / 512, 1024,...(i.e., start of new block)
 14124 00011D9F 813D[88030300]0002- <1> 	cmp	dword [u.count], 512
 14124 00011DA7 0000                <1>
 14125                              <1> 				; / if zero, is there enough data to fill
 14126                              <1> 				; / an entire block? (i.e., no. of
 14127 00011DA9 7337                <1> 	jnb	short dskw_2 ; / bytes to be written greater than 512.? 
 14128                              <1> 			     ; / Yes, branch. Don't have to read block
 14129                              <1> dskw_1: ; in as no past info. is to be saved 
 14130                              <1> 	; (the entire block will be overwritten).
 14131                              <1> 	; 23/10/2016
 14132                              <1> 
 14133 00011DAB BB[94070300]        <1> 	mov	ebx, writei_buffer
 14134                              <1> 	; esi = logical dos drive description table address
 14135                              <1> 	; eax = sector number
 14136                              <1> 	; ebx = buffer address (in kernel's memory space)
 14137                              <1> 	; ecx = sector count
 14138 00011DB0 B901000000          <1> 	mov	ecx, 1
 14139 00011DB5 E8A30D0000          <1> 	call	disk_read
 14140                              <1> 	;call	dskrd 	; / no, must retain old info.. 
 14141                              <1> 		       	; / Hence, read block 'r1' into an I/O buffer
 14142 00011DBA 7326                <1> 	jnc	short dskw_2
 14143                              <1> 
 14144                              <1> 	; disk read error
 14145 00011DBC B811000000          <1> 	mov	eax, 17 ; drive not ready or READ ERROR !
 14146                              <1> dskw_err: ; jump from disk write error
 14147 00011DC1 A3[64030300]        <1> 	mov	[u.r0], eax
 14148 00011DC6 A3[C8030300]        <1> 	mov	[u.error], eax
 14149                              <1> 
 14150 00011DCB 803D[7F960100]00    <1> 	cmp	byte [setfmod], 0
 14151 00011DD2 0F8604BBFFFF        <1> 	jna	error
 14152                              <1> 
 14153 00011DD8 E8AF030000          <1> 	call	update_file_lmdt ; update last modif. date&time of the file
 14154                              <1> 	;mov	byte [setfmod], 0	
 14155                              <1> 
 14156 00011DDD E9FABAFFFF          <1> 	jmp	error
 14157                              <1> 
 14158                              <1> dskw_2: ; 3:
 14159                              <1> 	; 23/10/2016
 14160 00011DE2 C605[20960100]01    <1> 	mov	byte [writei.valid], 1 ; writei buffer contains valid data
 14161 00011DE9 56                  <1> 	push	esi ; logical dos drive description table address
 14162                              <1> 	; EAX (r1) = block/sector number
 14163                              <1> 	;call	wslot
 14164                              <1> 		; jsr r0,wslot / set write and inhibit bits in I/O queue, 
 14165                              <1> 			   ; / proc. status=0, r5 points to 1st word of data
 14166 00011DEA 803D[C6030300]00    <1> 	cmp	byte [u.kcall], 0
 14167 00011DF1 770F                <1> 	ja	short dskw_4 ; zf=0 -> the caller is 'mkdir'
 14168                              <1> 	;
 14169 00011DF3 66833D[C4030300]00  <1> 	cmp	word [u.pcount], 0
 14170 00011DFB 7705                <1> 	ja	short dskw_4
 14171                              <1> dskw_3:
 14172                              <1> 	; [u.base] = virtual address to transfer (as source address)
 14173 00011DFD E821FAFFFF          <1> 	call	trans_addr_r ; translate virtual address to physical (r)
 14174                              <1> dskw_4:
 14175 00011E02 BB[94070300]        <1> 	mov	ebx, writei_buffer
 14176                              <1> 	; EBX (r5) = system (I/O) buffer address
 14177 00011E07 E883FAFFFF          <1> 	call	sioreg
 14178                              <1> 	; ESI = file (user data) offset
 14179                              <1> 	; EDI = sector (I/O) buffer offset
 14180                              <1> 	; ECX = byte count
 14181                              <1> 	;
 14182 00011E0C F3A4                <1>   	rep	movsb
 14183                              <1> 	; 25/07/2015
 14184                              <1> 	; eax = remain bytes in buffer
 14185                              <1>         ;       (check if remain bytes in the buffer > [u.pcount])
 14186 00011E0E 09C0                <1> 	or	eax, eax
 14187 00011E10 75EB                <1> 	jnz	short dskw_3 ; (page end before system buffer end!)	
 14188                              <1> 
 14189                              <1> 	; 23/10/2016
 14190 00011E12 B101                <1> 	mov	cl, 1
 14191 00011E14 5E                  <1> 	pop	esi
 14192 00011E15 A1[24960100]        <1> 	mov	eax, [writei.sector]
 14193                              <1> 	; esi = logical dos drive description table address
 14194                              <1> 	; eax = sector number
 14195                              <1> 	; ebx = writei buffer address
 14196                              <1> 	; ecx = sector count
 14197 00011E1A E82F0D0000          <1> 	call	disk_write ; / yes, write the block
 14198 00011E1F 7307                <1> 	jnc	short dskw_5
 14199                              <1> 
 14200 00011E21 B812000000          <1> 	mov	eax, 18 ; drive not ready or WRITE ERROR !
 14201 00011E26 EB99                <1> 	jmp	short dskw_err
 14202                              <1> 
 14203                              <1> dskw_5:
 14204                              <1> 	; 26/10/2016
 14205 00011E28 0FB61D[44960100]    <1> 	movzx	ebx, byte [writei.ofn] ; open file number
 14206 00011E2F C0E302              <1> 	shl	bl, 2 ; *4
 14207 00011E32 8B83[149A0100]      <1> 	mov	eax, [ebx+OF_POINTER]
 14208 00011E38 3B83[3C9A0100]      <1> 	cmp	eax, [ebx+OF_SIZE]
 14209 00011E3E 7606                <1> 	jna	short dskw_6
 14210 00011E40 8983[3C9A0100]      <1> 	mov	[ebx+OF_SIZE], eax
 14211                              <1> dskw_6:
 14212                              <1> 	;shr	bl, 2
 14213 00011E46 833D[88030300]00    <1>         cmp     dword [u.count], 0 ; / any more data to write?
 14214 00011E4D 760A                <1> 	jna	short dskw_7
 14215 00011E4F A1[34960100]        <1> 	mov	eax, [writei.fclust]
 14216 00011E54 E931FFFFFF          <1> 	jmp	dskw_0 ; / yes, branch
 14217                              <1> dskw_7:
 14218                              <1>  	; update last modif. date&time of the file
 14219                              <1> 	; (also updates file size as OF_SIZE)
 14220 00011E59 E82E030000          <1> 	call	update_file_lmdt
 14221                              <1> 	;mov	byte [setfmod], 0	
 14222                              <1> 
 14223                              <1> 	; 03/08/2013
 14224 00011E5E C605[C6030300]00    <1> 	mov	byte [u.kcall], 0
 14225                              <1> 	; 23/10/2016
 14226                              <1> 	;mov	eax, [writei.fclust]
 14227 00011E65 C3                  <1> 	retn
 14228                              <1> 
 14229                              <1> mget_w:
 14230                              <1> 	; 02/11/2016
 14231                              <1> 	; 01/11/2016
 14232                              <1> 	; 23/10/2016, 31/10/2016
 14233                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 14234                              <1> 	; 03/06/2015 (Retro UNIX 386 v1, 'mget', u.5s)
 14235                              <1> 	; 22/03/2013 - 31/07/2013 (Retro UNIX 8086 v1)
 14236                              <1> 	;
 14237                              <1> 	; Get existing or (allocate) a new disk block for file
 14238                              <1> 	; 
 14239                              <1> 	; INPUTS ->
 14240                              <1> 	;    [u.fofp] = file offset pointer
 14241                              <1> 	;    [i.size] = file size
 14242                              <1> 	;    [u.count] = byte count	 
 14243                              <1> 	;    EAX = First cluster
 14244                              <1> 	;    [cdev] = Logical dos drive number 	  
 14245                              <1> 	;    [writei.ofn] = File Number
 14246                              <1> 	;		   (Open file index, 0 based)
 14247                              <1> 	;    ([u.off] = file offset)
 14248                              <1> 	; OUTPUTS ->
 14249                              <1> 	;    EAX = logical sector number
 14250                              <1> 	;    ESI = Logical Dos Drive Description Table address
 14251                              <1> 	;
 14252                              <1> 	; Modified registers: EDX, EBX, ECX, ESI, EDI, EBP  
 14253                              <1> 
 14254 00011E66 8B35[74030300]      <1>         mov     esi, [u.fofp]
 14255 00011E6C 8B2E                <1> 	mov	ebp, [esi] ; u.off (or EBX*4+OF_POINTER)
 14256                              <1> 
 14257 00011E6E 29C9                <1> 	sub	ecx, ecx
 14258 00011E70 8A2D[46030300]      <1> 	mov	ch, [cdev]
 14259                              <1> 
 14260 00011E76 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 14261 00011E7B 01CE                <1> 	add	esi, ecx
 14262                              <1> 
 14263                              <1> 	; 31/10/2016
 14264 00011E7D 89C3                <1> 	mov	ebx, eax ; First Cluster or FDT address
 14265                              <1> 
 14266 00011E7F 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 14267 00011E83 0F86DD010000        <1> 	jna	mget_w_14 ; Singlix FS
 14268                              <1> 
 14269 00011E89 0FB74611            <1> 	movzx	eax, word [esi+LD_BPB+BytesPerSec]
 14270 00011E8D 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 14271 00011E91 8815[22960100]      <1> 	mov	[writei.spc], dl  ; sectors per cluster
 14272 00011E97 F7E2                <1> 	mul	edx
 14273                              <1> 	; edx = 0
 14274                              <1> 	; eax = bytes per cluster (<= 65536)
 14275                              <1> 
 14276                              <1> 	; 02/11/2016
 14277 00011E99 89C1                <1> 	mov	ecx, eax
 14278 00011E9B 48                  <1> 	dec	eax
 14279 00011E9C 66A3[28960100]      <1> 	mov	[writei.bpc], ax	
 14280                              <1> 	
 14281 00011EA2 89E8                <1> 	mov	eax, ebp
 14282 00011EA4 0305[88030300]      <1> 	add	eax, [u.count] ; next file position
 14283 00011EAA 3B05[55040300]      <1> 	cmp	eax, [i.size] ; <= file size ?
 14284 00011EB0 0F86FC000000        <1> 	jna	mget_w_4 ; no
 14285                              <1> 
 14286 00011EB6 F7F1                <1> 	div	ecx
 14287 00011EB8 A3[30960100]        <1> 	mov	[writei.c_index], eax ; cluster index
 14288                              <1> 	; edx = byte offset in cluster (<= 65535)
 14289                              <1> 	;mov	[writei.offset], dx
 14290                              <1> 	;shr	dx, 9 ; / 512
 14291                              <1> 	;mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 14292                              <1> 
 14293 00011EBD 29D2                <1> 	sub	edx, edx ; 01/11/2016
 14294 00011EBF 8915[24960100]      <1> 	mov 	[writei.sector], edx ; 0
 14295 00011EC5 668915[2A960100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 14296 00011ECC 8815[23960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 14297                              <1> 
 14298 00011ED2 89D8                <1> 	mov	eax, ebx ; First Cluster
 14299                              <1> 
 14300                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 14301 00011ED4 3815[20960100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 14302 00011EDA 7624                <1> 	jna	short mget_w_0
 14303                              <1> 
 14304 00011EDC 8815[20960100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 14305                              <1> 
 14306 00011EE2 3B05[34960100]      <1> 	cmp	eax, [writei.fclust]
 14307 00011EE8 7516                <1> 	jne	short mget_w_0
 14308                              <1> 
 14309 00011EEA 8A0D[46030300]      <1> 	mov	cl, [cdev]
 14310 00011EF0 3A0D[21960100]      <1> 	cmp	cl, [writei.drv]
 14311 00011EF6 7508                <1> 	jne	short mget_w_0
 14312                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 14313                              <1> 	;  we don't need to get last cluster & last cluster index
 14314 00011EF8 8B0D[40960100]      <1> 	mov	ecx, [writei.l_index]
 14315 00011EFE EB64                <1> 	jmp	short mget_w_2
 14316                              <1> mget_w_0:
 14317 00011F00 A3[34960100]        <1> 	mov	[writei.fclust], eax ; first cluster
 14318                              <1> 	; edx = 0
 14319 00011F05 A3[2C960100]        <1> 	mov	[writei.cluster], eax ; first cluster ; 01/11/2016
 14320 00011F0A 8915[38960100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; curret cluster index
 14321                              <1> 
 14322                              <1> 	; FAT file system (FAT12, FAT16, FAT32)
 14323 00011F10 E84CB6FFFF          <1> 	call	get_last_cluster
 14324 00011F15 0F822B010000        <1> 	jc	mget_w_err ; eax = error code
 14325                              <1> 		
 14326 00011F1B A3[3C960100]        <1> 	mov	[writei.lclust], eax ; last cluster
 14327                              <1> 
 14328 00011F20 8B0D[60940100]      <1> 	mov	ecx, [glc_index] ; last cluster index
 14329 00011F26 890D[40960100]      <1> 	mov	[writei.l_index], ecx
 14330                              <1> 
 14331 00011F2C A0[44960100]        <1> 	mov	al, [writei.ofn]
 14332 00011F31 FEC0                <1> 	inc	al
 14333 00011F33 A2[7F960100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 14334                              <1> 
 14335                              <1> mget_w_1:
 14336 00011F38 3B0D[30960100]      <1> 	cmp	ecx, [writei.c_index]  ; last cluster index
 14337 00011F3E 7324                <1> 	jnb	short mget_w_2 ; 01/11/2016
 14338                              <1> 
 14339 00011F40 A1[3C960100]        <1> 	mov	eax, [writei.lclust]
 14340                              <1> 	; EAX = Last cluster
 14341 00011F45 E825B7FFFF          <1> 	call	add_new_cluster
 14342 00011F4A 0F82F6000000        <1> 	jc	mget_w_err ; eax = error code
 14343                              <1> 	; edx = 0
 14344 00011F50 A3[3C960100]        <1> 	mov	[writei.lclust], eax ; (new) last cluster
 14345 00011F55 8B0D[40960100]      <1> 	mov	ecx, [writei.l_index]
 14346 00011F5B 41                  <1> 	inc	ecx ; add 1 to last cluster index
 14347 00011F5C 890D[40960100]      <1> 	mov	[writei.l_index], ecx ; current last cluster index
 14348                              <1> 
 14349 00011F62 EBD4                <1> 	jmp	short mget_w_1
 14350                              <1> 
 14351                              <1> mget_w_2:
 14352 00011F64 89E9                <1> 	mov	ecx, ebp
 14353 00011F66 030D[88030300]      <1> 	add	ecx, [u.count]
 14354 00011F6C 890D[55040300]      <1> 	mov	[i.size], ecx ; save new file size
 14355                              <1> 	;sub	edx, edx ; 0
 14356                              <1> 
 14357 00011F72 A0[46030300]        <1> 	mov	al, [cdev]
 14358 00011F77 A2[21960100]        <1> 	mov	[writei.drv], al ; physical drive number
 14359                              <1> 	; edx = 0
 14360 00011F7C 89E8                <1> 	mov	eax, ebp ; file offset
 14361 00011F7E 0FB70D[28960100]    <1> 	movzx	ecx, word [writei.bpc] ; bytes per cluster - 1
 14362 00011F85 41                  <1> 	inc	ecx ; bytes per cluster
 14363 00011F86 F7F1                <1> 	div	ecx
 14364                              <1> 	; edx = byte offset in cluster (<= 65535)
 14365                              <1> 	; eax = cluster index
 14366 00011F88 A3[30960100]        <1> 	mov	[writei.c_index], eax
 14367 00011F8D 668915[2A960100]    <1> 	mov	[writei.offset], dx
 14368 00011F94 66C1EA09            <1> 	shr	dx, 9 ; / 512
 14369 00011F98 8815[23960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 14370                              <1> 
 14371                              <1> mget_w_3:
 14372 00011F9E 3B05[40960100]      <1> 	cmp	eax, [writei.l_index] ; last cluster index
 14373 00011FA4 752A                <1> 	jne	short mget_w_5
 14374                              <1> 
 14375 00011FA6 A3[38960100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 14376 00011FAB A1[3C960100]        <1> 	mov	eax, [writei.lclust] ; last cluster
 14377 00011FB0 EB60                <1> 	jmp	short mget_w_10
 14378                              <1> 
 14379                              <1> mget_w_4: ; 02/11/2016
 14380                              <1> 	; eax = next file position
 14381 00011FB2 2B05[88030300]      <1> 	sub	eax, [u.count] ; current file position
 14382                              <1> 	; edx = 0
 14383                              <1> 	; ecx = bytes per cluster
 14384 00011FB8 F7F1                <1> 	div	ecx
 14385 00011FBA A3[30960100]        <1> 	mov	[writei.c_index], eax ; cluster index
 14386 00011FBF 668915[2A960100]    <1> 	mov	[writei.offset], dx
 14387 00011FC6 66C1EA09            <1> 	shr	dx, 9 ; / 512
 14388 00011FCA 8815[23960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 14389                              <1> 
 14390                              <1> mget_w_5:
 14391 00011FD0 21C0                <1> 	and	eax, eax ; 0 = First Cluster's index number
 14392 00011FD2 750C                <1> 	jnz	short mget_w_6
 14393                              <1> 
 14394 00011FD4 A3[38960100]        <1> 	mov	[writei.fs_index], eax ; cluster index (for next check)
 14395 00011FD9 A1[34960100]        <1> 	mov	eax, [writei.fclust] ; first cluster
 14396 00011FDE EB32                <1> 	jmp	short mget_w_10
 14397                              <1> 
 14398                              <1> mget_w_6:
 14399 00011FE0 3B05[38960100]      <1> 	cmp	eax, [writei.fs_index] ; current cluster index (>0)
 14400 00011FE6 7507                <1> 	jne	short mget_w_7
 14401 00011FE8 A1[2C960100]        <1> 	mov	eax, [writei.cluster] ; current cluster 
 14402 00011FED EB3A                <1> 	jmp	short mget_w_11
 14403                              <1> 
 14404                              <1> mget_w_7:
 14405 00011FEF 89C1                <1> 	mov	ecx, eax
 14406 00011FF1 2B0D[38960100]      <1> 	sub	ecx, [writei.fs_index]
 14407 00011FF7 730D                <1> 	jnc	short mget_w_8
 14408                              <1> 	; get cluster by index from the first cluster
 14409 00011FF9 A1[34960100]        <1> 	mov	eax, [writei.fclust]
 14410 00011FFE 8B0D[30960100]      <1> 	mov	ecx, [writei.c_index]
 14411 00012004 EB05                <1> 	jmp	short mget_w_9
 14412                              <1> 
 14413                              <1> mget_w_8:
 14414 00012006 A1[2C960100]        <1> 	mov	eax, [writei.cluster] ; beginning cluster
 14415                              <1> 	; ecx = cluster sequence number after the beginning cluster
 14416                              <1> 	; sub	edx, edx ; 0
 14417                              <1> 
 14418                              <1> mget_w_9:
 14419                              <1> 	; EAX = Beginning cluster
 14420                              <1> 	; EDX = Sector index in disk/file section
 14421                              <1> 	;	(Only for SINGLIX file system!)
 14422                              <1> 	; ECX = Cluster sequence number after the beginning cluster
 14423                              <1> 	; ESI = Logical DOS Drive Description Table address
 14424 0001200B E865B7FFFF          <1> 	call	get_cluster_by_index
 14425 00012010 7234                <1> 	jc	short mget_w_err ; error code in EAX
 14426                              <1> 	; EAX = Cluster number		
 14427                              <1> mget_w_10:
 14428 00012012 A3[2C960100]        <1> 	mov	[writei.cluster], eax ; FDT number for Singlix File System
 14429                              <1> 
 14430 00012017 807E0300            <1> 	cmp	byte [esi+LD_FATType], 0
 14431 0001201B 7638                <1> 	jna	short mget_w_13
 14432                              <1> 	; 01/11/2016
 14433 0001201D 8B15[30960100]      <1> 	mov	edx, [writei.c_index]
 14434 00012023 8915[38960100]      <1> 	mov	[writei.fs_index], edx
 14435                              <1> mget_w_11:
 14436 00012029 83E802              <1> 	sub	eax, 2
 14437 0001202C 0FB615[22960100]    <1> 	movzx	edx, byte [writei.spc]
 14438 00012033 F7E2                <1> 	mul	edx
 14439                              <1> 
 14440 00012035 034668              <1> 	add	eax, [esi+LD_DATABegin]
 14441 00012038 8A15[23960100]      <1> 	mov	dl, [writei.s_index]
 14442 0001203E 01D0                <1> 	add	eax, edx
 14443                              <1> mget_w_12:
 14444 00012040 A3[24960100]        <1> 	mov	[writei.sector], eax
 14445                              <1> 	;; buffer validation must be done in writei
 14446                              <1> 	;;mov	byte [writei.valid], 1 
 14447 00012045 C3                  <1> 	retn
 14448                              <1> 
 14449                              <1> mget_w_err:
 14450 00012046 A3[C8030300]        <1> 	mov	[u.error], eax
 14451 0001204B A3[64030300]        <1> 	mov	[u.r0], eax
 14452 00012050 E987B8FFFF          <1> 	jmp	error
 14453                              <1> 
 14454                              <1> mget_w_13:
 14455                              <1> 	; EAX = FDT number (Current Section)
 14456                              <1> 	; EDX = Sector index from the first section (0,1,2,3,4...)
 14457 00012055 2B15[38960100]      <1> 	sub	edx, [writei.fs_index]	
 14458                              <1> 	; EDX = Sector index from current section
 14459 0001205B 8915[38960100]      <1> 	mov	[writei.fs_index], edx
 14460 00012061 40                  <1> 	inc	eax ; the first data sector in FS disk section	
 14461 00012062 01D0                <1> 	add	eax, edx
 14462 00012064 EBDA                <1> 	jmp	short mget_w_12
 14463                              <1> 
 14464                              <1> mget_w_14:
 14465 00012066 8A4E12              <1> 	mov	cl, [esi+LD_FS_BytesPerSec+1]
 14466 00012069 D0E9                <1> 	shr	cl, 1 ;  ; 1 for 512 bytes, 4 for 2048 bytes
 14467 0001206B 880D[22960100]      <1> 	mov	[writei.spc], cl  ; sectors per cluster
 14468                              <1> 	; NOTE: writei bytes per sector value is always 512 ! 
 14469 00012071 66C705[28960100]00- <1> 	mov	word [writei.bpc], 512
 14469 00012079 02                  <1>
 14470                              <1> 
 14471 0001207A 89E9                <1> 	mov	ecx, ebp
 14472 0001207C 030D[88030300]      <1> 	add	ecx, [u.count] ; next file position
 14473 00012082 3B0D[55040300]      <1> 	cmp	ecx, [i.size] ; <= file size ?
 14474 00012088 0F86C8000000        <1> 	jna	mget_w_19 ; no
 14475                              <1> 
 14476 0001208E 29D2                <1> 	sub	edx, edx ; 0
 14477 00012090 8915[24960100]      <1> 	mov 	[writei.sector], edx ; 0
 14478 00012096 668915[2A960100]    <1> 	mov	[writei.offset], dx  ; byte offset in cluster 
 14479 0001209D 8815[23960100]      <1> 	mov	[writei.s_index], dl ; sector index in cluster (0 to spc -1)
 14480                              <1> 
 14481 000120A3 C1E909              <1> 	shr	ecx, 9 ; 1 cluster = 512 bytes
 14482 000120A6 890D[30960100]      <1> 	mov	[writei.c_index], ecx ; section/cluster index
 14483                              <1> 	
 14484 000120AC 89D8                <1> 	mov	eax, ebx ; FDT number (First FDT address)
 14485                              <1> 
 14486                              <1> 	; is this the 1st mget_w or a next mget_w call ? (by 'writei')
 14487 000120AE 3815[20960100]      <1> 	cmp	byte [writei.valid], dl ; 0 
 14488 000120B4 7624                <1> 	jna	short mget_w_15
 14489                              <1> 
 14490 000120B6 8815[20960100]      <1> 	mov 	byte [writei.valid], dl ; 0 ; reset ('writei' will set it) 
 14491                              <1> 
 14492 000120BC 3B05[34960100]      <1> 	cmp	eax, [writei.fclust]
 14493 000120C2 7516                <1> 	jne	short mget_w_15
 14494                              <1> 
 14495 000120C4 8A0D[46030300]      <1> 	mov	cl, [cdev]
 14496 000120CA 3A0D[21960100]      <1> 	cmp	cl, [writei.drv]
 14497 000120D0 7508                <1> 	jne	short mget_w_15
 14498                              <1>  	; [writei.l_clust] & [writei.l_index] are valid, 
 14499                              <1> 	;  we don't need to get last cluster & last cluster index
 14500 000120D2 8B0D[40960100]      <1> 	mov	ecx, [writei.l_index]
 14501 000120D8 EB49                <1> 	jmp	short mget_w_17
 14502                              <1> mget_w_15:
 14503 000120DA A3[34960100]        <1> 	mov	[writei.fclust], eax ; first section (FDT number)
 14504                              <1> 	; edx = 0
 14505 000120DF 8915[2C960100]      <1> 	mov	[writei.cluster], edx ; 0 ; current section
 14506 000120E5 8915[38960100]      <1> 	mov 	[writei.fs_index], edx ; 0 ; curret section index
 14507                              <1> 
 14508                              <1> 	; eax = FDT number (section 0 header address)
 14509 000120EB E8AFB6FFFF          <1> 	call	get_last_section
 14510 000120F0 0F8250FFFFFF        <1> 	jc	mget_w_err ; eax = error code
 14511                              <1> 
 14512 000120F6 8915[38960100]      <1> 	mov 	[writei.fs_index], edx ; sector index in last section
 14513                              <1> 		
 14514 000120FC A3[3C960100]        <1> 	mov	[writei.lclust], eax ; last section address
 14515                              <1> 
 14516 00012101 8B0D[60940100]      <1> 	mov	ecx, [glc_index] ; last section index
 14517 00012107 890D[40960100]      <1> 	mov	[writei.l_index], ecx
 14518                              <1> 
 14519 0001210D A0[44960100]        <1> 	mov	al, [writei.ofn]
 14520 00012112 FEC0                <1> 	inc	al
 14521 00012114 A2[7F960100]        <1> 	mov	[setfmod], al ; update lm date&time sign
 14522                              <1> 
 14523                              <1> mget_w_16:
 14524                              <1> 	; edx = (existing) last section (sector) index
 14525 00012119 8B0D[30960100]      <1> 	mov	ecx, [writei.c_index] ; final section (sector) index
 14526 0001211F 29D1                <1> 	sub	ecx, edx
 14527 00012121 7633                <1> 	jna	short mget_w_19
 14528                              <1> 	 ; ecx = sector count
 14529                              <1> mget_w_17:
 14530 00012123 A1[3C960100]        <1> 	mov	eax, [writei.lclust]
 14531                              <1> 	; ESI = Logical dos drv desc. table address
 14532                              <1>         ; EAX = Last section
 14533                              <1>         ; (ECX = 0 for directory) 
 14534                              <1>         ; ECX = sector count (except FDT)
 14535 00012128 E835ACFFFF          <1> 	call	add_new_fs_section
 14536 0001212D 7312                <1> 	jnc	short mget_w_18
 14537                              <1> 
 14538                              <1> 	; If error number = 27h (insufficient disk space)
 14539                              <1> 	; it is needed to check free consequent sectors
 14540                              <1> 	; (1 data sector at least and +1 section header sector) 
 14541                              <1> 
 14542 0001212F 83F827              <1> 	cmp	eax, 27h
 14543 00012132 0F850EFFFFFF        <1> 	jne	mget_w_err ; eax = error code
 14544                              <1> 
 14545                              <1> 	; ecx = count of free consequent sectors
 14546                              <1> 	; ecx must be > 1 (1 data + 1 header sector)
 14547 00012138 49                  <1> 	dec	ecx
 14548 00012139 0F8407FFFFFF        <1> 	jz	mget_w_err
 14549 0001213F EBE2                <1> 	jmp	short mget_w_17
 14550                              <1> 
 14551                              <1> mget_w_18:
 14552 00012141 A3[3C960100]        <1> 	mov	[writei.lclust], eax ; (new) last section
 14553                              <1> 	; ecx = sector count (except section header)
 14554 00012146 8B15[40960100]      <1> 	mov	edx, [writei.l_index]
 14555 0001214C 01CA                <1> 	add	edx, ecx ; add sector count to index
 14556 0001214E 8915[40960100]      <1> 	mov	[writei.l_index], edx
 14557 00012154 EBC3                <1> 	jmp	short mget_w_16
 14558                              <1> 
 14559                              <1> mget_w_19:
 14560 00012156 89E9                <1> 	mov	ecx, ebp
 14561 00012158 030D[88030300]      <1> 	add	ecx, [u.count]
 14562 0001215E 890D[55040300]      <1> 	mov	[i.size], ecx ; save new file size
 14563                              <1> 	;sub	edx, edx ; 0
 14564                              <1> 
 14565 00012164 A0[46030300]        <1> 	mov	al, [cdev]
 14566 00012169 A2[21960100]        <1> 	mov	[writei.drv], al ; physical drive number
 14567                              <1> 	; edx = 0
 14568 0001216E 89E8                <1> 	mov	eax, ebp ; file offset
 14569 00012170 89C2                <1> 	mov	edx, eax
 14570                              <1> 	; 1 cluster = 512 bytes (for Singlix FS)
 14571 00012172 C1E809              <1> 	shr	eax, 9  ; / 512
 14572 00012175 81E2FF010000        <1> 	and	edx, 1FFh
 14573                              <1> 	; edx = byte offset in cluster/sector (<= 511)
 14574                              <1> 	; eax = section (sector/cluster) index
 14575 0001217B A3[30960100]        <1> 	mov	[writei.c_index], eax
 14576 00012180 668915[2A960100]    <1> 	mov	[writei.offset], dx
 14577                              <1> 	;mov	byte [writei.s_index], 0 ; sector index in cluster
 14578 00012187 E912FEFFFF          <1> 	jmp	mget_w_3
 14579                              <1> 
 14580                              <1> update_file_lmdt: ; & update file size
 14581                              <1> 	; 26/10/2016
 14582                              <1> 	; 24/10/2016
 14583                              <1> 	; 23/10/2016
 14584                              <1> 	; 22/10/2016 - TRDOS 386 (TRDOS v2.0)
 14585                              <1> 	;
 14586                              <1> 	; Update last modification date&time of file
 14587                              <1> 	; (call from syswrite -> writei)
 14588                              <1> 	; ((also updates file size)) // 26/10/2016
 14589                              <1> 	; 
 14590                              <1> 	; INPUT:
 14591                              <1> 	;      byte [setfmod] = open file number
 14592                              <1> 	; OUTPUT:
 14593                              <1> 	;      cf = 0 -> success !
 14594                              <1> 	;      cf = 1 -> lmdt update has been failed! 	 
 14595                              <1> 	;
 14596                              <1> 	; Modified registers: eax, ebx, ecx, edx, esi, edi       				
 14597                              <1> 	;
 14598                              <1> 
 14599                              <1> 	;cmp	byte [setfmod], 0
 14600                              <1> 	;jna	short uflmdt_2 ; nothing to do
 14601                              <1> 
 14602 0001218C 31C0                <1> 	xor	eax, eax
 14603                              <1> 
 14604 0001218E 0FB61D[7F960100]    <1> 	movzx	ebx, byte [setfmod]
 14605 00012195 FECB                <1> 	dec	bl ; open file index number (0 based)
 14606                              <1> 
 14607 00012197 8AA3[EC990100]      <1> 	mov	ah, [ebx+OF_DRIVE]
 14608 0001219D BE00010900          <1> 	mov	esi, Logical_DOSDisks
 14609 000121A2 01C6                <1> 	add	esi, eax
 14610 000121A4 C0E302              <1> 	shl	bl, 2 ; *4	
 14611 000121A7 8B8B[C4990100]      <1> 	mov	ecx, [ebx+OF_FCLUSTER] ; first cluster
 14612 000121AD 8B93[8C9A0100]      <1> 	mov	edx, [ebx+OF_DIRCLUSTER] ; dir cluster
 14613                              <1> 
 14614 000121B3 D0EB                <1> 	shr	bl, 1 ; /2
 14615 000121B5 0FB7BB[2C9B0100]    <1> 	movzx	edi, word [ebx+OF_DIRENTRY]
 14616                              <1> 	
 14617 000121BC 803D[BC910100]01    <1> 	cmp	byte [DirBuff_ValidData], 1
 14618 000121C3 726E                <1> 	jb	short uflmdt_4
 14619                              <1> 
 14620 000121C5 A0[BA910100]        <1> 	mov	al, [DirBuff_DRV]
 14621 000121CA 2C41                <1> 	sub	al, 'A'	
 14622 000121CC 38E0                <1> 	cmp	al, ah
 14623 000121CE 7563                <1> 	jne	short uflmdt_4 ; different drive
 14624 000121D0 8A4603              <1> 	mov	al, [esi+LD_FATType] 
 14625 000121D3 3A05[BB910100]      <1> 	cmp	al, [DirBuff_FATType]
 14626 000121D9 755B                <1> 	jne	short uflmdt_5 ; different FS type
 14627 000121DB 3B15[C1910100]      <1> 	cmp	edx, [DirBuff_Cluster]
 14628 000121E1 7553                <1> 	jne	short uflmdt_5 ; different cluster
 14629                              <1> 
 14630                              <1> uflmdt_1:
 14631                              <1> 	; Directory buffer is ready here!
 14632                              <1> 	; OF_FCLUSTER must be compared/verified
 14633 000121E3 BE00000800          <1> 	mov	esi, Directory_Buffer
 14634 000121E8 66C1E705            <1> 	shl	di, 5 ; dir entry index * 32
 14635 000121EC 01FE                <1> 	add	esi, edi ; offset
 14636                              <1> 	;
 14637 000121EE F6460B18            <1> 	test	byte [esi+DirEntry_Attr], 18h ; Vol & Dir
 14638 000121F2 750F                <1> 	jnz	short uflmdt_2 ; not a valid file !
 14639 000121F4 668B4614            <1> 	mov	ax, [esi+DirEntry_FstClusHI]
 14640 000121F8 C1E010              <1> 	shl	eax, 16
 14641 000121FB 668B461A            <1> 	mov	ax, [esi+DirEntry_FstClusLO]
 14642 000121FF 39C8                <1> 	cmp	eax, ecx ; same first cluster ?
 14643 00012201 7407                <1> 	je	short uflmdt_3 ; yes, it is OK !!!	
 14644                              <1> 
 14645                              <1> uflmdt_2:	
 14646                              <1> 	; save directory buffer if has modified/changed sign
 14647                              <1> 	; (It is good to save dir buff even if the searched
 14648                              <1> 	; directory entry is not found !?)
 14649 00012203 E8AE98FFFF          <1> 	call	save_directory_buffer
 14650 00012208 F9                  <1> 	stc	; update failed
 14651 00012209 C3                  <1> 	retn
 14652                              <1> 	
 14653                              <1> uflmdt_3:
 14654                              <1> 	; Update directory entry
 14655                              <1> 	; 26/10/2016
 14656 0001220A D0E3                <1> 	shl	bl, 1 ; *2 
 14657 0001220C 8B83[3C9A0100]      <1> 	mov	eax, [ebx+OF_SIZE] ; file size
 14658 00012212 89461C              <1> 	mov	[esi+DirEntry_FileSize], eax
 14659                              <1> 	;
 14660 00012215 E8FE97FFFF          <1> 	call	convert_current_date_time
 14661                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 14662                              <1>         ; 	    AX = Time in dos dir entry format	
 14663 0001221A 66894616            <1> 	mov	[esi+DirEntry_WrtTime], ax
 14664 0001221E 66895618            <1> 	mov	[esi+DirEntry_WrtDate], dx	
 14665 00012222 66895612            <1> 	mov	[esi+DirEntry_LastAccDate], dx
 14666 00012226 C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2
 14667 0001222D E88498FFFF          <1> 	call	save_directory_buffer
 14668 00012232 C3                  <1> 	retn
 14669                              <1> 
 14670                              <1> uflmdt_4:
 14671                              <1> 	; Directory buffer sector read&write
 14672                              <1> 	; 23/10/2016
 14673                              <1> 	;
 14674 00012233 8A4603              <1> 	mov	al, [esi+LD_FATType]
 14675                              <1> uflmdt_5:
 14676 00012236 BB[9C090300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 14677                              <1> 		
 14678 0001223B 20C0                <1> 	and	al, al ; 0 = Singlix FS
 14679 0001223D 0F8492000000        <1> 	jz	uflmdt_11
 14680                              <1> 
 14681 00012243 21D2                <1> 	and	edx, edx
 14682 00012245 7521                <1> 	jnz	short uflmdt_9
 14683                              <1> 
 14684 00012247 3C02                <1> 	cmp	al, 2  ; 3 = FAT32
 14685 00012249 771A                <1> 	ja	short uflmdt_8
 14686                              <1> 
 14687 0001224B 89F8                <1> 	mov	eax, edi ; directory entry index number
 14688 0001224D 66C1E804            <1> 	shr	ax, 4 ; 16 entries per sector	 
 14689 00012251 034664              <1> 	add	eax, [esi+LD_ROOTBegin]
 14690                              <1> 	; eax = root directory sector
 14691                              <1> uflmdt_6:
 14692 00012254 50                  <1> 	push	eax ; * ; disk sector address
 14693 00012255 51                  <1> 	push	ecx ; first cluster	
 14694 00012256 B901000000          <1> 	mov	ecx, 1
 14695                              <1> 	; ecx = sector count
 14696 0001225B E8FD080000          <1> 	call	disk_read
 14697 00012260 59                  <1> 	pop	ecx
 14698 00012261 731A                <1> 	jnc	short uflmdt_10
 14699 00012263 58                  <1> 	pop	eax ; *
 14700                              <1> uflmdt_7:
 14701 00012264 C3                  <1> 	retn	
 14702                              <1> 
 14703                              <1> uflmdt_8:
 14704 00012265 8B5632              <1> 	mov	edx, [esi+LD_BPB+FAT32_RootFClust]
 14705                              <1> uflmdt_9:
 14706 00012268 83FA02              <1> 	cmp	edx, 2
 14707 0001226B 72F7                <1> 	jb	short uflmdt_7 ; invalid, nothing to do
 14708                              <1> 
 14709 0001226D 83EA02              <1> 	sub	edx, 2
 14710 00012270 89D0                <1> 	mov	eax, edx
 14711 00012272 0FB65613            <1> 	movzx	edx, byte [esi+LD_BPB+SecPerClust]
 14712 00012276 F7E2                <1> 	mul	edx
 14713 00012278 034668              <1> 	add	eax, [esi+LD_DATABegin]
 14714                              <1> 	; eax = sub directory (data) sector 
 14715 0001227B EBD7                <1> 	jmp	short uflmdt_6
 14716                              <1> 
 14717                              <1> uflmdt_10:
 14718                              <1> 	; Directory sector buffer is ready here!
 14719                              <1> 	; OF_FCLUSTER must be compared/verified
 14720                              <1> 	; edi = dir entry index number (<= 2047)
 14721 0001227D 6683E70F            <1> 	and	di, 0Fh ; 16 entries per sector
 14722 00012281 66C1E705            <1> 	shl	di, 5 ; dir entry index * 32
 14723 00012285 81C7[9C090300]      <1> 	add	edi, rw_buffer
 14724                              <1> 	;
 14725 0001228B F6470B18            <1> 	test	byte [edi+DirEntry_Attr], 18h ; Vol & Dir
 14726 0001228F 0F856EFFFFFF        <1> 	jnz	uflmdt_2 ; not a valid file !
 14727 00012295 668B5714            <1> 	mov	dx, [edi+DirEntry_FstClusHI]
 14728 00012299 C1E210              <1> 	shl	edx, 16
 14729 0001229C 668B571A            <1> 	mov	dx, [edi+DirEntry_FstClusLO]
 14730 000122A0 39CA                <1> 	cmp	edx, ecx ; same first cluster ?
 14731 000122A2 0F855BFFFFFF        <1> 	jne	uflmdt_2 ; no !?
 14732                              <1> 
 14733                              <1> 	; Update directory entry
 14734 000122A8 E86B97FFFF          <1> 	call	convert_current_date_time
 14735                              <1> 	; OUTPUT -> DX = Date in dos dir entry format
 14736                              <1>         ; 	    AX = Time in dos dir entry format	
 14737 000122AD 66894716            <1> 	mov	[edi+DirEntry_WrtTime], ax
 14738 000122B1 66895718            <1> 	mov	[edi+DirEntry_WrtDate], dx	
 14739 000122B5 66895712            <1> 	mov	[edi+DirEntry_LastAccDate], dx
 14740                              <1> 	
 14741 000122B9 58                  <1> 	pop	eax ; *
 14742                              <1> 
 14743 000122BA BB[9C090300]        <1> 	mov	ebx, rw_buffer ; Common r/w sector buffer addr
 14744 000122BF B901000000          <1> 	mov	ecx, 1
 14745                              <1> 	; esi = logical dos description table address
 14746                              <1> 	; eax = disk sector number/address (LBA)
 14747                              <1> 	; ecx = sector count
 14748                              <1> 	; ebx = buffer address
 14749 000122C4 E885080000          <1> 	call	disk_write
 14750 000122C9 0F8234FFFFFF        <1> 	jc	uflmdt_2
 14751                              <1> 	
 14752                              <1> 	; save directory buffer if has modified/changed sign
 14753 000122CF E8E297FFFF          <1> 	call	save_directory_buffer
 14754 000122D4 C3                  <1> 	retn
 14755                              <1> 
 14756                              <1> uflmdt_11:
 14757                              <1> 	; 24/10/2016
 14758                              <1> 	; Update last modification date & time of a file
 14759                              <1> 	; on a disk with Singlix File System.
 14760                              <1> 	;
 14761                              <1> 	; (Method: Read the FDT -File Description Table-
 14762                              <1> 	; sector of the file and update the lmdt data fields,
 14763                              <1> 	; then write FDT sector to the disk.
 14764                              <1> 	; /// It is easy but there is compatibility buffer
 14765                              <1> 	; method also for changing directory entry data and
 14766                              <1> 	; also there are some programming issues for Singlix
 14767                              <1> 	; file system (TRFS), which are not completed yet!)
 14768                              <1> 	;
 14769                              <1> 	; Not ready yet ! (24/10/2016)
 14770                              <1> 	; /// Temporary code for error return ! ///
 14771 000122D5 31C0                <1> 	xor	eax, eax
 14772 000122D7 F9                  <1> 	stc
 14773 000122D8 C3                  <1> 	retn
 14774                              <1> 
 14775                              <1> sysalloc:
 14776                              <1> 	; 14/10/2017
 14777                              <1> 	; 20/08/2017, 01/09/2017
 14778                              <1> 	; 20/02/2017, 04/03/2017, 15/05/2017
 14779                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 14780                              <1> 	; (TRDOS 386 feature only!)
 14781                              <1> 	;
 14782                              <1> 	; Allocate Contiguous Memory Block/Pages (for user)
 14783                              <1> 	; (System call for DMA Buffer allocation etc.)	
 14784                              <1> 	;
 14785                              <1> 	; INPUT ->
 14786                              <1> 	;	EBX = Virtual address (for user)
 14787                              <1> 	;	     (Physical memory block/aperture
 14788                              <1> 	;	     will be mapped to this virtual address) 
 14789                              <1> 	;	ECX = Byte Count
 14790                              <1> 	;	     (will be rounded up to page border)
 14791                              <1> 	;	If ECX = 0
 14792                              <1> 	;	    System call will return with an error (cf=1)
 14793                              <1> 	;	    but ECX will contain maximum size of
 14794                              <1> 	;	    available memory aperture and physical
 14795                              <1> 	;	    (beginning) address of that aperture
 14796                              <1> 	;	    (which have maximum size) will be in EAX.
 14797                              <1> 	;	EDX = Upper limit of the requested physical memory
 14798                              <1> 	;	      block/pages.
 14799                              <1> 	;	     (The last byte address of the memory aperture 
 14800                              <1> 	;	      must not be equal to or above this limit.)	
 14801                              <1> 	;	If EDX = 0
 14802                              <1> 	; 	   there is NOLIMIT !
 14803                              <1> 	;	If EDX = 0FFFFFFFFh (-1) 
 14804                              <1> 	;	   ESI = Lower Limit !
 14805                              <1> 	;		(Beginning of the block must not be 'less'
 14806                              <1> 	;		than this.) (Must be equal to or above...)
 14807                              <1> 	;	   EDI = Upper Limit !
 14808                              <1> 	;		(End of the block must be !less! than this)
 14809                              <1> 	;		(The last byte addr of the memory aperture 
 14810                              <1> 	;		must not be equal to or above this limit.)
 14811                              <1> 	;
 14812                              <1> 	; OUTPUT ->
 14813                              <1> 	;	If CF = 0
 14814                              <1> 	;	EAX = Physical address of the allocated memory block
 14815                              <1> 	;	ECX = Allocated bytes (as rounded up to page borders)
 14816                              <1> 	;	EBX = Virtual address (as rounded up)
 14817                              <1> 	;	IF CF = 1
 14818                              <1> 	;	    Requested (size of) Memory block could not be 
 14819                              <1> 	;	    allocated to the user!	
 14820                              <1> 	;	IF CF = 1 & EAX = 0 (Insufficient memory error!)
 14821                              <1> 	;	   ECX = Total number of free bytes
 14822                              <1> 	;	         (not size of available contiguous bytes!)		 	
 14823                              <1> 	;	If CF = 1 & EAX > 0
 14824                              <1> 	;	   there is not a memory aperture with requested size
 14825                              <1> 	;	   but total free mem is not less than requested size.
 14826                              <1> 	;	   EAX = Physical addr of available memory aperture
 14827                              <1> 	;	   	 with max size 
 14828                              <1> 	;	        (but it doesn't fit to the conditions!) 	
 14829                              <1> 	;	   ECX = Size of available memory aperture in bytes.
 14830                              <1> 	;	If CF = 1 -> EAX = 0FFFFFFFFh	
 14831                              <1> 	;	   Conditions/Parameters are wrong !		 		
 14832                              <1> 	;	   ECX is same with input value.
 14833                              <1> 	;
 14834                              <1> 	; Note:	Previously allocated pages will be deallocated if
 14835                              <1> 	;       new allocation conditions are met.
 14836                              <1> 	;
 14837                              <1> 	; Note: u.break control may be included in future versions	
 14838                              <1> 	;
 14839                              <1> 
 14840 000122D9 31C0                <1> 	xor	eax, eax ; 0
 14841                              <1> 	; 14/10/2017
 14842 000122DB 4A                  <1> 	dec	edx ; is there a limit ?
 14843 000122DC 7810                <1> 	js	short sysalloc_1 ;  0 -> 0FFFFFFFFh -> NO LIMIT
 14844 000122DE 42                  <1> 	inc	edx ; > 0
 14845                              <1> 	; Check upper address limit
 14846                              <1> 	;(round up to page borders)
 14847 000122DF 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
 14848 000122E5 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
 14849 000122EA 39CA                <1> 	cmp	edx, ecx ; upper limit - block size
 14850 000122EC 7224                <1> 	jb	short sysalloc_err
 14851                              <1> sysalloc_1:
 14852                              <1> 	; EAX = Beginning address (physical)
 14853                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
 14854                              <1> 	; ECX = Number of bytes to be allocated		
 14855 000122EE E88A41FFFF          <1> 	call	allocate_memory_block
 14856 000122F3 721D                <1> 	jc	short sysalloc_err
 14857                              <1> 	; 01/09/2017
 14858 000122F5 29C2                <1> 	sub	edx, eax ; upper limit address - beginning address
 14859 000122F7 760F                <1> 	jna	short sysalloc_3 ; begin addr not less than the limit
 14860 000122F9 39CA                <1> 	cmp	edx, ecx
 14861 000122FB 720B                <1> 	jb	short sysalloc_3 ; end address overs the limit
 14862                              <1> sysalloc_2:	
 14863                              <1> 	; EAX = Beginning (physical) addr of the allocated mem block
 14864                              <1> 	; ECX = Num of allocated bytes (rounded up to page borders) 
 14865 000122FD 50                  <1> 	push	eax ; * ; 04/03/2017	
 14866                              <1> 	; Here, requested contiquous memory pages have been allocated
 14867                              <1> 	; on Memory Allocation Table but user's page directory 
 14868                              <1> 	; and page tables have not been updated yet!
 14869 000122FE 51                  <1> 	push	ecx ; **
 14870                              <1> 	; ebx = virtual address (will be rounded up to page border)
 14871                              <1> 	; ecx = number of bytes to be deallocated
 14872                              <1> 	;	will be adjusted to ebx+ecx round down - ebx round up
 14873 000122FF E8D444FFFF          <1> 	call	deallocate_user_pages 
 14874 00012304 731F                <1> 	jnc	short sysalloc_4 ; EAX = Deallocated memory bytes
 14875 00012306 59                  <1> 	pop	ecx ; **
 14876 00012307 58                  <1> 	pop	eax ; *
 14877                              <1> sysalloc_3:
 14878                              <1> 	; error !
 14879                              <1> 	; restore Memory Allocation Table Content
 14880 00012308 E87D43FFFF          <1> 	call	deallocate_memory_block
 14881 0001230D 31C0                <1> 	xor	eax, eax ; 0
 14882 0001230F 48                  <1> 	dec	eax ; 0FFFFFFFFh ; 15/05/2017
 14883 00012310 EB09                <1> 	jmp	short sysalloc_wrong
 14884                              <1> sysalloc_err:
 14885 00012312 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 14886 00012318 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value 
 14887                              <1> sysalloc_wrong:
 14888                              <1> 	; eax = 0FFFFFFFFh
 14889 0001231B A3[64030300]        <1> 	mov	[u.r0], eax
 14890 00012320 E9B7B5FFFF          <1> 	jmp	error
 14891                              <1> sysalloc_4:
 14892 00012325 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 14893 0001232B 894518              <1> 	mov	[ebp+24], eax ; return to user with ecx value 
 14894 0001232E 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx (rounded up)
 14895 00012331 89C1                <1> 	mov	ecx, eax ; byte count (from 'deallocate_user_pages')
 14896 00012333 5A                  <1> 	pop	edx ; ** ; discard (another) byte count
 14897 00012334 58                  <1> 	pop	eax ; *
 14898 00012335 A3[64030300]        <1> 	mov	[u.r0], eax ; physical address
 14899                              <1> 	
 14900 0001233A 51                  <1> 	push	ecx ; 20/08/2017
 14901                              <1> 	;
 14902                              <1> 	; Write newly allocated contiguous (physical) pages
 14903                              <1> 	; on page dir and page tables of current user/process	
 14904                              <1> 	; as PRESENT, USER, WRITABLE
 14905                              <1> 	; (then clear allocated pages)
 14906 0001233B E88D45FFFF          <1> 	call	allocate_user_pages
 14907                              <1> 	;jnc	sysret ; OK! return to process with success...
 14908                              <1> 
 14909                              <1> 	; 20/08/2017 ('sysdma' modification)
 14910 00012340 59                  <1> 	pop	ecx
 14911 00012341 A1[64030300]        <1> 	mov	eax, [u.r0]   ; physical address (of the block)
 14912                              <1> 
 14913 00012346 721D                <1> 	jc	short sysalloc_6
 14914                              <1> 
 14915 00012348 833D[94A00100]FF    <1> 	cmp	dword [dma_addr], 0FFFFFFFFh ; -1	
 14916 0001234F 0F82A7B5FFFF        <1> 	jb	sysret
 14917                              <1> 
 14918 00012355 A3[94A00100]        <1> 	mov	[dma_addr], eax ; save dma address for sysdma
 14919 0001235A 890D[98A00100]      <1> 	mov	[dma_size], ecx ; save dma buff size for sysdma
 14920                              <1> 
 14921 00012360 E997B5FFFF          <1> 	jmp	sysret
 14922                              <1> 		
 14923                              <1> sysalloc_6:
 14924                              <1> 	;
 14925                              <1> 	; unexpected error ! insufficient memory !? conflict !?
 14926                              <1> 	; (!!?there is not a free page for a new page table?!!)
 14927                              <1> 	; We need to terminate process with error message !!!  
 14928                              <1> 	;
 14929 00012365 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
 14930 0001236B 8B4D18              <1> 	mov	ecx, [ebp+24] ; byte count
 14931                              <1> 	
 14932                              <1> 	; 20/08/2017
 14933                              <1> 	;mov	eax, [u.r0]   ; physical address (of the block)
 14934                              <1> 	
 14935                              <1> 	;
 14936                              <1> 	; restore Memory Allocation Table Content
 14937 0001236E E81743FFFF          <1> 	call	deallocate_memory_block
 14938                              <1> 	;
 14939 00012373 803D[CA6F0000]03    <1> 	cmp	byte [CRT_MODE], 3 ; 80x25 text mode?
 14940 0001237A 7407                <1> 	je	short sysalloc_7 ; yes
 14941                              <1> 	; Current mode is VGA (or CGA graphics) mode,
 14942                              <1> 	; We need to return to text mode for displaying
 14943                              <1> 	; error message just before 'sysexit'.  
 14944 0001237C B003                <1> 	mov	al, 3
 14945 0001237E E8E5F7FEFF          <1> 	call	_set_mode
 14946                              <1> sysalloc_7:
 14947 00012383 BE[C4430100]        <1> 	mov	esi, beep_Insufficient_Memory ; error message
 14948 00012388 E8C851FFFF          <1> 	call	print_msg ; print/display the message
 14949 0001238D B801000000          <1> 	mov	eax, 1 ; ax=1 is needed for 'sysexit' procedure
 14950 00012392 E9ECB6FFFF          <1> 	jmp	sysexit ; and terminate the process !
 14951                              <1> 
 14952                              <1> sysdalloc:
 14953                              <1> 	; 19/02/2017 - TRDOS 386 (TRDOS v2.0)
 14954                              <1> 	; (TRDOS 386 feature only!)
 14955                              <1> 	;
 14956                              <1> 	; Deallocate Memory Block/Pages (for user)
 14957                              <1> 	; (Complementary call for sysalloc.)	
 14958                              <1> 	;
 14959                              <1> 	; INPUT ->
 14960                              <1> 	;	EBX = Virtual address (for user)
 14961                              <1> 	;	      (will be rounded up to page border)
 14962                              <1> 	;	ECX = Byte Count
 14963                              <1> 	;	     (will be adjusted to page borders)
 14964                              <1> 	;	If ICX = 0
 14965                              <1> 	;	   nothing to do
 14966                              <1> 	;	If EBX + ECX > User's ESP
 14967                              <1> 	;	   nothing to do		
 14968                              <1> 	; 
 14969                              <1> 	; Note: u.break control may be included in future versions	
 14970                              <1> 	;
 14971                              <1> 	; OUTPUT ->
 14972                              <1> 	;	If CF = 0
 14973                              <1> 	;	   EAX = Deallocated memory bytes
 14974                              <1> 	;	   EBX = Virtual address (as rounded up)	
 14975                              <1> 	;	IF CF = 1
 14976                              <1> 	;	   EAX = 0
 14977                              <1> 	;
 14978                              <1> 	; Note:	Main purpose of this call is to deallocate/release
 14979                              <1> 	;	previously allocated (physically) contiguous memory
 14980                              <1> 	;	pages but beginning (virtual) address may not be
 14981                              <1> 	;	followed by physically contiguous pages. So, this
 14982                              <1> 	;	system call will deallocate user's virtually
 14983                              <1> 	;	contiguous memory pages. Also, there is not any
 14984                              <1> 	;	objections to use this system call without sysalloc
 14985                              <1> 	;	system call; only possible objection is to lost data
 14986                              <1> 	;	within user's memory space, if the beginning address
 14987                              <1> 	;	and size is not proper.
 14988                              <1> 	;
 14989                              <1> 	; Note: Empty page tables will not be deallocated!!!
 14990                              <1> 	;       (they will be deallocated at process termination)
 14991                              <1> 	;
 14992                              <1> 	; Note: When the program terminates itself or when it is 
 14993                              <1> 	;	terminated by operating system kernel, all allocated
 14994                              <1> 	;	memory pages will be deallocated during termination
 14995                              <1> 	;	stage. So, 'sysdalloc' is not necessary except 
 14996                              <1> 	;	forgiving memory block to other programs/processes.
 14997                              <1> 	;	
 14998 00012397 8B15[5C030300]      <1> 	mov	edx, [u.sp]
 14999 0001239D 8B420C              <1> 	mov	eax, [edx+12] ; user's stack pointer
 15000 000123A0 29C8                <1> 	sub	eax, ecx ; esp - byte count
 15001 000123A2 24FC                <1> 	and	al, 0FCh ; dword alignment
 15002 000123A4 39D8                <1> 	cmp	eax, ebx
 15003 000123A6 7220                <1> 	jb	short sysdalloc_err ; deallocation overlaps with stack 	
 15004                              <1> 
 15005 000123A8 31C0                <1> 	xor	eax, eax
 15006 000123AA 21C9                <1> 	and	ecx, ecx
 15007 000123AC 7407                <1> 	jz	short sysdalloc_2
 15008                              <1> 	
 15009 000123AE E82544FFFF          <1> 	call	deallocate_user_pages
 15010 000123B3 7213                <1> 	jc	short sysdalloc_err
 15011                              <1> 
 15012                              <1> sysdalloc_2:
 15013 000123B5 A3[64030300]        <1> 	mov	[u.r0], eax
 15014 000123BA 8B2D[60030300]      <1> 	mov	ebp, [u.usp]
 15015 000123C0 895D10              <1> 	mov	[ebp+16], ebx ; new value of ebx
 15016 000123C3 E934B5FFFF          <1> 	jmp	sysret
 15017                              <1> 
 15018                              <1> sysdalloc_err:
 15019 000123C8 A3[64030300]        <1> 	mov	[u.r0], eax ; 0
 15020 000123CD E90AB5FFFF          <1> 	jmp	error
 15021                              <1> 
 15022                              <1> syscalbac:
 15023                              <1> 	; SYS CALLBACK
 15024                              <1> 	; 03/08/2020
 15025                              <1> 	; 16/04/2017
 15026                              <1> 	; 14/04/2017
 15027                              <1> 	; 13/04/2017
 15028                              <1> 	; 28/02/2017
 15029                              <1> 	; 26/02/2017
 15030                              <1> 	; 24/02/2017
 15031                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
 15032                              <1> 	; (TRDOS 386 feature only!)
 15033                              <1> 	;
 15034                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
 15035                              <1> 	;
 15036                              <1> 	; INPUT ->
 15037                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
 15038                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
 15039                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
 15040                              <1> 	;	     (numbers >15 are invalid)
 15041                              <1> 	;
 15042                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
 15043                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
 15044                              <1> 	;	     2 = Link IRQ by using Callback service method 		
 15045                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
 15046                              <1> 	;	    >3 = invalid 
 15047                              <1> 	;	
 15048                              <1> 	;	CL = Signal Return/Response Byte value 
 15049                              <1> 	;
 15050                              <1> 	;	If BH = 3, kernel will put a counter value  ; 03/08/2020
 15051                              <1> 	;	          (into the S.R.B. addr)
 15052                              <1> 	;		  between 0 to 255. (start value = CL+1)
 15053                              <1> 	;	
 15054                              <1> 	;	NOTE: counter value, for example: even and odd numbers
 15055                              <1> 	;	      may be used for -audio- DMA buffer switch 
 15056                              <1> 	;	      within double buffer method, etc. 		
 15057                              <1> 	;
 15058                              <1> 	;	EDX = Signal return (Response) byte address
 15059                              <1> 	;	       		  - or -
 15060                              <1> 	;	      Interrupt/Callback service/routine address
 15061                              <1> 	; 	
 15062                              <1> 	;	      (virtual address in user's memory space)
 15063                              <1> 	;
 15064                              <1> 	; OUTPUT ->
 15065                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
 15066                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
 15067                              <1> 	;			by another process
 15068                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
 15069                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
 15070                              <1> 	;		       invalid parameter/option or bad address
 15071                              <1> 	;
 15072                              <1> 	;	NOTE: Timer callbacks are set by using 'systimer'
 15073                              <1> 	;	      system call (IRQ 0, PIT and IRQ 8, RTC)
 15074                              <1> 	;
 15075                              <1> 	;	      Direct keyboard access is performed by using
 15076                              <1> 	;	      Keyboard Interrupt (INT 32h)	 	
 15077                              <1> 	;	
 15078                              <1> 	;	      It is prohibited here because:
 15079                              <1> 	;		1) Signal Response Byte method has not advantage
 15080                              <1> 	;		   against INT 32h, function AH = 1. Also,
 15081                              <1> 	;		   keyboard service interrupt will return with
 15082                              <1> 	;		   ascii and scan codes (AL, AH) while
 15083                              <1> 	;		   SRB method has only 1 byte space for ascii code
 15084                              <1> 	;		   or scan code. One byte signal response is used 
 15085                              <1> 	;		   for ensuring very simple and very fast
 15086                              <1> 	;		   virtual to physical memory address conversion
 15087                              <1> 	;		   without any memory page crossover risk. 
 15088                              <1> 	;		   (Otherwise double page conversion or word 
 15089                              <1> 	;		   alignment would be needed.)
 15090                              <1> 	;		2) Badly written user code (callback code)
 15091                              <1> 	;		   can prevent keyboard and timesharing functions
 15092                              <1> 	;		   of the operating system via continuous and long
 15093                              <1> 	;		   keyboard event handling by callback service.
 15094                              <1> 	;		   (It can cause to lose immediate keystroke 
 15095                              <1> 	;		   response from hardware to user.)
 15096                              <1> 	;		3) If user will check any keyboard events, 'getkey'
 15097                              <1> 	;		   (or 'getchar') must have more priority than other
 15098                              <1> 	;		   (video etc.) events because only control ability
 15099                              <1> 	;		   on a procedural infinite loop is a keyboard or
 15100                              <1> 	;		   mouse event. So user can use keyboard function
 15101                              <1> 	;		   at the end or at the beginning of a loop.
 15102                              <1> 	;		   In this case, INT 32h is used for that purpose
 15103                              <1> 	;		   and timer interrupt etc. callbacks can be used
 15104                              <1> 	;		   for dynamic and synchronized data refresh/transfer
 15105                              <1> 	;		   while cpu is in a static loop (without polling).
 15106                              <1> 	;		   Keyboard Int callback is not more useful because 
 15107                              <1> 	;		   already a manual check (a key is pressed or not)
 15108                              <1> 	;		   can be performed (via INT 32h, AH = 1) efficiently
 15109                              <1> 	;		   in a loop to prevent a locked infinitive loop.
 15110                              <1> 	;
 15111                              <1> 	;	    Disk IRQs (6,14,15) have been phohibited from ring 3 
 15112                              <1> 	;	    callback because, disk operations (file system services
 15113                              <1> 	;	    etc.) are independent from user program, for fast disk r/w.
 15114                              <1> 	;	    They are not more useful at ring 3 while they are in use
 15115                              <1> 	;	    by standard diskio functions which are mandatory part of 
 15116                              <1> 	;	    (monolithic) OS kernel and mainprog command interpreter.
 15117                              <1> 	;	    INT 33h diskio functions are enough for user level disk
 15118                              <1> 	;	    r/w.				
 15119                              <1> 	;
 15120                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
 15121                              <1> 	;	
 15122                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
 15123                              <1> 	;			which IRQs are locked by (that) user.
 15124                              <1> 	;		        Lock and unlock (by user) will change
 15125                              <1> 	;			these flags or 'terminate process' (sysexit)
 15126                              <1> 	;			will clear these flags and unlock those IRQs.
 15127                              <1> 	;			               
 15128                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
 15129                              <1> 	;
 15130                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
 15131                              <1> 	;
 15132                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
 15133                              <1> 	;			   0 = Signal Response Byte method
 15134                              <1> 	;			   1 = Callback service method
 15135                              <1> 	;			   >1 = invalid for current 'syscalback'.
 15136                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
 15137                              <1> 	;			            function (audio etc.) or
 15138                              <1> 	;			   	    a device driver.	   	
 15139                              <1> 	;			(system function will ignore the lock/owner)
 15140                              <1> 	;
 15141                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
 15142                              <1> 	;			  (a fixed value by user or a counter value
 15143                              <1> 	;			 from 0 to 255, which is increased by every
 15144                              <1> 	;			 interrupt just before putting it into 
 15145                              <1> 	;			 the Signal Response byte address
 15146                              <1> 	;			 (This is not used in callback serv method)
 15147                              <1> 	;	    	  
 15148                              <1> 	;	   IRQ(x).addr	: 1 dword
 15149                              <1> 	;			  Signal Response Byte address (physical)
 15150                              <1> 	;			  		-or-
 15151                              <1> 	;			  Callback service address (virtual)
 15152                              <1> 	;
 15153                              <1> 	;	   IRQ(x).dev	: 1 byte
 15154                              <1> 	;			  0 = Default device or kernel function
 15155                              <1> 	;			  		-or-
 15156                              <1> 	;			  1-255 = Assigned device driver number
 15157                              <1> 	;
 15158                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
 15159                              <1> 	;
 15160                              <1> 	;	
 15161                              <1> 	;	NOTE: If user's process/program calls the kernel (INT 40h)
 15162                              <1> 	;	      while it is already running in a (ring 3) callback
 15163                              <1> 	;	      service, kernel will force (convert) system call to
 15164                              <1> 	;	      'sysrele' (sys release). So, this feature provides
 15165                              <1> 	;	      easy and simple usage of callback services without
 15166                              <1> 	;	      falling into deepless <please 'callback me' then 
 15167                              <1> 	;	      let me 'callback you'> cycles! (User must return
 15168                              <1> 	;	      from callback service by using 'sysrele' system
 15169                              <1> 	;	      call, without a significant delay. Otherwise user
 15170                              <1> 	;	      process/program may be late to catch the next event
 15171                              <1> 	;	      within same callback purpose.	    		 	
 15172                              <1> 	;
 15173                              <1> 
 15174 000123D2 30C0                <1> 	xor	al, al ; the caller is 'syscalbac' sign/flag
 15175 000123D4 E85F180000          <1>  	call	set_irq_callback_service
 15176                              <1> 	; 16/04/2017
 15177 000123D9 A3[64030300]        <1> 	mov	[u.r0], eax
 15178 000123DE 0F8318B5FFFF        <1> 	jnc	sysret
 15179 000123E4 A3[C8030300]        <1> 	mov	dword [u.error], eax
 15180 000123E9 E9EEB4FFFF          <1> 	jmp	error
 15181                              <1> 
 15182                              <1> sysfpstat:
 15183                              <1> 	; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
 15184                              <1> 	; (TRDOS 386 feature only!)
 15185                              <1> 	;
 15186                              <1> 	; Set or reset FPU registers save/restore option (for user)
 15187                              <1> 	;	       (during software task switching, wswap-rswap)
 15188                              <1> 	;
 15189                              <1> 	; INPUT ->
 15190                              <1> 	;	BL = 0 -> reset
 15191                              <1> 	;	BL = 1 -> set (FPU register will be saved and restored)
 15192                              <1> 	;	
 15193                              <1> 	; OUTPUT ->
 15194                              <1> 	;	cf = 0 -> no error, FPU is ready... 
 15195                              <1> 	;		  (EAX = 0)
 15196                              <1> 	;	Cf = 1 -> error, 80387 FPU is not ready !
 15197                              <1> 	;		  (EAX = 0FFFFFFFFh)
 15198                              <1> 
 15199 000123EE 31C0                <1> 	xor	eax, eax
 15200 000123F0 803D[8C960100]00    <1> 	cmp	byte [fpready], 0
 15201 000123F7 7613                <1> 	jna	short sysfpstat_err	
 15202                              <1> 
 15203 000123F9 80E301              <1> 	and	bl, 1 ; use BIT 0 only !
 15204 000123FC 881D[DA030300]      <1> 	mov	[u.fpsave], bl
 15205 00012402 A3[64030300]        <1> 	mov	[u.r0], eax ; 0
 15206 00012407 E9F0B4FFFF          <1> 	jmp	sysret	 	
 15207                              <1> 
 15208                              <1> sysfpstat_err:
 15209 0001240C 48                  <1> 	dec 	eax ; 0FFFFFFFFh
 15210 0001240D A3[64030300]        <1> 	mov 	[u.r0], eax ; -1
 15211 00012412 E9C5B4FFFF          <1> 	jmp 	error
 15212                              <1> 
 15213                              <1> sysdelete: ; Delete (Remove, Unlink) File
 15214                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15215                              <1> 	;	
 15216                              <1>         ; INPUT ->
 15217                              <1>         ;          EBX = File name (ASCIIZ string) address
 15218                              <1> 	; OUTPUT ->
 15219                              <1> 	;          cf = 0 -> eax = 0
 15220                              <1> 	;          cf = 1 -> Error code in AL
 15221                              <1> 	;
 15222                              <1> 	; Modified Registers: EAX (at the return of system call)
 15223                              <1> 	;   
 15224                              <1> 
 15225 00012417 89DE                <1> 	mov	esi, ebx
 15226                              <1> 	; file name is forced, change directory as temporary
 15227                              <1> 	;mov	ax, 1
 15228                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 15229                              <1> 	;call	set_working_path 
 15230 00012419 E8620B0000          <1> 	call	set_working_path_x
 15231 0001241E 731D                <1> 	jnc	short sysdelete_1
 15232                              <1> 
 15233 00012420 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 15234 00012422 7505                <1> 	jnz	short sysdelete_err
 15235                              <1> 	; eax = 0
 15236                              <1> sysdelete_path_err:
 15237 00012424 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 15238                              <1> sysdelete_err:
 15239 00012429 A3[64030300]        <1> 	mov	[u.r0], eax
 15240 0001242E A3[C8030300]        <1> 	mov	[u.error], eax
 15241 00012433 E81D0C0000          <1> 	call 	reset_working_path
 15242 00012438 E99FB4FFFF          <1> 	jmp	error
 15243                              <1> sysdelete_1:
 15244                              <1> 	;mov	esi, FindFile_Name
 15245 0001243D 66B80018            <1> 	mov	ax, 1800h ; Only files
 15246 00012441 E83B70FFFF          <1> 	call	find_first_file
 15247 00012446 72E1                <1> 	jc	short sysdelete_err
 15248                              <1> sysdelete_2:
 15249                              <1> 	; check file attributes
 15250                              <1> 
 15251                              <1> 	;test	bl, 17 ; system, hidden, readonly, directory
 15252 00012448 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 15253 0001244B 7407                <1>         jz	short sysdelete_3
 15254                              <1> 
 15255 0001244D B80B000000          <1>         mov	eax, ERR_FILE_ACCESS ; 11 = 'permission denied !'
 15256 00012452 EBD5                <1>         jmp	short sysdelete_err
 15257                              <1> sysdelete_3:
 15258 00012454 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 15259 00012457 7407                <1> 	jz	short sysdelete_4
 15260 00012459 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 26 = 'invalid file name !'
 15261 0001245E EBC9                <1>         jmp	short sysdelete_err
 15262                              <1> sysdelete_4:
 15263                              <1> 	;mov	bh, [LongName_EntryLength]
 15264 00012460 883D[FE930100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 15265                              <1> 	; edi = Directory Entry Offset (DirBuff)
 15266                              <1> 	; esi = Directory Entry (FFF Structure)
 15267 00012466 E89399FFFF          <1> 	call	remove_file
 15268 0001246B 72BC                <1> 	jc	short sysdelete_err
 15269                              <1> sysrmdir_5:
 15270 0001246D 31C0                <1> 	xor	eax, eax ; 0
 15271 0001246F A3[64030300]        <1> 	mov	[u.r0], eax
 15272                              <1> 	;mov	[u.error], eax
 15273 00012474 E8DC0B0000          <1> 	call 	reset_working_path
 15274 00012479 E97EB4FFFF          <1> 	jmp	sysret
 15275                              <1> 
 15276                              <1> 
 15277                              <1> sysrmdir: ; Remove (Unlink) Directory
 15278                              <1> 	; 19/01/2021
 15279                              <1> 	; 29/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15280                              <1> 	;	
 15281                              <1>         ; INPUT ->
 15282                              <1>         ;          EBX = Pointer to directory name
 15283                              <1> 	; OUTPUT ->
 15284                              <1> 	;          cf = 0 -> eax = 0
 15285                              <1> 	;          cf = 1 -> Error code in AL
 15286                              <1> 	;
 15287                              <1> 	; Modified Registers: EAX (at the return of system call)
 15288                              <1> 	;  
 15289                              <1> 
 15290                              <1> 	; 19/01/2021
 15291 0001247E 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 15292 00012485 7614                <1> 	jna	short sysrmdir_0
 15293                              <1> 
 15294                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 15295 00012487 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; ERR_NOT_SUPERUSER
 15296 0001248C A3[64030300]        <1> 	mov	[u.r0], eax
 15297 00012491 A3[C8030300]        <1> 	mov	[u.error], eax
 15298 00012496 E941B4FFFF          <1> 	jmp	error
 15299                              <1> 
 15300                              <1> sysrmdir_0:
 15301 0001249B 89DE                <1> 	mov	esi, ebx
 15302                              <1> 	; file name is forced, change directory as temporary
 15303                              <1> 	;mov	ax, 1
 15304                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 15305                              <1> 	;call	set_working_path 
 15306 0001249D E8DE0A0000          <1> 	call	set_working_path_x
 15307 000124A2 731D                <1> 	jnc	short sysrmdir_1
 15308                              <1> 
 15309 000124A4 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 15310 000124A6 7505                <1> 	jnz	short sysrmdir_err
 15311                              <1> 	; eax = 0
 15312                              <1> sysrmdir_not_found:
 15313 000124A8 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 15314                              <1> sysrmdir_err:
 15315 000124AD A3[64030300]        <1> 	mov	[u.r0], eax
 15316 000124B2 A3[C8030300]        <1> 	mov	[u.error], eax
 15317 000124B7 E8990B0000          <1> 	call 	reset_working_path
 15318 000124BC E91BB4FFFF          <1> 	jmp	error
 15319                              <1> sysrmdir_1:
 15320                              <1> 	;mov	esi, FindFile_Name
 15321 000124C1 66B81008            <1> 	mov	ax, 0810h ; Only directories
 15322 000124C5 E8B76FFFFF          <1> 	call	find_first_file
 15323 000124CA 7306                <1> 	jnc	short sysrmdir_2
 15324                              <1> 
 15325                              <1> 	; eax = 2 (File not found !)
 15326 000124CC 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 15327 000124CE 74D8                <1> 	je	short sysrmdir_not_found
 15328 000124D0 EBDB                <1> 	jmp	short sysrmdir_err
 15329                              <1> sysrmdir_2:
 15330                              <1> 	; check directory attributes
 15331                              <1> 
 15332 000124D2 F6C307              <1>         test	bl, 7 ; system, hidden, readonly 
 15333 000124D5 7407                <1>         jz	short sysrmdir_3
 15334                              <1> 
 15335 000124D7 B80B000000          <1>         mov	eax, ERR_DIR_ACCESS ; 11 = 'permission denied !'
 15336 000124DC EBCF                <1>         jmp	short sysrmdir_err
 15337                              <1> sysrmdir_3:
 15338 000124DE 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 15339 000124E1 7407                <1> 	jz	short sysrmdir_4
 15340                              <1> 	;mov	eax, ERR_NOT_DIR ; 'not a valid directory !'
 15341 000124E3 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'bad path name !'
 15342 000124E8 EBC3                <1>         jmp	short sysrmdir_err
 15343                              <1> sysrmdir_4:
 15344                              <1> 	;mov	bh, [LongName_EntryLength]
 15345 000124EA 883D[FE930100]      <1> 	mov	[DelFile_LNEL], bh ; Long name entry length (if > 0)
 15346                              <1> 	; edi = Directory Entry Offset (DirBuff)
 15347                              <1> 	; esi = Directory Entry (FFF Structure)
 15348 000124F0 E86176FFFF          <1> 	call	delete_sub_directory
 15349 000124F5 0F8372FFFFFF        <1> 	jnc	sysrmdir_5
 15350                              <1> ;	jc	short sysrmdir_6
 15351                              <1> ;
 15352                              <1> ;	xor	eax, eax ; 0
 15353                              <1> ;sysrmdir_5:
 15354                              <1> ;	mov	[u.r0], eax
 15355                              <1> ;	;mov	[u.error], eax
 15356                              <1> ;	call 	reset_working_path
 15357                              <1> ;	jmp	sysret
 15358                              <1> sysrmdir_6:
 15359 000124FB A3[64030300]        <1> 	mov	[u.r0], eax
 15360 00012500 A3[C8030300]        <1> 	mov	[u.error], eax
 15361                              <1> 
 15362 00012505 09C0                <1> 	or	eax, eax ; EAX = 0 -> Directory not empty!
 15363 00012507 741C                <1> 	jz	short sysrmdir_9
 15364                              <1> 
 15365                              <1> 	; EAX > 0 -> Error code in AL (or AX or EAX)
 15366                              <1> 
 15367 00012509 833D[B2910100]01    <1> 	cmp	dword [FAT_ClusterCounter], 1
 15368 00012510 7209                <1> 	jb	short sysrmdir_8
 15369                              <1> sysrmdir_7:
 15370                              <1> 	; ESI = Logical DOS Drive Description Table address	
 15371 00012512 66BB00FF            <1> 	mov	bx, 0FF00h ; BH = FFh -> use ESI for Drive parameters
 15372                              <1> 	           ; BL = 0 -> Recalculate free cluster count
 15373 00012516 E8C7AEFFFF          <1> 	call	calculate_fat_freespace	
 15374                              <1> sysrmdir_8:
 15375 0001251B E8350B0000          <1> 	call 	reset_working_path
 15376 00012520 E9B7B3FFFF          <1> 	jmp	error
 15377                              <1> 
 15378                              <1> sysrmdir_9:
 15379 00012525 A1[B2910100]        <1> 	mov	eax, [FAT_ClusterCounter]
 15380 0001252A 09C0                <1> 	or	eax, eax ; 0 ?
 15381 0001252C 0F847BFFFFFF        <1> 	jz	sysrmdir_err
 15382                              <1> 	; ESI = Logical DOS Drive Description Table address	
 15383 00012532 66BB01FF            <1> 	mov	bx, 0FF01h ; BH = FFh -> use ESI for Drive parameters
 15384                              <1> 	           ; BL = 1 -> add free clusters
 15385 00012536 E8A7AEFFFF          <1> 	call	calculate_fat_freespace
 15386 0001253B 09C9                <1> 	or	ecx, ecx
 15387 0001253D 74DC                <1>         jz	short sysrmdir_8 ; ecx = 0 -> OK
 15388                              <1> 	; ecx > 0 -> Error (Recalculation is needed)
 15389 0001253F EBD1                <1> 	jmp	short sysrmdir_7
 15390                              <1> 
 15391                              <1> 
 15392                              <1> syschdir: ; Change Current (Working) Drive & Directory (for user)
 15393                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15394                              <1> 	;	
 15395                              <1>         ; INPUT ->
 15396                              <1>         ;          EBX = Directory name (ASCIIZ string) address
 15397                              <1> 	; OUTPUT ->
 15398                              <1> 	;          cf = 0 -> eax = 0
 15399                              <1> 	;          cf = 1 -> Error code in AL
 15400                              <1> 	;
 15401                              <1> 	; Modified Registers: EAX (at the return of system call)
 15402                              <1> 	;
 15403                              <1> 	; NOTE: If drive name is not included, only the working
 15404                              <1> 	; directory (for user, not for drive/OS) will be chanded.
 15405                              <1> 	; If there is a drive name (as A:, B:, C:, D: etc.)
 15406                              <1> 	; at the beginning of the ASCIIZ (directory) string,
 15407                              <1> 	; working drive and working directory (for user) 
 15408                              <1> 	; will be changed together.
 15409                              <1> 	; (When the program is terminated, MainProg -internal 
 15410                              <1> 	; shell- will reset working directory to the previous
 15411                              <1> 	; -current- logical drive's current directory again.) 	
 15412                              <1>   
 15413 00012541 89DE                <1> 	mov	esi, ebx
 15414                              <1> 	; file name is not forced, change directory as temporary
 15415 00012543 31C0                <1> 	xor	eax, eax
 15416                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 15417                              <1> 	;call	set_working_path 
 15418 00012545 E83A0A0000          <1> 	call	set_working_path_xx
 15419 0001254A 731D                <1> 	jnc	short syschdir_ok
 15420 0001254C 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 15421 0001254E 7505                <1> 	jnz	short syschdir_err
 15422                              <1> 	; eax = 0
 15423                              <1> syschdir_not_found:
 15424 00012550 B80C000000          <1> 	mov	eax, ERR_DIR_NOT_FOUND ; Directory not found !
 15425                              <1> syschdir_err:
 15426 00012555 A3[64030300]        <1> 	mov	[u.r0], eax
 15427 0001255A A3[C8030300]        <1> 	mov	[u.error], eax
 15428 0001255F E8F10A0000          <1> 	call 	reset_working_path
 15429 00012564 E973B3FFFF          <1> 	jmp	error
 15430                              <1> syschdir_ok:
 15431 00012569 31C0                <1> 	xor	eax, eax ; 0
 15432 0001256B A3[64030300]        <1> 	mov	[u.r0], eax
 15433                              <1> 	;mov	[u.error], eax
 15434 00012570 E987B3FFFF          <1> 	jmp	sysret
 15435                              <1> 
 15436                              <1> 
 15437                              <1> syschmod: ; Get & Change File (or Directory) Attributes
 15438                              <1> 	; 19/01/2021
 15439                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15440                              <1> 	;	
 15441                              <1>         ; INPUT ->
 15442                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 15443                              <1> 	;	    CL = New attributes (if CL < 40h)
 15444                              <1> 	;	    CL >= 40h -> Get File Attributes		
 15445                              <1> 	; OUTPUT ->
 15446                              <1> 	;          cf = 0 -> EAX = File attributes (in AL)
 15447                              <1> 	;          cf = 1 -> Error code in AL
 15448                              <1> 	;
 15449                              <1> 	; Modified Registers: EAX (at the return of system call)
 15450                              <1> 	;  
 15451                              <1> 	; MSDOS File Attributes:    (bit value of attrib byte)
 15452                              <1> 	;	ATTR_READ_ONLY	=	01h  (bit 0, 'R')
 15453                              <1> 	;	ATTR_HIDDEN	=	02h  (bit 1, 'H')
 15454                              <1> 	;	ATTR_SYSTEM	=	04h  (bit 2, 'S')
 15455                              <1> 	;	ATTR_VOLUME_ID	=	08h  (bit 3)
 15456                              <1> 	;	ATTR_DIRECTORY	=	10h  (bit 4)
 15457                              <1> 	;	ATTR_ARCHIVE	=	20h  (bit 5, 'A')
 15458                              <1> 	;	ATTR_LONG_NAME	=	ATTR_READONLY |
 15459                              <1> 	;				ATTR_HIDDEN |
 15460                              <1> 	;				ATTR_SYSTEM |
 15461                              <1> 	;				ATTR_VOLUME_ID				
 15462                              <1> 	;	The upper two bits of attributes must be 0.
 15463                              <1> 
 15464                              <1> 	; Note:	* If ATTR_DIRECTORY is set, only directory names
 15465                              <1> 	;	  will be searched (and S,H,R,A attributeds of 
 15466                              <1> 	;	  the directory will be changed.)
 15467                              <1> 	;	* If ATTR_VOLUME_ID is set, 'syschmod' system call
 15468                              <1> 	;	  will return with 'permission denied' error.
 15469                              <1> 	;	* If ATTR_DIRECTORY is not set, only file names
 15470                              <1> 	;	  will be searched (and S,H,R,A attributes of the
 15471                              <1> 	;	  file will be changed.)
 15472                              <1> 	;
 15473                              <1> 	; (Ony Super User can change S,H,R attributes.) 
 15474                              <1> 
 15475 00012575 80F940              <1> 	cmp	cl, 40h	
 15476 00012578 7327                <1> 	jnb	short syschmod_0
 15477                              <1> 
 15478 0001257A F6C108              <1> 	test	cl, 08h ; ATTR_VOLUME_ID
 15479 0001257D 750E                <1> 	jnz	short syschmod_perm_err
 15480                              <1> 
 15481                              <1> 	; 19/01/2021
 15482 0001257F 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 15483 00012586 7619                <1> 	jna	short syschmod_0
 15484                              <1> 
 15485                              <1> 	; Not super user..
 15486 00012588 F6C107              <1> 	test	cl, 07h	; S,H,R attributes
 15487 0001258B 7414                <1> 	jz	short syschmod_0
 15488                              <1> 
 15489                              <1> syschmod_perm_err:
 15490                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 15491 0001258D B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 15492 00012592 A3[64030300]        <1> 	mov	[u.r0], eax
 15493 00012597 A3[C8030300]        <1> 	mov	[u.error], eax
 15494 0001259C E93BB3FFFF          <1> 	jmp	error
 15495                              <1> 
 15496                              <1> syschmod_0:
 15497 000125A1 880D[4C940100]      <1> 	mov	[Attributes], cl
 15498 000125A7 89DE                <1> 	mov	esi, ebx
 15499                              <1> 	; file name is forced, change directory as temporary
 15500                              <1> 	;mov	ax, 1
 15501                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 15502                              <1> 	;call	set_working_path 
 15503 000125A9 E8D2090000          <1> 	call	set_working_path_x
 15504 000125AE 731D                <1> 	jnc	short syschmod_1
 15505 000125B0 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 15506 000125B2 7505                <1> 	jnz	short syschmod_err
 15507                              <1> 	; eax = 0
 15508                              <1> syschmod_path_not_found:
 15509 000125B4 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 15510                              <1> syschmod_err:
 15511 000125B9 A3[64030300]        <1> 	mov	[u.r0], eax
 15512 000125BE A3[C8030300]        <1> 	mov	[u.error], eax
 15513 000125C3 E88D0A0000          <1> 	call 	reset_working_path
 15514 000125C8 E90FB3FFFF          <1> 	jmp	error
 15515                              <1> syschmod_1:
 15516 000125CD B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 15517 000125CF A0[4C940100]        <1> 	mov	al, [Attributes]
 15518 000125D4 2410                <1> 	and	al, 10h ;
 15519                              <1> 	;mov	esi, FindFile_Name
 15520                              <1> 	;mov	ax, 1800h ; Only files
 15521                              <1> 	;mov	ax, 0810h ; Only directories
 15522 000125D6 E8A66EFFFF          <1> 	call	find_first_file
 15523                              <1> 	;jnc	short syschmod_2
 15524 000125DB 72DC                <1> 	jc	short syschmod_err
 15525                              <1> 
 15526                              <1> 	;; eax = 2 (File not found !)
 15527                              <1> 	;cmp	al, 2 ; ERR_NOT_FOUND
 15528                              <1> 	;jne	short syschmod_err
 15529                              <1> 
 15530                              <1> 	;and	byte [Attributes], 10h
 15531                              <1> 	;jz	short syschmod_err
 15532                              <1> 
 15533                              <1> 	;; Directory not found !
 15534                              <1> 	;mov	al, 3 ; ERR_PATH_NOT_FOUND
 15535                              <1> 	;jmp	short syschmod_err
 15536                              <1> 
 15537                              <1> syschmod_2:
 15538 000125DD 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 15539 000125E0 7407                <1> 	jz	short syschmod_3
 15540 000125E2 B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 15541 000125E7 EBD0                <1>         jmp	short syschmod_err
 15542                              <1> syschmod_3:
 15543                              <1> 	; EDI = Directory buffer entry offset/address
 15544                              <1> 	; BL = File (or Directory) Attributes 
 15545                              <1> 	; mov	bl, [EDI+0Bh]
 15546                              <1> 
 15547                              <1> 	; check directory attributes
 15548 000125E9 8A3D[4C940100]      <1> 	mov	bh, [Attributes] ; new attributes
 15549 000125EF 80FF40              <1> 	cmp	bh, 40h  ;>=40 -> get file/directory attributes
 15550 000125F2 732D                <1> 	jnb	short syschmod_6
 15551                              <1> 
 15552                              <1> 	; set file/directory attributes
 15553 000125F4 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 15554 000125F7 7409                <1>         jz	short syschmod_4
 15555                              <1> 
 15556                              <1> 	; 19/01/2021
 15557 000125F9 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 15558 00012600 778B                <1> 	ja	short syschmod_perm_err
 15559                              <1> syschmod_4:
 15560 00012602 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 15561 00012608 7424                <1> 	je	short syschmod_7
 15562                              <1> 
 15563 0001260A 887F0B              <1> 	mov	[edi+0Bh], bh    ; Attributes (New!)
 15564                              <1> 
 15565 0001260D C605[BC910100]02    <1> 	mov	byte [DirBuff_ValidData], 2 ; modified sign
 15566                              <1> 					    ; to force write	
 15567 00012614 E89D94FFFF          <1> 	call 	save_directory_buffer
 15568 00012619 729E                <1> 	jc	short syschmod_err
 15569                              <1> 
 15570                              <1> syschmod_5:
 15571 0001261B 8A1D[4C940100]      <1> 	mov	bl, [Attributes]
 15572                              <1> syschmod_6:
 15573 00012621 0FB6C3              <1> 	movzx	eax, bl
 15574 00012624 A3[64030300]        <1> 	mov	[u.r0], eax
 15575                              <1> 	;mov	dword [u.error], 0
 15576 00012629 E9CEB2FFFF          <1> 	jmp	sysret
 15577                              <1> 
 15578                              <1> syschmod_7:
 15579 0001262E 29C0                <1> 	sub	eax, eax
 15580 00012630 8A25[BA910100]      <1>         mov     ah, [DirBuff_DRV]
 15581 00012636 BE00010900          <1> 	mov	esi, Logical_DOSDisks
 15582 0001263B 01C6                <1>         add     esi, eax
 15583 0001263D 807E04A1            <1>         cmp     byte [esi+LD_FSType], 0A1h
 15584 00012641 7307                <1> 	jnc	short syschmod_8
 15585 00012643 B01D                <1> 	mov	al, ERR_INV_DATA ; 29 = Invalid Data
 15586 00012645 E96FFFFFFF          <1> 	jmp	syschmod_err
 15587                              <1> 
 15588                              <1> syschmod_8:
 15589                              <1> 	; BH = New MS-DOS File Attributes
 15590 0001264A 88F8                <1> 	mov	al, bh ; File/Directory Attributes
 15591 0001264C 30E4                <1> 	xor	ah, ah ; Attributes in MS-DOS format sign	  
 15592 0001264E E88C7FFFFF          <1> 	call	change_fs_file_attributes
 15593 00012653 0F8260FFFFFF        <1> 	jc	syschmod_err
 15594 00012659 EBC0                <1> 	jmp	short syschmod_5
 15595                              <1> 
 15596                              <1> 
 15597                              <1> sysdrive: ; Get/Set Current (Working) Drive (for user)
 15598                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15599                              <1> 	;	
 15600                              <1>         ; INPUT ->
 15601                              <1>         ;          BL = Logical DOS Drive number (0=A: ... 2=C:)
 15602                              <1> 	;	   If BL = 0FFh -> Get Current Drive 	
 15603                              <1> 	; OUTPUT ->
 15604                              <1> 	;          cf = 0 -> 
 15605                              <1> 	;		   AL = Current Drive number	
 15606                              <1> 	;		   AH = The Last Logical DOS Drive no.
 15607                              <1> 	;          cf = 1 -> Error code in AL
 15608                              <1> 	;
 15609                              <1> 	; Modified Registers: EAX (at the return of system call)
 15610                              <1> 	;
 15611                              <1> 	; NOTE: If the requested logical dos drive is ready, 
 15612                              <1> 	;	it's current current directory will be the user's
 15613                              <1> 	;	(program's) current directory.
 15614                              <1> 	;	(When the program is terminated, MainProg -internal 
 15615                              <1> 	;	shell- will reset the previous -current- logical drive
 15616                              <1> 	;       as current drive again).	
 15617                              <1>   
 15618 0001265B 80FBFF              <1> 	cmp	bl, 0FFh
 15619 0001265E 7435                <1> 	je	short sysdrive_ok
 15620 00012660 3A1D[62400100]      <1> 	cmp	bl, [Last_DOS_DiskNo]
 15621 00012666 771E                <1> 	ja	short sysdrive_err	
 15622                              <1> 
 15623                              <1> 	; Save current drive and reset mode
 15624                              <1> 	; for 'reset_working_path' procedure (for MainProg)
 15625 00012668 30C0                <1> 	xor	al, al
 15626 0001266A 66A3[88960100]      <1> 	mov	[SWP_Mode], ax ; ah = 0
 15627 00012670 A0[968A0100]        <1> 	mov	al, [Current_Drv]
 15628 00012675 FEC4                <1> 	inc	ah ; mov ah, 1
 15629 00012677 66A3[8A960100]      <1> 	mov	[SWP_DRV], ax 
 15630                              <1> 
 15631 0001267D 88DA                <1> 	mov	dl, bl
 15632 0001267F E85A5AFFFF          <1> 	call	change_current_drive
 15633 00012684 730F                <1> 	jnc	short sysdrive_ok
 15634                              <1> sysdrive_err:
 15635 00012686 C705[64030300]0F00- <1> 	mov	dword [u.r0], ERR_DRV_NOT_RDY ; 'drive not ready !'
 15635 0001268E 0000                <1>
 15636 00012690 E947B2FFFF          <1> 	jmp	error
 15637                              <1> sysdrive_ok:
 15638 00012695 A0[968A0100]        <1> 	mov	al, [Current_Drv]
 15639 0001269A 8A25[62400100]      <1> 	mov	ah, [Last_DOS_DiskNo]
 15640 000126A0 A3[64030300]        <1> 	mov	[u.r0], eax
 15641 000126A5 E952B2FFFF          <1> 	jmp	sysret
 15642                              <1> 
 15643                              <1> 
 15644                              <1> sysdir: ; Get Current (Working) Drive & Directory (for user)
 15645                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15646                              <1> 	;	
 15647                              <1>         ; INPUT ->
 15648                              <1>         ;          EBX = Current directory name buffer address
 15649                              <1> 	;		(Buffer length = 92 bytes)
 15650                              <1> 	; OUTPUT ->
 15651                              <1> 	;          AL = Current drive (0=A: .. 2=C:)
 15652                              <1> 	;	   If CF = 1 -> AL = error code
 15653                              <1> 	;
 15654                              <1> 	; Modified Registers: EAX (at the return of system call)
 15655                              <1> 	;
 15656                              <1> 	; Note: Required directory name buffer length may be 
 15657                              <1> 	;	<= 92 bytes for current TRDOS 386 version.
 15658                              <1> 	;	(7*12 name chars + 7 slash + 0)
 15659                              <1> 
 15660 000126AA 89E5                <1> 	mov	ebp, esp
 15661 000126AC 83EC60              <1> 	sub	esp, 96
 15662 000126AF 53                  <1> 	push	ebx ; User's buffer address
 15663 000126B0 30D2                <1> 	xor	dl, dl ; 0 = current drive
 15664 000126B2 E82389FFFF          <1>   	call	get_current_directory
 15665 000126B7 72CD                <1> 	jc	short sysdrive_err ; 'drive not ready !' error
 15666 000126B9 89E6                <1> 	mov	esi, esp ; System's buffer address
 15667 000126BB 5F                  <1> 	pop	edi  ; User's buffer address
 15668                              <1> 	; ecx = transfer (byte) count (<=92)
 15669 000126BC E843F4FFFF          <1> 	call	transfer_to_user_buffer
 15670 000126C1 89EC                <1> 	mov	esp, ebp
 15671 000126C3 730F                <1> 	jnc	short sysdir_ok
 15672                              <1> sysdir_err:
 15673 000126C5 C705[64030300]2E00- <1> 	mov	dword [u.r0], ERR_BUFFER  ; 'buffer error !'
 15673 000126CD 0000                <1>
 15674 000126CF E908B2FFFF          <1> 	jmp	error
 15675                              <1> sysdir_ok:	
 15676 000126D4 8A0D[968A0100]      <1> 	mov	cl, [Current_Drv]
 15677 000126DA 890D[64030300]      <1> 	mov	[u.r0], ecx
 15678 000126E0 E917B2FFFF          <1> 	jmp	sysret
 15679                              <1> 
 15680                              <1> 
 15681                              <1> sysldrvt: ; Get copy of Logical DOS Drive Description Table
 15682                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15683                              <1> 	;	
 15684                              <1>         ; INPUT ->
 15685                              <1> 	;	    BL = Logical DOS drive number (zero based)	
 15686                              <1>         ;          ECX = Logical DOS drv desc table buffer addr
 15687                              <1> 	;		(Buffer length = 256 bytes)
 15688                              <1> 	; OUTPUT ->
 15689                              <1> 	;          cf = 0 -> 
 15690                              <1> 	;		   AL = Current Drive number	
 15691                              <1> 	;		   AH = The Last Logical DOS Drive no.
 15692                              <1> 	;          cf = 1 -> Error code in AL
 15693                              <1> 	;		   AH = The Last Logical DOS Drive no.
 15694                              <1> 	;
 15695                              <1> 	; Modified Registers: EAX (at the return of system call)
 15696                              <1> 	;
 15697                              <1> 	; Note: Required description table buffer length is
 15698                              <1> 	;	256 bytes for current TRDOS 386 version.
 15699                              <1> 	
 15700 000126E5 89CF                <1> 	mov	edi, ecx ; Destination address (user space)
 15701 000126E7 88DC                <1> 	mov	ah, bl
 15702 000126E9 30C0                <1> 	xor	al, al
 15703 000126EB BE00010900          <1> 	mov	esi, Logical_DOSDisks
 15704 000126F0 01C6                <1> 	add	esi, eax ; Source address (system space)	 
 15705 000126F2 B900010000          <1> 	mov	ecx, 256 ; Byte count 
 15706                              <1> 			 ; Logical Dos Drv Desc Table size
 15707 000126F7 E808F4FFFF          <1> 	call	transfer_to_user_buffer
 15708 000126FC 72C7                <1> 	jc	short sysdir_err
 15709 000126FE 8A2D[62400100]      <1> 	mov	ch, [Last_DOS_DiskNo]
 15710 00012704 EBCE                <1> 	jmp	short sysdir_ok
 15711                              <1> 
 15712                              <1> 
 15713                              <1> systime: ; Get System Date&Time
 15714                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15715                              <1> 	;	
 15716                              <1>         ; INPUT -> BL =
 15717                              <1> 	;	    0 = Get Date&Time in Unix/Epoch format
 15718                              <1> 	;	    1 = Get Time in MSDOS format
 15719                              <1> 	;	    2 = Get Date in MSDOS format
 15720                              <1> 	;	    3 = Get Date&Time in MSDOS format
 15721                              <1> 	;	    4 & other values =
 15722                              <1> 	;		System timer ticks will be returned
 15723                              <1> 	;		in EAX and Carry Flag will be set.
 15724                              <1> 	;		(CF will not be set if BL = 4)	 	
 15725                              <1> 	; OUTPUT ->
 15726                              <1> 	;	For BL input = 3
 15727                              <1> 	;          EAX = Current Time (RTC)
 15728                              <1> 	;		AL = Second (DL in MSDOS)
 15729                              <1> 	;		AH = Minute (CL in MSDOS)
 15730                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 15731                              <1> 	;	   EDX = Current System Date (RTC)
 15732                              <1> 	;		DL = Day (DL in MSDOS)
 15733                              <1> 	;		DH = Month (DH in MSDOS)
 15734                              <1> 	;		HW of EDX = Year (CX in MSDOS)	
 15735                              <1> 	;
 15736                              <1> 	;	For BL input = 2
 15737                              <1> 	;	   EAX = Current System Date (RTC)
 15738                              <1> 	;		DL = Day (DL in MSDOS)
 15739                              <1> 	;		DH = Month (DH in MSDOS)
 15740                              <1> 	;		HW of EDX = Year (CX in MSDOS)
 15741                              <1> 	;
 15742                              <1> 	;	For BL input = 1
 15743                              <1> 	;          EAX = Current Time (RTC)
 15744                              <1> 	;		AL = Second (DL in MSDOS)
 15745                              <1> 	;		AH = Minute (CL in MSDOS)
 15746                              <1> 	;	   	HW of EAX = Hour (CH in MSDOS)	
 15747                              <1> 	;
 15748                              <1> 	;	For BL input = 0
 15749                              <1> 	;          EAX = Unix (Epoch) Time Ticks/Seconds
 15750                              <1> 	;
 15751                              <1> 	;	For BL input  = 4
 15752                              <1> 	;	   EAX = System timer ticks
 15753                              <1> 	;
 15754                              <1> 	;	If CF = 1 (for other values of BL input)
 15755                              <1> 	;	   EAX = System timer ticks (no error code!)	
 15756                              <1> 	;		
 15757                              <1> 	; Modified Registers: EAX, (EDX)
 15758                              <1> 	;		 (at the return of system call)
 15759                              <1> 	;
 15760                              <1> 
 15761 00012706 20DB                <1> 	and	bl, bl
 15762 00012708 750F                <1> 	jnz	short systime_1
 15763 0001270A E8BF4FFFFF          <1> 	call	epoch
 15764                              <1> systime_0:
 15765 0001270F A3[64030300]        <1> 	mov	[u.r0], eax
 15766 00012714 E9E3B1FFFF          <1> 	jmp	sysret
 15767                              <1> systime_1:
 15768 00012719 80FB04              <1> 	cmp	bl, 4
 15769 0001271C 7211                <1> 	jb	short systime_2
 15770 0001271E A1[508A0100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 15771                              <1> 				; Note: [TIMER_LH] may be set
 15772                              <1> 				; to wrong timer value due to
 15773                              <1> 				; program functions.
 15774                              <1> 				; (This value must not be
 15775                              <1> 				; accepted as [TIMER_LH]/18.2
 15776                              <1> 				; seconds since the midnight.)
 15777 00012723 76EA                <1> 	jna	short systime_0
 15778 00012725 A3[64030300]        <1> 	mov	[u.r0], eax	
 15779 0001272A E9ADB1FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 15780                              <1> 
 15781                              <1> systime_2:
 15782                              <1> 	;push	ebx
 15783 0001272F E8FC4EFFFF          <1> 	call	get_rtc_date_time
 15784                              <1> 	;pop	ebx
 15785 00012734 F6C301              <1> 	test	bl, 1
 15786 00012737 7429                <1> 	jz	short systime_4
 15787 00012739 30E4                <1> 	xor	ah, ah
 15788 0001273B A0[9E860100]        <1> 	mov	al, [hour]
 15789 00012740 88C2                <1> 	mov	dl, al
 15790 00012742 C1E010              <1> 	shl	eax, 16
 15791 00012745 A0[A2860100]        <1> 	mov	al, [second]
 15792 0001274A 8A25[A0860100]      <1> 	mov	ah, [minute]
 15793 00012750 F6C302              <1> 	test	bl, 2
 15794 00012753 74BA                <1> 	jz	short systime_0
 15795                              <1> 	; Check time & date match risk 
 15796                              <1> 	; (23:59:59 may cause to wrong
 15797                              <1> 	; date -new day with previous date-...)
 15798 00012755 80FA17              <1> 	cmp	dl, 23
 15799 00012758 7206                <1> 	jb	short systime_3
 15800 0001275A 663D3B3B            <1> 	cmp	ax, (59*256)+59 ; if hour is 23:59:59
 15801 0001275E 73CF                <1> 	jnb	short systime_2 ; wait for 1 second
 15802                              <1> systime_3:
 15803                              <1> 	; eax = time
 15804 00012760 89C6                <1> 	mov	esi, eax
 15805                              <1> systime_4:	
 15806 00012762 66A1[98860100]      <1> 	mov	ax, [year]
 15807 00012768 C1E010              <1> 	shl	eax, 16
 15808 0001276B A0[9C860100]        <1> 	mov	al, [day]
 15809 00012770 8A25[9A860100]      <1> 	mov	ah, [month]
 15810                              <1> 	; eax = date
 15811 00012776 80E301              <1> 	and	bl, 1
 15812 00012779 7494                <1> 	jz	short systime_0
 15813 0001277B 96                  <1> 	xchg	esi, eax
 15814                              <1> 	; eax = time, esi = date
 15815 0001277C 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 15816                              <1> 	; (user) edx <-- (system) esi
 15817 00012782 897514              <1> 	mov	[ebp+20], esi ; return to user with EDX value 
 15818 00012785 EB88                <1> 	jmp	short systime_0
 15819                              <1> 
 15820                              <1> 
 15821                              <1> sysstime: ; Set System Date&Time
 15822                              <1> 	; 31/12/2017
 15823                              <1> 	; 30/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15824                              <1> 	;	
 15825                              <1>         ; INPUT -> BL =
 15826                              <1> 	;	    0 = Set Date&Time in Unix/Epoch format
 15827                              <1> 	;	    1 = Set Time in MSDOS format
 15828                              <1> 	;	    2 = Set Date in MSDOS format
 15829                              <1> 	;	    3 = Set Date&Time in MSDOS format
 15830                              <1> 	;	    4 = Set System Timer (Ticks)
 15831                              <1> 	;	    5 = Convert/Save current time to/as
 15832                              <1> 	;		18.2 Hz system timer ticks
 15833                              <1> 	;	    6 = Convert MSDOS Date&Time to UNIX format
 15834                              <1> 	;		without setting system date&time ; (test)
 15835                              <1> 	;	    7 = Convert UNIX Date&Time to MSDOS format
 15836                              <1> 	;		without setting system date&time ; (test)
 15837                              <1> 	;	   8-0FFh = invalid !
 15838                              <1> 	;	  ECX = Time (or Timer) value in selected format  	
 15839                              <1> 	;	  EDX = Date value in MSDOS format if BL=2,3,6	
 15840                              <1> 	; 	
 15841                              <1> 	; OUTPUT ->
 15842                              <1> 	;	If CF = 0 ->
 15843                              <1> 	;          EAX = Set value
 15844                              <1> 	;	If CF = 1 -> (invalid BL input)
 15845                              <1> 	;	   EAX = Ticks count [TIMER_LH]	
 15846                              <1> 	;
 15847                              <1> 
 15848 00012787 20DB                <1> 	and	bl, bl ; 0
 15849 00012789 7511                <1> 	jnz	short sysstime_0
 15850 0001278B 89C8                <1> 	mov	eax, ecx
 15851 0001278D E8C64FFFFF          <1> 	call	convert_from_epoch
 15852 00012792 E87250FFFF          <1> 	call	set_rtc_date_time
 15853 00012797 E960B1FFFF          <1> 	jmp	sysret
 15854                              <1> sysstime_0:
 15855 0001279C 80FB08              <1> 	cmp	bl, 8
 15856 0001279F 722D                <1> 	jb	short sysstime_1
 15857                              <1> 	; invalid input (>7)
 15858 000127A1 A1[508A0100]        <1> 	mov	eax, [TIMER_LH] ; 18.2 Hz timer ticks
 15859                              <1> 				; Note: [TIMER_LH] may be set
 15860                              <1> 				; to wrong timer value due to
 15861                              <1> 				; program functions.
 15862                              <1> 				; (This value must not be
 15863                              <1> 				; accepted as [TIMER_LH]/18.2
 15864                              <1> 				; seconds since the midnight.)
 15865 000127A6 A3[64030300]        <1> 	mov	[u.r0], eax	
 15866 000127AB E92CB1FFFF          <1> 	jmp	error ; cf = 1 & [u.r0] = eax = timer ticks 
 15867                              <1> 
 15868                              <1> sysstime_8:	
 15869                              <1> 	; BL = 7
 15870 000127B0 89C8                <1> 	mov	eax, ecx ; seconds since 1/1/1970 00:00:00
 15871 000127B2 E8A14FFFFF          <1> 	call	convert_from_epoch
 15872 000127B7 30E4                <1> 	xor	ah, ah
 15873 000127B9 A0[9E860100]        <1> 	mov	al, [hour]
 15874 000127BE C1E010              <1> 	shl	eax, 16
 15875 000127C1 A0[A2860100]        <1> 	mov	al, [second]
 15876 000127C6 8A25[A0860100]      <1> 	mov	ah, [minute]
 15877 000127CC EB92                <1> 	jmp	short systime_3
 15878                              <1> 
 15879                              <1> sysstime_1:
 15880 000127CE 80FB04              <1> 	cmp	bl, 4
 15881 000127D1 743F                <1> 	je	short sysstime_2 ; set system timer ticks	
 15882 000127D3 80FB05              <1> 	cmp	bl, 5
 15883 000127D6 754B                <1> 	jne	short sysstime_4
 15884                              <1> 	; convert current time to system timer ticks (18.2Hz)
 15885 000127D8 E8534EFFFF          <1> 	call	get_rtc_date_time
 15886 000127DD 0FB60D[9E860100]    <1> 	movzx	ecx, byte [hour]
 15887 000127E4 B8100E0000          <1> 	mov	eax, 60*60 ; 1 hour = 3600 seconds
 15888 000127E9 F7E1                <1> 	mul	ecx
 15889 000127EB 89C3                <1> 	mov	ebx, eax	
 15890 000127ED B13C                <1> 	mov	cl, 60  ; 1 minute = 60 seconds
 15891 000127EF 0FB605[A0860100]    <1> 	movzx	eax, byte [minute]
 15892 000127F6 F7E1                <1> 	mul	ecx
 15893 000127F8 01D8                <1> 	add	eax, ebx  
 15894 000127FA 8A0D[A2860100]      <1> 	mov	cl, [second]
 15895 00012800 01C8                <1> 	add	eax, ecx
 15896 00012802 B1B6                <1> 	mov	cl, 182
 15897 00012804 F7E1                <1> 	mul	ecx
 15898 00012806 83C009              <1> 	add	eax, 9
 15899 00012809 83D200              <1> 	adc	edx, 0
 15900 0001280C B10A                <1> 	mov	cl, 10
 15901 0001280E F7F1                <1> 	div	ecx
 15902                              <1> 	; eax = ((182*seconds)+9)/10
 15903 00012810 89C1                <1> 	mov	ecx, eax
 15904                              <1> sysstime_2:
 15905 00012812 890D[508A0100]      <1> 	mov	[TIMER_LH], ecx ; 18.2 * seconds
 15906                              <1> sysstime_3:
 15907 00012818 890D[64030300]      <1> 	mov	[u.r0], ecx
 15908 0001281E E9D9B0FFFF          <1> 	jmp	sysret
 15909                              <1> sysstime_4:
 15910 00012823 80FB06              <1> 	cmp	bl, 6
 15911 00012826 7788                <1> 	ja	short sysstime_8
 15912                              <1> 
 15913 00012828 890D[64030300]      <1> 	mov	[u.r0], ecx
 15914                              <1> 
 15915 0001282E 880D[A2860100]      <1> 	mov	[second], cl
 15916 00012834 882D[A0860100]      <1> 	mov	[minute], ch
 15917 0001283A C1E910              <1> 	shr	ecx, 16
 15918 0001283D 880D[9E860100]      <1> 	mov	[hour], cl
 15919                              <1> 	; BL = 1,2,3,6
 15920 00012843 80FB01              <1> 	cmp	bl, 1
 15921 00012846 762A                <1> 	jna	short sysstime_5
 15922                              <1> 	; BL = 2,3,6
 15923 00012848 8815[9C860100]      <1> 	mov	[day], dl
 15924 0001284E 8835[9A860100]      <1> 	mov	[month], dh
 15925 00012854 C1EA10              <1> 	shr	edx, 16
 15926 00012857 668915[98860100]    <1> 	mov	[year], dx
 15927 0001285E 80E303              <1> 	and	bl, 3
 15928 00012861 742D                <1> 	jz	short sysstime_7 ; 6
 15929                              <1> 	; BL = 2,3
 15930 00012863 F6C301              <1> 	test	bl, 1
 15931 00012866 7419                <1> 	jz	short sysstime_6 ; 2
 15932                              <1> 	; BL = 3
 15933 00012868 E89C4FFFFF          <1> 	call	set_rtc_date_time
 15934 0001286D E98AB0FFFF          <1> 	jmp	sysret
 15935                              <1> sysstime_5:
 15936                              <1> 	; BL = 1
 15937 00012872 E8D34FFFFF          <1> 	call	set_time_bcd
 15938 00012877 E85D42FFFF          <1> 	call	set_rtc_time
 15939 0001287C E97BB0FFFF          <1> 	jmp	sysret	
 15940                              <1> sysstime_6:
 15941                              <1> 	; BL = 2
 15942 00012881 E8974FFFFF          <1> 	call	set_date_bcd
 15943 00012886 E8BD42FFFF          <1> 	call	set_rtc_date
 15944 0001288B E96CB0FFFF          <1> 	jmp	sysret
 15945                              <1> sysstime_7:
 15946                              <1> 	; BL = 6
 15947                              <1> 	; [year], [month], [day], 
 15948                              <1> 	; [hour], [minute], [second]
 15949 00012890 E83E4EFFFF          <1> 	call	convert_to_epoch
 15950 00012895 89C1                <1> 	mov	ecx, eax ; seconds since 1/1/1970 00:00:00
 15951 00012897 E97CFFFFFF          <1> 	jmp	sysstime_3
 15952                              <1> 
 15953                              <1> sysrename: ; Rename File (or Directory)
 15954                              <1> 	; 19/01/2021
 15955                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 15956                              <1> 	;	
 15957                              <1>         ; INPUT ->
 15958                              <1>         ;          EBX = File/Directory (ASCIIZ) name address
 15959                              <1> 	;	   ECX = New name (in same dir, no path name)			
 15960                              <1> 	; OUTPUT ->
 15961                              <1> 	;          cf = 0 -> EAX = 0
 15962                              <1> 	;          cf = 1 -> Error code in AL
 15963                              <1> 
 15964                              <1> 	; 19/01/2021
 15965 0001289C 803D[B0030300]00    <1> 	cmp	byte [u.uid], 0  ; root (super user) ?
 15966 000128A3 7614                <1> 	jna	short sysrename_0
 15967                              <1> 
 15968                              <1> sysrename_perm_err:
 15969                              <1> 	;mov	dword [u.r0], ERR_PERM_DENIED
 15970 000128A5 B80B000000          <1> 	mov	eax, ERR_PERM_DENIED ; 'permission denied !'
 15971 000128AA A3[64030300]        <1> 	mov	[u.r0], eax
 15972 000128AF A3[C8030300]        <1> 	mov	[u.error], eax
 15973 000128B4 E923B0FFFF          <1> 	jmp	error
 15974                              <1> 
 15975                              <1> sysrename_0:
 15976 000128B9 51                  <1> 	push	ecx ; new file name address (in user space)
 15977 000128BA 89DE                <1> 	mov	esi, ebx
 15978                              <1> 	; file name is forced, change directory as temporary
 15979                              <1> 	;mov	ax, 1
 15980                              <1> 	;mov	[FFF_Valid], ah ; 0 ; reset
 15981                              <1> 	;call	set_working_path 
 15982 000128BC E8BF060000          <1> 	call	set_working_path_x
 15983 000128C1 731E                <1> 	jnc	short sysrename_1
 15984 000128C3 21C0                <1> 	and	eax, eax  ; 0 -> Bad Path!  
 15985 000128C5 7505                <1> 	jnz	short sysrename_err
 15986                              <1> 	; eax = 0
 15987                              <1> sysrename_path_not_found:
 15988 000128C7 B813000000          <1> 	mov	eax, ERR_INV_PATH_NAME ; 'Bad path name !'
 15989                              <1> sysrename_err:
 15990 000128CC 59                  <1> 	pop	ecx ; new file name address (in user space)
 15991                              <1> sysrename_error:
 15992 000128CD A3[64030300]        <1> 	mov	[u.r0], eax
 15993 000128D2 A3[C8030300]        <1> 	mov	[u.error], eax
 15994 000128D7 E879070000          <1> 	call 	reset_working_path
 15995 000128DC E9FBAFFFFF          <1> 	jmp	error
 15996                              <1> sysrename_1:
 15997 000128E1 B008                <1> 	mov	al, 08h ; Except volume labels (& long names)
 15998 000128E3 A0[4C940100]        <1> 	mov	al, [Attributes]
 15999 000128E8 2410                <1> 	and	al, 10h ;
 16000                              <1> 	;mov	esi, FindFile_Name
 16001                              <1> 	;mov	ax, 1800h ; Only files
 16002                              <1> 	;mov	ax, 0810h ; Only directories
 16003 000128EA 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 16004 000128EE E88E6BFFFF          <1> 	call	find_first_file
 16005                              <1> 	;jnc	short sysrename_2
 16006 000128F3 72D7                <1> 	jc	short sysrename_err
 16007                              <1> sysrename_2:
 16008                              <1> 	; ESI = Directory Entry (FindFile_DirEntry) Location
 16009                              <1> 	; EDI = Directory Buffer Directory Entry Location
 16010                              <1> 	; EAX = File Size
 16011                              <1> 	;  BL = Attributes of The File/Directory
 16012                              <1> 	;  BH = Long Name Yes/No Status (>0 is YES)
 16013                              <1> 	;  DX > 0 : Ambiguous filename chars are used
 16014                              <1> 
 16015 000128F5 6621D2              <1> 	and	dx, dx ; Ambiguous filename chars used sign (DX>0)
 16016 000128F8 7407                <1> 	jz	short sysrename_3
 16017 000128FA B81A000000          <1> 	mov	eax, ERR_INV_FILE_NAME ; 'invalid file name !'
 16018 000128FF EBCB                <1>         jmp	short sysrename_err
 16019                              <1> sysrename_3:
 16020                              <1> 	; EDI = Directory buffer entry offset/address
 16021                              <1> 	; BL = File (or Directory) Attributes 
 16022                              <1> 	; mov	bl, [EDI+0Bh]
 16023                              <1> 
 16024 00012901 5A                  <1> 	pop	edx ; new file name address (in user space)
 16025                              <1> 
 16026                              <1> 	; check file/directory attributes
 16027 00012902 F6C307              <1> 	test	bl, 7 ; system, hidden, readonly 
 16028 00012905 759E                <1>         jnz	short sysrename_perm_err
 16029                              <1> sysrename_4:
 16030 00012907 66817F0CA101        <1> 	cmp	word [edi+DirEntry_NTRes], 01A1h ; Singlix FS
 16031 0001290D 7496                <1> 	je	short sysrename_perm_err ; -temporary!-
 16032                              <1> 
 16033                              <1> 	; save old file name & file info (FFF structure)
 16034 0001290F BE[36930100]        <1> 	mov	esi, FindFile_Drv
 16035 00012914 BF[7C940100]        <1> 	mov	edi, SourceFile_Drv
 16036 00012919 B920000000          <1> 	mov	ecx, 128/4
 16037 0001291E F3A5                <1> 	rep	movsd
 16038                              <1> 
 16039 00012920 89D6                <1> 	mov	esi, edx ; new file name address (in user space)
 16040 00012922 BF[FC940100]        <1> 	mov	edi, DestinationFile_Drv
 16041 00012927 E8268DFFFF          <1> 	call	parse_path_name
 16042 0001292C 729F                <1> 	jc	short sysrename_error ; eax = 1 (Bad file name)
 16043                              <1> 
 16044                              <1> 	; same drive ? 
 16045 0001292E A0[36930100]        <1> 	mov	al, [FindFile_Drv]
 16046 00012933 3A05[FC940100]      <1> 	cmp	al, [DestinationFile_Drv]
 16047                              <1> 	;jne	short sysrename_perm_err ; Permission denied
 16048 00012939 7509                <1> 	jne	short sysrename_5 ; Bad file name
 16049                              <1>  
 16050                              <1> 	; no path name !? (rename file in same directory)
 16051 0001293B 803D[FD940100]20    <1> 	cmp	byte [DestinationFile_Directory], 20h
 16052 00012942 7607                <1> 	jna	short sysrename_6
 16053                              <1> sysrename_5:
 16054 00012944 B801000000          <1> 	mov	eax, ERR_BAD_CMD_ARG ; 1 = Bad file name 
 16055                              <1> 				     ; (Bad argument)
 16056 00012949 EB82                <1> 	jmp	short sysrename_error
 16057                              <1> sysrename_6:
 16058 0001294B 803D[3E950100]20    <1> 	cmp	byte [DestinationFile_Name], 20h
 16059 00012952 76F0                <1> 	jna	short sysrename_5
 16060                              <1> 
 16061 00012954 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name
 16062 00012959 E8E16EFFFF          <1> 	call	check_filename ; is it a valid msdos file name?
 16063 0001295E 0F8269FFFFFF        <1> 	jc	sysrename_error ; 26 = ERR_INV_FILE_NAME 
 16064                              <1> 	
 16065                              <1> 	;mov	esi, DestinationFile_Name
 16066 00012964 66B80008            <1> 	mov	ax, 0800h ; Find File or Directory
 16067 00012968 E8146BFFFF          <1> 	call	find_first_file
 16068 0001296D 720A                <1> 	jc	short sysrename_7
 16069                              <1> 	
 16070 0001296F B80E000000          <1> 	mov	eax, ERR_FILE_EXISTS  ; file already exists !
 16071 00012974 E954FFFFFF          <1> 	jmp	sysrename_error	
 16072                              <1> sysrename_7:
 16073                              <1> 	; eax = 2 (File not found !)
 16074 00012979 3C02                <1> 	cmp	al, 2 ; ERR_NOT_FOUND
 16075 0001297B 0F854CFFFFFF        <1> 	jne	sysrename_error
 16076                              <1> 
 16077                              <1> 	; 31/12/2017
 16078                              <1> 	; Following code is also part of 'rename_file' in
 16079                              <1> 	; 'trdosk3.s' (MainProg's 'rename' command) ; 13/11/2017
 16080 00012981 BE[3E950100]        <1> 	mov	esi, DestinationFile_Name ; (Rename_NewName)
 16081 00012986 668B0D[F6940100]    <1> 	mov	cx, [SourceFile_DirEntryNumber] 
 16082 0001298D 66A1[E2940100]      <1> 	mov	ax, [SourceFile_DirEntry+20] ; First Cluster, HW 
 16083 00012993 C1E010              <1> 	shl	eax, 16
 16084 00012996 66A1[E8940100]      <1> 	mov	ax, [SourceFile_DirEntry+26] ; First Cluster, LW 
 16085 0001299C 0FB61D[CB940100]    <1>   	movzx	ebx, byte [SourceFile_LongNameEntryLength]  
 16086 000129A3 E8F294FFFF          <1>    	call	rename_directory_entry
 16087 000129A8 0F821FFFFFFF        <1> 	jc	sysrename_error
 16088                              <1> 	;xor	eax, eax
 16089 000129AE A3[64030300]        <1> 	mov	[u.r0], eax ; 0
 16090                              <1> 	;mov	[u.error], eax
 16091 000129B3 E89D060000          <1> 	call 	reset_working_path
 16092 000129B8 E93FAFFFFF          <1> 	jmp	sysret
 16093                              <1> 
 16094                              <1> sysmem: ; Get Total&Free Memory amount 
 16095                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16096                              <1> 	;	
 16097                              <1>         ; INPUT -> 
 16098                              <1> 	;	none	
 16099                              <1> 	; OUTPUT ->
 16100                              <1> 	;	EAX = Total memory count (in bytes)
 16101                              <1> 	;	EBX = Virtually available memory amount (in bytes)
 16102                              <1> 	;	      = 4GB - CORE (4MB)	
 16103                              <1> 	;	ECX = Free memory count (in bytes)
 16104                              <1> 	;	EDX = Calculated free memory count (in bytes)
 16105                              <1> 	
 16106 000129BD A1[D4890100]        <1> 	mov	eax, [memory_size] ; in pages
 16107 000129C2 C1E00C              <1> 	shl	eax, 12		   ; in bytes
 16108 000129C5 A3[64030300]        <1> 	mov	[u.r0], eax
 16109 000129CA E87E19FFFF          <1> 	call	calc_free_mem
 16110                              <1> 	; edx = calculated free pages
 16111                              <1> 	; ecx = 0
 16112 000129CF 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; EBP points to user's registers
 16113 000129D5 C745100000C0FF      <1> 	mov	dword [ebp+16], ECORE ; EBX (for user)
 16114                              <1> 				; 0FFC00000h ; 4GB - 4MB
 16115 000129DC C1E20C              <1> 	shl	edx, 12
 16116 000129DF 895514              <1> 	mov	[ebp+20], edx ; EDX (for user)
 16117 000129E2 8B0D[D8890100]      <1> 	mov 	ecx, [free_pages]
 16118 000129E8 C1E10C              <1> 	shl	ecx, 12	; free bytes
 16119 000129EB 894D18              <1> 	mov	[ebp+24], ecx ; ECX (for user)
 16120                              <1> 	;mov	[free_pages], edx	
 16121 000129EE E909AFFFFF          <1> 	jmp	sysret
 16122                              <1> 
 16123                              <1> sysprompt:
 16124                              <1> 	; Set TRDOS 386 Command Interpreter (MainProg) prompt 
 16125                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16126                              <1> 	;	
 16127                              <1>         ; INPUT -> 
 16128                              <1> 	;	EBX = 0 -> use default prompt
 16129                              <1> 	;	EBX > 0 -> prompt string (ASCIIZ) address
 16130                              <1> 	;		  (Max. 11 characters except ZERO tail)	
 16131                              <1> 	; OUTPUT ->
 16132                              <1> 	;	(EAX = 0)
 16133                              <1> 	;	CF = 0 -> Successful
 16134                              <1> 	;	CF = 1 -> Failed
 16135                              <1> 
 16136 000129F3 21DB                <1> 	and	ebx, ebx
 16137 000129F5 750A                <1> 	jnz	short sysprompt_0
 16138                              <1> 
 16139 000129F7 E88964FFFF          <1> 	call	default_command_prompt ; '['+'TRDOS'+']'
 16140 000129FC E9FBAEFFFF          <1> 	jmp	sysret
 16141                              <1> 
 16142                              <1> sysprompt_0:
 16143 00012A01 31C0                <1> 	xor	eax, eax
 16144 00012A03 A3[64030300]        <1> 	mov	[u.r0], eax 
 16145 00012A08 89DE                <1> 	mov	esi, ebx
 16146 00012A0A B90C000000          <1> 	mov	ecx, 12
 16147 00012A0F 89E5                <1> 	mov	ebp, esp
 16148 00012A11 29CC                <1> 	sub	esp, ecx
 16149 00012A13 49                  <1> 	dec	ecx ; 11
 16150 00012A14 89E7                <1> 	mov	edi, esp
 16151 00012A16 E833F1FFFF          <1> 	call	transfer_from_user_buffer
 16152 00012A1B 7211                <1> 	jc	short sysprompt_err
 16153 00012A1D 803E20              <1> 	cmp	byte [esi], 20h
 16154 00012A20 760C                <1> 	jna	short sysprompt_err
 16155 00012A22 E87064FFFF          <1> 	call	set_command_prompt
 16156 00012A27 89EC                <1> 	mov	esp, ebp
 16157 00012A29 E9CEAEFFFF          <1> 	jmp	sysret
 16158                              <1> sysprompt_err:
 16159                              <1> syspath_err:
 16160 00012A2E 89EC                <1> 	mov	esp, ebp
 16161 00012A30 E9A7AEFFFF          <1> 	jmp	error
 16162                              <1> 
 16163                              <1> syspath:
 16164                              <1> 	; Get/Set Run Path
 16165                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16166                              <1> 	;	
 16167                              <1>         ; INPUT -> 
 16168                              <1> 	;	EBX = 0 -> get path (to buffer address in ECX)
 16169                              <1> 	;	EBX > 0 -> set path
 16170                              <1> 	;	    EBX = Path string buffer address (ASCIIZ)
 16171                              <1> 	;	    	  (Path description except 'PATH=')
 16172                              <1> 	;	ECX = Buffer address (if EBX = 0)
 16173                              <1> 	;	      (ECX will not be used if EBX > 0)	
 16174                              <1> 	;	DL = Buffer size (0 = 256 byte)	
 16175                              <1> 	;
 16176                              <1> 	; OUTPUT ->
 16177                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 16178                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 16179                              <1> 	;
 16180                              <1> 	; NOTE: 'PATH=' or 'PATH' must be excluded
 16181                              <1> 	;  (It must not be at the beginning of the string.)
 16182                              <1> 
 16183 00012A35 89E5                <1> 	mov	ebp, esp
 16184 00012A37 81EC00010000        <1> 	sub	esp, 256
 16185 00012A3D 89E7                <1> 	mov	edi, esp
 16186                              <1> 
 16187 00012A3F 31C0                <1> 	xor	eax, eax
 16188 00012A41 A3[64030300]        <1> 	mov	[u.r0], eax 
 16189                              <1> 	
 16190 00012A46 21DB                <1> 	and	ebx, ebx
 16191 00012A48 752E                <1> 	jnz	short syspath_0
 16192                              <1> 
 16193                              <1> 	; EBX = 0 -> get run path
 16194 00012A4A 89CB                <1> 	mov	ebx, ecx ; buffer addr (in user's mem space)
 16195 00012A4C BE[2F410100]        <1> 	mov	esi, Cmd_Path  ; 'PATH' address
 16196 00012A51 0FB6CA              <1> 	movzx	ecx, dl
 16197 00012A54 80E901              <1> 	sub	cl, 1 ; 0 -> 255, 1 -> 0
 16198 00012A57 6683D101            <1> 	adc	cx, 1 ; 255 -> 256, 0 -> 1
 16199                              <1> 	; EDI = Output buffer 
 16200                              <1> 	; CX = Buffer length
 16201                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 16202                              <1> 	; ESI = 'PATH' address (with zero tail)
 16203 00012A5B E86B7CFFFF          <1> 	call	get_environment_string
 16204 00012A60 72CC                <1> 	jc	short syspath_err
 16205 00012A62 89DF                <1> 	mov	edi, ebx ; User's buffer address
 16206 00012A64 89E6                <1> 	mov	esi, esp 
 16207                              <1> 	; EDI = User's buffer address
 16208                              <1> 	; ECX = transfer (byte) count
 16209 00012A66 E899F0FFFF          <1> 	call	transfer_to_user_buffer
 16210 00012A6B 72C1                <1> 	jc	short syspath_err
 16211 00012A6D 890D[64030300]      <1> 	mov	[u.r0], ecx 
 16212 00012A73 E984AEFFFF          <1> 	jmp	sysret
 16213                              <1> 
 16214                              <1> syspath_0:
 16215 00012A78 89DE                <1> 	mov	esi, ebx
 16216 00012A7A 0FB6CA              <1> 	movzx	ecx, dl
 16217 00012A7D 80E901              <1> 	sub	cl, 1 ; 0 -> 255, 1 -> 0
 16218 00012A80 6683D101            <1> 	adc	cx, 1 ; 255 -> 256, 0 -> 1
 16219 00012A84 E8C5F0FFFF          <1> 	call	transfer_from_user_buffer
 16220 00012A89 72A3                <1> 	jc	short syspath_err
 16221                              <1> 	;(*) 'PATH=' will be added to 
 16222                              <1> 	;         the head of the string
 16223 00012A8B 83EC08              <1> 	sub	esp, 8 ;(*)
 16224 00012A8E 89FE                <1> 	mov	esi, edi ;(*)
 16225 00012A90 E81A7CFFFF          <1> 	call	set_path_x ;(*)
 16226 00012A95 7297                <1> 	jc	short syspath_err
 16227 00012A97 8915[64030300]      <1> 	mov	[u.r0], edx ; run path string length
 16228 00012A9D E95AAEFFFF          <1> 	jmp	sysret	
 16229                              <1> 
 16230                              <1> sysenv:
 16231                              <1> 	; Get/Set Environment Variables
 16232                              <1> 	; 31/12/2017 (TRDOS 386 = TRDOS v2.0) 
 16233                              <1> 	;	
 16234                              <1>         ; INPUT -> 
 16235                              <1> 	;	EBX = 0 -> get (all) environment variables
 16236                              <1> 	;	      (Required Buffer length = 512 bytes)
 16237                              <1> 	;	EBX > 0 -> set (one) environment variable
 16238                              <1> 	;	      (If there is not a '=' after
 16239                              <1> 	;	      the environment variable name, it will
 16240                              <1> 	;	      accepted as 'get environment variable'.) 
 16241                              <1> 	;	       EBX = Buffer address
 16242                              <1> 	;	ECX = Buffer address (if EBX = 0)
 16243                              <1> 	;	      (ECX will not be used if EBX > 0)	
 16244                              <1> 	;	      (Note: Buffer size is 512 bytes.)	
 16245                              <1> 	;	DL = Buffer size (0 = 256 byte)
 16246                              <1> 	;	     (For one envrionment variable)		
 16247                              <1> 	;
 16248                              <1> 	; OUTPUT ->
 16249                              <1> 	;	(EAX = 0)
 16250                              <1> 	;	CF = 0 -> Successful (EAX = String length)
 16251                              <1> 	;	CF = 1 -> Failed (EAX = 0)
 16252                              <1> 	;
 16253                              <1> 	; Note: Environment variable name, for example,
 16254                              <1> 	;	'PATH=' must be included at the beginning
 16255                              <1> 	;	of the environment string. If the variable
 16256                              <1> 	;	name is as 'PATH' but it is not as 'PATH='
 16257                              <1> 	;	the variable string (row) will be returned.
 16258                              <1> 	;	If variable name is as 'PATH=' but there is
 16259                              <1> 	;	not a following text after the variable name,
 16260                              <1> 	;	the environment variable will be reset/deleted.
 16261                              <1> 
 16262 00012AA2 89E5                <1> 	mov	ebp, esp
 16263 00012AA4 81EC00020000        <1> 	sub	esp, 512
 16264 00012AAA 89E7                <1> 	mov	edi, esp
 16265                              <1> 
 16266 00012AAC 31C0                <1> 	xor	eax, eax
 16267 00012AAE A3[64030300]        <1> 	mov	[u.r0], eax 
 16268                              <1> 	
 16269 00012AB3 21DB                <1> 	and	ebx, ebx
 16270 00012AB5 7524                <1> 	jnz	short sysenv_0
 16271                              <1> 
 16272                              <1> 	; EBX = 0 -> get (all) environment variables
 16273 00012AB7 89EC                <1> 	mov	esp, ebp
 16274 00012AB9 BE00300900          <1> 	mov	esi, Env_Page  ; Environment page
 16275 00012ABE 89CF                <1> 	mov	edi, ecx ; buffer addr (in user's mem space)
 16276 00012AC0 B900020000          <1> 	mov	ecx, 512
 16277 00012AC5 E83AF0FFFF          <1> 	call	transfer_to_user_buffer
 16278 00012ACA 0F820CAEFFFF        <1> 	jc	error
 16279 00012AD0 890D[64030300]      <1> 	mov	[u.r0], ecx 
 16280 00012AD6 E921AEFFFF          <1> 	jmp	sysret
 16281                              <1> 
 16282                              <1> sysenv_0:
 16283 00012ADB 89DE                <1> 	mov	esi, ebx ; * ; user's buffer address
 16284 00012ADD 0FB6CA              <1> 	movzx	ecx, dl
 16285 00012AE0 80E901              <1> 	sub	cl, 1 ; 0 -> 255, 1 -> 0
 16286 00012AE3 6683D101            <1> 	adc	cx, 1 ; 255 -> 256, 0 -> 1
 16287 00012AE7 E862F0FFFF          <1> 	call	transfer_from_user_buffer
 16288 00012AEC 723F                <1> 	jc	short sysenv_err
 16289 00012AEE 89FE                <1> 	mov	esi, edi
 16290 00012AF0 8A06                <1> 	mov	al, [esi]
 16291 00012AF2 3C20                <1> 	cmp	al, 20h
 16292 00012AF4 7637                <1> 	jna	short sysenv_err
 16293 00012AF6 3C3D                <1> 	cmp	al, '='
 16294 00012AF8 7433                <1> 	je	short sysenv_err
 16295 00012AFA 56                  <1> 	push	esi
 16296                              <1> sysenv_1:
 16297 00012AFB 46                  <1> 	inc	esi
 16298 00012AFC 803E3D              <1> 	cmp	byte [esi], '='
 16299 00012AFF 7433                <1> 	je	short sysenv_3
 16300 00012B01 803E20              <1> 	cmp	byte [esi], 20h
 16301 00012B04 73F5                <1> 	jnb	short sysenv_1
 16302 00012B06 C60600              <1> 	mov	byte [esi], 0 
 16303 00012B09 5E                  <1> 	pop	esi
 16304                              <1> 	; EDI = Output buffer 
 16305                              <1> 	; CX = Buffer length
 16306 00012B0A 30C0                <1> 	xor	al, al
 16307                              <1> 	; AL = 0 -> use ASCIIZ word in [ESI]
 16308                              <1> 	; ESI = Environment variable name address
 16309 00012B0C E8BA7BFFFF          <1> 	call	get_environment_string
 16310 00012B11 721A                <1> 	jc	short sysenv_err
 16311 00012B13 89DF                <1> 	mov	edi, ebx ; * ; user's buffer address
 16312 00012B15 89C1                <1> 	mov	ecx, eax ; String length
 16313 00012B17 89E6                <1> 	mov	esi, esp 
 16314                              <1> 	; ESI = system buffer address
 16315                              <1> 	; EDI = User's buffer address
 16316                              <1> 	; ECX = transfer (byte) count
 16317 00012B19 E8E6EFFFFF          <1> 	call	transfer_to_user_buffer
 16318 00012B1E 720D                <1> 	jc	short sysenv_err
 16319 00012B20 890D[64030300]      <1> 	mov	[u.r0], ecx ; transfer (byte) count
 16320                              <1> sysenv_2:
 16321 00012B26 89EC                <1> 	mov	esp, ebp
 16322 00012B28 E9CFADFFFF          <1> 	jmp	sysret
 16323                              <1> sysenv_err:
 16324 00012B2D 89EC                <1> 	mov	esp, ebp
 16325 00012B2F E9A8ADFFFF          <1> 	jmp	error
 16326                              <1> sysenv_3:
 16327 00012B34 46                  <1> 	inc	esi
 16328 00012B35 803E20              <1> 	cmp	byte [esi], 20h
 16329 00012B38 73FA                <1> 	jnb	short sysenv_3
 16330 00012B3A C60600              <1> 	mov	byte [esi], 0	
 16331 00012B3D 5E                  <1> 	pop	esi
 16332 00012B3E E84B7CFFFF          <1> 	call	set_environment_string
 16333 00012B43 72E8                <1> 	jc	short sysenv_err
 16334 00012B45 8915[64030300]      <1> 	mov	[u.r0], edx
 16335 00012B4B EBD9                <1> 	jmp	short sysenv_2
 16336                              <1> 
 16337                              <1> 
 16338                              <1> ; 22/01/2021
 16339                              <1> ; temporary - 24/01/2016
 16340                              <1> 
 16341                              <1> iget:
 16342                              <1> 	;retn
 16343                              <1> isintr:
 16344                              <1> 	;retn
 16345                              <1> iopen:
 16346                              <1> 	;retn
 16347                              <1> iclose:
 16348                              <1> 	;retn
 16349                              <1> sndc:
 16350                              <1> 	;retn
 16351                              <1> access:
 16352                              <1> 	;retn
 16353                              <1> sleep:
 16354 00012B4D C3                  <1> 	retn
  3085                                  %include 'trdosk7.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - DISK READ&WRITE : trdosk7.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 25/02/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; DISK_IO.ASM (20/07/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DISK_IO.ASM (c) 2009-2011 Erdogan TAN [ 04/07/2009 ] Last Update: 20/07/2011
    14                              <1> 
    15                              <1> disk_write:
    16                              <1> 	; 25/02/2016
    17                              <1> 	; 24/02/2016
    18                              <1> 	; 23/02/2016
    19 00012B4E 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
    20 00012B52 777B                <1>         ja      short lba_write
    21                              <1> 
    22                              <1> chs_write:
    23                              <1> 	; 25/02/2016
    24                              <1> 	; 23/02/2016
    25 00012B54 C605[85920100]03    <1> 	mov	byte [disk_rw_op], 3 ; CHS write
    26 00012B5B EB0D                <1> 	jmp	short chs_rw
    27                              <1> 
    28                              <1> disk_read:
    29                              <1> 	; 25/02/2016
    30                              <1> 	; 24/02/2016
    31                              <1> 	; 23/02/2016
    32                              <1> 	; 17/02/2016
    33                              <1> 	; 14/02/2016
    34                              <1> 	; 31/01/2016 (TRDOS 386 =  TRDOS v2.0)
    35                              <1> 	; 17/10/2010
    36                              <1> 	; 18/04/2010
    37                              <1> 	;
    38                              <1> 	; INPUT -> EAX = Logical Block Address
    39                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
    40                              <1> 	;	   ECX = Sector Count	
    41                              <1> 	; 	   EBX = Destination Buffer
    42                              <1> 	; OUTPUT -> 
    43                              <1> 	;	   cf = 0 or cf = 1
    44                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
    45                              <1> 
    46 00012B5D 807E0500            <1> 	cmp	byte [esi+LD_LBAYes], 0
    47 00012B61 7775                <1>         ja      short lba_read
    48                              <1> 
    49                              <1> chs_read:
    50                              <1> 	; 25/02/2016
    51                              <1> 	; 24/02/2016
    52                              <1> 	; 23/02/2016
    53                              <1> 	; 31/01/2016 (TRDOS 386 =  TRDOS v2.0)
    54                              <1> 	; 20/07/2011
    55                              <1> 	; 04/07/2009
    56                              <1> 	;
    57                              <1> 	; INPUT -> EAX = Logical Block Address
    58                              <1> 	;	   ECX = Number of sectors to read
    59                              <1> 	; 	   ESI = Logical Dos Disk Table Offset (DRV)
    60                              <1> 	; 	   EBX = Destination Buffer
    61                              <1> 	; OUTPUT -> 
    62                              <1> 	;	   cf = 0 or cf = 1
    63                              <1> 	; (Modified registers: EAX; EBX, ECX, EDX)
    64                              <1> 
    65                              <1> 	; 23/02/2016
    66 00012B63 C605[85920100]02    <1> 	mov	byte [disk_rw_op], 2 ; CHS read
    67                              <1> 
    68                              <1> chs_rw:
    69                              <1> 	;;movzx	edx, word [esi+LD_BPB+SecPerTrack]
    70                              <1> 	;movzx	edx, byte [esi+LD_BPB+SecPerTrack] ; <= 63
    71                              <1> 	;mov	[disk_rw_spt], dl
    72                              <1> 
    73                              <1> chs_read_next_sector:
    74 00012B6A C605[86920100]04    <1> 	mov	byte [retry_count], 4
    75                              <1>      
    76                              <1> chs_read_retry:
    77                              <1> 	;mov	[sector_count], ecx ; 23/02/2016
    78                              <1> 
    79 00012B71 50                  <1> 	push	eax			; Linear sector #
    80 00012B72 51                  <1> 	push	ecx			; # of FAT/FILE/DIR sectors
    81                              <1>                 
    82 00012B73 0FB74E1E            <1> 	movzx	ecx, word [esi+LD_BPB+SecPerTrack]
    83                              <1> 	;movzx	ecx, byte [disk_rw_spt] ; 23/02/2016
    84 00012B77 29D2                <1> 	sub	edx, edx
    85 00012B79 F7F1                <1> 	div	ecx
    86                              <1> 	; eax = track, dx (dl ) = sector (on track)
    87                              <1> 	;sub	cl, dl ; 24/02/2016 (spt - sec)
    88                              <1> 	;push	ecx ; *
    89 00012B7B 6689D1              <1> 	mov	cx, dx			; Sector (zero based)
    90 00012B7E 6641                <1> 	inc	cx			; To make it 1 based
    91 00012B80 6651                <1> 	push	cx
    92 00012B82 668B4E20            <1> 	mov	cx, [esi+LD_BPB+Heads]
    93 00012B86 6629D2              <1> 	sub	dx, dx
    94 00012B89 F7F1                <1> 	div	ecx			; Convert track to head & cyl
    95                              <1> 	; eax (ax) = cylinder, dx (dl) = head (max. FFh)
    96 00012B8B 88D6                <1> 	mov	dh, dl
    97 00012B8D 6659                <1> 	pop	cx			; AX=Cyl, DH=Head, CX=Sector
    98 00012B8F 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
    99                              <1> 
   100 00012B92 88C5                <1> 	mov	ch, al			; NOTE: max. 1023 cylinders !                   
   101 00012B94 C0CC02              <1> 	ror	ah, 2			; Rotate 2 bits right
   102 00012B97 08E1                <1> 	or	cl, ah
   103                              <1> 
   104                              <1> 	; 24/02/2016
   105                              <1> 	;pop	eax ; * (spt - sec) (example: 63 - 0 = 63)
   106                              <1> 	;cmp	eax, [sector_count]
   107                              <1> 	;jb	short chs_write_sectors
   108                              <1> 	;je	short chs_read_sectors
   109                              <1> 	;; (# of sectors to read is more than remaining sectors on the track)
   110                              <1> 	;mov	al, [sector_count]
   111                              <1> ;chs_read_sectors: ; read or write !
   112 00012B99 B001                <1> 	mov	al, 1 ; 25/02/2016
   113 00012B9B 8A25[85920100]      <1> 	mov	ah, [disk_rw_op]  ; 02h = chs read, 03h = chs write 
   114                              <1> 	;
   115 00012BA1 E88326FFFF          <1> 	call	int13h			; BIOS Service func ( ah ) = 2
   116                              <1>                                         ; Read disk sectors
   117                              <1>                                         ; AL-sec num CH-track CL-sec
   118                              <1>                                         ; DH-head DL-drive ES:BX-buffer
   119                              <1>                                         ; CF-flag AH-stat AL-sec read
   120                              <1> 	                                ; If CF = 1 then (If AH > 0)
   121 00012BA6 8825[87920100]      <1> 	mov	[disk_rw_err], ah
   122                              <1> 	
   123 00012BAC 59                  <1> 	pop	ecx
   124 00012BAD 58                  <1> 	pop	eax
   125 00012BAE 7314                <1> 	jnc	short chs_read_ok
   126                              <1> 
   127 00012BB0 803D[87920100]09    <1> 	cmp	byte [disk_rw_err], 09h ; DMA crossed 64K segment boundary
   128 00012BB7 7408                <1> 	je	short chs_read_error_retn
   129                              <1>              
   130 00012BB9 FE0D[86920100]      <1> 	dec	byte [retry_count]
   131 00012BBF 75B0                <1> 	jnz	short chs_read_retry
   132                              <1> 
   133                              <1> chs_read_error_retn:
   134 00012BC1 F9                  <1> 	stc
   135                              <1> 	;retn
   136 00012BC2 EB69                <1> 	jmp	short update_drv_error_byte
   137                              <1> 
   138                              <1> ;chs_write_sectors: ; read or write 
   139                              <1> 	;; (# of sectors to read is less than remaining sectors on the track)
   140                              <1> 	;mov	[sector_count], al
   141                              <1> 	;jmp	short chs_read_sectors
   142                              <1> 
   143                              <1> chs_read_ok:
   144                              <1> 	;; 23/02/2016
   145                              <1> 	;movzx	edx, byte [sector_count] ; sector count (<= spt)	
   146                              <1>         ;sub    ecx, edx  ; remaining sector count
   147                              <1> 	;jna	short update_drv_error_byte	
   148                              <1> 	;add	eax, edx ; next disk sector
   149                              <1> 	;shl	edx, 9 ; 512 * sector count
   150                              <1> 	;add	ebx, edx ; next buffer byte address 
   151                              <1>         ;jmp     chs_read_next_sector        
   152                              <1> 	; 25/02/2016
   153 00012BC4 40                  <1> 	inc	eax ; next sector
   154 00012BC5 81C300020000        <1> 	add	ebx, 512
   155 00012BCB E29D                <1> 	loop	chs_read_next_sector
   156 00012BCD EB5E                <1> 	jmp	short update_drv_error_byte
   157                              <1> 
   158                              <1> lba_write:
   159                              <1> 	; 23/02/2016
   160 00012BCF C605[85920100]1C    <1> 	mov	byte [disk_rw_op], 1Ch ; LBA write
   161 00012BD6 EB07                <1> 	jmp	short lba_rw
   162                              <1> 
   163                              <1> lba_read:
   164                              <1> 	; 23/02/2016
   165                              <1> 	; 17/02/2016
   166                              <1> 	; 14/02/2016
   167                              <1> 	; 13/02/2016
   168                              <1> 	; 31/01/2016 (TRDOS 386 =  TRDOS v2.0)
   169                              <1> 	; 10/07/2015 (Retro UNIX 386 v1)
   170                              <1> 	;
   171                              <1> 	; INPUT -> EAX = Logical Block Address
   172                              <1> 	;	   ESI = Logical Dos Disk Table Offset (DRV)	
   173                              <1> 	;	   ECX = Sector Count	
   174                              <1> 	; 	   EBX = Destination Buffer
   175                              <1> 	; OUTPUT -> 
   176                              <1> 	;	   cf = 0 or cf = 1
   177                              <1> 	; (Modified registers: EAX, EBX, ECX, EDX)
   178                              <1> 
   179                              <1> 	; LBA read/write (with private LBA function) 
   180                              <1> 	;((Retro UNIX 386 v1 - DISK I/O code by Erdogan Tan))
   181                              <1> 
   182                              <1> 
   183                              <1> 	; 23/02/2016
   184 00012BD8 C605[85920100]1B    <1> 	mov	byte [disk_rw_op], 1Bh ; LBA read
   185                              <1> 
   186                              <1> lba_rw:
   187                              <1> 	; 17/02/2016
   188 00012BDF 57                  <1> 	push	edi
   189                              <1> 
   190 00012BE0 890D[88920100]      <1> 	mov	[sector_count], ecx ; total sector (read) count
   191                              <1> 
   192 00012BE6 8A5602              <1> 	mov	dl, [esi+LD_PhyDrvNo]
   193                              <1> 	; dl = physical drive number (0,1, 80h, 81h, 82h, 83h)
   194                              <1> 
   195                              <1> lba_read_next:
   196 00012BE9 81F900010000        <1> 	cmp	ecx, 256
   197 00012BEF 7605                <1> 	jna	short lba_read_rsc
   198 00012BF1 B900010000          <1> 	mov	ecx, 256 ; 17/02/2016
   199                              <1> lba_read_rsc:
   200 00012BF6 290D[88920100]      <1> 	sub	[sector_count], ecx ; remain sectors
   201                              <1> 
   202 00012BFC 89CF                <1> 	mov	edi, ecx 
   203 00012BFE 89C1                <1> 	mov	ecx, eax ; sector number/address
   204                              <1> 
   205 00012C00 C605[86920100]04    <1> 	mov	byte [retry_count], 4
   206                              <1> lba_read_retry:
   207 00012C07 89F8                <1> 	mov	eax, edi
   208                              <1> 	;
   209                              <1> 	; ecx = sector number
   210                              <1> 	; al = sector count (0 - 255) /// (0 = 256)
   211                              <1> 	; dl = drive number
   212                              <1> 	; ebx = buffer offset
   213                              <1> 	;
   214                              <1> 	; Function 1Bh = LBA read, 1Ch = LBA write
   215                              <1> 	; 23/02/2016
   216 00012C09 8A25[85920100]      <1> 	mov	ah, [disk_rw_op] ; 1Bh = LBA read, 1Ch = LBA write
   217 00012C0F E81526FFFF          <1> 	call	int13h
   218                              <1> 	; al = ? (changed)
   219                              <1> 	; ah = error code
   220 00012C14 8825[87920100]      <1> 	mov	[disk_rw_err], ah
   221 00012C1A 7334                <1> 	jnc	short lba_read_ok
   222 00012C1C 80FC80              <1> 	cmp	ah, 80h ; time out?
   223 00012C1F 740A                <1>         je      short lba_read_stc_retn
   224 00012C21 FE0D[86920100]      <1> 	dec	byte [retry_count]
   225 00012C27 7FDE                <1> 	jg	short lba_read_retry
   226 00012C29 743A                <1> 	jz	short lba_read_reset
   227                              <1> 	; sf =  1
   228                              <1> 
   229                              <1> lba_read_stc_retn:
   230 00012C2B F9                  <1> 	stc
   231                              <1> lba_read_retn:
   232 00012C2C 5F                  <1> 	pop	edi
   233                              <1> 
   234                              <1> update_drv_error_byte:
   235 00012C2D 9C                  <1> 	pushf
   236 00012C2E 53                  <1> 	push	ebx
   237 00012C2F 6651                <1> 	push	cx
   238                              <1> 	;or	ecx, ecx
   239                              <1> 	;jz	short udrv_errb0
   240 00012C31 8A0D[87920100]      <1> 	mov	cl, [disk_rw_err]
   241                              <1> udrv_errb0:
   242 00012C37 0FB65E02            <1> 	movzx	ebx, byte [esi+LD_PhyDrvNo]
   243 00012C3B 80FB02              <1> 	cmp	bl, 2
   244 00012C3E 7203                <1>         jb      short udrv_errb1
   245 00012C40 80EB7E              <1> 	sub	bl, 7Eh
   246                              <1> 	;cmp	bl, 5
   247                              <1> 	;ja	short udrv_errb2	
   248                              <1> udrv_errb1:
   249 00012C43 81C3[516E0000]      <1>         add     ebx, drv.error ; 13/02/2016
   250 00012C49 880B                <1> 	mov	[ebx], cl ; error code
   251                              <1> udrv_errb2:
   252 00012C4B 6659                <1> 	pop	cx
   253 00012C4D 5B                  <1> 	pop	ebx
   254 00012C4E 9D                  <1> 	popf
   255 00012C4F C3                  <1> 	retn
   256                              <1> 
   257                              <1> lba_read_ok:
   258 00012C50 89C8                <1> 	mov	eax, ecx ; sector number
   259 00012C52 01F8                <1> 	add	eax, edi ; sector number (next)
   260 00012C54 C1E709              <1> 	shl	edi, 9 ; sector count * 512
   261 00012C57 01FB                <1> 	add	ebx, edi ; next buffer offset
   262                              <1> 
   263 00012C59 8B0D[88920100]      <1> 	mov	ecx, [sector_count] ; remaining sectors
   264 00012C5F 09C9                <1> 	or	ecx, ecx
   265 00012C61 7586                <1> 	jnz	short lba_read_next
   266 00012C63 EBC7                <1> 	jmp	short lba_read_retn
   267                              <1> 
   268                              <1> lba_read_reset:
   269 00012C65 B40D                <1> 	mov	ah, 0Dh ; Alternate reset
   270 00012C67 E8BD25FFFF          <1>         call	int13h
   271                              <1> 	; al = ? (changed)
   272                              <1> 	; ah = error code
   273 00012C6C 7399                <1> 	jnc	short lba_read_retry
   274 00012C6E EBBC                <1> 	jmp	short lba_read_retn
  3086                                  %include 'trdosk8.s' ; 24/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.2) - MAIN PROGRAM : trdosk8.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 12/02/2021
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; u0.s (20/11/2015), u4.s (14/10/2015)
    12                              <1> ; ****************************************************************************
    13                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    14                              <1> ; TRDOS2.ASM (09/11/2011)
    15                              <1> ; ----------------------------------------------------------------------------
    16                              <1> ; DIR.ASM (c) 2004-2011 Erdogan TAN  [07/01/2004] Last Update: 09/10/2011
    17                              <1> 
    18                              <1> set_run_sequence:
    19                              <1> 	; 23/12/2016
    20                              <1> 	; 10/06/2016
    21                              <1> 	; 22/05/2016
    22                              <1> 	; 20/05/2016
    23                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
    24                              <1> 	; TRDOS 386 feature only !
    25                              <1> 	;
    26                              <1> 	; INPUT ->
    27                              <1> 	;	AL = process number (next process)
    28                              <1> 	;
    29                              <1> 	;	this process must be added to run sequence
    30                              <1> 	;
    31                              <1> 	;	[u.pri] = priority of present process
    32                              <1> 	;
    33                              <1> 	;	DL = priority (queue)
    34                              <1> 	;	     0 = background (low) ; run on background 
    35                              <1> 	;	     1 = regular (normal) ; run as regular
    36                              <1> 	;	     2 = event (high)     ; run for event
    37                              <1> 	;
    38                              <1> 	;	1) If the requested process is already running:
    39                              <1> 	;	   a) If present priority is high ([u.pri]=2) 
    40                              <1> 	;	      and requested priority is also high, 
    41                              <1> 	;	      there is nothing to do! Because it has been
    42                              <1> 	;	      done already (before this attempt).		 	
    43                              <1> 	;	   b) If present priority is high ([u.pri]=2)
    44                              <1> 	;	      and requested priority is not high, there is
    45                              <1> 	;	      nothing to do! Because, it's current
    46                              <1> 	;	      run queue is unspecified, here. (It may be in
    47                              <1> 	;	      a waiting list or in a run queue; if the new
    48                              <1> 	;	      priority would be used to add it to relavant
    49                              <1>         ;             run queue, this would be wrong, unnecessary
    50                              <1> 	;	      and destabilizing duplication!)
    51                              <1> 	;	   c) If present priority is not high ([u.pri]<2)
    52                              <1>         ;             and requested priority is high (event),
    53                              <1> 	;	      process will be added to present priority's
    54                              <1> 	;	      run queue and then, priority will be changed
    55                              <1> 	;	      to high ([u.pri]=2).
    56                              <1> 	;	   d) If present priority is not high ([u.pri]<2)
    57                              <1> 	;	      and requested priority is not high, [u.pri]
    58                              <1> 	;	      value will be changed. There is nothing to do
    59                              <1> 	;	      in addition. (The new priority value will be
    60                              <1> 	;	      used by 'tswap/tswitch' procedure at 'sysret'
    61                              <1> 	;	      or 'sysrele' stage.)
    62                              <1> 	;
    63                              <1> 	;	2) If the requested process is not running:
    64                              <1> 	;	   a) If requested priority of the requested
    65                              <1> 	;	      (next) process is high (event) and priority
    66                              <1> 	;	      of present process is not high, the requested
    67                              <1> 	;	      process will be added to ('runq_event') high
    68                              <1> 	;	      priority run queue and then present (running)
    69                              <1> 	;	      process will be stopped (swapped/switched out)
    70                              <1> 	;	      immediately if it is in user mode, or it's 
    71                              <1> 	;	      [u.quant] value will be reset to 0 and (then) 
    72                              <1> 	;	      it will be stopped at 'sysret' stage.			
    73                              <1> 	;	   b) If requested priority of the requested
    74                              <1> 	;	      (next) process is high (event) and priority
    75                              <1> 	;	      of present process is also high, the requested
    76                              <1> 	;	      process will be added to ('runq_event') high
    77                              <1> 	;	      priority run queue and present (running) 
    78                              <1> 	;	      process will be allowed to run until it's 
    79                              <1> 	;	      time quantum will be elapsed ([u.quant]=0).	
    80                              <1> 	;	   c) If requested priority of the requested
    81                              <1> 	;	      (next) process is not high ('run for event'), 
    82                              <1> 	;	      there is nothing to do. Because, it's current
    83                              <1> 	;	      run queue is unspecified, here. (It may be in
    84                              <1> 	;	      a waiting list or in a run queue; if the new
    85                              <1> 	;	      priority would be used to add it to relavant
    86                              <1>         ;             run queue, this would be wrong, unnecessary
    87                              <1> 	;	      and destabilizing duplication!) 
    88                              <1> 	;
    89                              <1> 	; OUTPUT ->
    90                              <1> 	;	none
    91                              <1> 	;
    92                              <1> 	;	[u.pri] = priority of present process
    93                              <1> 	;
    94                              <1> 	;	cf = 1, if the request could not be fulfilled.
    95                              <1> 	;			 	     	  
    96                              <1> 	;	NOTE: 
    97                              <1>         ;          * Processes in 'run as regular' queue can run
    98                              <1> 	;	     if there is no process in 'run for event' queue
    99                              <1> 	;	     ('run for event' processes have higher priority)	 		 
   100                              <1> 	;	   * When [u.quant] time quantum of a process is
   101                              <1> 	;	     elapsed, it's high priority ('run for event')
   102                              <1> 	;	     status will be disabled, it can be run in sequence
   103                              <1> 	;	     of it's actual run queue.
   104                              <1> 	;	   * A 'run on background' process will always be 
   105                              <1> 	;	     sequenced in 'run on background' (low priority)
   106                              <1> 	;	     queue, it can run only when other priority queues
   107                              <1> 	;	     are empty. (idle time processes, e.g. printing)  	 	
   108                              <1> 	;
   109                              <1> 	; Modified registers: eax, ebx, edx
   110                              <1> 	;
   111                              <1> 
   112                              <1> srunseq_0:
   113 00012C70 3A05[B3030300]      <1>         cmp     al, [u.uno]     ; same process ?
   114 00012C76 750C                <1> 	jne	short srunseq_2 ; no
   115                              <1> 
   116 00012C78 8A25[A9030300]      <1> 	mov	ah, [u.pri] 	; present/current priority
   117 00012C7E 80FC02              <1> 	cmp	ah, 2       	; 'run for event' priority level
   118 00012C81 7221                <1> 	jb	short srunseq_6 ; no
   119                              <1> 
   120                              <1> srunseq_1:
   121                              <1> 	; there is nothing to do!
   122 00012C83 C3                  <1> 	retn
   123                              <1> 
   124                              <1> srunseq_2:
   125                              <1> 	;;this not necessary ! 23/12/2016
   126                              <1>         ;;cmp	al, nproc	; number of processes = 16 
   127                              <1> 	;;jnb	short srunseq_5	; error ! invalid process number 
   128                              <1> 
   129                              <1> 	; dl = priority
   130 00012C84 80FA02              <1> 	cmp	dl, 2 		; event queue
   131 00012C87 72FA                <1> 	jb	short srunseq_1 ; requested process is not present
   132                              <1> 				; process and priority of requested
   133                              <1> 				; process is not high (event), 
   134                              <1> 				; there is nothing to do!
   135                              <1> 	
   136                              <1> 	; requested process is not present process
   137                              <1> 	; & priority of requested process is high
   138 00012C89 3A15[A9030300]      <1> 	cmp	dl, [u.pri] 	; priority of present process
   139 00012C8F 7606                <1> 	jna	short srunseq_3 ; is high, also
   140                              <1> 	;
   141                              <1> 	; present process will be swapped/switched out
   142 00012C91 FE05[61960100]      <1> 	inc	byte [p_change] ; 1
   143                              <1> 
   144                              <1> srunseq_3:
   145                              <1> 	; add process to 'runq_event' queue for new event
   146 00012C97 BB[52030300]        <1> 	mov	ebx, runq_event ; high priority run queue
   147                              <1> 
   148                              <1> srunseq_4:
   149                              <1> 	; al = process number
   150                              <1> 	; ebx = run queue
   151 00012C9C E887EDFFFF          <1> 	call	putlu
   152 00012CA1 C3                  <1> 	retn
   153                              <1> 
   154                              <1> srunseq_5:
   155 00012CA2 F5                  <1> 	cmc
   156 00012CA3 C3                  <1> 	retn
   157                              <1> 
   158                              <1> srunseq_6:
   159                              <1> 	; present priority of the process is not high
   160                              <1> 	
   161 00012CA4 8815[A9030300]      <1> 	mov	[u.pri], dl ; new priority 
   162                              <1> 			    ; (will be used by 'tswap')
   163                              <1> 
   164 00012CAA 80FA02              <1> 	cmp	dl, 2 		; high priority ?
   165 00012CAD 72F3                <1> 	jb	short srunseq_5 ; no, there is nothing to do
   166                              <1> 				; in addition
   167                              <1> 
   168                              <1> 	; process must be added to relevant run queue, here!
   169                              <1> 	; (new priority is high/event priority and process
   170                              <1> 	; will not be added to a run queue by 'tswap')
   171                              <1> 
   172 00012CAF BB[54030300]        <1> 	mov	ebx, runq_normal ; 'run as regular' queue
   173                              <1> 
   174 00012CB4 20E4                <1> 	and	ah, ah  ;  previous value of [u.pri]
   175 00012CB6 75E4                <1> 	jnz	short srunseq_4
   176                              <1> 
   177 00012CB8 43                  <1> 	inc	ebx
   178 00012CB9 43                  <1> 	inc	ebx
   179                              <1> 	; ebx = runq_background ; 'run on backgroud' queue 
   180                              <1> 
   181 00012CBA EBE0                <1> 	jmp	short srunseq_4
   182                              <1> clock:
   183                              <1> 	; 23/05/2016
   184                              <1> 	; 22/05/2016
   185                              <1> 	; 20/05/2016
   186                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
   187                              <1> 	; 14/05/2015 - 14/10/2015 (Retro UNIX 386 v1)
   188                              <1> 	; 07/12/2013 - 10/04/2014 (Retro UNIX 8086 v1)
   189                              <1> 
   190 00012CBC 803D[A8030300]00    <1> 	cmp	byte [u.quant], 0
   191 00012CC3 772C                <1> 	ja	short clk_1
   192                              <1> 	;
   193 00012CC5 803D[B3030300]01    <1> 	cmp     byte [u.uno], 1 ; /etc/init ? (for Retro UNIX 8086 & 386 v1)
   194                              <1> 				; MainProg (Kernel's Command Interpreter)
   195                              <1> 				; for TRDOS 386.
   196 00012CCC 7623                <1> 	jna	short clk_1 ; yes, do not swap out
   197                              <1> 	;
   198 00012CCE 803D[5B030300]FF    <1> 	cmp     byte [sysflg], 0FFh ; user or system space ?
   199 00012CD5 7520                <1> 	jne	short clk_2 	    ; system space (sysflg <> 0FFh)
   200                              <1> 	;
   201 00012CD7 66833D[AA030300]00  <1> 	cmp	word [u.intr], 0
   202 00012CDF 7616                <1> 	jna	short clk_2
   203                              <1> 	;
   204                              <1> 	; 23/05/2016
   205 00012CE1 803D[62960100]00    <1> 	cmp	byte [multi_tasking], 0
   206 00012CE8 760D                <1> 	jna	short clk_2
   207                              <1> 	;
   208 00012CEA FE05[61960100]      <1> 	inc	byte [p_change] ; it is time to change running process	
   209 00012CF0 C3                  <1> 	retn
   210                              <1> clk_1:
   211 00012CF1 FE0D[A8030300]      <1> 	dec	byte [u.quant]
   212                              <1> clk_2:
   213 00012CF7 C3                  <1> 	retn   ; return to (hardware) timer interrupt routine
   214                              <1> 
   215                              <1> ; 12/10/2017
   216                              <1> ; 15/01/2017
   217                              <1> ; 14/01/2017
   218                              <1> ; 07/01/2017
   219                              <1> ; 02/01/2017
   220                              <1> ; 17/08/2016
   221                              <1> ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   222                              <1> int34h:  ; #IOCTL# (I/O port access support for ring 3)
   223                              <1> ; 23/05/2016
   224                              <1> 	; 20/06/2016
   225                              <1> 	; 29/04/2016 - TRDOS 386 (TRDOS v2.0)
   226                              <1> 	;
   227                              <1> 	; INPUT ->
   228                              <1> 	;	AH = 0 -> read port  (physical IO port) -byte-
   229                              <1> 	;	AH = 1 -> write port (physical IO port) -byte-
   230                              <1> 	;		AL = data byte
   231                              <1> 	;	AH = 2 -> read port  (physical IO port) -word-
   232                              <1> 	;	AH = 3 -> write port (physical IO port) -word-
   233                              <1> 	;		BX = data word
   234                              <1> 	;	AH = 4 -> read port  (physical IO port) -dword-
   235                              <1> 	;	AH = 5 -> write port (physical IO port) -dword-
   236                              <1> 	;		EBX = data dword
   237                              <1> 	;	; 12/10/2017
   238                              <1> 	;	AH = 6 -> read port (physical IO port) twice -byte-
   239                              <1> 	;	AH = 7 -> write port (physical IO port) twice -byte-
   240                              <1> 	;		BX = data word	
   241                              <1> 	;
   242                              <1> 	;	DX = Port number (<= 0FFFFh)
   243                              <1> 	;
   244                              <1> 	; OUTPUT ->
   245                              <1> 	;	AL = data byte (in al, dx)
   246                              <1> 	;	AX = data word (in ax, dx)
   247                              <1> 	;	EAX = data dword (in eax, dx)
   248                              <1> 	;
   249                              <1> 	;	(ECX = actual TRANSFER COUNT for string functions)
   250                              <1> 	;
   251                              <1> 	;
   252                              <1> 	; Modified registers: EAX
   253                              <1> 	;
   254                              <1> 
   255                              <1> 	;cmp	ah, 5
   256                              <1> 	;ja	short int34h_5 ; invalid function !
   257                              <1> 
   258                              <1> 	; 12/10/2017
   259 00012CF8 80FC07              <1> 	cmp	ah, 7
   260 00012CFB 7743                <1> 	ja	short int34h_5 ; invalid function !
   261                              <1> 
   262                              <1> 	;; 15/01/2017
   263                              <1> 	; 14/01/2017
   264                              <1> 	; 02/01/2017
   265                              <1> 	;;mov	byte [ss:intflg], 34h	; IOCTL interrupt 
   266 00012CFD FB                  <1> 	sti
   267                              <1> 	
   268                              <1> 	;sti	; enable interrupts
   269 00012CFE 80642408FE          <1> 	and	byte [esp+8], 11111110b	; clear carry bit of eflags register
   270                              <1> 
   271 00012D03 80FC01              <1> 	cmp	ah, 1
   272 00012D06 7205                <1> 	jb	short int34h_0
   273 00012D08 7705                <1> 	ja	short int34h_1
   274                              <1> 
   275 00012D0A EE                  <1> 	out	dx, al
   276                              <1> 	;iretd
   277 00012D0B EB01                <1> 	jmp short int34h_iret
   278                              <1> 
   279                              <1> int34h_0:
   280 00012D0D EC                  <1> 	in	al, dx
   281                              <1> 	;iretd
   282                              <1> int34h_iret:
   283                              <1> 	;cli	; 07/01/2017
   284                              <1> 	;; 15/01/2017
   285                              <1> 	;;mov	byte [ss:intflg], 0 ; reset
   286 00012D0E CF                  <1> 	iretd 
   287                              <1> 
   288                              <1> int34h_1:
   289 00012D0F F6C401              <1> 	test	ah, 1
   290 00012D12 7516                <1> 	jnz	short int34h_3 ; out
   291                              <1> 
   292                              <1> 	; in
   293 00012D14 80FC02              <1> 	cmp	ah, 2
   294 00012D17 7707                <1> 	ja	short int34h_2
   295                              <1> 
   296 00012D19 6689D8              <1> 	mov	ax, bx
   297 00012D1C 66ED                <1> 	in	ax, dx
   298                              <1> 	;iretd
   299 00012D1E EBEE                <1> 	jmp	short int34h_iret
   300                              <1> 
   301                              <1> int34h_2:
   302 00012D20 80FC04              <1> 	cmp	ah, 4
   303 00012D23 772C                <1> 	ja	short int34h_7	; 12/10/2017
   304                              <1> 	; ah = 4
   305 00012D25 89D8                <1> 	mov	eax, ebx
   306 00012D27 ED                  <1> 	in	eax, dx
   307                              <1> 	;iretd
   308 00012D28 EBE4                <1> 	jmp	short int34h_iret
   309                              <1> 
   310                              <1> int34h_3:
   311 00012D2A 80FC03              <1> 	cmp	ah, 3
   312 00012D2D 7707                <1> 	ja	short int34h_4
   313                              <1> 
   314 00012D2F 6689D8              <1> 	mov	ax, bx
   315 00012D32 66EF                <1> 	out	dx, ax
   316                              <1> 	;iretd
   317 00012D34 EBD8                <1> 	jmp	short int34h_iret
   318                              <1> 
   319                              <1> int34h_4:
   320 00012D36 80FC05              <1> 	cmp	ah, 5
   321 00012D39 770B                <1> 	ja	short int34h_6	; 12/10/2017
   322                              <1> 	; ah = 5
   323 00012D3B 89D8                <1> 	mov	eax, ebx
   324 00012D3D EF                  <1> 	out	dx, eax
   325                              <1> 	;iretd
   326 00012D3E EBCE                <1> 	jmp	short int34h_iret
   327                              <1> 
   328                              <1> int34h_5:
   329 00012D40 804C240801          <1> 	or	byte [esp+8], 1	; set carry bit of eflags register
   330 00012D45 CF                  <1> 	iretd
   331                              <1> 
   332                              <1> 	; 12/10/2017
   333                              <1> int34h_6:
   334 00012D46 6689D8              <1> 	mov	ax, bx
   335 00012D49 EE                  <1> 	out	dx, al
   336 00012D4A EB00                <1> 	jmp	short $+2
   337 00012D4C 86E0                <1> 	xchg	ah, al
   338 00012D4E EE                  <1> 	out	dx, al
   339                              <1> 	;xchg	al, ah
   340                              <1> 	;iretd
   341 00012D4F EB06                <1> 	jmp	short int34h_8
   342                              <1> int34h_7:
   343 00012D51 EC                  <1> 	in	al, dx
   344 00012D52 EB00                <1> 	jmp	short $+2
   345 00012D54 88C4                <1> 	mov	ah, al
   346 00012D56 EC                  <1> 	in	al, dx
   347                              <1> int34h_8:
   348 00012D57 86C4                <1> 	xchg	al, ah
   349 00012D59 CF                  <1> 	iretd
   350                              <1> 			
   351                              <1> 
   352                              <1> INT4Ah:
   353                              <1> 	; 24/01/2016
   354                              <1> 	; this procedure will be called by 'RTC_INT' (in 'timer.s')
   355 00012D5A C3                  <1> 	retn
   356                              <1> 
   357                              <1> ; u0.s
   358                              <1> ; Retro UNIX 386 v1 Kernel (v0.2) - SYS0.INC
   359                              <1> ; Last Modification: 20/11/2015
   360                              <1> 
   361                              <1> com2_int:
   362                              <1> 	; 07/11/2015 
   363                              <1> 	; 24/10/2015
   364                              <1> 	; 23/10/2015
   365                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
   366                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
   367                              <1> 	; < serial port 2 interrupt handler >
   368                              <1> 	;
   369 00012D5B 890424              <1> 	mov 	[esp], eax ; overwrite call return address
   370                              <1> 	;push	eax
   371 00012D5E 66B80900            <1> 	mov	ax, 9
   372 00012D62 EB07                <1> 	jmp	short comm_int
   373                              <1> com1_int:
   374                              <1> 	; 07/11/2015
   375                              <1> 	; 24/10/2015
   376 00012D64 890424              <1> 	mov 	[esp], eax ; overwrite call return address
   377                              <1> 	; 23/10/2015
   378                              <1> 	;push	eax
   379 00012D67 66B80800            <1> 	mov	ax, 8
   380                              <1> comm_int:
   381                              <1> 	; 20/11/2015
   382                              <1> 	; 18/11/2015
   383                              <1> 	; 17/11/2015
   384                              <1> 	; 16/11/2015
   385                              <1> 	; 09/11/2015
   386                              <1> 	; 08/11/2015
   387                              <1> 	; 07/11/2015
   388                              <1> 	; 06/11/2015 (serial4.asm, 'serial')	
   389                              <1> 	; 01/11/2015
   390                              <1> 	; 26/10/2015
   391                              <1> 	; 23/10/2015
   392 00012D6B 53                  <1> 	push	ebx
   393 00012D6C 56                  <1> 	push	esi
   394 00012D6D 57                  <1> 	push	edi
   395 00012D6E 1E                  <1> 	push 	ds
   396 00012D6F 06                  <1> 	push 	es
   397                              <1> 	; 18/11/2015
   398 00012D70 0F20DB              <1> 	mov	ebx, cr3
   399 00012D73 53                  <1> 	push	ebx ; ****
   400                              <1> 	;
   401 00012D74 51                  <1> 	push	ecx ; ***
   402 00012D75 52                  <1> 	push	edx ; **
   403                              <1> 	;
   404 00012D76 BB10000000          <1> 	mov	ebx, KDATA
   405 00012D7B 8EDB                <1> 	mov	ds, bx
   406 00012D7D 8EC3                <1> 	mov	es, bx
   407                              <1> 	;
   408 00012D7F 8B0D[D0890100]      <1> 	mov	ecx, [k_page_dir]
   409 00012D85 0F22D9              <1> 	mov	cr3, ecx
   410                              <1> 	; 20/11/2015
   411                              <1> 	; Interrupt identification register
   412 00012D88 66BAFA02            <1> 	mov	dx, 2FAh ; COM2
   413                              <1> 	;
   414 00012D8C 3C08                <1> 	cmp 	al, 8 
   415 00012D8E 7702                <1> 	ja 	short com_i0
   416                              <1> 	;
   417                              <1> 	; 20/11/2015
   418                              <1> 	; 17/11/2015
   419                              <1> 	; 16/11/2015
   420                              <1> 	; 15/11/2015
   421                              <1> 	; 24/10/2015
   422                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - Beginning)
   423                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1)
   424                              <1> 	; < serial port 1 interrupt handler >
   425                              <1> 	;
   426 00012D90 FEC6                <1> 	inc	dh ; 3FAh ; COM1 Interrupt id. register
   427                              <1> com_i0:
   428                              <1> 	;push	eax ; *
   429                              <1> 	; 07/11/2015
   430 00012D92 A2[3A8A0100]        <1> 	mov 	byte [ccomport], al
   431                              <1> 	; 09/11/2015
   432 00012D97 0FB7D8              <1> 	movzx	ebx, ax ; 8 or 9
   433                              <1> 	; 17/11/2015
   434                              <1>  	; reset request for response status
   435 00012D9A 88A3[308A0100]      <1> 	mov	[ebx+req_resp-8], ah ; 0
   436                              <1> 	;
   437                              <1> 	; 20/11/2015
   438 00012DA0 EC                  <1> 	in	al, dx		; read interrupt id. register
   439 00012DA1 EB00                <1> 	JMP	$+2	   	; I/O DELAY
   440 00012DA3 2404                <1> 	and	al, 4		; received data available?	
   441 00012DA5 7470                <1> 	jz	short com_eoi	; (transmit. holding reg. empty)
   442                              <1> 	;
   443                              <1> 	; 20/11/2015
   444 00012DA7 80EA02              <1> 	sub	dl, 3FAh-3F8h	; data register (3F8h, 2F8h)
   445 00012DAA EC                  <1> 	in	al, dx     	; read character
   446                              <1> 	;JMP	$+2	   	; I/O DELAY
   447                              <1> 	; 08/11/2015
   448                              <1> 	; 07/11/2015
   449 00012DAB 89DE                <1> 	mov	esi, ebx 
   450 00012DAD 89DF                <1> 	mov	edi, ebx
   451 00012DAF 81C6[348A0100]      <1> 	add 	esi, rchar - 8 ; points to last received char
   452 00012DB5 81C7[368A0100]      <1> 	add	edi, schar - 8 ; points to last sent char
   453 00012DBB 8806                <1> 	mov	[esi], al ; received char (current char)
   454                              <1> 	; query
   455 00012DBD 20C0                <1> 	and	al, al
   456 00012DBF 7527                <1> 	jnz	short com_i2
   457                              <1>    	; response
   458                              <1> 	; 17/11/2015
   459                              <1> 	; set request for response status
   460 00012DC1 FE83[308A0100]      <1>         inc     byte [ebx+req_resp-8] ; 1 
   461                              <1> 	;
   462 00012DC7 6683C205            <1> 	add	dx, 3FDh-3F8h	; (3FDh, 2FDh)
   463 00012DCB EC                  <1> 	in	al, dx	   	; read line status register 
   464 00012DCC EB00                <1> 	JMP	$+2	   	; I/O DELAY
   465 00012DCE 2420                <1> 	and	al, 20h	   	; transmitter holding reg. empty?
   466 00012DD0 7445                <1> 	jz	short com_eoi 	; no
   467 00012DD2 B0FF                <1> 	mov 	al, 0FFh   	; response			
   468 00012DD4 6683EA05            <1> 	sub	dx, 3FDh-3F8h 	; data port (3F8h, 2F8h)
   469 00012DD8 EE                  <1> 	out	dx, al	   	; send on serial port
   470                              <1> 	; 17/11/2015
   471 00012DD9 803F00              <1> 	cmp 	byte [edi], 0   ; query ? (schar)
   472 00012DDC 7502                <1> 	jne 	short com_i1    ; no
   473 00012DDE 8807                <1> 	mov	[edi], al 	; 0FFh (responded)
   474                              <1> com_i1:
   475                              <1> 	; 17/11/2015
   476                              <1> 	; reset request for response status (again)
   477 00012DE0 FE8B[308A0100]      <1>         dec     byte [ebx+req_resp-8] ; 0 
   478 00012DE6 EB2F                <1> 	jmp	short com_eoi
   479                              <1> com_i2:	
   480                              <1> 	; 08/11/2015
   481 00012DE8 3CFF                <1> 	cmp 	al, 0FFh	; (response ?)
   482 00012DEA 7417                <1> 	je	short com_i3	; (check for response signal)
   483                              <1> 	; 07/11/2015
   484 00012DEC 3C04                <1> 	cmp	al, 04h	; EOT
   485 00012DEE 751C                <1> 	jne	short com_i4	
   486                              <1> 	; EOT = 04h (End of Transmit) - 'CTRL + D'
   487                              <1> 	;(an EOT char is supposed as a ctrl+brk from the terminal)
   488                              <1> 	; 08/11/2015
   489                              <1> 		; ptty -> tty 0 to 7 (pseudo screens)
   490 00012DF0 861D[FE890100]      <1> 	xchg	bl, [ptty]  ; tty number (8 or 9)
   491 00012DF6 E8E547FFFF          <1> 	call 	ctrlbrk
   492 00012DFB 861D[FE890100]      <1> 	xchg	[ptty], bl ; (restore ptty value and BL value)
   493                              <1> 	;mov	al, 04h ; EOT
   494                              <1> 	; 08/11/2015
   495 00012E01 EB09                <1> 	jmp	short com_i4	
   496                              <1> com_i3:
   497                              <1> 	; 08/11/2015
   498                              <1> 	; If 0FFh has been received just after a query
   499                              <1> 	; (schar, ZERO), it is a response signal.
   500                              <1> 	; 17/11/2015
   501 00012E03 803F00              <1>         cmp     byte [edi], 0 ; query ? (schar)
   502 00012E06 7704                <1> 	ja	short com_i4 ; no
   503                              <1> 	; reset query status (schar)
   504 00012E08 8807                <1> 	mov	[edi], al ; 0FFh
   505 00012E0A FEC0                <1> 	inc	al ; 0
   506                              <1> com_i4:
   507                              <1> 	; 27/07/2014
   508                              <1> 	; 09/07/2014
   509 00012E0C D0E3                <1> 	shl	bl, 1	
   510 00012E0E 81C3[008A0100]      <1> 	add	ebx, ttychr
   511                              <1> 	; 23/07/2014 (always overwrite)
   512                              <1> 	;;cmp	word [ebx], 0
   513                              <1> 	;;ja	short com_eoi
   514                              <1> 	;
   515 00012E14 668903              <1> 	mov	[ebx], ax   ; Save ascii code
   516                              <1> 			    ; scan code = 0
   517                              <1> com_eoi:
   518                              <1> 	;mov	al, 20h
   519                              <1> 	;out	20h, al	   ; end of interrupt
   520                              <1> 	;
   521                              <1> 	; 07/11/2015
   522                              <1>       	;pop	eax ; *
   523 00012E17 A0[3A8A0100]        <1> 	mov	al, byte [ccomport] ; current COM port
   524                              <1> 	 ; al = tty number (8 or 9)
   525 00012E1C E85E010000          <1>         call	wakeup
   526                              <1> com_iret:
   527                              <1> 	; 23/10/2015
   528 00012E21 5A                  <1> 	pop	edx ; **
   529 00012E22 59                  <1> 	pop	ecx ; ***
   530                              <1> 	; 18/11/2015
   531                              <1> 	;pop	eax ; ****
   532                              <1> 	;mov	cr3, eax
   533                              <1> 	;jmp	iiret
   534 00012E23 E983DFFEFF          <1> 	jmp	iiretp
   535                              <1> 
   536                              <1> ;iiretp: ; 01/09/2015
   537                              <1> ;	; 28/08/2015
   538                              <1> ;	pop	eax ; (*) page directory
   539                              <1> ;	mov	cr3, eax
   540                              <1> ;iiret:
   541                              <1> ;	; 22/08/2014
   542                              <1> ;	mov	al, 20h ; END OF INTERRUPT COMMAND TO 8259
   543                              <1> ;	out	20h, al	; 8259 PORT
   544                              <1> ;	;
   545                              <1> ;	pop	es
   546                              <1> ;	pop	ds
   547                              <1> ;	pop	edi
   548                              <1> ;	pop	esi
   549                              <1> ;	pop	ebx ; 29/08/2014
   550                              <1> ;	pop 	eax
   551                              <1> ;	iretd
   552                              <1> 
   553                              <1> sp_init:
   554                              <1> 	; 07/11/2015
   555                              <1> 	; 29/10/2015
   556                              <1> 	; 26/10/2015
   557                              <1> 	; 23/10/2015
   558                              <1> 	; 29/06/2015
   559                              <1> 	; 14/03/2015 (Retro UNIX 386 v1 - 115200 baud)
   560                              <1> 	; 28/07/2014 (Retro UNIX 8086 v1 - 9600 baud)
   561                              <1> 	; Initialization of Serial Port Communication Parameters
   562                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
   563                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
   564                              <1> 	;
   565                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
   566                              <1> 	;
   567                              <1> 	; INPUT:  (29/06/2015)
   568                              <1> 	;	AL = 0 for COM1
   569                              <1> 	;	     1 for COM2
   570                              <1> 	;	AH = Communication parameters	
   571                              <1> 	;
   572                              <1> 	;  (*) Communication parameters (except BAUD RATE):
   573                              <1> 	;	Bit	4	3	2	1	0
   574                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
   575                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
   576                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
   577                              <1> 	;		11 = even
   578                              <1> 	;  Baud rate setting bits: (29/06/2015)
   579                              <1> 	;		Retro UNIX 386 v1 feature only !
   580                              <1> 	;	Bit	7    6    5  | Baud rate
   581                              <1> 	;		------------------------
   582                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
   583                              <1> 	;		0    0    1  | 9600 (12)
   584                              <1> 	;		0    1    0  | 19200 (6) 
   585                              <1> 	;		0    1	  1  | 38400 (3) 
   586                              <1> 	;		1    0	  0  | 14400 (8)
   587                              <1> 	;		1    0	  1  | 28800 (4)
   588                              <1> 	;		1    1    0  | 57600 (2)
   589                              <1> 	;		1    1    1  | 115200 (1) 	
   590                              <1> 	
   591                              <1> 	; References:	
   592                              <1> 	; (1) IBM PC-XT Model 286 BIOS Source Code
   593                              <1> 	;     RS232.ASM --- 10/06/1985 COMMUNICATIONS BIOS (RS232)
   594                              <1> 	; (2) Award BIOS 1999 - ATORGS.ASM
   595                              <1> 	; (3) http://wiki.osdev.org/Serial_Ports
   596                              <1> 	;
   597                              <1> 	; Set communication parameters for COM1 (= 03h)	
   598                              <1> 	;
   599 00012E28 BB[368A0100]        <1> 	mov	ebx, com1p		; COM1 parameters  
   600 00012E2D 66BAF803            <1> 	mov	dx, 3F8h		; COM1
   601                              <1> 	 ; 29/10/2015
   602 00012E31 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
   603 00012E35 E86F000000          <1> 	call	sp_i3	; call A4	
   604 00012E3A A880                <1> 	test	al, 80h
   605 00012E3C 7410                <1> 	jz	short sp_i0 ; OK..
   606                              <1> 		; Error !
   607                              <1> 	;mov	dx, 3F8h
   608 00012E3E 80EA05              <1> 	sub	dl, 5 ; 3FDh -> 3F8h
   609 00012E41 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
   610 00012E45 E85F000000          <1> 	call	sp_i3	; call A4	
   611 00012E4A A880                <1> 	test	al, 80h
   612 00012E4C 7508                <1> 	jnz	short sp_i1
   613                              <1> sp_i0:
   614                              <1>         ; (Note: Serial port interrupts will be disabled here...)	
   615                              <1>         ; (INT 14h initialization code disables interrupts.)
   616                              <1> 	;
   617 00012E4E C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
   618 00012E51 E8DC000000          <1> 	call	sp_i5 ; 29/06/2015
   619                              <1> sp_i1:
   620 00012E56 43                  <1> 	inc	ebx
   621 00012E57 66BAF802            <1> 	mov	dx, 2F8h		; COM2
   622                              <1> 	 ; 29/10/2015
   623 00012E5B 66B90103            <1> 	mov	cx, 301h  ; divisor = 1 (115200 baud)
   624 00012E5F E845000000          <1> 	call	sp_i3	; call A4	
   625 00012E64 A880                <1> 	test	al, 80h
   626 00012E66 7410                <1> 	jz	short sp_i2 ; OK..
   627                              <1> 		; Error !
   628                              <1> 	;mov	dx, 2F8h
   629 00012E68 80EA05              <1> 	sub	dl, 5 ; 2FDh -> 2F8h
   630 00012E6B 66B90E03            <1> 	mov	cx, 30Eh  ; divisor = 12 (9600 baud)
   631 00012E6F E835000000          <1> 	call	sp_i3	; call A4	
   632 00012E74 A880                <1> 	test	al, 80h
   633 00012E76 7530                <1> 	jnz	short sp_i7
   634                              <1> sp_i2:
   635 00012E78 C603E3              <1> 	mov	byte [ebx], 0E3h ; 11100011b
   636                              <1> sp_i6:
   637                              <1> 	;; COM2 - enabling IRQ 3
   638                              <1> 	; 07/11/2015
   639                              <1> 	; 26/10/2015
   640 00012E7B 9C                  <1> 	pushf
   641 00012E7C FA                  <1> 	cli
   642                              <1> 	;
   643 00012E7D 66BAFC02            <1> 	mov	dx, 2FCh   		; modem control register
   644 00012E81 EC                  <1> 	in	al, dx 	   		; read register
   645 00012E82 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   646 00012E84 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
   647 00012E86 EE                  <1> 	out	dx, al     		; write back to register
   648 00012E87 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   649 00012E89 66BAF902            <1> 	mov	dx, 2F9h   		; interrupt enable register
   650 00012E8D EC                  <1> 	in	al, dx     		; read register
   651 00012E8E EB00                <1> 	JMP	$+2	   		; I/O DELAY
   652                              <1> 	;or	al, 1      		; receiver data interrupt enable and
   653 00012E90 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
   654 00012E92 EE                  <1> 	out	dx, al 	   		; write back to register
   655 00012E93 EB00                <1> 	JMP	$+2        		; I/O DELAY
   656 00012E95 E421                <1> 	in	al, 21h    		; read interrupt mask register
   657 00012E97 EB00                <1> 	JMP	$+2	   		; I/O DELAY
   658 00012E99 24F7                <1> 	and	al, 0F7h   		; enable IRQ 3 (COM2)
   659 00012E9B E621                <1> 	out	21h, al    		; write back to register
   660                              <1> 	;
   661                              <1> 	; 23/10/2015
   662 00012E9D B8[5B2D0100]        <1> 	mov 	eax, com2_int
   663 00012EA2 A3[7A2F0100]        <1> 	mov	[com2_irq3], eax
   664                              <1> 	; 26/10/2015
   665 00012EA7 9D                  <1> 	popf	
   666                              <1> sp_i7:
   667 00012EA8 C3                  <1> 	retn
   668                              <1> 
   669                              <1> sp_i3:
   670                              <1> ;A4:  	;-----	INITIALIZE THE COMMUNICATIONS PORT
   671                              <1> 	; 28/10/2015
   672 00012EA9 FEC2                <1> 	inc	dl	; 3F9h (2F9h)	; 3F9h, COM1 Interrupt enable register 
   673 00012EAB B000                <1> 	mov	al, 0
   674 00012EAD EE                  <1> 	out	dx, al			; disable serial port interrupt
   675 00012EAE EB00                <1> 	JMP	$+2			; I/O DELAY
   676 00012EB0 80C202              <1> 	add	dl, 2 	; 3FBh (2FBh)	; COM1 Line control register (3FBh)
   677 00012EB3 B080                <1> 	mov	al, 80h			
   678 00012EB5 EE                  <1> 	out	dx, al			; SET DLAB=1 ; divisor latch access bit
   679                              <1> 	;-----	SET BAUD RATE DIVISOR
   680                              <1> 	; 26/10/2015
   681 00012EB6 80EA03              <1> 	sub 	dl, 3   ; 3F8h (2F8h)	; register for least significant byte
   682                              <1> 					; of the divisor value
   683 00012EB9 88C8                <1> 	mov	al, cl	; 1
   684 00012EBB EE                  <1> 	out	dx, al			; 1 = 115200 baud (Retro UNIX 386 v1)
   685                              <1> 					; 2 = 57600 baud
   686                              <1> 					; 3 = 38400 baud
   687                              <1> 					; 6 = 19200 baud
   688                              <1> 					; 12 = 9600 baud (Retro UNIX 8086 v1)
   689 00012EBC EB00                <1> 	JMP	$+2			; I/O DELAY
   690 00012EBE 28C0                <1> 	sub	al, al
   691 00012EC0 FEC2                <1> 	inc	dl      ; 3F9h (2F9h)	; register for most significant byte
   692                              <1> 					; of the divisor value
   693 00012EC2 EE                  <1> 	out	dx, al ; 0
   694 00012EC3 EB00                <1> 	JMP	$+2			; I/O DELAY
   695                              <1> 	;	
   696 00012EC5 88E8                <1> 	mov	al, ch ; 3		; 8 data bits, 1 stop bit, no parity
   697                              <1> 	;and	al, 1Fh ; Bits 0,1,2,3,4	
   698 00012EC7 80C202              <1> 	add	dl, 2	; 3FBh (2FBh)	; Line control register
   699 00012ECA EE                  <1> 	out	dx, al			
   700 00012ECB EB00                <1> 	JMP	$+2			; I/O DELAY
   701                              <1> 	; 29/10/2015
   702 00012ECD FECA                <1> 	dec 	dl 	; 3FAh (2FAh)	; FIFO Control register (16550/16750)
   703 00012ECF 30C0                <1> 	xor	al, al			; 0
   704 00012ED1 EE                  <1> 	out	dx, al			; Disable FIFOs (reset to 8250 mode)
   705 00012ED2 EB00                <1> 	JMP	$+2	
   706                              <1> sp_i4:
   707                              <1> ;A18:	;-----	COMM PORT STATUS ROUTINE
   708                              <1> 	; 29/06/2015 (line status after modem status)
   709 00012ED4 80C204              <1> 	add	dl, 4	; 3FEh (2FEh)	; Modem status register
   710                              <1> sp_i4s:
   711 00012ED7 EC                  <1> 	in	al, dx			; GET MODEM CONTROL STATUS
   712 00012ED8 EB00                <1> 	JMP	$+2			; I/O DELAY
   713 00012EDA 88C4                <1> 	mov	ah, al			; PUT IN (AH) FOR RETURN
   714 00012EDC FECA                <1> 	dec	dl	; 3FDh (2FDh)	; POINT TO LINE STATUS REGISTER
   715                              <1> 					; dx = 3FDh for COM1, 2FDh for COM2
   716 00012EDE EC                  <1> 	in	al, dx			; GET LINE CONTROL STATUS
   717                              <1> 	; AL = Line status, AH = Modem status
   718 00012EDF C3                  <1> 	retn
   719                              <1> 
   720                              <1> sp_status:
   721                              <1> 	; 29/06/2015
   722                              <1> 	; 27/06/2015 (Retro UNIX 386 v1)
   723                              <1> 	; Get serial port status
   724 00012EE0 66BAFE03            <1> 	mov	dx, 3FEh		; Modem status register (COM1)
   725 00012EE4 28C6                <1> 	sub	dh, al			; dh = 2 for COM2 (al = 1)
   726                              <1> 					; dx = 2FEh for COM2
   727 00012EE6 EBEF                <1> 	jmp	short sp_i4s
   728                              <1> 
   729                              <1> sp_setp: ; Set serial port communication parameters
   730                              <1> 	; 07/11/2015
   731                              <1> 	; 29/10/2015
   732                              <1> 	; 29/06/2015
   733                              <1> 	; Retro UNIX 386 v1 feature only !	
   734                              <1> 	;
   735                              <1> 	; INPUT:
   736                              <1> 	;	AL = 0 for COM1
   737                              <1> 	;	     1 for COM2
   738                              <1> 	;	AH = Communication parameters (*)
   739                              <1> 	; OUTPUT:
   740                              <1> 	;	CL = Line status
   741                              <1> 	;	CH = Modem status
   742                              <1> 	;   If cf = 1 -> Error code in [u.error]
   743                              <1> 	;		 'invalid parameter !' 
   744                              <1> 	;		 	 or
   745                              <1> 	;		 'device not ready !' error
   746                              <1> 	;	
   747                              <1> 	;  (*) Communication parameters (except BAUD RATE):
   748                              <1> 	;	Bit	4	3	2	1	0
   749                              <1> 	;		-PARITY--   STOP BIT  -WORD LENGTH-	 		 
   750                              <1> 	;  this one -->	00 = none    0 = 1 bit  11 = 8 bits
   751                              <1> 	;		01 = odd     1 = 2 bits	10 = 7 bits
   752                              <1> 	;		11 = even
   753                              <1> 	;  Baud rate setting bits: (29/06/2015)
   754                              <1> 	;		Retro UNIX 386 v1 feature only !
   755                              <1> 	;	Bit	7    6    5  | Baud rate
   756                              <1> 	;		------------------------
   757                              <1> 	;	value	0    0    0  | Default (Divisor = 1)
   758                              <1> 	;		0    0    1  | 9600 (12)
   759                              <1> 	;		0    1    0  | 19200 (6) 
   760                              <1> 	;		0    1	  1  | 38400 (3) 
   761                              <1> 	;		1    0	  0  | 14400 (8)
   762                              <1> 	;		1    0	  1  | 28800 (4)
   763                              <1> 	;		1    1    0  | 57600 (2)
   764                              <1> 	;		1    1    1  | 115200 (1) 
   765                              <1> 	;
   766                              <1> 	; (COM1 base port address = 3F8h, COM1 Interrupt = IRQ 4)
   767                              <1> 	; (COM2 base port address = 2F8h, COM1 Interrupt = IRQ 3)
   768                              <1> 	;
   769                              <1> 	; ((Modified registers: EAX, ECX, EDX, EBX))
   770                              <1> 	;
   771 00012EE8 66BAF803            <1> 	mov	dx, 3F8h
   772 00012EEC BB[368A0100]        <1> 	mov	ebx, com1p ; COM1 control byte offset
   773 00012EF1 3C01                <1> 	cmp	al, 1
   774 00012EF3 776B                <1> 	ja 	short sp_invp_err
   775 00012EF5 7203                <1> 	jb	short sp_setp1 ;  COM1 (AL = 0)
   776 00012EF7 FECE                <1> 	dec	dh ; 2F8h
   777 00012EF9 43                  <1> 	inc	ebx ; COM2 control byte offset
   778                              <1> sp_setp1:
   779                              <1> 	; 29/10/2015
   780 00012EFA 8823                <1> 	mov	[ebx], ah
   781 00012EFC 0FB6CC              <1> 	movzx 	ecx, ah
   782 00012EFF C0E905              <1> 	shr	cl, 5 ; -> baud rate index
   783 00012F02 80E41F              <1> 	and	ah, 1Fh ; communication parameters except baud rate
   784 00012F05 8A81[6F2F0100]      <1> 	mov	al, [ecx+b_div_tbl]
   785 00012F0B 6689C1              <1> 	mov	cx, ax
   786 00012F0E E896FFFFFF          <1> 	call	sp_i3
   787 00012F13 6689C1              <1> 	mov	cx, ax ; CL = Line status, CH = Modem status
   788 00012F16 A880                <1> 	test	al, 80h
   789 00012F18 740F                <1> 	jz	short sp_setp2
   790 00012F1A C603E3              <1>         mov     byte [ebx], 0E3h ; Reset to initial value (11100011b)
   791                              <1> stp_dnr_err:
   792 00012F1D C705[C8030300]0F00- <1> 	mov	dword [u.error], ERR_DEV_NOT_RDY ; 'device not ready !'
   792 00012F25 0000                <1>
   793                              <1> 	; CL = Line status, CH = Modem status
   794 00012F27 F9                  <1> 	stc
   795 00012F28 C3                  <1> 	retn
   796                              <1> sp_setp2:
   797 00012F29 80FE02              <1> 	cmp	dh, 2 ; COM2 (2F?h)
   798 00012F2C 0F8649FFFFFF        <1>         jna     sp_i6 
   799                              <1> 		      ; COM1 (3F?h)
   800                              <1> sp_i5: 
   801                              <1> 	; 07/11/2015
   802                              <1> 	; 26/10/2015
   803                              <1> 	; 29/06/2015
   804                              <1> 	;
   805                              <1> 	;; COM1 - enabling IRQ 4
   806 00012F32 9C                  <1> 	pushf
   807 00012F33 FA                  <1> 	cli
   808 00012F34 66BAFC03            <1> 	mov	dx, 3FCh   		; modem control register
   809 00012F38 EC                  <1> 	in	al, dx 	   		; read register
   810 00012F39 EB00                <1> 	JMP	$+2			; I/O DELAY
   811 00012F3B 0C08                <1> 	or	al, 8      		; enable bit 3 (OUT2)
   812 00012F3D EE                  <1> 	out	dx, al     		; write back to register
   813 00012F3E EB00                <1> 	JMP	$+2			; I/O DELAY
   814 00012F40 66BAF903            <1> 	mov	dx, 3F9h   		; interrupt enable register
   815 00012F44 EC                  <1> 	in	al, dx     		; read register
   816 00012F45 EB00                <1> 	JMP	$+2			; I/O DELAY
   817                              <1> 	;or	al, 1      		; receiver data interrupt enable and
   818 00012F47 0C03                <1> 	or	al, 3	   		; transmitter empty interrupt enable
   819 00012F49 EE                  <1> 	out	dx, al 	   		; write back to register
   820 00012F4A EB00                <1> 	JMP	$+2        		; I/O DELAY
   821 00012F4C E421                <1> 	in	al, 21h    		; read interrupt mask register
   822 00012F4E EB00                <1> 	JMP	$+2			; I/O DELAY
   823 00012F50 24EF                <1> 	and	al, 0EFh   		; enable IRQ 4 (COM1)
   824 00012F52 E621                <1> 	out	21h, al    		; write back to register
   825                              <1> 	;
   826                              <1> 	; 23/10/2015
   827 00012F54 B8[642D0100]        <1> 	mov 	eax, com1_int
   828 00012F59 A3[762F0100]        <1> 	mov	[com1_irq4], eax
   829                              <1> 	; 26/10/2015
   830 00012F5E 9D                  <1> 	popf
   831 00012F5F C3                  <1> 	retn
   832                              <1> 
   833                              <1> sp_invp_err:
   834 00012F60 C705[C8030300]1700- <1> 	mov	dword [u.error], ERR_INV_PARAMETER ; 'invalid parameter !' 
   834 00012F68 0000                <1>
   835 00012F6A 31C9                <1> 	xor	ecx, ecx
   836 00012F6C 49                  <1> 	dec	ecx ; 0FFFFh
   837 00012F6D F9                  <1> 	stc
   838 00012F6E C3                  <1> 	retn
   839                              <1> 
   840                              <1> ; 29/10/2015
   841                              <1> b_div_tbl: ; Baud rate divisor table (115200/divisor)
   842 00012F6F 010C0603080401      <1> 	db 1, 12, 6, 3, 8, 4, 1
   843                              <1> 
   844                              <1> 
   845                              <1> ; 23/10/2015
   846                              <1> com1_irq4:
   847 00012F76 [7E2F0100]          <1> 	dd dummy_retn
   848                              <1> com2_irq3:
   849 00012F7A [7E2F0100]          <1> 	dd dummy_retn
   850                              <1> 
   851                              <1> dummy_retn:
   852 00012F7E C3                  <1> 	retn
   853                              <1> 
   854                              <1> wakeup:
   855                              <1> 	; 24/01/2016
   856 00012F7F C3                  <1> 	retn
   857                              <1> 
   858                              <1> set_working_path_x:
   859                              <1> 		; 17/10/2016 (TRDOS 386 - FFF & FNF)
   860 00012F80 66B80100            <1> 		mov	ax, 1 
   861                              <1> 			; File name is needed/forced (AL=1)
   862                              <1> 			; Change directory as temporary (AH=0)	
   863                              <1> 
   864                              <1> set_working_path_xx: ; 30/12/2017 (syschdir)
   865                              <1> 		; This is needed for preventing wrong Find Next File
   866                              <1> 		; system call after sysopen, syscreate, sysmkdir etc. 
   867                              <1> 		; Find Next File must immediate follow Find First File)
   868                              <1> 
   869 00012F84 8825[84960100]      <1> 		mov	[FFF_Valid], ah ; 0 ; reset ; 17/10/2016
   870                              <1> 
   871                              <1> set_working_path:
   872                              <1> 		; 16/10/2016
   873                              <1> 		; 12/10/2016
   874                              <1> 		; 10/10/2016
   875                              <1> 		; 05/10/2016 - TRDOS 386 (TRDOS v2.0)
   876                              <1> 		;
   877                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_set_working_path")
   878                              <1>                 ; 27/01/2011 - 08/02/2011 
   879                              <1> 		; Set/Changes current drive, directory and file
   880                              <1> 		; depending on command tail
   881                              <1> 		; (procedure is derivated from CMD_INTR.ASM 
   882                              <1> 		; file or dir locating code of internal commands)
   883                              <1> 		; (This procedure is prepared for INT 21H file/dir 
   884                              <1> 		; functions and also to get compact code for 
   885                              <1> 		; internal mainprog -command interpreter- commands)
   886                              <1> 		; 
   887                              <1> 		; INPUT: DS:SI -> Command tail (ASCIIZ string)
   888                              <1> 		; AL = 0 -> any, AL > 0 -> file name is forced
   889                              <1> 		; AH = CD -> Change directory permanently 
   890                              <1> 		; AH <> CD -> Change directory as temporary    
   891                              <1> 		; 
   892                              <1> 		; OUTPUT: ES=DS, FindFile structure has been set
   893                              <1> 		;        RUN_CDRV points previous current drive  
   894                              <1> 		;        DS:SI = FindFile structure address
   895                              <1> 		;        (DS=CS)       
   896                              <1> 		;        AX, BX, CX, DX, DI will be changed
   897                              <1> 		;   cf = 1 -> Error code in AX (AL)
   898                              <1> 		;        stc & AX = 0 -> Bad command or path name 
   899                              <1> 		; -----------------------------------------------
   900                              <1> 		;
   901                              <1> 		; TRDOS 386 (05/10/2016)
   902                              <1> 		; INPUT:
   903                              <1> 		;	ESI = File/Directory Path (ASCIIZ string)
   904                              <1> 		;             address in user's memory space
   905                              <1> 		;       AL = 0 -> any
   906                              <1> 		;       AL > 0 -> file name is forced
   907                              <1> 		;       AH = CD -> change directory as permanent
   908                              <1> 		;       AH <> CD -> change directory as temporary
   909                              <1> 		; 
   910                              <1> 		; OUTPUT:
   911                              <1> 		;	FindFile structure has been set
   912                              <1> 		;       RUN_CDRV points previous current drive  
   913                              <1> 		;       ESI = FindFile_Name address ; 12/10/2016
   914                              <1> 		;
   915                              <1> 		;       cf = 1 -> Error code in EAX (AL)
   916                              <1> 		;       stc & EAX = 0 -> Bad command or path name
   917                              <1> 		;  
   918                              <1> 		; Modified registers: EAX, EBX, ECX, EDX, ESI, EDI
   919                              <1> 
   920 00012F8A 66A3[88960100]      <1> 		mov	[SWP_Mode], ax
   921 00012F90 A0[968A0100]        <1> 		mov	al, [Current_Drv]
   922 00012F95 30E4                <1> 		xor	ah, ah
   923 00012F97 66A3[8A960100]      <1> 		mov	[SWP_DRV], ax
   924                              <1> 
   925                              <1> 		; TRDOS 386 ring 3 (user's page directory)
   926                              <1> 		; to ring 0 (kernel's page directory) 
   927                              <1> 		; transfer modifications (05/10/2016).
   928                              <1> 
   929 00012F9D 55                  <1> 		push	ebp
   930 00012F9E 89E5                <1> 		mov	ebp, esp
   931                              <1> 		
   932 00012FA0 B980000000          <1> 		mov	ecx, 128 ; maximum path length = 128 bytes
   933 00012FA5 29CC                <1> 		sub	esp, ecx ; reserve 128 bytes (buffer) on stack
   934 00012FA7 89E7                <1> 		mov	edi, esp ; destination address (kernel space)
   935                              <1> 		; esi = source address (virtual, in user's memory space)
   936 00012FA9 E8A0EBFFFF          <1> 		call	transfer_from_user_buffer
   937 00012FAE 720A                <1> 		jc	short loc_swp_xor_retn 
   938                              <1> 		
   939 00012FB0 89E6                <1> 		mov	esi, esp ; temporary buffer (the path) on stack
   940                              <1> loc_swp_fchar:
   941 00012FB2 8A06                <1> 		mov	al, [esi]
   942 00012FB4 3C20                <1> 		cmp	al, 20h
   943 00012FB6 7711                <1> 		ja	short loc_swp_parse_path_name
   944 00012FB8 740C                <1> 		je	short loc_swp_fchar_next
   945                              <1> 
   946                              <1> loc_swp_xor_retn:
   947 00012FBA 31C0                <1> 		xor	eax, eax
   948 00012FBC F9                  <1> 		stc
   949                              <1> loc_swp_retn:
   950 00012FBD 89EC                <1> 		mov	esp, ebp
   951 00012FBF 5D                  <1> 		pop	ebp
   952                              <1> 
   953                              <1> 		;mov	esi, FindFile_Drv
   954 00012FC0 BE[78930100]        <1> 		mov	esi, FindFile_Name ; 12/10/2016
   955 00012FC5 C3                  <1> 		retn 
   956                              <1> 
   957                              <1> loc_swp_fchar_next:
   958 00012FC6 46                  <1> 		inc	esi
   959 00012FC7 EBE9                <1> 		jmp	short loc_swp_fchar  
   960                              <1> 
   961                              <1> loc_swp_parse_path_name:
   962 00012FC9 BF[36930100]        <1> 		mov	edi, FindFile_Drv
   963 00012FCE E87F86FFFF          <1> 		call	parse_path_name
   964 00012FD3 72E8                <1> 		jc	short loc_swp_retn
   965                              <1> 
   966                              <1> loc_swp_checkfile_name:
   967 00012FD5 803D[88960100]00    <1> 		cmp	byte [SWP_Mode], 0
   968 00012FDC 761E                <1> 		jna	short loc_swp_drv
   969                              <1> 
   970                              <1> 		; 10/10/2016 (valid file name checking)
   971 00012FDE BE[78930100]        <1> 		mov	esi, FindFile_Name
   972 00012FE3 803E20              <1> 		cmp	byte [esi], 20h
   973 00012FE6 76D2                <1> 		jna	short loc_swp_xor_retn
   974                              <1> 
   975                              <1> 		; 16/10/2016
   976 00012FE8 C605[87960100]00    <1> 		mov	byte [SWP_inv_fname], 0 ; reset 
   977                              <1> 		; esi = file name address (ASCIIZ)
   978 00012FEF E84B68FFFF          <1> 		call	check_filename
   979 00012FF4 7306                <1> 		jnc	short loc_swp_drv
   980                              <1> 
   981 00012FF6 FE05[87960100]      <1> 		inc	byte [SWP_inv_fname] ; set 	
   982                              <1> loc_swp_drv:
   983 00012FFC 8A35[968A0100]      <1> 		mov	dh, [Current_Drv]
   984                              <1>                ;mov	[RUN_CDRV], dh
   985                              <1> 
   986 00013002 8A15[36930100]      <1> 		mov	dl, [FindFile_Drv]
   987                              <1>                ;cmp	dl, dh
   988 00013008 3A15[968A0100]      <1> 		cmp	dl, [Current_Drv]
   989 0001300E 740D                <1> 		je	short loc_swp_change_directory
   990                              <1> 
   991 00013010 FE05[8B960100]      <1> 		inc	byte [SWP_DRV_chg]
   992 00013016 E8C350FFFF          <1> 		call	change_current_drive
   993 0001301B 72A0                <1> 		jc	short loc_swp_retn ; eax = error code
   994                              <1> 		; eax = 0
   995                              <1> 
   996                              <1> loc_swp_change_directory:
   997 0001301D 803D[37930100]21    <1> 		cmp	byte [FindFile_Directory], 21h
   998 00013024 F5                  <1> 		cmc
   999 00013025 7396                <1> 		jnc	short loc_swp_retn
  1000                              <1> 
  1001 00013027 FE05[8B960100]      <1> 		inc	byte [SWP_DRV_chg]
  1002 0001302D FE05[63400100]      <1> 		inc	byte [Restore_CDIR]
  1003 00013033 BE[37930100]        <1> 		mov	esi, FindFile_Directory
  1004 00013038 8A25[89960100]      <1> 		mov	ah, [SWP_Mode+1] 
  1005 0001303E E8F97FFFFF          <1> 		call	change_current_directory
  1006 00013043 0F8274FFFFFF        <1> 		jc	loc_swp_retn ; eax = error code
  1007                              <1> 
  1008                              <1> loc_swp_change_prompt_dir_string:
  1009                              <1> 		; esi = PATH_Array
  1010                              <1> 		; eax = Current Directory First Cluster
  1011                              <1> 		; edi = Logical DOS Drive Description Table	
  1012 00013049 E8137FFFFF          <1> 		call	change_prompt_dir_str 
  1013 0001304E 29C0                <1> 		sub	eax, eax ; 0
  1014 00013050 E968FFFFFF          <1> 		jmp	loc_swp_retn 
  1015                              <1> 
  1016                              <1> reset_working_path:
  1017                              <1> 		; 06/10/2016 - TRDOS 386 (TRDOS v2.0)
  1018                              <1> 		;
  1019                              <1> 		; TRDOS v1.0 (DIR.ASM, "proc_reset_working_path")
  1020                              <1> 		; 05/02/2011 - 08/02/2011 
  1021                              <1> 		;
  1022                              <1> 		; Restores current drive and directory 
  1023                              <1> 		; 
  1024                              <1> 		; INPUT: none
  1025                              <1> 		; OUTPUT: DL = SWP_DRV, EAX = 0 -> OK
  1026                              <1> 		;
  1027                              <1> 		;    AX = 0 -> ESI = Logical Dos Drv Desc. Table
  1028                              <1> 		;
  1029                              <1> 		;    EAX, EBX, ECX, EDX, ESI, EDI will be changed
  1030                              <1> 		;
  1031                              <1> 
  1032                              <1>   
  1033 00013055 31C0                <1> 		xor	eax, eax
  1034 00013057 48                  <1> 		dec	eax 
  1035                              <1> 
  1036 00013058 668B15[8A960100]    <1> 		mov	dx, [SWP_DRV]
  1037 0001305F 08F6                <1> 		or	dh, dh
  1038 00013061 742E                <1> 		jz	short loc_rwp_return
  1039                              <1> 
  1040 00013063 3A15[968A0100]      <1> 		cmp	dl, [Current_Drv]
  1041 00013069 7407                <1> 		je	short loc_rwp_restore_cdir
  1042                              <1> loc_rwp_restore_cdrv:
  1043 0001306B E86E50FFFF          <1> 		call	change_current_drive 
  1044 00013070 EB10                <1> 		jmp	short loc_rwp_restore_ok
  1045                              <1> loc_rwp_restore_cdir:
  1046 00013072 31DB                <1> 		xor	ebx, ebx
  1047 00013074 88D7                <1> 		mov	bh, dl
  1048 00013076 BE00010900          <1> 		mov	esi, Logical_DOSDisks
  1049 0001307B 01DE                <1> 		add	esi, ebx
  1050                              <1> 
  1051 0001307D E81351FFFF          <1> 		call	restore_current_directory
  1052                              <1> 
  1053                              <1> loc_rwp_restore_ok:
  1054 00013082 668B15[8A960100]    <1> 		mov	dx, [SWP_DRV]
  1055 00013089 31C0                <1> 		xor	eax, eax  
  1056 0001308B 66A3[8B960100]      <1> 		mov	[SWP_DRV_chg], ax
  1057                              <1> loc_rwp_return:
  1058 00013091 C3                  <1> 		retn
  1059                              <1> 
  1060                              <1> get_file_name:
  1061                              <1> 		; 15/10/2016 - TRDOS 386 (TRDOS v2.0)
  1062                              <1> 		; Convert file name 
  1063                              <1> 		;	from directory entry format
  1064                              <1>                 ; 	to (8.3) dot file name format 
  1065                              <1> 		;
  1066                              <1> 		; TRDOS v1.0 (DIR.ASM, "get_file_name")
  1067                              <1>                 ; 2005 - 09/10/2011 	
  1068                              <1> 		; INPUT: 
  1069                              <1> 		;	DS:SI -> Directory Entry Format File Name
  1070                              <1> 		;       ES:DI -> DOS Dot File Name Address
  1071                              <1> 		; OUTPUT:
  1072                              <1> 		;	DS:SI -> DOS Dot File Name Address
  1073                              <1>                 ;	ES:DI -> Directory Entry Format File Name
  1074                              <1> 		;	
  1075                              <1> 		; TRDOS 386 (15/10/2016)
  1076                              <1> 		; INPUT:
  1077                              <1> 		;	ESI = File name addr in dir entry format
  1078                              <1> 		;	EDI = Dot file name address (destination)
  1079                              <1> 		; OUTPUT: 
  1080                              <1> 		;	File name is converted and moved
  1081                              <1> 		;	to destination (as 8.3 dot filename)
  1082                              <1> 		;  
  1083                              <1> 		; Modified registers: EAX, ECX
  1084                              <1> 
  1085                              <1>                 ; 2005 (TRDOS 8086) - 2016 (TRDOS 386)
  1086                              <1>                             
  1087 00013092 57                  <1> 		push	edi
  1088 00013093 56                  <1> 		push	esi
  1089 00013094 AC                  <1> 		lodsb
  1090 00013095 3C20                <1> 		cmp	al, 20h
  1091 00013097 762A                <1> 		jna	short pass_gfn_ext
  1092 00013099 56                  <1> 		push	esi
  1093 0001309A AA                  <1> 		stosb
  1094 0001309B B907000000          <1> 		mov	ecx, 7
  1095                              <1> loc_gfn_next_char:
  1096 000130A0 AC                  <1> 		lodsb
  1097 000130A1 3C20                <1> 		cmp	al, 20h
  1098 000130A3 7603                <1> 		jna	short pass_gfn_fn
  1099 000130A5 AA                  <1> 		stosb
  1100 000130A6 E2F8                <1> 		loop	loc_gfn_next_char
  1101                              <1> pass_gfn_fn:
  1102 000130A8 5E                  <1> 		pop	esi
  1103 000130A9 83C607              <1> 		add	esi, 7
  1104 000130AC AC                  <1> 		lodsb
  1105 000130AD 3C20                <1> 		cmp	al, 20h
  1106 000130AF 7612                <1> 		jna	short pass_gfn_ext
  1107 000130B1 B42E                <1> 		mov	ah, '.'
  1108 000130B3 86E0                <1> 		xchg	ah, al
  1109 000130B5 66AB                <1> 		stosw
  1110 000130B7 AC                  <1> 		lodsb
  1111 000130B8 3C20                <1> 		cmp	al, 20h
  1112 000130BA 7607                <1> 		jna	short pass_gfn_ext
  1113 000130BC AA                  <1> 		stosb
  1114 000130BD AC                  <1> 		lodsb
  1115 000130BE 3C20                <1> 		cmp	al, 20h
  1116 000130C0 7601                <1> 		jna	short pass_gfn_ext
  1117 000130C2 AA                  <1> 		stosb
  1118                              <1> pass_gfn_ext:		
  1119 000130C3 30C0                <1> 		xor	al, al
  1120 000130C5 AA                  <1> 		stosb
  1121 000130C6 5E                  <1> 		pop	esi
  1122 000130C7 5F                  <1> 		pop	edi
  1123 000130C8 C3                  <1> 		retn
  1124                              <1> 
  1125                              <1> set_hardware_int_vector:
  1126                              <1> 		; 18/03/2017
  1127                              <1> 		; 03/03/2017
  1128                              <1> 		; 28/02/2017 - TRDOS 386 (TRDOS v2.0)
  1129                              <1> 		;
  1130                              <1> 		; SET/RESET HARDWARE INTERRUPT GATE
  1131                              <1> 		;
  1132                              <1> 		; Changes interrupt gate descriptor table
  1133                              <1> 		; (without changing default interrupt list)
  1134                              <1> 		;
  1135                              <1> 		; INPUT:
  1136                              <1> 		;	AL = IRQ number (0 to 15)
  1137                              <1> 		;	AH > 0 -> set
  1138                              <1> 		;	AH = 0 -> reset
  1139                              <1> 		;	
  1140                              <1> 		; Modified registers: eax, ebx, edx, edi 
  1141                              <1> 		;
  1142                              <1> 		
  1143 000130C9 C0E002              <1> 		shl	al, 2 ; IRQ number * 4
  1144 000130CC 0FB6D8              <1> 		movzx	ebx, al
  1145                              <1> 
  1146 000130CF 08E4                <1> 		or	ah, ah
  1147 000130D1 7508                <1> 		jnz	short shintv_1 ; set (for user call service)
  1148                              <1> 		
  1149                              <1> 		; 18/03/2017
  1150 000130D3 81C3[604A0100]      <1> 		add	ebx, IRQ_list ; reset to default interrupt list
  1151 000130D9 EB06                <1> 		jmp	short shintv_2
  1152                              <1> shintv_1:
  1153 000130DB 81C3[02310100]      <1> 		add	ebx, IRQ_u_list
  1154                              <1> shintv_2:	
  1155 000130E1 8B13                <1> 		mov	edx, [ebx] ; IRQ handler address
  1156                              <1> 		
  1157                              <1> 		; 03/03/2017
  1158 000130E3 D0E0                <1> 		shl	al, 1 ; IRQ number * 8 
  1159                              <1> 		; 18/03/2017
  1160 000130E5 0FB6F8              <1> 		movzx	edi, al 
  1161 000130E8 81C7[E8870100]      <1> 		add	edi, idt + (8*32) ; IRQ 0 offset = idt + 256
  1162                              <1> 		
  1163 000130EE 89D0                <1> 		mov	eax, edx ; IRQ handler address
  1164 000130F0 BB00000800          <1> 		mov	ebx, 80000h
  1165                              <1> 
  1166                              <1> 		;mov	edx, eax
  1167 000130F5 66BA008E            <1> 		mov	dx, 8E00h
  1168 000130F9 6689C3              <1> 		mov	bx, ax
  1169 000130FC 89D8                <1> 		mov	eax, ebx ; /* selector = 0x0008 = cs */
  1170                              <1>        			         ; /* interrupt gate - dpl=0, present */
  1171 000130FE AB                  <1> 		stosd	; selector & offset bits 0-15 	
  1172 000130FF 8917                <1> 		mov	[edi], edx ; attributes & offset bits 16-23
  1173                              <1> 
  1174 00013101 C3                  <1> 		retn
  1175                              <1> IRQ_u_list:
  1176                              <1> 		; 28/02/2017
  1177 00013102 [56090000]          <1> 		dd	timer_int
  1178 00013106 [CE100000]          <1> 		dd	kb_int
  1179 0001310A [380B0000]          <1> 		dd	irq2
  1180 0001310E [42310100]          <1> 		dd	IRQ_service3
  1181 00013112 [4C310100]          <1> 		dd	IRQ_service4
  1182 00013116 [56310100]          <1> 		dd	IRQ_service5
  1183 0001311A [D3510000]          <1> 		dd	fdc_int	
  1184 0001311E [60310100]          <1> 		dd	IRQ_service7
  1185 00013122 [C10A0000]          <1> 		dd	rtc_int
  1186 00013126 [6A310100]          <1> 		dd	IRQ_service9
  1187 0001312A [74310100]          <1> 		dd	IRQ_service10
  1188 0001312E [7E310100]          <1> 		dd	IRQ_service11
  1189 00013132 [88310100]          <1> 		dd	IRQ_service12
  1190 00013136 [92310100]          <1> 		dd	IRQ_service13
  1191 0001313A [865B0000]          <1> 		dd	hdc1_int
  1192 0001313E [AD5B0000]          <1> 		dd	hdc2_int
  1193                              <1> 
  1194                              <1> 		; 03/03/2017
  1195                              <1> 		; 27/02/2017
  1196                              <1> IRQ_service3:
  1197 00013142 36C605[4E9C0100]03  <1> 		mov	byte [ss:IRQnum], 3
  1198 0001314A EB4E                <1> 		jmp	short IRQ_service
  1199                              <1> IRQ_service4:
  1200 0001314C 36C605[4E9C0100]04  <1> 		mov	byte [ss:IRQnum], 4
  1201 00013154 EB44                <1> 		jmp	short IRQ_service
  1202                              <1> IRQ_service5:
  1203 00013156 36C605[4E9C0100]05  <1> 		mov	byte [ss:IRQnum], 5
  1204 0001315E EB3A                <1> 		jmp	short IRQ_service
  1205                              <1> IRQ_service7:
  1206 00013160 36C605[4E9C0100]07  <1> 		mov	byte [ss:IRQnum], 7
  1207 00013168 EB30                <1> 		jmp	short IRQ_service
  1208                              <1> IRQ_service9:
  1209 0001316A 36C605[4E9C0100]09  <1> 		mov	byte [ss:IRQnum], 9
  1210 00013172 EB26                <1> 		jmp	short IRQ_service
  1211                              <1> IRQ_service10:
  1212 00013174 36C605[4E9C0100]0A  <1> 		mov	byte [ss:IRQnum], 10
  1213 0001317C EB1C                <1> 		jmp	short IRQ_service
  1214                              <1> IRQ_service11:
  1215 0001317E 36C605[4E9C0100]0B  <1> 		mov	byte [ss:IRQnum], 11
  1216 00013186 EB12                <1> 		jmp	short IRQ_service
  1217                              <1> IRQ_service12:
  1218 00013188 36C605[4E9C0100]0C  <1> 		mov	byte [ss:IRQnum], 12
  1219 00013190 EB08                <1> 		jmp	short IRQ_service
  1220                              <1> IRQ_service13:
  1221 00013192 36C605[4E9C0100]0D  <1> 		mov	byte [ss:IRQnum], 13
  1222                              <1> 		;jmp	short IRQ_service
  1223                              <1> IRQ_service:
  1224                              <1> 		; 13/06/2017
  1225                              <1> 		; 11/06/2017
  1226                              <1> 		; 10/06/2017
  1227                              <1> 		; 01/03/2017, 04/03/2017
  1228                              <1> 		; 27/02/2017, 28/02/2017
  1229 0001319A 1E                  <1> 		push	ds
  1230 0001319B 06                  <1> 		push	es
  1231 0001319C 0FA0                <1> 		push	fs
  1232 0001319E 0FA8                <1> 		push	gs
  1233                              <1> 
  1234 000131A0 60                  <1> 		pushad	; eax,ecx,edx,ebx,esp,ebp,esi,edi
  1235 000131A1 66B91000            <1> 		mov     cx, KDATA
  1236 000131A5 8ED9                <1>         	mov     ds, cx
  1237 000131A7 8EC1                <1>         	mov     es, cx
  1238 000131A9 8EE1                <1>         	mov     fs, cx
  1239 000131AB 8EE9                <1>         	mov     gs, cx
  1240                              <1> 
  1241 000131AD 0F20D8              <1> 		mov	eax, cr3
  1242 000131B0 A3[4A9C0100]        <1> 		mov	[IRQ_cr3], eax
  1243                              <1> 
  1244 000131B5 A1[D0890100]        <1> 		mov	eax, [k_page_dir]
  1245 000131BA 0F22D8              <1> 		mov	cr3, eax 
  1246                              <1> 
  1247 000131BD A0[4E9C0100]        <1> 		mov	al, [IRQnum]
  1248                              <1> 
  1249                              <1> 		;mov	cl, [sysflg]
  1250                              <1> 		;mov	[u.r_mode], cl  ; system (0) or user mode (FFh) 
  1251                              <1> IRQsrv_0:
  1252 000131C2 0FB6D8              <1> 		movzx	ebx, al
  1253 000131C5 8A9B[98490100]      <1> 		mov	bl, [ebx+IRQenum] ; IRQ (available) index number + 1
  1254                              <1> 		; 01/03/2017
  1255 000131CB FECB                <1> 		dec	bl  ; IRQ index number, 0 to 8
  1256 000131CD 0F8807010000        <1> 		js	IRQsrv_5 ; not available to use here!?
  1257                              <1> 		;		 
  1258 000131D3 80BB[149C0100]80    <1> 		cmp	byte [ebx+IRQ.method], 80h ; using by a dev or kernel? 
  1259 000131DA 7205                <1> 		jb	short IRQsrv_1 ; no
  1260                              <1> 
  1261                              <1> 		; If the IRQ service is already owned by TRDOS 386 kernel
  1262                              <1> 		;	 or a Device driver
  1263                              <1> 		; we need to call 'dev_IRQ_service'
  1264                              <1> 
  1265                              <1> 		; IRQ number in AL
  1266 000131DC E866020000          <1> 		call	dev_IRQ_service	 ; IRQ service for device drivers	
  1267                              <1> 		; IRQ number in AL
  1268                              <1> IRQsrv_1:		
  1269                              <1> 		; check user callback service status
  1270                              <1> 		; AL = IRQ number
  1271                              <1> 		; EBX = IRQ (Available) Index number
  1272                              <1> 
  1273 000131E1 A2[D7030300]        <1> 		mov	[u.irqwait], al ; set waiting IRQ flag
  1274                              <1> 
  1275 000131E6 8A83[029C0100]      <1> 		mov	al, [ebx+IRQ.owner]
  1276 000131EC 20C0                <1> 		and	al, al
  1277 000131EE 0F84E6000000        <1> 		jz	IRQsrv_5 ; it is not owned by a user/proc
  1278                              <1> 
  1279                              <1> 		; 03/03/2017
  1280 000131F4 89DA                <1> 		mov	edx, ebx
  1281 000131F6 C0E202              <1> 		shl	dl, 2
  1282 000131F9 8B92[269C0100]      <1> 		mov	edx, [edx+IRQ.addr] ; S.R.B. or Callback service addr
  1283                              <1> 		
  1284 000131FF 8AA3[149C0100]      <1> 		mov	ah, [ebx+IRQ.method]
  1285 00013205 F6C401              <1> 		test	ah, 1
  1286 00013208 7534                <1> 		jnz	short IRQsrv_4 ; Callback service method
  1287                              <1> 
  1288                              <1> 		; Signal Response Byte method
  1289                              <1> 		;mov	edx, [edx+IRQ.addr] ; Signal Response Byte address
  1290                              <1> 		;			    ; (Physical address, non-swappable) 	
  1291 0001320A 80E402              <1> 		and	ah, 2 ; bit 1, (S.R.B.) counter (auto increment) method
  1292 0001320D 8AA3[1D9C0100]      <1> 		mov	ah, [ebx+IRQ.srb] ; Signal Response Byte value
  1293 00013213 7408                <1> 		jz	short IRQsrv_2 ; fixed S.R.B. value
  1294                              <1> 		; counter method (auto increment)
  1295 00013215 FEC4                <1> 		inc	ah
  1296 00013217 88A3[1D9C0100]      <1> 		mov	[ebx+IRQ.srb], ah ; next (count) number
  1297                              <1> IRQsrv_2:
  1298 0001321D 8822                <1> 		mov	[edx], ah ; put S.R.B. val to the user's S.R.B. addr
  1299 0001321F C605[D7030300]00    <1> 		mov	byte [u.irqwait], 0 ; clear waiting IRQ flag
  1300                              <1> 
  1301 00013226 3A05[B3030300]      <1> 		cmp	al, [u.uno]
  1302 0001322C 0F84A8000000        <1> 		je	IRQsrv_5 ; the owner is current user/process
  1303                              <1> IRQsrv_3:
  1304                              <1> 		; the owner is not current user/process
  1305                              <1> 		; AL = process number
  1306 00013232 B202                <1> 		mov	dl, 2 ; priority, 2 = event (high)	
  1307 00013234 E837FAFFFF          <1> 		call	set_run_sequence
  1308                              <1> 
  1309                              <1> 		; [u.irqwait] = waiting IRQ number for callback service
  1310                              <1> 
  1311 00013239 E99C000000          <1> 		jmp	IRQsrv_5
  1312                              <1> IRQsrv_4:
  1313 0001323E 3A05[B3030300]      <1> 		cmp	al, [u.uno]  ; is the owner is current user/process?
  1314 00013244 75EC                <1> 		jne	short IRQsrv_3 ; no !
  1315                              <1> 
  1316                              <1> 		; Check if an IRQ callback service already in progress
  1317 00013246 803D[D8030300]00    <1> 		cmp	byte [u.r_lock], 0
  1318 0001324D 0F8787000000        <1> 		ja	IRQsrv_5 ; nothing to do !  
  1319                              <1> 				     ; (we need to complete prev callback)
  1320 00013253 803D[D4030300]00    <1> 		cmp	byte [u.t_lock], 0
  1321 0001325A 777E                <1> 		ja	short IRQsrv_5 ; nothing to do !  
  1322                              <1> 				     ; (we need to complete timer callback)
  1323                              <1> 
  1324                              <1> 		; 04/03/2017
  1325 0001325C C605[D7030300]00    <1> 		mov	byte [u.irqwait], 0 ; reset/clear waiting IRQ flag
  1326                              <1> 
  1327 00013263 FE05[D8030300]      <1> 		inc	byte [u.r_lock] ; 'IRQ callback service in progress' flag
  1328                              <1> 
  1329 00013269 8A0D[5B030300]      <1> 		mov	cl, [sysflg]   ; (system call) mode flag (kernel/user)
  1330 0001326F 880D[D9030300]      <1> 		mov	[u.r_mode], cl ; system mode (0) or user mode (FFh)
  1331                              <1> 
  1332                              <1> 		; 
  1333 00013275 8B2D[6C890100]      <1> 		mov	ebp, [tss.esp0] ; kernel stack address (for ring 0)
  1334 0001327B 83ED14              <1> 		sub	ebp, 20		; eip, cs, eflags, esp, ss
  1335 0001327E 892D[5C030300]      <1> 	 	mov	[u.sp], ebp
  1336 00013284 8925[60030300]      <1> 		mov	[u.usp], esp
  1337                              <1> 
  1338                              <1> 		;or	word [ebp+8], 200h ; 22/01/2017, force enabling interrupts
  1339                              <1> 
  1340 0001328A 8B44241C            <1> 		mov	eax, [esp+28] ; pushed eax
  1341 0001328E A3[64030300]        <1> 		mov	[u.r0], eax
  1342                              <1> 
  1343 00013293 E820E7FFFF          <1> 		call	wswap ; save user's registers & status
  1344                              <1> 
  1345                              <1> 		; software int is in ring 0 but IRQ handler must return to ring 3
  1346                              <1> 		; so, ring 3 return address and stack registers
  1347                              <1> 		; (eip, cs, eflags, esp, ss) 
  1348                              <1> 		; must be copied to IRQ handler return
  1349                              <1> 		; eip will be replaced by callback service routine address
  1350                              <1> 
  1351 00013298 C605[5B030300]FF    <1> 		mov	byte [sysflg], 0FFh ; user mode
  1352                              <1> 
  1353                              <1> 		; system mode (system call)
  1354                              <1> 		;mov	ebp, [u.sp] ; EIP (u), CS (UCODE), EFLAGS (u),
  1355                              <1> 				    ; ESP (u), SS (UDATA)
  1356                              <1> 
  1357 0001329F 8B4510              <1> 		mov	eax, [ebp+16]	; SS (UDATA)
  1358 000132A2 89E6                <1> 		mov	esi, esp
  1359 000132A4 50                  <1> 		push	eax
  1360 000132A5 50                  <1> 		push	eax
  1361 000132A6 89E7                <1> 		mov	edi, esp
  1362 000132A8 893D[60030300]      <1> 		mov	[u.usp], edi
  1363 000132AE B908000000          <1> 		mov	ecx, ((ESPACE/4) - 4) ; except DS, ES, FS, GS
  1364 000132B3 F3A5                <1> 		rep	movsd
  1365 000132B5 B104                <1> 		mov	cl, 4	
  1366 000132B7 F3AB                <1> 		rep	stosd
  1367 000132B9 893D[5C030300]      <1> 		mov	[u.sp], edi
  1368 000132BF 89EE                <1> 		mov	esi, ebp
  1369 000132C1 B105                <1> 		mov	cl, 5 ; EIP (u), CS (UCODE), EFLAGS (u), ESP (u), SS (UDATA)
  1370 000132C3 F3A5                <1> 		rep	movsd
  1371                              <1> 		;
  1372                              <1> 
  1373 000132C5 8B0D[B8030300]      <1> 		mov	ecx, [u.pgdir]
  1374 000132CB 890D[4A9C0100]      <1> 		mov	[IRQ_cr3], ecx
  1375                              <1> 
  1376                              <1> set_IRQ_callback_addr:
  1377                              <1> 		;
  1378                              <1> 		; This routine sets return address
  1379                              <1> 		; to start of user's interrupt
  1380                              <1> 		; service (callback) address
  1381                              <1> 		;
  1382                              <1> 		; INPUT:
  1383                              <1> 		;	EDX = callback routine/service address
  1384                              <1> 		;	      (virtual, not physical address!)	
  1385                              <1> 		;	[u.sp] = kernel stack, points to
  1386                              <1> 		;		 user's EIP,CS,EFLAGS,ESP,SS
  1387                              <1> 		;		 registers.
  1388                              <1> 		; OUTPUT:
  1389                              <1> 		;	EIP (user) = callback (service) address
  1390                              <1> 		;	CS (user) = UCODE
  1391                              <1> 		;	EFLAGS (user) = flags before callback 	 
  1392                              <1> 		;       ESP (user) = ESP-4 (user, before callback) 
  1393                              <1> 		;	[ESP](user) = EIP (user) before callback
  1394                              <1> 		;
  1395                              <1> 		; Note: If CPU was in user mode while entering 
  1396                              <1> 		;	the timer interrupt service routine,
  1397                              <1> 		;	'IRET' will get return to callback routine
  1398                              <1> 		;	immediately. If CPU was in system/kernel mode  
  1399                              <1> 		;	'iret' will get return to system call and
  1400                              <1> 		;	then, callback routine will be return address
  1401                              <1> 		;	from system call. (User's callback/service code
  1402                              <1> 		;	will be able to return to normal return address
  1403                              <1> 		;	via a 'sysrele' system call at the end.) 
  1404                              <1> 		;
  1405                              <1> 		; Note: User's IRQ callback service code must be ended
  1406                              <1> 		;	with a 'sysrele' system call !
  1407                              <1> 		;
  1408                              <1> 		;	For example:
  1409                              <1> 		;
  1410                              <1> 		;	audio_IRQ_callback:
  1411                              <1> 		;	    ...	 
  1412                              <1> 		;	    <load DMA buffer with audio data>
  1413                              <1> 		;	    ...
  1414                              <1> 		;	    mov eax, 39 ; 'sysrele'
  1415                              <1> 		;	    int 40h ; TRDOS 386 system call (interrupt)		
  1416                              <1> 		;
  1417                              <1> 		
  1418                              <1> 		;mov	edx, [edx+IRQ.addr] ; Callback service address
  1419                              <1> 		;			    ; (Virtual address)
  1420                              <1> 		
  1421 000132D1 8B2D[5C030300]      <1> 		mov	ebp, [u.sp]; kernel's stack, points to EIP (user)
  1422 000132D7 895500              <1> 		mov	[ebp], edx
  1423                              <1> IRQsrv_5:
  1424                              <1> 		; EOI & return
  1425                              <1> 		; 01/08/2020
  1426                              <1> 		; 11/06/2017
  1427                              <1> 		; 10/06/2017 
  1428                              <1> 		;mov	al, [IRQnum]
  1429 000132DA B020                <1> 		mov	al, 20h ; 01/08/2020
  1430 000132DC FA                  <1> 		cli
  1431                              <1> 		;cmp	al, 7
  1432 000132DD 803D[4E9C0100]07    <1> 		cmp	byte [IRQnum], 7 ; 01/08/2020	
  1433 000132E4 7602                <1> 		jna	short IRQsrv_6
  1434                              <1> 		;
  1435                              <1> 		;;mov	al, EOI	; end of interrupt
  1436                              <1> 		;mov	al, 20h ; 01/08/2020
  1437                              <1> 		;cli		; disable interrupts till stack cleared
  1438                              <1> 		;out	INTB00, al ; For controll2 #2
  1439 000132E6 E6A0                <1> 		out	0A0h, al
  1440                              <1> IRQsrv_6:
  1441                              <1> 		;mov	byte [IRQnum], 0 ; reset
  1442                              <1> 		;;mov	al, EOI	; end of interrupt
  1443                              <1> 		;mov	al, 20h ; 01/08/2020
  1444                              <1> 		;cli		; disable interrupts till stack cleared
  1445                              <1> 		;out	INTA00, al ; end of interrupt to 8259 - 1
  1446 000132E8 E620                <1> 		out	20h, al	
  1447                              <1> IRQsrv_7:	
  1448                              <1> 		;; 13/06/2017
  1449                              <1> 		;or	word [ebp+8], 200h ; force enabling interrupts
  1450                              <1> 		;
  1451 000132EA 8B0D[4A9C0100]      <1> 		mov 	ecx, [IRQ_cr3]	; previous content of cr3 register
  1452 000132F0 0F22D9              <1>  		mov	cr3, ecx	; restore cr3 register content
  1453                              <1> 		;
  1454 000132F3 61                  <1> 		popad ; edi,esi,ebp,(icrement esp by 4),ebx,edx,ecx,eax
  1455                              <1> 		;
  1456 000132F4 0FA9                <1> 		pop	gs
  1457 000132F6 0FA1                <1> 		pop	fs
  1458 000132F8 07                  <1> 		pop	es
  1459 000132F9 1F                  <1> 		pop	ds
  1460                              <1> 		;
  1461 000132FA CF                  <1> 		iretd	; return from interrupt
  1462                              <1> 
  1463                              <1> get_device_number:
  1464                              <1> 		; 08/10/2016
  1465                              <1> 		; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1466                              <1> 		;
  1467                              <1> 		; This procedure compares name of requested
  1468                              <1> 		; device with kernel device names and
  1469                              <1> 		; installable device names. If names match, 
  1470                              <1> 		; the relevant device index (entry) number 
  1471                              <1> 		; will be returned the caller (sysopen) 
  1472                              <1> 		; for the requested device.
  1473                              <1> 		;
  1474                              <1> 		; NOTE: Installable device drivers must
  1475                              <1> 		; be loaded before using 'sysopen'
  1476                              <1> 		; (opendev) system call.
  1477                              <1> 		;
  1478                              <1> 		; INPUT:
  1479                              <1> 		;    ESI = device name address (ASCIIZ)
  1480                              <1> 		;         (in kernel's memory space)  
  1481                              <1>    		;    max name length = 8 without '/dev/')
  1482                              <1> 		;    Device name will be capitalized 
  1483                              <1> 		;    and if there is, '/dev/' will be
  1484                              <1> 		;    removed from name before comparising)
  1485                              <1> 		;
  1486                              <1> 		; OUTPUT:
  1487                              <1> 		;    cf = 0 -> 
  1488                              <1> 		;      EAX (AL) = device entry/index number 	 	
  1489                              <1> 		;    cf = 1 -> device not found (installed)
  1490                              <1> 		;	       or invalid device name
  1491                              <1> 		;	       (AL=0)
  1492                              <1> 		;    device_name = device name address (asciiz)
  1493                              <1> 			;
  1494                              <1> 		; Modified registers: EAX, EBX, ESI, EDI
  1495                              <1> 
  1496 000132FB BF[8D960100]        <1> 		mov	edi, device_name
  1497 00013300 E805010000          <1> 		call 	lodsb_capitalize
  1498 00013305 88C4                <1> 		mov	ah, al
  1499 00013307 3C2F                <1> 		cmp	al, '/'
  1500 00013309 750E                <1> 		jne	short gdn_1
  1501 0001330B BF[8D960100]        <1> 		mov	edi, device_name
  1502 00013310 E8F5000000          <1> 		call 	lodsb_capitalize
  1503                              <1> gdn_0:
  1504 00013315 20C0                <1> 		and	al, al ; 0 ?
  1505 00013317 7420                <1> 		jz	short gdn_err ; null name after '/'
  1506                              <1> gdn_1:
  1507 00013319 3C44                <1> 		cmp	al, 'D'
  1508 0001331B 7517                <1> 		jne	short gdn_2
  1509 0001331D E8E8000000          <1> 		call 	lodsb_capitalize
  1510 00013322 3C45                <1> 		cmp	al, 'E'
  1511 00013324 750E                <1> 		jne	short gdn_2
  1512 00013326 E8DF000000          <1> 		call 	lodsb_capitalize
  1513 0001332B 3C56                <1> 		cmp	al, 'V'
  1514 0001332D 7505                <1> 		jne	short gdn_2			
  1515 0001332F AC                  <1> 		lodsb
  1516 00013330 3C2F                <1> 		cmp	al, '/'
  1517 00013332 740D                <1> 		je	short gdn_4
  1518                              <1> gdn_2:
  1519 00013334 80FC2F              <1> 		cmp	ah, '/'
  1520 00013337 750F                <1> 		jne	short gdn_5
  1521                              <1> gdn_err:		
  1522                              <1> 		; invalid device name or device not found
  1523 00013339 31C0                <1> 		xor	eax, eax ; 0
  1524 0001333B F9                  <1> 		stc
  1525 0001333C C3                  <1> 		retn
  1526                              <1> gdn_3:
  1527 0001333D 3C2F                <1> 		cmp	al, '/'
  1528 0001333F 7507                <1> 		jne	short gdn_5
  1529                              <1> gdn_4:
  1530 00013341 BF[8D960100]        <1> 		mov	edi, device_name
  1531 00013346 EB04                <1> 		jmp	short gdn_6
  1532                              <1> gdn_5:
  1533 00013348 3C00                <1> 		cmp	al, 0
  1534 0001334A 7419                <1> 		je	short gdn_7
  1535                              <1> gdn_6:
  1536 0001334C E8B9000000          <1> 		call lodsb_capitalize
  1537 00013351 81FF[95960100]      <1> 		cmp	edi, device_name + 8
  1538 00013357 72E4                <1> 		jb	short gdn_3
  1539 00013359 3C00                <1> 		cmp	al, 0
  1540 0001335B 75DC                <1> 		jne	short gdn_err
  1541 0001335D 81FF[8E960100]      <1> 		cmp	edi, device_name + 1
  1542 00013363 76D4                <1> 		jna	short gdn_err ; null name after '/'
  1543                              <1> gdn_7:
  1544 00013365 AA                  <1> 		stosb
  1545                              <1> 		; zero padding ("NAME",0,0,0,0)
  1546 00013366 81FF[95960100]      <1> 		cmp	edi, device_name + 8
  1547 0001336C 72F7                <1> 		jb	short gdn_7
  1548                              <1> gdn_8:
  1549                              <1> 		; search for kernel device names
  1550 0001336E BE[8D960100]        <1> 		mov	esi, device_name 
  1551 00013373 BF[7E470100]        <1> 		mov	edi, KDEV_NAME
  1552 00013378 31C0                <1> 		xor	eax, eax
  1553                              <1> gdn_9:
  1554 0001337A A7                  <1> 		cmpsd	
  1555 0001337B 7505                <1> 		jne	short gdn_10
  1556 0001337D A7                  <1> 		cmpsd
  1557 0001337E 7503                <1> 		jne	short gdn_11
  1558 00013380 EB2B                <1> 		jmp	short gdn_17 ; match
  1559                              <1> gdn_10:
  1560 00013382 A7                  <1> 		cmpsd  ; add esi, 4 & add edi, 4
  1561                              <1> gdn_11:
  1562 00013383 BE[8D960100]        <1> 		mov	esi, device_name
  1563 00013388 FEC0                <1> 		inc	al
  1564 0001338A 3C16                <1> 		cmp	al, NumOfKernelDevNames
  1565 0001338C 72EC                <1> 		jb	short gdn_9
  1566                              <1> gdn_12:
  1567                              <1> 		; search for installable device names
  1568                              <1> 		; esi = offset device_name 
  1569 0001338E BF[B8960100]        <1> 		mov	edi, IDEV_NAME
  1570 00013393 28C0                <1> 		sub	al, al ; 0
  1571                              <1> gdn_13:
  1572 00013395 A7                  <1> 		cmpsd	
  1573 00013396 7505                <1> 		jne	short gdn_14
  1574 00013398 A7                  <1> 		cmpsd
  1575 00013399 7503                <1> 		jne	short gdn_15
  1576 0001339B EB3F                <1> 		jmp	short gdn_19 ; match
  1577                              <1> gdn_14:
  1578 0001339D A7                  <1> 		cmpsd  ; add esi, 4 & add edi, 4
  1579                              <1> gdn_15:
  1580 0001339E BE[8D960100]        <1> 		mov	esi, device_name
  1581 000133A3 FEC0                <1> 		inc	al
  1582 000133A5 3C08                <1> 		cmp	al, NumOfInstallableDevices
  1583 000133A7 72EC                <1> 		jb	short gdn_13
  1584                              <1> 
  1585                              <1> gdn_16: 	; error: invalid device name (not found) !
  1586 000133A9 30C0                <1> 		xor	al, al
  1587 000133AB F9                  <1> 		stc
  1588 000133AC C3                  <1> 		retn
  1589                              <1> 
  1590                              <1> gdn_17:		; name match (with one of kernel device names)
  1591                              <1> 		;
  1592                              <1> 		; convert KDEV_NAME index to 
  1593                              <1> 		; KDEV_NUMBER index
  1594                              <1> 		; (different names are used for same devices)
  1595                              <1> 		; (example: "COM1" & "TTY8" = device number 18) 
  1596 000133AD 89C3                <1> 		mov	ebx, eax ; < 256
  1597 000133AF 8A83[2E480100]      <1> 		mov	al, [KDEV_NUMBER+ebx]
  1598                              <1> 
  1599                              <1> 		; check if empty dev entry in the list
  1600 000133B5 80B8[3C980100]00    <1> 		cmp	byte [DEV_OPENMODE+eax], 0
  1601 000133BC 771B                <1> 		ja	short gdn_18 ; it must be already set
  1602                              <1> 
  1603                              <1> 		; (re)set device name and access flags
  1604                              <1> 		; (remain open work will be easy after that)
  1605                              <1> 		; (NOTE: here, data will be copied to bss section)
  1606 000133BE 88C3                <1> 		mov	bl, al
  1607 000133C0 83EF08              <1> 		sub	edi, 8 ; kernel device name address (data)
  1608 000133C3 66C1E302            <1> 		shl	bx, 2 
  1609 000133C7 89BB[5A980100]      <1> 		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
  1610 000133CD 8A98[84490100]      <1> 		mov	bl, [KDEV_ACCESS+eax] ; kernel dev list (data)
  1611 000133D3 8898[88970100]      <1> 		mov	[DEV_ACCESS+eax], bl ; (all) device list (bss)
  1612                              <1> gdn_18:
  1613 000133D9 FEC0                <1> 		inc	al ; 1 to NumOfKernelDevNames (<=7Fh)
  1614                              <1> 		; eax = device index/entry number
  1615 000133DB C3                  <1> 		retn		
  1616                              <1> 
  1617                              <1> gdn_19:		; name match (with one of installable device names)
  1618                              <1> 		;
  1619                              <1> 		; al = 0 to NumOfInstallableDevices - 1 (<=7Fh)
  1620                              <1> 
  1621 000133DC 89C3                <1> 		mov	ebx, eax
  1622 000133DE 80C316              <1> 		add	bl, NumOfKernelDevices 	; < NUMOFDEVICES	
  1623                              <1> 
  1624                              <1> 		; check if empty dev entry in the list
  1625 000133E1 80BB[3C980100]00    <1> 		cmp	byte [DEV_OPENMODE+ebx], 0
  1626 000133E8 771D                <1> 		ja	short gdn_20 ; it must be already set
  1627                              <1> 
  1628                              <1> 		; (re)set device name and access flags
  1629                              <1> 		; (remain open work will be easy after that)
  1630 000133EA 83EF08              <1> 		sub	edi, 8 ; installable device name address
  1631 000133ED 66C1E302            <1> 		shl	bx, 2 ;*4
  1632 000133F1 89BB[5A980100]      <1> 		mov	[DEV_NAME_PTR+ebx], edi ; (all) device names
  1633 000133F7 66C1EB02            <1> 		shr	bx, 2
  1634 000133FB 8A80[00970100]      <1> 		mov	al, [IDEV_FLAGS+eax] ; installable dev list
  1635 00013401 8883[88970100]      <1> 		mov	[DEV_ACCESS+ebx], al ; (all) device list
  1636                              <1> gdn_20:	
  1637 00013407 88D8                <1> 		mov	al, bl
  1638                              <1> 		; eax = device index/entry number ; < NUMOFDEVICES  
  1639 00013409 C3                  <1> 		retn
  1640                              <1> 
  1641                              <1> lodsb_capitalize:
  1642                              <1> 	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1643                              <1> 	; INPUT -> [esi] = character
  1644                              <1> 	;          edi = destination
  1645                              <1> 	; OUTPUT -> AL contains capitalized character
  1646                              <1> 	;	   esi = esi+1
  1647                              <1> 	;	   edi = edi+1	
  1648                              <1> 	; 
  1649 0001340A AC                  <1> 	lodsb	
  1650 0001340B 3C61                <1> 	cmp al, 61h
  1651 0001340D 7206                <1>      	jb  short lodsb_cap_retn
  1652 0001340F 3C7A                <1>      	cmp al, 7Ah
  1653 00013411 7702                <1>      	ja  short lodsb_cap_retn
  1654 00013413 24DF                <1>      	and al, 0DFh
  1655                              <1> lodsb_cap_retn:
  1656 00013415 AA                  <1> 	stosb
  1657 00013416 C3                  <1> 	retn
  1658                              <1> 
  1659                              <1> device_open:
  1660                              <1> 	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
  1661                              <1> 	; Complete device opening work for sysopen (device)
  1662                              <1> 	;
  1663                              <1> 	; INPUT -> 
  1664                              <1> 	;	EAX = Device Number (AL)
  1665                              <1> 	;        CL = Open mode (1 = read, 2 = write)
  1666                              <1> 	;	 CH = Device access byte (bit 0 = 0)		
  1667                              <1> 	; OUTPUT ->
  1668                              <1> 	;	EAX = Device Number	
  1669                              <1> 	;	CF = 0 -> device has been opened
  1670                              <1> 	;	CF = 1 -> device could not be opened
  1671                              <1> 	;
  1672                              <1> 	;  Modified registers: ebx, (edx, ecx, esi, edi, ebp)
  1673                              <1> 	;
  1674                              <1> 
  1675 00013417 89C3                <1> 	mov	ebx, eax
  1676 00013419 66C1E302            <1> 	shl	bx, 2 ; *4
  1677                              <1> 
  1678 0001341D F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  1679 00013420 7406                <1> 	jz	short d_open_2 ; Kernel device
  1680                              <1> 	; installable device
  1681                              <1> d_open_1:
  1682 00013422 FFA3[04970100]      <1>         jmp	dword [ebx+IDEV_OADDR-4]
  1683                              <1> d_open_2:
  1684 00013428 FFA3[40480100]      <1> 	jmp	dword [ebx+KDEV_OADDR-4]
  1685                              <1> 
  1686                              <1> device_close:
  1687                              <1> 	; 08/10/2016 - TRDOS 386 (TRDOS v2.0)
  1688                              <1> 	; Complete device closing work for sysclose (device)
  1689                              <1> 	;
  1690                              <1> 	; INPUT -> 
  1691                              <1> 	;	EAX = Device Number (AL)
  1692                              <1> 	;        CL = Open mode (1 = read, 2 = write)
  1693                              <1> 	;	 CH = Device access byte (bit 0 = 0)		
  1694                              <1> 	; OUTPUT ->
  1695                              <1> 	;	EAX = Device Number	
  1696                              <1> 	;	CF = 0 -> device has been closed
  1697                              <1> 	;	CF = 1 -> device could not be closed
  1698                              <1> 	;
  1699                              <1> 	; Modified registers: ebx, (edx, ecx, esi, edi, ebp)
  1700                              <1> 	;
  1701                              <1> 
  1702 0001342E 89C3                <1> 	mov	ebx, eax
  1703 00013430 66C1E302            <1> 	shl	bx, 2 ; *4
  1704                              <1> 
  1705 00013434 F6C580              <1> 	test	ch, 80h ; bit 7, installable device driver flag
  1706 00013437 7406                <1> 	jz	short d_close_2 ; Kernel device
  1707                              <1> 	; installable device
  1708                              <1> d_close_1:
  1709 00013439 FFA3[24970100]      <1>         jmp	dword [ebx+IDEV_CADDR-4]
  1710                              <1> d_close_2:
  1711 0001343F FFA3[90480100]      <1> 	jmp	dword [ebx+KDEV_CADDR-4]	
  1712                              <1> 
  1713                              <1> rnull:
  1714                              <1> 	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1715                              <1> 	; read null (read from null device)
  1716 00013445 C3                  <1> 	retn
  1717                              <1> 
  1718                              <1> wnull:
  1719                              <1> 	; 07/10/2016 - TRDOS 386 (TRDOS v2.0)
  1720                              <1> 	; write null (write to null device)
  1721 00013446 C3                  <1> 	retn
  1722                              <1> 
  1723                              <1> dev_IRQ_service:
  1724                              <1> 	; 12/05/2017
  1725                              <1> 	; 13/04/2017
  1726                              <1> 	; 27/02/2017 - TRDOS 386 (TRDOS v2.0)
  1727                              <1> 	; INPUT ->
  1728                              <1> 	;	AL = IRQ Number (0 to 15)
  1729                              <1> 	;	
  1730 00013447 53                  <1> 	push	ebx
  1731 00013448 0FB6D8              <1> 	movzx	ebx, al
  1732 0001344B C0E302              <1> 	shl	bl, 2 ; * 4	
  1733 0001344E 8B9B[C29B0100]      <1> 	mov	ebx, [ebx+DEV_INT_HNDLR]
  1734 00013454 21DB                <1> 	and 	ebx, ebx
  1735 00013456 7404                <1>         jz	short dIRQ_s_retn
  1736 00013458 50                  <1> 	push	eax
  1737                              <1> 
  1738 00013459 FFD3                <1> 	call	ebx
  1739                              <1> 
  1740 0001345B 58                  <1> 	pop	eax
  1741                              <1> dIRQ_s_retn:
  1742 0001345C 5B                  <1> 	pop	ebx
  1743 0001345D C3                  <1> 	retn		
  1744                              <1> 
  1745                              <1> 
  1746                              <1> set_dev_IRQ_service:
  1747                              <1> 	; 13/04/2017 - TRDOS 386 (TRDOS v2.0)
  1748                              <1> 	;
  1749                              <1> 	; Set Device Interrupt Service
  1750                              <1> 	;
  1751                              <1> 	; INPUT ->
  1752                              <1> 	;	AL = IRQ Number
  1753                              <1> 	;	EBX = Hardware Interrupt Service Address
  1754                              <1> 	;
  1755                              <1> 	; Note: There is not a validation check here
  1756                              <1> 	;	because this procedure is called by
  1757                              <1> 	;	TRDOS 386 kernel !
  1758                              <1> 	;       (Even if a device driver does not exist
  1759                              <1> 	;	this setting may be used by sysaudio
  1760                              <1> 	;	and other system calls for hardware
  1761                              <1> 	;	components which use IRQ method for I/O.)
  1762                              <1> 	;
  1763                              <1> 	;push	esi
  1764 0001345E 0FB6F0              <1> 	movzx	esi, al
  1765 00013461 66C1E602            <1> 	shl	si, 2 ; * 4	
  1766 00013465 899E[C29B0100]      <1> 	mov	[esi+DEV_INT_HNDLR], ebx
  1767                              <1> 	;pop	esi
  1768 0001346B C3                  <1> 	retn		
  1769                              <1> 	
  1770                              <1> 
  1771                              <1> sysaudio: ; AUDIO FUNCTIONS
  1772                              <1> 	; 12/02/2021 (TRDOS 386 v2.0.3) 
  1773                              <1> 	; 28/07/2020
  1774                              <1> 	; 27/07/2020
  1775                              <1> 	; 10/10/2017
  1776                              <1> 	; 22/06/2017
  1777                              <1> 	; 28/05/2017, 04/06/2017, 05/06/2017, 10/06/2017
  1778                              <1> 	; 01/05/2017, 12/05/2017, 15/05/2017, 20/05/2017
  1779                              <1> 	; 21/04/2017, 22/04/2017, 23/04/2017, 24/04/2017
  1780                              <1> 	; 10/04/2017, 13/04/2017, 14/04/2017, 16/04/2017
  1781                              <1> 	; 03/04/2017 (VIA VT8237R)
  1782                              <1> 	; 01/04/2016 (trdosk6.s -> tdosk8.s)
  1783                              <1> 	; 16/05/2016 - TRDOS 386 (TRDOS v2.0)
  1784                              <1> 	;
  1785                              <1> 	; Inputs:
  1786                              <1> 	;
  1787                              <1> 	;	BH = 0 -> Beep (PC Speaker)
  1788                              <1> 	;	     BL = Duration Counter (1 for 1/64 second)
  1789                              <1> 	;	     CX = Frequency Divisor (1193180/Frequency)
  1790                              <1> 	;		 (1331 for 886 Hz)
  1791                              <1> 	;
  1792                              <1> 	;	01/04/2017	
  1793                              <1> 	;
  1794                              <1> 	; 	BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
  1795                              <1> 	;	     BL = 0 : PC SPEAKER
  1796                              <1> 	;		  1 : SOUND BLASTER 16
  1797                              <1> 	;		  2 : INTEL AC'97
  1798                              <1> 	;		  3 : VIA VT8237R (VT8233)			 				
  1799                              <1> 	;		  4 : INTEL HDA
  1800                              <1> 	;	      5-FEh : unknown/invalid
  1801                              <1> 	;	        ; 04/06/2017
  1802                              <1> 	;		FFh : Get current audio device id
  1803                              <1> 	;
  1804                              <1> 	; 	BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
  1805                              <1> 	;		ECX = Audio Buffer Size (must be equal to
  1806                              <1> 	;		      the half of DMA buffer size) 
  1807                              <1> 	;		EDX = Virtual Address of the buffer
  1808                              <1> 	;		      (This is not DMA buffer!)
  1809                              <1> 	;
  1810                              <1> 	;	BH = 3 -> INITIALIZE AUDIO DEVICE
  1811                              <1> 	;	     BL = 0,2 -> for Signal Response Byte	 	
  1812                              <1> 	;	     	CL = Signal Response Byte Value (fixed)
  1813                              <1> 	;				if BL = 0
  1814                              <1> 	;	             auto increment of S.R.B. value
  1815                              <1> 	;			 	if BL = 2
  1816                              <1> 	;	        EDX = Signal Response (Return) Byte Address
  1817                              <1> 	;	     	   			
  1818                              <1> 	;	     BL = 1 for CallBack Method	 	
  1819                              <1> 	;	    	EDX = CallBack Service Address (Virtual)
  1820                              <1> 	;
  1821                              <1> 	;	     BL > 2 -> invalid function	
  1822                              <1> 	;
  1823                              <1> 	;	    (Audio buffer must be allocated before
  1824                              <1> 	;	     initialization.) 		
  1825                              <1> 	;
  1826                              <1> 	;	BH = 4 -> START TO PLAY
  1827                              <1> 	;	     BL = Mode
  1828                              <1> 	;		  Bit 0 = mono/stereo (1 = stereo)		
  1829                              <1> 	;		  Bit 1 = 8 bit / 16 bit (1 = 16 bit)
  1830                              <1> 	;	     CX = Sampling Rate (Hz)
  1831                              <1> 	;
  1832                              <1> 	;	BH = 5 -> PAUSE
  1833                              <1> 	;	     BL = Any
  1834                              <1> 	;
  1835                              <1> 	;	BH = 6 -> CONTINUE TO PLAY
  1836                              <1> 	;	     BL = Any
  1837                              <1> 	;
  1838                              <1> 	;	BH = 7 -> STOP
  1839                              <1> 	;	     BL = Any
  1840                              <1> 	;
  1841                              <1> 	;	BH = 8 -> RESET 
  1842                              <1> 	;	     BL = Any
  1843                              <1> 	;
  1844                              <1> 	;	BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
  1845                              <1> 	;	     BL = Any	
  1846                              <1> 	;	
  1847                              <1> 	;	BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
  1848                              <1> 	;	     BL = Any
  1849                              <1> 	;
  1850                              <1> 	;	BH = 11 -> SET VOLUME LEVEL
  1851                              <1> 	;	     BL: (Bit 0 to 6)
  1852                              <1> 	;		  0 = Master (Playback, Lineout) volume
  1853                              <1> 	;	     CL = Left Channel Volume
  1854                              <1> 	;	     CH = Right Channel Volume
  1855                              <1> 	;	
  1856                              <1> 	;	     Note: If BL >= 80h (Bit 7 of BL is set),
  1857                              <1> 	;	     volume level will be set for next playing
  1858                              <1> 	;	     (actual volume level will not be changed
  1859                              <1> 	;	     immediately)	
  1860                              <1> 	;
  1861                              <1> 	;	BH = 12 -> DISABLE AUDIO DEVICE
  1862                              <1> 	;	     (reset audio device and unlink dma buffer)	
  1863                              <1> 	;	     BL = Any	  		  	  	
  1864                              <1> 	;
  1865                              <1> 	;    	12/05/2017
  1866                              <1> 	;	BH = 13 -> MAP DMA BUFFER TO USER
  1867                              <1> 	;	    (for direct access to system's dma buffer)
  1868                              <1> 	;
  1869                              <1> 	;	     ECX = map size in bytes 
  1870                              <1> 	;		  (will be rounded up to page borders)
  1871                              <1> 	;	     EDX = Virtual Address of the buffer
  1872                              <1> 	;		  (Will be rounded up to page borders)
  1873                              <1> 	;
  1874                              <1> 	;	05/06/2017	
  1875                              <1> 	;    	04/06/2017
  1876                              <1> 	;	BH = 14 -> GET AUDIO DEVICE INFO
  1877                              <1> 	;	     BL: 0 = Audio Controller Info
  1878                              <1> 	;	       > 0 = Invalid for now! 
  1879                              <1> 	;
  1880                              <1> 	;	22/06/2017	
  1881                              <1> 	;	BH = 15 -> GET CURRENT SOUND DATA (for graphics)
  1882                              <1> 	;	     BL: 0 -> PCM OUT data
  1883                              <1> 	;	       > 0 -> Invalid for now! 
  1884                              <1> 	;	     ECX = 0 -> Get DMA Buffer Pointer
  1885                              <1> 	;		 EDX = Not Used
  1886                              <1> 	;	     ECX > 0 -> Byte count for buffer (EDX)	 	
  1887                              <1> 	;	         EDX = Buffer Address (Virtual)	
  1888                              <1> 	;
  1889                              <1> 	;	10/10/2017	
  1890                              <1> 	;	BH = 16 -> UPDATE DMA BUFFER DATA
  1891                              <1> 	;		   (by using the Audio Buffer content)
  1892                              <1> 	;	     BL = 0 : Update dma half buffer in sequence
  1893                              <1> 	;		      (automatic destination)	
  1894                              <1> 	;		  1 : Update 1st half of the dma buffer
  1895                              <1> 	;		  2 : Update 2nd half of the dma buffer
  1896                              <1> 	;		  3-FEh: Invalid!
  1897                              <1> 	;		  FFh = Get current flag value
  1898                              <1> 	;			(Half buffer number -1)
  1899                              <1> 	;
  1900                              <1> 	;
  1901                              <1> 	; Outputs:
  1902                              <1> 	;
  1903                              <1> 	;	For BH = 0 -> Beep
  1904                              <1> 	;	    None
  1905                              <1> 	;
  1906                              <1> 	;	01/04/2017
  1907                              <1> 	;
  1908                              <1> 	; 	For BH = 1 -> DETECT (& ENABLE) AUDIO DEVICE
  1909                              <1> 	;	    AH = 0 : PC SPEAKER
  1910                              <1> 	;		 1 : SOUND BLASTER 16
  1911                              <1> 	;		 2 : INTEL AC'97
  1912                              <1> 	;		 3 : VIA VT8237R (VT8233)			 				
  1913                              <1> 	;		 4 : INTEL HDA
  1914                              <1> 	;	      5-FFh : unknown/invalid
  1915                              <1> 	;	    AL = mode status
  1916                              <1> 	;		 bit 0 = mono /stereo (1 = stereo)
  1917                              <1> 	;		 bit 1 = 8 bit / 16 bit ( 1 = 16 bit)
  1918                              <1> 	;	    04/06/2017
  1919                              <1> 	;	    EBX = PCI DEVICE/VENDOR ID (if >0)
  1920                              <1> 	;		 (BX = VENDOR ID) 
  1921                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  1922                              <1> 	;
  1923                              <1> 	; 	For BH = 2 -> ALLOCATE AUDIO BUFFER (for user)
  1924                              <1> 	;	    EAX = Physical Address of the buffer
  1925                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  1926                              <1> 	;
  1927                              <1> 	;	For BH = 3 -> INITIALIZE AUDIO DEVICE
  1928                              <1> 	;	    (if CF = 1 -> Error code in EAX)
  1929                              <1> 	;
  1930                              <1> 	;	For BH = 4 -> START TO PLAY
  1931                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  1932                              <1> 	;
  1933                              <1> 	;	For BH = 5 -> PAUSE
  1934                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  1935                              <1> 	;
  1936                              <1> 	;	For BH = 6 -> CONTINUE TO PLAY
  1937                              <1> 	;	    none (if CF = 1 -> Error code in EAX)	
  1938                              <1> 	;
  1939                              <1> 	;	For BH = 7 -> STOP
  1940                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1941                              <1> 	;
  1942                              <1> 	;	For BH = 8 -> RESET 
  1943                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1944                              <1> 	;
  1945                              <1> 	;	For BH = 9 -> CANCEL (CALLBACK or S.R.B. SERVICE)
  1946                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1947                              <1> 	;	
  1948                              <1> 	;	For BH = 10 -> DEALLOCATE AUDIO BUFFER (for user)
  1949                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1950                              <1> 	;
  1951                              <1> 	;	For BH = 11 -> SET VOLUME LEVEL
  1952                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1953                              <1> 	;
  1954                              <1> 	;	For BH = 12 -> DISABLE AUDIO DEVICE
  1955                              <1> 	;	    none (if CF = 1 -> Error code in EAX)
  1956                              <1> 	; 
  1957                              <1> 	;    	12/05/2017
  1958                              <1> 	;	For BH = 13 -> MAP DMA BUFFER TO USER
  1959                              <1> 	;	    EAX = Physical Address of the buffer
  1960                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
  1961                              <1> 	;
  1962                              <1> 	;    	04/06/2017
  1963                              <1> 	;	For BH = 14 -> GET AUDIO DEVICE INFO
  1964                              <1> 	;	(for BL = 0) ; 05/06/2017	
  1965                              <1> 	;	    EAX = IRQ Number in AL
  1966                              <1> 	;		  Audio Device Number in AH 
  1967                              <1> 	;	    EBX = DEV/VENDOR ID
  1968                              <1> 	;		 (DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
  1969                              <1> 	;	    ECX = BUS/DEV/FN 
  1970                              <1> 	;		 (00000000BBBBBBBBDDDDDFFF00000000)
  1971                              <1> 	;	    EDX = NABMBAR/NAMBAR (for AC97)
  1972                              <1> 	;		  (Low word, DX = NAMBAR address)
  1973                              <1> 	;	    EDX = Base IO Addr (DX) for SB16 & VT8233	  			  		
  1974                              <1> 	;	    (if CF = 1 -> Error code in EAX)	
  1975                              <1> 	;	                 (ERR_DEV_NOT_RDY = 15)  
  1976                              <1> 	;
  1977                              <1> 	;	22/06/2017	
  1978                              <1> 	;	For BH = 15 -> GET CURRENT SOUND DATA
  1979                              <1> 	;			 (for graphics)
  1980                              <1> 	;	(for BL = 0)
  1981                              <1> 	;	 If ECX input is 0 
  1982                              <1> 	;	    EAX = DMA Buffer Current Position (Offset)
  1983                              <1> 	;	 If ECX input >  0
  1984                              <1> 	;	    EAX = Actual transfer count 		 	
  1985                              <1> 	;	    (Sound samples will be copied from 
  1986                              <1> 	;	     Current DMA Buffer Position to EDX
  1987                              <1> 	;	     virtual address as EAX bytes.)
  1988                              <1> 	;	 ((If CF = 1 ->  Error code in EAX))
  1989                              <1> 	;
  1990                              <1> 	;
  1991                              <1> 	;	10/10/2017	
  1992                              <1> 	;	For BH = 16 -> UPDATE DMA BUFFER DATA
  1993                              <1> 	;	    EAX = 0, if the updated (or current)
  1994                              <1> 	;		     half buffer is DMA half buffer 1
  1995                              <1> 	;	    EAX = 1, if the updated (or current)
  1996                              <1> 	; 		     half buffer is DMA half buffer 2 	  	
  1997                              <1> 	;	    (If CF = 1 -> Error code in EAX)	
  1998                              <1> 	;	
  1999                              <1> 
  2000 0001346C 80FF11              <1> 	cmp	bh, AUDIO1L/4
  2001 0001346F 0F8387A4FFFF        <1> 	jnb	sysret
  2002                              <1> 
  2003 00013475 C0E702              <1> 	shl	bh, 2 ; *4	
  2004 00013478 0FB6F7              <1> 	movzx	esi, bh
  2005                              <1> 
  2006                              <1> 	; 22/04/2017
  2007 0001347B 31C0                <1> 	xor	eax, eax
  2008 0001347D A3[64030300]        <1> 	mov	[u.r0], eax  ; 0
  2009                              <1> 		
  2010 00013482 FF96[8D340100]      <1> 	call	dword [esi+AUDIO1]
  2011                              <1> 	;jc	error
  2012 00013488 E96FA4FFFF          <1> 	jmp	sysret	
  2013                              <1> 
  2014 0001348D [E1230000]          <1> AUDIO1:	dd	_beep ; 12/02/2021	
  2015                              <1> 	;dd	beep ; FUNCTION = 0 (bl = Duration Counter
  2016                              <1> 		     ; 		     cx = Frequency Divisor
  2017 00013491 [D1340100]          <1> 	dd	soundc_detect
  2018 00013495 [6D350100]          <1> 	dd	sound_alloc
  2019 00013499 [2B360100]          <1> 	dd	soundc_init
  2020 0001349D [E3370100]          <1> 	dd	sound_play
  2021 000134A1 [7F380100]          <1> 	dd	sound_pause
  2022 000134A5 [A9380100]          <1> 	dd	sound_continue
  2023 000134A9 [D3380100]          <1> 	dd	sound_stop
  2024 000134AD [FC380100]          <1> 	dd	soundc_reset
  2025 000134B1 [2D390100]          <1> 	dd	soundc_cancel
  2026 000134B5 [53390100]          <1> 	dd	sound_dalloc
  2027 000134B9 [7E390100]          <1> 	dd	sound_volume
  2028 000134BD [D0390100]          <1> 	dd	soundc_disable
  2029 000134C1 [423A0100]          <1> 	dd	sound_dma_map
  2030 000134C5 [B13A0100]          <1> 	dd	soundc_info
  2031 000134C9 [103B0100]          <1> 	dd	sound_data
  2032 000134CD [BD3B0100]          <1> 	dd	sound_update
  2033                              <1> 	
  2034                              <1> AUDIO1L	EQU	$ - AUDIO1
  2035                              <1> 
  2036                              <1> soundc_detect:
  2037                              <1> 	; FUNCTION = 1
  2038                              <1> 	; bl = Audio device type number 
  2039                              <1> 	; (0= pc speaker, 1 = sound blaster 16, 2 = intel ac97
  2040                              <1> 	;  3= via vt823x, 4 = intel HDA, 0FFh= any)
  2041                              <1> 	
  2042                              <1> 	; 04/06/2017
  2043 000134D1 8A25[519C0100]      <1> 	mov	ah, [audio_device]
  2044 000134D7 80FBFF              <1> 	cmp	bl, 0FFh ; get current audio device id
  2045 000134DA 7408                <1> 	je	short sysaudio0
  2046                              <1> 
  2047 000134DC 20E4                <1> 	and	ah, ah
  2048 000134DE 741E                <1> 	jz	short soundc_get_dev
  2049                              <1> 
  2050 000134E0 38DC                <1> 	cmp	ah, bl
  2051 000134E2 7567                <1> 	jne	short soundc_dev_err
  2052                              <1> 
  2053                              <1> sysaudio0:	
  2054 000134E4 A0[529C0100]        <1> 	mov	al, [audio_mode]
  2055                              <1> sysaudio1:
  2056 000134E9 A3[64030300]        <1> 	mov	[u.r0], eax
  2057 000134EE 8B1D[5C9C0100]      <1> 	mov	ebx, [audio_vendor] ; (DEVICE/VENDOR ID)
  2058 000134F4 8B2D[60030300]      <1> 	mov	ebp, [u.usp]
  2059 000134FA 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
  2060 000134FD C3                  <1> 	retn
  2061                              <1> 
  2062                              <1> soundc_get_dev:
  2063                              <1> 	; 28/05/2017
  2064                              <1> 	; 03/04/2017, 24/04/2017
  2065 000134FE C605[509C0100]00    <1> 	mov	byte [audio_pci], 0
  2066 00013505 80FB03              <1> 	cmp	bl, 3 ; VIA VT8233 (VT8237R) Audio Controller & AC97 Codec
  2067                              <1> 	;jne	short soundc_get_dev_sb
  2068                              <1> 	; 28/05/2017
  2069 00013508 7220                <1> 	jb	short soundc_get_dev_sb
  2070 0001350A 773F                <1> 	ja	short soundc_dev_err  ; temporary (28/05/2017)
  2071                              <1> 	;  		
  2072 0001350C E86C180000          <1> 	call	DetectVT8233
  2073 00013511 7238                <1> 	jc	short soundc_dev_err
  2074                              <1> 	; eax = 0
  2075                              <1> 
  2076                              <1> 	;mov	ebx, [audio_vendor]
  2077                              <1> 	; ebx = DEVICE/VENDOR ID
  2078                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
  2079                              <1> 
  2080 00013513 B003                <1> 	mov	al, 3  ; VIA VT8237R (VT3233) Audio Controller
  2081 00013515 88C4                <1> 	mov	ah, al
  2082                              <1> 
  2083                              <1> soundc_get_pci_dev_ok: ; 28/05/2017
  2084 00013517 FE05[509C0100]      <1> 	inc	byte [audio_pci] ; = 1
  2085                              <1> soundc_get_dev_ok:
  2086                              <1> 	
  2087                              <1> soundc_get_dev_sb16_ok:
  2088 0001351D A2[519C0100]        <1> 	mov	[audio_device], al
  2089 00013522 8825[529C0100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability	
  2090 00013528 EBBF                <1> 	jmp	short sysaudio1
  2091                              <1> 
  2092                              <1> soundc_get_dev_sb:
  2093                              <1> 	; 24/04/2017
  2094 0001352A 80FB01              <1> 	cmp	bl, 1 ; Sound Blaster 16
  2095 0001352D 750E                <1> 	jne	short soundc_get_dev_ich ; 28/05/2017
  2096                              <1> 	;
  2097 0001352F E86D1D0000          <1> 	call	DetectSB
  2098 00013534 7215                <1> 	jc	short soundc_dev_err
  2099 00013536 B801030000          <1> 	mov	eax, 0301h ; Sound Blaster 16
  2100 0001353B EBE0                <1> 	jmp	short soundc_get_dev_sb16_ok
  2101                              <1> 
  2102                              <1> soundc_get_dev_ich:
  2103                              <1> 	; 28/05/2017
  2104                              <1> 	;cmp	bl, 2 ; Intel AC'97 Audio Controller (ICH)
  2105                              <1> 	;jne	short soundc_dev_err ; Temporary  (28/05/2017)
  2106                              <1> 	;			     ; (Here will be modified just after
  2107                              <1> 	;			     ; new sound card code will be ready!)  	
  2108 0001353D E82E180000          <1> 	call	DetectICH
  2109 00013542 7207                <1> 	jc	short soundc_dev_err
  2110                              <1> 	;
  2111 00013544 B802030000          <1> 	mov	eax, 0302h ; AC'97 (ICH)
  2112 00013549 EBCC                <1> 	jmp	short soundc_get_pci_dev_ok
  2113                              <1> 
  2114                              <1> soundc_dev_err:
  2115 0001354B B80F000000          <1> 	mov	eax, ERR_DEV_NOT_RDY ; Device not ready !
  2116 00013550 EB0C                <1> 	jmp	short sysaudio_err
  2117                              <1> 
  2118                              <1> sound_buff_error:
  2119 00013552 B82E000000          <1> 	mov	eax, ERR_BUFFER ; Buffer error !
  2120 00013557 EB05                <1> 	jmp	short sysaudio_err
  2121                              <1> 
  2122                              <1> soundc_respond_err:
  2123                              <1> 	; ERR_TIME_OUT ; 'time out !' error	
  2124 00013559 B819000000          <1> 	mov	eax, ERR_DEV_NOT_RESP ; 'device not responding !' error
  2125                              <1> sysaudio_err:
  2126 0001355E A3[64030300]        <1> 	mov	[u.r0], eax
  2127 00013563 A3[C8030300]        <1> 	mov	[u.error], eax
  2128 00013568 E96FA3FFFF          <1> 	jmp	error
  2129                              <1> 
  2130                              <1> sound_alloc:
  2131                              <1> 	; FUNCTION =  2
  2132                              <1> 	; ecx = audio buffer size (in bytes)
  2133                              <1> 	; edx = audio buffer address (virtual)
  2134                              <1> 	; 27/07/2020
  2135                              <1> 	; 28/05/2017
  2136                              <1> 	; 01/05/2017, 15/05/2017
  2137                              <1> 	; 21/04/2017, 24/04/2017
  2138 0001356D 803D[509C0100]00    <1> 	cmp	byte [audio_pci], 0
  2139 00013574 7708                <1> 	ja	short snd_alloc_0
  2140                              <1> 	; Max. 64KB DMA buffer !!!
  2141 00013576 81F900800000        <1> 	cmp	ecx, 32768
  2142 0001357C 77D4                <1> 	ja	short sound_buff_error
  2143                              <1> snd_alloc_0:
  2144                              <1> 	; 15/05/2017
  2145 0001357E 81F900100000        <1> 	cmp	ecx, 4096 ; PAGE_SIZE
  2146 00013584 72CC                <1> 	jb	short sound_buff_error
  2147                              <1> 	;
  2148 00013586 A1[649C0100]        <1> 	mov	eax, [audio_buffer] ; audio buffer address (current)
  2149 0001358B 09C0                <1> 	or	eax, eax
  2150 0001358D 7445                <1> 	jz	short snd_alloc_2
  2151                              <1> 	; audio buffer exists !
  2152 0001358F 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
  2153 00013595 3A1D[799C0100]      <1> 	cmp	bl, [audio_user]
  2154 0001359B 0F85FC000000        <1> 	jne	sndc_owner_error ; not owner !
  2155 000135A1 39D0                <1> 	cmp	eax, edx ; same virtual buffer address ?
  2156 000135A3 7508                <1> 	jne	short snd_alloc_1
  2157 000135A5 3B0D[6C9C0100]      <1> 	cmp	ecx, [audio_buff_size]
  2158 000135AB 746C                <1> 	je	short snd_alloc_3 ; Nothing to do !
  2159                              <1> 				  ; Buffer has been set already!
  2160                              <1> snd_alloc_1:
  2161 000135AD 51                  <1> 	push	ecx
  2162 000135AE 52                  <1> 	push	edx
  2163 000135AF 89C3                <1> 	mov	ebx, eax ; audio buffer address (current)
  2164 000135B1 8B0D[6C9C0100]      <1> 	mov	ecx, [audio_buff_size]
  2165 000135B7 E81C32FFFF          <1> 	call	deallocate_user_pages
  2166 000135BC 5A                  <1> 	pop	edx
  2167 000135BD 59                  <1> 	pop	ecx
  2168 000135BE 31C0                <1> 	xor	eax, eax ; 0
  2169 000135C0 A3[649C0100]        <1> 	mov	[audio_buffer], eax  ; 0
  2170 000135C5 A3[689C0100]        <1>  	mov	[audio_p_buffer], eax  ; 0
  2171 000135CA A3[6C9C0100]        <1>  	mov	[audio_buff_size], eax
  2172 000135CF A2[799C0100]        <1> 	mov	[audio_user], al ; 0
  2173                              <1> snd_alloc_2:
  2174 000135D4 89D3                <1> 	mov	ebx, edx
  2175                              <1> 	; 01/05/2017
  2176 000135D6 BA00F0FFFF          <1> 	mov	edx, ~PAGE_OFF ; truncating page offsets
  2177                              <1> 			       ; for aligning to page borders	
  2178                              <1> 	;and	eax, edx
  2179 000135DB 21D3                <1> 	and	ebx, edx
  2180 000135DD 21D1                <1> 	and	ecx, edx
  2181                              <1> 	; 15/05/2017
  2182                              <1> 	; EAX = Beginning address (physical)
  2183                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
  2184                              <1> 	; ECX = Number of bytes to be allocated		
  2185 000135DF E8992EFFFF          <1> 	call	allocate_memory_block
  2186 000135E4 0F8268FFFFFF        <1> 	jc	sound_buff_error
  2187                              <1> 	; EAX = Physical address of the allocated memory block
  2188                              <1> 	; ECX = Allocated bytes (as truncated to page border)
  2189                              <1> 	; EBX = Virtual address (as truncated to page border)
  2190 000135EA 50                  <1> 	push	eax
  2191 000135EB 53                  <1> 	push	ebx
  2192 000135EC 51                  <1> 	push	ecx
  2193 000135ED E8DB32FFFF          <1> 	call	allocate_user_pages
  2194 000135F2 59                  <1> 	pop	ecx
  2195 000135F3 5B                  <1> 	pop	ebx
  2196 000135F4 58                  <1> 	pop	eax
  2197 000135F5 722A                <1> 	jc	short snd_alloc_4  ; insufficient memory, buff error
  2198                              <1> 	; eax = physical address of the user's audio buffer
  2199                              <1> 	; ebx = virtual address of the user's audio buffer
  2200                              <1> 	; ecx = buffer size (in bytes)
  2201 000135F7 A3[689C0100]        <1> 	mov	[audio_p_buffer], eax
  2202 000135FC 891D[649C0100]      <1> 	mov	[audio_buffer], ebx
  2203 00013602 890D[6C9C0100]      <1>  	mov	[audio_buff_size], ecx
  2204 00013608 8A15[B3030300]      <1> 	mov	dl, [u.uno]
  2205 0001360E 8815[799C0100]      <1> 	mov	[audio_user], dl
  2206 00013614 A3[64030300]        <1> 	mov	[u.r0], eax
  2207                              <1> snd_alloc_3:
  2208                              <1> 	; 27/07/2020
  2209 00013619 C605[789C0100]00    <1> 	mov	byte [audio_flag], 0 ; clear dma half buffer flag
  2210                              <1> 	;	
  2211 00013620 C3                  <1> 	retn
  2212                              <1> snd_alloc_4:
  2213                              <1> 	; 15/05/2017
  2214                              <1> 	; EAX = Beginning address (physical)
  2215                              <1> 	; ECX = Number of bytes to be deallocated
  2216 00013621 E86430FFFF          <1> 	call	deallocate_memory_block
  2217 00013626 E927FFFFFF          <1> 	jmp	sound_buff_error  ; insufficient memory, buff error
  2218                              <1> 
  2219                              <1> soundc_init:
  2220                              <1> 	; FUNCTION = 3 
  2221                              <1> 	; bl = method (0= s.r.b., 1= callback, 2= auto incr s.r.b.)
  2222                              <1> 	; cl = signal response byte (initial or fixed) value
  2223                              <1> 	; edx = signal response byte or callback address
  2224                              <1> 	; 27/07/2020
  2225                              <1> 	; 28/05/2017
  2226                              <1> 	; 12/05/2017, 20/05/2017
  2227                              <1> 	; 22/04/2017, 23/04/2017, 24/04/2017
  2228                              <1> 	; 13/04/2017, 14/04/2017, 16/04/2017, 21/04/2017
  2229                              <1> 	; 03/04/2017, 10/04/2017
  2230                              <1> 
  2231 0001362B A0[519C0100]        <1> 	mov	al, [audio_device]
  2232 00013630 20C0                <1> 	and	al, al
  2233 00013632 7549                <1> 	jnz	short sndc_init_6
  2234                              <1> 	;
  2235 00013634 C605[509C0100]00    <1> 	mov	byte [audio_pci], 0
  2236 0001363B 52                  <1> 	push	edx
  2237 0001363C 53                  <1> 	push	ebx
  2238 0001363D 51                  <1> 	push	ecx
  2239 0001363E E85E1C0000          <1> 	call	DetectSB
  2240 00013643 7213                <1> 	jc	short sndc_init_8
  2241 00013645 66B80103            <1> 	mov	ax, 0301h ; Sound Blaster 16
  2242 00013649 EB1E                <1> 	jmp	short sndc_init_7
  2243                              <1> 
  2244                              <1> sndc_init_11:
  2245                              <1> 	; 28/05/2017
  2246 0001364B E820170000          <1> 	call	DetectICH ; Detect AC'97 (ICH) Audio Controller
  2247 00013650 7217                <1> 	jc	short sndc_init_7
  2248 00013652 66B80203            <1> 	mov	ax, 0302h ; Intel AC'97 Audio Device
  2249 00013656 EB0B                <1> 	jmp	short sndc_init_12 ; (PCI device)
  2250                              <1> 
  2251                              <1> sndc_init_8:
  2252 00013658 E820170000          <1> 	call	DetectVT8233
  2253                              <1> 	;jc	short sndc_init_7
  2254 0001365D 72EC                <1> 	jc	sndc_init_11 ; 28/05/2017
  2255                              <1> 	; eax = 0
  2256 0001365F B003                <1> 	mov	al, 3	; VIA VT8237R (VT3233) Audio Controller
  2257 00013661 88C4                <1> 	mov	ah, al
  2258                              <1> 
  2259                              <1> sndc_init_12:
  2260 00013663 FE05[509C0100]      <1> 	inc	byte [audio_pci] ; = 1
  2261                              <1> sndc_init_7:
  2262 00013669 59                  <1> 	pop	ecx
  2263 0001366A 5B                  <1> 	pop	ebx
  2264 0001366B 5A                  <1> 	pop	edx
  2265 0001366C 0F82D9FEFFFF        <1> 	jc	soundc_dev_err
  2266                              <1> 	;
  2267 00013672 A2[519C0100]        <1> 	mov	[audio_device], al
  2268 00013677 8825[529C0100]      <1> 	mov	[audio_mode], ah ; stereo (bit0), 16 bit (bit1) capability
  2269                              <1> 
  2270                              <1> sndc_init_6:
  2271 0001367D 833D[649C0100]00    <1> 	cmp	dword [audio_buffer], 0
  2272 00013684 0F86C8FEFFFF        <1> 	jna	sound_buff_error
  2273                              <1> 
  2274 0001368A A0[B3030300]        <1> 	mov	al, [u.uno]
  2275 0001368F 8A25[799C0100]      <1> 	mov	ah, [audio_user]
  2276 00013695 08E4                <1> 	or	ah, ah
  2277 00013697 7418                <1> 	jz	short sndc_init0
  2278 00013699 38E0                <1> 	cmp	al, ah
  2279 0001369B 7419                <1> 	je	short sndc_init1
  2280                              <1> 
  2281                              <1> sndc_owner_error:
  2282 0001369D B80B000000          <1> 	mov	eax, ERR_NOT_OWNER ; 'permission denied !' error
  2283                              <1> sndc_perm_error:
  2284 000136A2 A3[64030300]        <1> 	mov	[u.r0], eax
  2285 000136A7 A3[C8030300]        <1> 	mov	[u.error], eax
  2286 000136AC E92BA2FFFF          <1> 	jmp	error
  2287                              <1> sndc_init0:
  2288 000136B1 A2[799C0100]        <1> 	mov	[audio_user], al
  2289                              <1> sndc_init1:
  2290 000136B6 8915[7C9C0100]      <1> 	mov	[audio_cb_addr], edx
  2291 000136BC 881D[7A9C0100]      <1> 	mov	[audio_cb_mode], bl
  2292 000136C2 880D[7B9C0100]      <1> 	mov	[audio_srb], cl
  2293                              <1> 
  2294                              <1> 	; 27/07/2020
  2295                              <1> 	;mov	byte [audio_flag], 0  ; clear dma half buffer flag
  2296                              <1> 
  2297                              <1> 	; 24/04/2017
  2298 000136C8 803D[519C0100]03    <1> 	cmp	byte [audio_device], 3 ; VT8233 (VT8237R)
  2299 000136CF 7438                <1> 	je	short sndc_init_9
  2300                              <1> 	;ja	short soundc_respond_err ; temporary (28/05/2017)
  2301 000136D1 803D[519C0100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
  2302 000136D8 7510                <1> 	jne	short sndc_init_13
  2303 000136DA BB[C6540100]        <1> 	mov	ebx, sb16_int_handler
  2304                              <1> 	; Note: 'SbInit' is at 'Start to Play' stage
  2305                              <1> 	; 20/05/2017
  2306 000136DF 66C705[869C0100]08- <1> 	mov	word [audio_master_volume], 0808h ; 2/8
  2306 000136E7 08                  <1>
  2307 000136E8 EB3F                <1> 	jmp	short sndc_init_10
  2308                              <1> sndc_init_13:
  2309                              <1> 	; 28/05/2017
  2310 000136EA 803D[519C0100]02    <1> 	cmp	byte [audio_device], 2 ; AC 97 (ICH)	
  2311 000136F1 0F8562FEFFFF        <1> 	jne	soundc_respond_err ; temporary (28/05/2017)
  2312                              <1> 
  2313 000136F7 E81F1F0000          <1> 	call	ac97_codec_config
  2314 000136FC 0F8257FEFFFF        <1> 	jc	soundc_respond_err ; codec error !
  2315                              <1> 
  2316 00013702 BB[02580100]        <1> 	mov	ebx, ac97_int_handler
  2317 00013707 EB20                <1> 	jmp	short sndc_init_10	
  2318                              <1> 
  2319                              <1> sndc_init_9:
  2320                              <1> 	;call	reset_codec
  2321                              <1> 	;; eax = 1
  2322                              <1> 	;call	codec_io_w16 ; w32
  2323 00013709 E8E6170000          <1> 	call	init_codec ; 28/05/2017
  2324 0001370E 0F8245FEFFFF        <1> 	jc	soundc_respond_err ; codec error !
  2325                              <1> 
  2326 00013714 E80D1A0000          <1> 	call	channel_reset
  2327                              <1> 
  2328                              <1> 	; setup the Codec (actually mixer registers) 
  2329 00013719 E82D190000          <1>         call    codec_config  ; unmute codec, set rates.
  2330 0001371E 0F8235FEFFFF        <1> 	jc	soundc_respond_err ; codec error !
  2331                              <1> 
  2332 00013724 BB[B8500100]        <1> 	mov	ebx, vt8233_int_handler
  2333                              <1> sndc_init_10:
  2334                              <1> 	; 13/04/2017
  2335 00013729 A0[539C0100]        <1> 	mov	al, [audio_intr] ; IRQ number	
  2336 0001372E E82BFDFFFF          <1> 	call	set_dev_IRQ_service
  2337                              <1> 
  2338                              <1> 	; SETUP (audio) INTERRUPT CALLBACK SERVICE
  2339 00013733 8A1D[539C0100]      <1> 	mov	bl, [audio_intr] ; IRQ number
  2340 00013739 8A3D[7A9C0100]      <1> 	mov	bh, [audio_cb_mode]
  2341 0001373F FEC7                <1> 	inc	bh  ; 1 = Signal Response Byte method (fixed value)
  2342                              <1> 		    ; 2 = Callback service method
  2343                              <1> 		    ; 3 = Auto Increment S.R.B. method 	
  2344 00013741 8A0D[7B9C0100]      <1> 	mov	cl, [audio_srb]
  2345 00013747 8B15[7C9C0100]      <1> 	mov	edx, [audio_cb_addr]
  2346 0001374D A0[799C0100]        <1> 	mov	al, [audio_user]
  2347                              <1> 	; 14/04/2017
  2348 00013752 E8E1040000          <1>  	call	set_irq_callback_service
  2349                              <1> 	; 16/04/2017
  2350 00013757 A3[64030300]        <1> 	mov	[u.r0], eax
  2351                              <1> 	;jnc	sysret
  2352 0001375C 7316                <1> 	jnc	short sndc_init2 ; 21/04/2017
  2353                              <1> 	;
  2354 0001375E A3[C8030300]        <1> 	mov	dword [u.error], eax
  2355                              <1> 
  2356 00013763 A0[539C0100]        <1> 	mov	al, [audio_intr] ; IRQ number	
  2357 00013768 31DB                <1> 	xor	ebx, ebx ; reset IRQ handler address
  2358 0001376A E8EFFCFFFF          <1> 	call	set_dev_IRQ_service
  2359                              <1> 
  2360 0001376F E968A1FFFF          <1> 	jmp	error
  2361                              <1> 
  2362                              <1> sndc_init2:
  2363                              <1> 	; 21/04/2017
  2364 00013774 8B0D[6C9C0100]      <1> 	mov	ecx, [audio_buff_size] ; audio buffer size
  2365 0001377A D1E1                <1> 	shl	ecx, 1 ; *2
  2366 0001377C A1[709C0100]        <1> 	mov	eax, [audio_dma_buff]
  2367 00013781 21C0                <1> 	and	eax, eax
  2368 00013783 7415                <1> 	jz	short sndc_init3
  2369                              <1> 
  2370 00013785 8B15[749C0100]      <1> 	mov	edx, [audio_dmabuff_size] ; dma buffer size
  2371 0001378B 39D1                <1> 	cmp	ecx, edx
  2372 0001378D 744D                <1> 	je	short sndc_init5
  2373                              <1> 
  2374 0001378F 87CA                <1> 	xchg	ecx, edx
  2375 00013791 E8F42EFFFF          <1> 	call	deallocate_memory_block
  2376 00013796 87D1                <1> 	xchg	edx, ecx
  2377 00013798 31C0                <1> 	xor	eax, eax
  2378                              <1> sndc_init3:
  2379                              <1> 	; 12/05/2017
  2380 0001379A 803D[519C0100]01    <1> 	cmp	byte [audio_device], 1 ; SB 16
  2381 000137A1 7515                <1> 	jne	short sndc_init4
  2382 000137A3 C705[709C0100]-     <1> 	mov	dword [audio_dma_buff], sb16_dma_buffer
  2382 000137A9 [00000200]          <1>
  2383 000137AD C705[749C0100]0000- <1> 	mov	dword [audio_dmabuff_size], 65536
  2383 000137B5 0100                <1>
  2384                              <1> 	;xor	eax, eax
  2385                              <1> 	;mov	[u.r0], eax ; 0 = no error, successful
  2386 000137B7 C3                  <1> 	retn 
  2387                              <1> 
  2388                              <1> sndc_init4:
  2389                              <1> 	; EAX = Beginning address (physical)
  2390                              <1> 	; EAX = 0 -> Allocate mem block from the 1st proper aperture	
  2391                              <1> 	; ECX = Number of bytes to be allocated	(>0)	
  2392 000137B8 E8C02CFFFF          <1> 	call	allocate_memory_block
  2393 000137BD 0F828FFDFFFF        <1> 	jc	sound_buff_error
  2394                              <1> 
  2395                              <1> 	; set dma buffer address and size parameters
  2396 000137C3 A3[709C0100]        <1> 	mov	[audio_dma_buff], eax ; dma buffer address
  2397 000137C8 890D[749C0100]      <1> 	mov	[audio_dmabuff_size], ecx ; dma buffer size
  2398                              <1> ;	; EAX = Beginning (physical) addr of the allocated mem block
  2399                              <1> ;	; ECX = Num of allocated bytes (rounded up to page borders)
  2400                              <1> ;	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
  2401                              <1> ;	ja	short sndc_init4
  2402                              <1> ;
  2403                              <1> ;	; Sound Blaster 16 uses classic DMA
  2404                              <1> ;	mov	edx, eax
  2405                              <1> ;	add	edx, ecx
  2406                              <1> ;	cmp	edx, 1000000h ; 1st 16 MB
  2407                              <1> ;	jna	short sndc_init4
  2408                              <1> ;
  2409                              <1> ;	; error !
  2410                              <1> ;	; restore Memory Allocation Table Content
  2411                              <1> ;	; EAX = Beginning address (physical)
  2412                              <1> ;	; ECX = Number of bytes to be deallocated
  2413                              <1> ;	call	deallocate_memory_block
  2414                              <1> ;	; reset dma buffer address and size parameters
  2415                              <1> ;	xor	eax, eax ; 0
  2416                              <1> ;	mov	[audio_dma_buff], eax ; 0
  2417                              <1> ;	mov	[audio_dmabuff_size], ecx ; 0
  2418                              <1> ;	jmp	sound_buff_error				
  2419                              <1> ;
  2420                              <1> ;sndc_init4:
  2421 000137CE 803D[519C0100]03    <1> 	cmp	byte [audio_device], 3
  2422                              <1> 	;jne	short sndc_init5
  2423 000137D5 7506                <1> 	jne	short sndc_init14 ; 28/05/2017
  2424 000137D7 E88B190000          <1> 	call	set_vt8233_bdl	
  2425                              <1> sndc_init5:
  2426                              <1> 	;sub	eax, eax ; 0
  2427                              <1> 	;mov	[u.r0], eax ; 0 = no error, successful
  2428 000137DC C3                  <1> 	retn
  2429                              <1> sndc_init14:
  2430 000137DD E8521F0000          <1> 	call	set_ac97_bdl
  2431                              <1> 	;jmp	short sndc_init5
  2432 000137E2 C3                  <1> 	retn
  2433                              <1> 
  2434                              <1> sound_play:
  2435                              <1> 	; FUNCTION = 4 
  2436                              <1> 	; bl = Mode 
  2437                              <1> 	;      bit 0 = mono/stereo (1 = stereo)		
  2438                              <1> 	;      bit 1 = 8 bit / 16 bit (1 = 16 bit)
  2439                              <1> 	; cx = Sampling Rate (Hz)
  2440                              <1> 
  2441                              <1> 	; 13/06/2017
  2442                              <1> 	; Note: Even if Mode bits are not 11b,
  2443                              <1> 	; 	AC'97 Audio Controller (&Codec)
  2444                              <1> 	;	will play audio samples as 16 bit, stereo
  2445                              <1> 	;	samples.
  2446                              <1> 	;	(Program must fill the audio buffer
  2447                              <1> 	;	as required; 8 bit samples must be converted
  2448                              <1> 	;	to 16 bit samples and mono samples must be
  2449                              <1> 	;	converted to stereo samples...)
  2450                              <1> 	; 
  2451                              <1> 	; 28/07/2020
  2452                              <1> 	; 27/07/2020	 	
  2453                              <1> 	; 28/05/2017
  2454                              <1> 	; 15/05/2017, 20/05/2017
  2455                              <1> 	; 21/04/2017, 24/04/2017
  2456                              <1> 	; ... device check at first
  2457 000137E3 A0[519C0100]        <1> 	mov	al, [audio_device]
  2458 000137E8 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
  2459 000137EA 0F8402ECFEFF        <1> 	jz	beeper_gfx ; 'video.s' ; temporary !
  2460                              <1> ;	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2461                              <1> ;	je	short snd_play_1
  2462                              <1> ;	cmp	al, 1 ; SB 16
  2463                              <1> ;	jne	soundc_dev_err ; temporary !
  2464                              <1> ;snd_play_0:
  2465                              <1> 	; ... buffer & (buffer) owner check at second
  2466 000137F0 833D[649C0100]00    <1> 	cmp	dword [audio_buffer], 0
  2467 000137F7 0F8655FDFFFF        <1> 	jna	sound_buff_error
  2468 000137FD A0[B3030300]        <1> 	mov	al, [u.uno]
  2469 00013802 3A05[799C0100]      <1> 	cmp	al, [audio_user]
  2470 00013808 0F858FFEFFFF        <1> 	jne	sndc_owner_error
  2471                              <1> 
  2472 0001380E 66890D[829C0100]    <1> 	mov	[audio_freq], cx ; sample frequency (Hertz)
  2473 00013815 88D8                <1> 	mov	al, bl
  2474 00013817 2401                <1> 	and	al, 1 ; mono/stereo (1= stereo)
  2475 00013819 FEC0                <1> 	inc	al ; channels
  2476 0001381B A2[819C0100]        <1> 	mov	[audio_stmo], al ; sound channels (1 or 2)
  2477 00013820 B008                <1> 	mov	al, 8
  2478 00013822 F6C302              <1> 	test	bl, 2 ; bits per sample (1= 16 bit)
  2479 00013825 7402                <1> 	jz	short snd_play_bps
  2480 00013827 D0E0                <1> 	shl	al, 1  
  2481                              <1> snd_play_bps:	
  2482 00013829 A2[809C0100]        <1> 	mov	[audio_bps], al
  2483                              <1> 
  2484                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
  2485 0001382E 8B3D[709C0100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
  2486 00013834 09FF                <1> 	or	edi, edi
  2487 00013836 0F8416FDFFFF        <1> 	jz	sound_buff_error
  2488                              <1> 
  2489                              <1> 	; 27/07/2020
  2490                              <1> 
  2491 0001383C 8B35[689C0100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
  2492                              <1> 	;mov	ecx, [audio_buff_size] ; 15/05/2017
  2493 00013842 8B0D[749C0100]      <1> 	mov	ecx, [audio_dmabuff_size] ; 27/07/2020
  2494                              <1> 	;or	ecx, ecx 
  2495                              <1> 	;jz	sound_buff_error
  2496                              <1> 	; 28/07/2020
  2497 00013848 D1E9                <1> 	shr	ecx, 1  ; dma half buffer size
  2498                              <1> 
  2499 0001384A 8035[789C0100]01    <1> 	xor	byte [audio_flag], 1 ;  0 -> 1, 1 -> 0
  2500 00013851 7502                <1> 	jnz	short snd_play_0 ; [audio_flag] = 1
  2501                              <1> 				 ; fill dma half buffer 1
  2502                              <1> 	; [audio_flag] = 0
  2503                              <1> 	
  2504                              <1> 	; fill dma half buffer 2
  2505 00013853 01CF                <1> 	add	edi, ecx
  2506                              <1> 
  2507                              <1> snd_play_0:
  2508                              <1> 	;rep	movsb
  2509 00013855 C1E902              <1> 	shr	ecx, 2  ; convert byte count to dword count
  2510 00013858 F3A5                <1> 	rep	movsd
  2511                              <1> 
  2512                              <1> 	; here, if [audio_flag] = 0, interrupt handler will update
  2513                              <1> 				; dma half buffer 2 
  2514                              <1> 				; (user's audio buffer data will be 
  2515                              <1> 				; copied into dma half buffer 2) 
  2516                              <1> 	;; 20/05/2017
  2517                              <1> 	;mov	byte [audio_flag], 1 ; next half (on next time)
  2518                              <1> 
  2519                              <1> 	; 24/04/2017
  2520 0001385A A0[519C0100]        <1> 	mov	al, [audio_device]
  2521 0001385F 3C03                <1> 	cmp	al, 3 ; VT8233 (VT8237R) 
  2522 00013861 7410                <1> 	je	short snd_play_1
  2523 00013863 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2524 00013865 7512                <1> 	jne	short snd_play_2  ; 28/05/2017
  2525 00013867 E8031B0000          <1> 	call	SbInit_play
  2526 0001386C 0F82E7FCFFFF        <1> 	jc	soundc_respond_err
  2527 00013872 C3                  <1> 	retn
  2528                              <1> 
  2529                              <1> snd_play_1:	
  2530 00013873 E826190000          <1> 	call	vt8233_start_play
  2531 00013878 C3                  <1> 	retn
  2532                              <1> 
  2533                              <1> snd_play_2:
  2534                              <1> 	; 28/05/2017
  2535                              <1> 	;cmp	al, 2 ; AC'97
  2536                              <1> 	;jne	short snd_play_3
  2537                              <1> 
  2538 00013879 E8EA1E0000          <1> 	call	ac97_start_play
  2539 0001387E C3                  <1> 	retn
  2540                              <1> 
  2541                              <1> ;snd_play_3:
  2542                              <1> ;	;call	hda_start_play
  2543                              <1> ;	retn
  2544                              <1> 
  2545                              <1> sound_pause:
  2546                              <1> 	; FUNCTION = 5
  2547                              <1> 	; Pause
  2548                              <1> 	; 28/05/2017
  2549                              <1> 	; 24/04/2017
  2550                              <1> 	; 22/04/2017
  2551 0001387F E814030000          <1> 	call	snd_dev_check
  2552 00013884 7275                <1> 	jc	short snd_nothing ; temporary.
  2553 00013886 E81A030000          <1> 	call	snd_buf_check
  2554 0001388B 726E                <1> 	jc	short snd_nothing ; temporary.
  2555 0001388D A0[519C0100]        <1> 	mov	al, [audio_device]
  2556 00013892 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2557 00013894 7409                <1> 	je	short snd_pause_1
  2558 00013896 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2559 00013898 750A                <1> 	jne	short snd_pause_2 ; 28/05/2017
  2560 0001389A E9AE1C0000          <1> 	jmp	sb16_pause
  2561                              <1> snd_pause_1:
  2562 0001389F E9B3190000          <1> 	jmp	vt8233_pause
  2563                              <1> snd_pause_2:
  2564                              <1> 	; 28/05/2017
  2565                              <1> 	;cmp	al, 2 ; AC'97
  2566                              <1> 	;jne	short snd_nothing ; temporary.
  2567 000138A4 E94D200000          <1> 	jmp	ac97_pause
  2568                              <1> 
  2569                              <1> sound_continue:
  2570                              <1> 	; FUNCTION = 6
  2571                              <1> 	; Continue to play
  2572                              <1> 	; 28/05/2017
  2573                              <1> 	; 22/04/2017
  2574 000138A9 E8EA020000          <1> 	call	snd_dev_check
  2575 000138AE 724B                <1> 	jc	short snd_nothing ; temporary.
  2576 000138B0 E8F0020000          <1> 	call	snd_buf_check
  2577 000138B5 7244                <1> 	jc	short snd_nothing ; temporary.
  2578 000138B7 A0[519C0100]        <1> 	mov	al, [audio_device]
  2579 000138BC 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2580 000138BE 7409                <1> 	je	short snd_cont_1
  2581 000138C0 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2582 000138C2 750A                <1> 	jne	short snd_cont_2 ; 28/05/2017
  2583 000138C4 E9A71C0000          <1> 	jmp	sb16_continue
  2584                              <1> snd_cont_1:
  2585 000138C9 E93A190000          <1> 	jmp	vt8233_play
  2586                              <1> snd_cont_2:
  2587                              <1> 	; 28/05/2017
  2588                              <1> 	;cmp	al, 2 ; AC'97
  2589                              <1> 	;jne	short snd_nothing ; temporary.
  2590 000138CE E9EB1E0000          <1> 	jmp	ac97_play
  2591                              <1> 
  2592                              <1> sound_stop:
  2593                              <1> 	; FUNCTION = 7
  2594                              <1> 	; Stop playing
  2595                              <1> 	; 28/05/2017
  2596                              <1> 	; 24/05/2017
  2597                              <1> 	; 21/04/2017, 22/04/2017, 24/04/2017
  2598 000138D3 E8C0020000          <1> 	call	snd_dev_check
  2599 000138D8 7221                <1> 	jc	short snd_nothing ; temporary.
  2600                              <1> 	;call	snd_buf_check
  2601 000138DA E8CF020000          <1> 	call	snd_user_check ; 24/05/2017
  2602 000138DF 721A                <1> 	jc	short snd_nothing ; temporary.	
  2603                              <1> 	
  2604 000138E1 A0[519C0100]        <1> 	mov	al, [audio_device]
  2605 000138E6 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2606 000138E8 0F8470180000        <1> 	je	vt8233_stop
  2607                              <1> 	; 28/05/2017
  2608                              <1> 	;ja	short snd_nothing
  2609 000138EE 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2610 000138F0 0F849D1C0000        <1> 	je	sb16_stop
  2611                              <1> 	;cmp	al, 2 
  2612                              <1> 	;je	short ac97_stop
  2613 000138F6 E9CD1F0000          <1> 	jmp	ac97_stop ; temporary.
  2614                              <1> 	;jmp	hda_stop
  2615                              <1> 
  2616                              <1> snd_nothing:
  2617                              <1> 	; 21/04/2017
  2618 000138FB C3                  <1> 	retn
  2619                              <1> 
  2620                              <1> soundc_reset:
  2621                              <1> 	; FUNCTION = 8
  2622                              <1> 	; Reset Audio Controller
  2623                              <1> 	; 28/05/2017
  2624                              <1> 	; 22/04/2017
  2625 000138FC E897020000          <1> 	call	snd_dev_check
  2626 00013901 72F8                <1> 	jc	snd_nothing ; temporary.
  2627 00013903 E89D020000          <1> 	call	snd_buf_check
  2628 00013908 72F1                <1> 	jc	snd_nothing ; temporary.	
  2629                              <1> 	
  2630 0001390A A0[519C0100]        <1> 	mov	al, [audio_device]
  2631 0001390F 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2632 00013911 0F844C190000        <1> 	je	vt8233_reset
  2633 00013917 77E2                <1> 	ja	short snd_nothing ; temporary.
  2634                              <1> 	;ja	hda_reset	
  2635 00013919 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2636 0001391B 0F8526200000        <1> 	jne	ac97_reset	
  2637 00013921 E8BF1C0000          <1> 	call	sb16_reset
  2638 00013926 0F822DFCFFFF        <1> 	jc	soundc_respond_err
  2639 0001392C C3                  <1> 	retn
  2640                              <1> 
  2641                              <1> soundc_cancel:
  2642                              <1> 	; FUNCTION = 9
  2643                              <1> 	; Cancel audio callback service
  2644                              <1> 	; 22/04/2017
  2645 0001392D A0[799C0100]        <1> 	mov	al, [audio_user]	
  2646 00013932 3A05[B3030300]      <1> 	cmp	al, [u.uno]
  2647 00013938 75C1                <1> 	jne	short snd_nothing
  2648                              <1> 	; RESET (audio) INTERRUPT CALLBACK SERVICE
  2649 0001393A 8A1D[539C0100]      <1> 	mov	bl, [audio_intr] ; IRQ number
  2650 00013940 A0[B3030300]        <1> 	mov	al, [u.uno]
  2651 00013945 28FF                <1> 	sub	bh, bh ; 0 ; unlink IRQ from user service
  2652 00013947 E8EC020000          <1>  	call	set_irq_callback_service
  2653 0001394C 0F8250FDFFFF        <1> 	jc	sndc_perm_error ; 'permission denied' error
  2654 00013952 C3                  <1> 	retn
  2655                              <1> 
  2656                              <1> sound_dalloc:
  2657                              <1> 	; FUNCTION = 10
  2658                              <1> 	; Deallocate (ring 3) audio buffer
  2659                              <1> 	; 22/04/2017
  2660 00013953 A0[799C0100]        <1> 	mov	al, [audio_user]	
  2661 00013958 3A05[B3030300]      <1> 	cmp	al, [u.uno]
  2662 0001395E 759B                <1> 	jne	short snd_nothing
  2663 00013960 8B1D[649C0100]      <1> 	mov	ebx, [audio_buffer]
  2664                              <1> 	;or	ebx, ebx
  2665                              <1> 	;jz	short snd_nothing
  2666 00013966 8B0D[6C9C0100]      <1> 	mov	ecx, [audio_buff_size]
  2667 0001396C E8672EFFFF          <1> 	call	deallocate_user_pages
  2668 00013971 31C0                <1> 	xor	eax, eax
  2669 00013973 A3[649C0100]        <1> 	mov	[audio_buffer], eax ; 0
  2670 00013978 A2[799C0100]        <1> 	mov	[audio_user], al ; 0
  2671 0001397D C3                  <1> 	retn
  2672                              <1> 
  2673                              <1> sound_volume:
  2674                              <1> 	; FUNCTION = 11
  2675                              <1> 	; Set sound volume level
  2676                              <1> 	; 28/05/2017
  2677                              <1> 	; 20/05/2017
  2678                              <1> 	; 22/04/2017, 24/04/2017
  2679                              <1> 	; bl = component (0 = master/playback/lineout volume)
  2680                              <1> 	; cl = left channel volume level (0 to 31)
  2681                              <1> 	; ch = right channel volume level (0 to 31)
  2682                              <1> 
  2683 0001397E 80FB80              <1> 	cmp	bl, 80h
  2684 00013981 720E                <1> 	jb	short snd_vol_1
  2685 00013983 0F8772FFFFFF        <1> 	ja	snd_nothing ; temporary.
  2686                              <1> 	; Set volume level for next play (BL>= 80h)
  2687 00013989 66890D[869C0100]    <1> 	mov	[audio_master_volume], cx
  2688 00013990 C3                  <1> 	retn
  2689                              <1> snd_vol_1:
  2690                              <1> 	; set volume level immediate (BL< 80h)
  2691 00013991 80FB00              <1> 	cmp	bl, 0
  2692 00013994 0F8761FFFFFF        <1> 	ja	snd_nothing ; temporary.
  2693                              <1> 
  2694 0001399A E8F9010000          <1> 	call	snd_dev_check
  2695 0001399F 0F8256FFFFFF        <1> 	jc	snd_nothing ; temporary.
  2696 000139A5 E8FB010000          <1> 	call	snd_buf_check
  2697 000139AA 0F824BFFFFFF        <1> 	jc	snd_nothing ; temporary.	
  2698                              <1> 
  2699 000139B0 A0[519C0100]        <1> 	mov	al, [audio_device]
  2700 000139B5 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2701 000139B7 0F84BF180000        <1> 	je	vt8233_volume
  2702                              <1> 	; 28/05/2017
  2703 000139BD 0F8738FFFFFF        <1> 	ja	snd_nothing ; temporary.
  2704                              <1> 	;ja	hda_volume	
  2705                              <1> 	; Sound Blaster 16
  2706 000139C3 3C01                <1> 	cmp	al, 1 ; SB 16
  2707 000139C5 0F844D1B0000        <1> 	je	sb16_volume
  2708 000139CB E90A1E0000          <1> 	jmp	ac97_volume
  2709                              <1> 
  2710                              <1> soundc_disable:
  2711                              <1> 	; FUNCTION = 12 
  2712                              <1> 	; Disable audio device (and unlink DMA memory)
  2713                              <1> 	; 28/05/2017
  2714                              <1> 	; 24/05/2017
  2715                              <1> 	; 22/04/2017
  2716 000139D0 E8C3010000          <1> 	call	snd_dev_check
  2717 000139D5 0F8270FBFFFF        <1> 	jc	soundc_dev_err ; temporary.
  2718                              <1> 	;call	snd_buf_check
  2719                              <1> 	;jc	sndc_owner_error ; temporary.
  2720                              <1> 
  2721 000139DB A0[519C0100]        <1> 	mov	al, [audio_device]
  2722 000139E0 3C03                <1> 	cmp	al, 3 ; VIA VT 8237R (vt8233)
  2723 000139E2 7418                <1> 	je	short snd_disable_1
  2724 000139E4 0F8711FFFFFF        <1> 	ja	snd_nothing ; temporary.
  2725 000139EA 3C01                <1> 	cmp	al, 1 ; Sound Blaster 16
  2726 000139EC 7507                <1> 	jne	short snd_disable_0
  2727 000139EE E8A01B0000          <1> 	call	sb16_stop
  2728 000139F3 EB0C                <1> 	jmp	short snd_disable_2
  2729                              <1> snd_disable_0:
  2730 000139F5 E8CE1E0000          <1> 	call	ac97_stop
  2731 000139FA EB05                <1> 	jmp	short snd_disable_2
  2732                              <1> snd_disable_1:
  2733 000139FC E85D170000          <1> 	call	vt8233_stop
  2734                              <1> snd_disable_2:
  2735 00013A01 A0[539C0100]        <1> 	mov	al, [audio_intr]
  2736 00013A06 29DB                <1> 	sub	ebx, ebx ; 0 = reset
  2737 00013A08 E851FAFFFF          <1> 	call	set_dev_IRQ_service
  2738                              <1> 
  2739                              <1> 	;mov	al, [audio_intr]
  2740 00013A0D 28E4                <1> 	sub	ah, ah ; 0 = reset
  2741 00013A0F E8B5F6FFFF          <1> 	call	set_hardware_int_vector
  2742                              <1> 
  2743 00013A14 31C0                <1> 	xor	eax, eax
  2744 00013A16 A2[519C0100]        <1> 	mov	byte [audio_device], al
  2745 00013A1B A2[539C0100]        <1> 	mov	byte [audio_intr], al
  2746 00013A20 8705[709C0100]      <1> 	xchg	eax, [audio_dma_buff]
  2747                              <1> 	; 24/05/2017
  2748                              <1> 	;or	eax, eax
  2749                              <1> 	;jz	short snd_disable_3
  2750                              <1> 	;cmp	eax, sb16_dma_buffer ; default DMA buffer
  2751                              <1> 	;je	short snd_disable_3
  2752 00013A26 803D[509C0100]00    <1> 	cmp	byte [audio_pci], 0 ; AC97 audio controller ?
  2753 00013A2D 7612                <1> 	jna	short snd_disable_3
  2754 00013A2F C605[509C0100]00    <1> 	mov	byte [audio_pci], 0
  2755                              <1> 	;sub	ecx, ecx
  2756                              <1> 	;xchg	ecx, [audio_dmabuff_size]
  2757 00013A36 8B0D[749C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  2758 00013A3C E8492CFFFF          <1> 	call	deallocate_memory_block
  2759                              <1> snd_disable_3:
  2760 00013A41 C3                  <1> 	retn
  2761                              <1> 
  2762                              <1> sound_dma_map:
  2763                              <1> 	; FUNCTION = 13 
  2764                              <1> 	; Map audio dma buff addr to user's buffer addr
  2765                              <1> 	; 12/05/2017
  2766 00013A42 21C9                <1> 	and	ecx, ecx
  2767 00013A44 0F8408FBFFFF        <1> 	jz	sound_buff_error
  2768 00013A4A 803D[519C0100]01    <1> 	cmp	byte [audio_device], 1
  2769 00013A51 7229                <1> 	jb	short snd_dma_map_1
  2770                              <1> snd_dma_map_0:
  2771 00013A53 A1[709C0100]        <1> 	mov	eax, [audio_dma_buff]
  2772 00013A58 21C0                <1> 	and	eax, eax
  2773 00013A5A 7420                <1> 	jz	short snd_dma_map_1
  2774                              <1> 	;
  2775 00013A5C 8A1D[799C0100]      <1> 	mov	bl, [audio_user]
  2776 00013A62 08DB                <1> 	or	bl, bl
  2777 00013A64 7416                <1> 	jz	short snd_dma_map_1
  2778 00013A66 3A1D[B3030300]      <1> 	cmp	bl, [u.uno]
  2779 00013A6C 0F852BFCFFFF        <1> 	jne	sndc_owner_error
  2780                              <1> 	;
  2781 00013A72 8B1D[749C0100]      <1> 	mov	ebx, [audio_dmabuff_size]
  2782 00013A78 21DB                <1> 	and	ebx, ebx
  2783 00013A7A 750A                <1> 	jnz	short snd_dma_map_2
  2784                              <1> snd_dma_map_1:
  2785 00013A7C B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  2786 00013A81 BB00000100          <1> 	mov	ebx, 65536
  2787                              <1> snd_dma_map_2:	
  2788 00013A86 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
  2789 00013A8C 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
  2790 00013A91 39D9                <1> 	cmp	ecx, ebx
  2791 00013A93 0F87B9FAFFFF        <1> 	ja	sound_buff_error
  2792 00013A99 50                  <1> 	push	eax
  2793 00013A9A 89D3                <1> 	mov	ebx, edx
  2794 00013A9C C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
  2795                              <1> 	; eax = physical address of (audio) dma buffer
  2796                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
  2797                              <1> 	; ecx = page count (>0)
  2798 00013A9F E8562CFFFF          <1> 	call	direct_memory_access
  2799 00013AA4 58                  <1> 	pop	eax
  2800 00013AA5 0F82A7FAFFFF        <1> 	jc	sound_buff_error
  2801 00013AAB A3[64030300]        <1> 	mov	[u.r0], eax
  2802 00013AB0 C3                  <1> 	retn
  2803                              <1> 
  2804                              <1> soundc_info:
  2805                              <1> 	; FUNCTION = 14 
  2806                              <1> 	; Get Audio Controller Info
  2807                              <1> 	; 10/06/2017
  2808                              <1> 	; 05/06/2017
  2809 00013AB1 20DB                <1> 	and	bl, bl ; 0
  2810 00013AB3 740A                <1> 	jz	short sndc_info_0
  2811                              <1> 	; invalid parameter !
  2812 00013AB5 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER ; 23
  2813                              <1> ;sndc_inf_error:
  2814                              <1> ;	mov	[u.r0], eax
  2815                              <1> ;	mov	[u.error], eax
  2816                              <1> ;	jmp	error
  2817 00013ABA E99FFAFFFF          <1> 	jmp	sysaudio_err
  2818                              <1> 
  2819                              <1> sndc_info_0:
  2820 00013ABF E8D4000000          <1> 	call	snd_dev_check
  2821 00013AC4 0F8281FAFFFF        <1> 	jc	soundc_dev_err
  2822                              <1> 
  2823 00013ACA 8B1D[5C9C0100]      <1> 	mov	ebx, [audio_vendor]
  2824 00013AD0 8B0D[589C0100]      <1> 	mov	ecx, [audio_dev_id]
  2825                              <1> 	;mov	al,  [audio_device]
  2826 00013AD6 3C02                <1> 	cmp	al, 2 ; AC'97 (ICH)
  2827 00013AD8 7513                <1> 	jne	short sndc_info_1
  2828                              <1> 	; Intel AC97 (ICH) Audio Controller (=2)	
  2829 00013ADA 668B15[8A9C0100]    <1> 	mov	dx, [NABMBAR]
  2830 00013AE1 C1E210              <1> 	shl	edx, 16
  2831 00013AE4 668B15[889C0100]    <1> 	mov	dx, [NAMBAR]
  2832 00013AEB EB07                <1> 	jmp	short sndc_info_2
  2833                              <1> sndc_info_1:
  2834                              <1> 	; 05/06/2017
  2835                              <1> 	; Note: Intel HDA code (here) is not ready yet!
  2836                              <1> 	; !!! SB16 or VT8233 (VT8237R) !!!
  2837 00013AED 0FB715[569C0100]    <1> 	movzx	edx, word [audio_io_base]	
  2838                              <1> sndc_info_2:
  2839 00013AF4 88C4                <1> 	mov	ah, al ;  [audio_device]
  2840 00013AF6 A0[539C0100]        <1> 	mov	al, [audio_intr] 
  2841                              <1> 
  2842                              <1> 	; EAX = IRQ Number in AL
  2843                              <1> 	;	Audio Device Number in AH 
  2844                              <1> 	; EBX = DEV/VENDOR ID
  2845                              <1> 	;	(DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV)
  2846                              <1> 	; ECX = BUS/DEV/FN 
  2847                              <1> 	;	(00000000BBBBBBBBDDDDDFFF00000000)
  2848                              <1> 	; EDX = NABMBAR/NAMBAR (for AC97)
  2849                              <1> 	;	(Low word, DX = NAMBAR address)
  2850                              <1> 	; EDX = Base IO Addr (DX) for SB16 & VT8233
  2851                              <1> 
  2852                              <1> 	; 10/06/2017
  2853 00013AFB A3[64030300]        <1> 	mov	[u.r0], eax
  2854 00013B00 8B2D[60030300]      <1> 	mov	ebp, [u.usp]
  2855 00013B06 895D10              <1> 	mov	[ebp+16], ebx  ; ebx
  2856 00013B09 895514              <1> 	mov	[ebp+20], edx  ; edx
  2857 00013B0C 894D18              <1> 	mov	[ebp+24], ecx  ; ecx
  2858                              <1>   			  		
  2859 00013B0F C3                  <1>  	retn
  2860                              <1> 
  2861                              <1> sound_data:
  2862                              <1> 	; FUNCTION = 15 
  2863                              <1> 	; Get Current Sound data for graphics
  2864                              <1> 	; 22/06/2017
  2865                              <1> 	;
  2866 00013B10 E883000000          <1> 	call	snd_dev_check
  2867 00013B15 0F8230FAFFFF        <1> 	jc	soundc_dev_err ; Device not ready !
  2868                              <1> 
  2869 00013B1B 80FB00              <1> 	cmp	bl, 0
  2870 00013B1E 760A                <1> 	jna	short sound_data_0
  2871                              <1> 
  2872                              <1> 	; Only PCM OUT buffer data is valid for now!
  2873 00013B20 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER  ; 23
  2874 00013B25 E934FAFFFF          <1> 	jmp	sysaudio_err
  2875                              <1> 
  2876                              <1> sound_data_0:
  2877 00013B2A A1[709C0100]        <1> 	mov	eax, [audio_dma_buff]
  2878 00013B2F 09C0                <1> 	or	eax, eax
  2879 00013B31 0F841BFAFFFF        <1> 	jz	sound_buff_error
  2880                              <1> 
  2881 00013B37 803D[519C0100]04    <1> 	cmp	byte [audio_device], 4 ; Intel HDA
  2882 00013B3E 744F                <1> 	je	short sound_data_4 ; temporary ! (22/06/2017)
  2883                              <1> 
  2884 00013B40 21C9                <1> 	and	ecx, ecx
  2885                              <1> 	;jnz	short sound_data_1 ; sample tranfer
  2886                              <1> 	
  2887                              <1> 	; Return only DMA Buffer pointer/offset... 
  2888                              <1> 	; (If DMA Buffer has been mapped to user's
  2889                              <1> 	;  memory space; program can get graphics
  2890                              <1> 	;  data by using only this pointer value.)
  2891                              <1> 	   	
  2892                              <1> 	;call	get_dma_buffer_offset
  2893                              <1> 	;; eax = DMA buffer offset
  2894                              <1> 	;;	(!not half buffer offset!)
  2895                              <1> 	;mov	[u.r0], eax
  2896                              <1> 	;retn
  2897                              <1> 
  2898 00013B42 0F84771F0000        <1> 	jz	get_dma_buffer_offset	
  2899                              <1> 	
  2900                              <1> sound_data_1:
  2901                              <1> 	;mov	eax, [audio_dmabuff_size]
  2902                              <1> 	;shr	eax, 1 ; half buffer size
  2903                              <1> 	;cmp	ecx, eax
  2904                              <1> 	;ja	short sound_buff_error	
  2905                              <1> 
  2906 00013B48 3B0D[749C0100]      <1> 	cmp	ecx, [audio_dmabuff_size]
  2907 00013B4E 0F87FEF9FFFF        <1> 	ja	sound_buff_error
  2908                              <1> 
  2909 00013B54 89D0                <1> 	mov	eax, edx
  2910 00013B56 25FF0F0000          <1> 	and	eax, PAGE_OFF ; 4095 (0FFFh)
  2911 00013B5B 81F900100000        <1> 	cmp	ecx, 4096
  2912 00013B61 7605                <1> 	jna	short sound_data_2
  2913 00013B63 B900100000          <1> 	mov	ecx, 4096 ; max. 1 page
  2914                              <1> sound_data_2:
  2915 00013B68 01C8                <1> 	add	eax, ecx
  2916 00013B6A 3D00100000          <1> 	cmp	eax, 4096
  2917 00013B6F 7606                <1> 	jna	short sound_data_3
  2918 00013B71 6625FF0F            <1> 	and	ax, PAGE_OFF ; 4095 (0FFFh)
  2919 00013B75 29C1                <1> 	sub	ecx, eax
  2920                              <1> 	; here, ECX has been adjusted to fit 
  2921                              <1> 	;	in page border..  (<= 4096, >0)
  2922                              <1> sound_data_3:
  2923 00013B77 51                  <1> 	push	ecx
  2924 00013B78 52                  <1> 	push	edx
  2925 00013B79 89D3                <1> 	mov	ebx, edx 
  2926 00013B7B E86827FFFF          <1> 	call	get_physical_addr
  2927 00013B80 5A                  <1> 	pop	edx
  2928 00013B81 59                  <1> 	pop	ecx
  2929 00013B82 0F82CAF9FFFF        <1> 	jc	sound_buff_error	
  2930                              <1> 	
  2931                              <1> 	; eax = physical address of user's buffer
  2932 00013B88 89C3                <1> 	mov	ebx, eax  
  2933                              <1> 	; ecx = byte (transfer) count
  2934                              <1> 	;call	get_current_sound_data
  2935                              <1> 	;retn
  2936 00013B8A E98D1E0000          <1> 	jmp	get_current_sound_data
  2937                              <1> 
  2938                              <1> sound_data_4:
  2939                              <1> 	; Intel HDA code is not ready yet !
  2940                              <1> 	; 22/06/2017
  2941 00013B8F 31C0                <1> 	xor	eax, eax
  2942 00013B91 48                  <1> 	dec	eax
  2943 00013B92 A3[64030300]        <1> 	mov	[u.r0], eax ; 0FFFFFFFFh
  2944 00013B97 C3                  <1> 	retn 
  2945                              <1> 
  2946                              <1> snd_dev_check:
  2947                              <1> 	; 10/06/2017
  2948                              <1> 	; 05/06/2017
  2949                              <1> 	; 24/05/2017
  2950                              <1> 	; 22/04/2017
  2951                              <1> 	; 21/04/2017
  2952                              <1> 	; ... device check at first
  2953 00013B98 A0[519C0100]        <1> 	mov	al, [audio_device]
  2954 00013B9D 3C01                <1> 	cmp	al, 1 ; SB 16
  2955 00013B9F 7203                <1> 	jb	short snd_dev_chk_retn ; error !
  2956                              <1> 	;cmp	al, 4 ; Intel HDA
  2957                              <1> 	;ja	short snd_dbchk_stc ; invalid !
  2958                              <1> 	; 10/06/2017
  2959 00013BA1 3C05                <1> 	cmp	al, 5
  2960 00013BA3 F5                  <1> 	cmc
  2961                              <1> snd_dev_chk_retn:
  2962 00013BA4 C3                  <1> 	retn
  2963                              <1> 
  2964                              <1> snd_buf_check:
  2965                              <1> 	; 10/06/2017
  2966                              <1> 	; 22/04/2017
  2967                              <1> 	; 21/04/2017
  2968                              <1> 	; ... buffer & (buffer) owner check at second
  2969 00013BA5 833D[649C0100]00    <1> 	cmp	dword [audio_buffer], 0
  2970 00013BAC 760D                <1> 	jna	short snd_dbchk_stc
  2971                              <1> snd_user_check:
  2972 00013BAE A0[B3030300]        <1> 	mov	al, [u.uno]
  2973 00013BB3 3A05[799C0100]      <1> 	cmp	al, [audio_user]
  2974                              <1> 	;jne	short snd_dbchk_stc
  2975                              <1> 	;retn
  2976 00013BB9 74E9                <1> 	je	short snd_dev_chk_retn
  2977                              <1> 
  2978                              <1> snd_dbchk_stc:
  2979 00013BBB F9                  <1> 	stc
  2980 00013BBC C3                  <1> 	retn
  2981                              <1> 
  2982                              <1> sound_update:
  2983                              <1> 	; FUNCTION = 16 
  2984                              <1> 	; bl = 
  2985                              <1> 	;    0 = automatic (sequental) update (with flag switch!)
  2986                              <1> 	;    1 = update dma half buffer 1 (without flag switch!)		
  2987                              <1> 	;    2 = update dma half buffer 2 (without flag switch!)
  2988                              <1> 	;  FFh = get current flag value	
  2989                              <1> 	;      0 = dma half buffer 1 (will be played next)
  2990                              <1> 	;      1 = dma half buffer 2 (will be played next)
  2991                              <1> 	
  2992                              <1> 	; 10/10/2017
  2993                              <1> 	
  2994                              <1> 	; ... device check at first
  2995 00013BBD A0[519C0100]        <1> 	mov	al, [audio_device]
  2996 00013BC2 08C0                <1> 	or	al, al ; 0 ; pc speaker or invalid 
  2997 00013BC4 0F8481F9FFFF        <1> 	jz	soundc_dev_err
  2998                              <1> 
  2999                              <1> 	; ... buffer & (buffer) owner check at second
  3000 00013BCA 833D[649C0100]00    <1> 	cmp	dword [audio_buffer], 0
  3001 00013BD1 0F867BF9FFFF        <1> 	jna	sound_buff_error
  3002 00013BD7 A0[B3030300]        <1> 	mov	al, [u.uno]
  3003 00013BDC 3A05[799C0100]      <1> 	cmp	al, [audio_user]
  3004 00013BE2 0F85B5FAFFFF        <1> 	jne	sndc_owner_error
  3005                              <1> 
  3006                              <1> 	; Transfer ring 3 (user's) audio buffer content to dma buffer
  3007 00013BE8 8B3D[709C0100]      <1> 	mov	edi, [audio_dma_buff] ; dma buffer (ring 0)
  3008 00013BEE 09FF                <1> 	or	edi, edi
  3009 00013BF0 0F845CF9FFFF        <1> 	jz	sound_buff_error
  3010 00013BF6 8B35[689C0100]      <1> 	mov	esi, [audio_p_buffer] ; physical address (ring 3)
  3011 00013BFC 8B0D[6C9C0100]      <1> 	mov	ecx, [audio_buff_size]
  3012                              <1> 	
  3013                              <1> 	;movzx	eax, byte [audio_flag]
  3014 00013C02 A0[789C0100]        <1> 	mov	al, [audio_flag]
  3015                              <1> 
  3016 00013C07 FEC3                <1> 	inc	bl
  3017 00013C09 7427                <1> 	jz	short snd_update_3 ; bl = 0FFh
  3018 00013C0B FECB                <1> 	dec	bl 
  3019 00013C0D 7411                <1> 	jz	short snd_update_0 ; bl = 0
  3020                              <1> 
  3021 00013C0F 80FB02              <1> 	cmp	bl, 2
  3022 00013C12 7417                <1> 	je	short snd_update_1 ; dma half buffer 2
  3023 00013C14 7217                <1> 	jb	short snd_update_2 ; dma half buffer 1
  3024                              <1>  
  3025                              <1> 	; invalid parameter !
  3026 00013C16 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER ; 23
  3027                              <1> ;	mov	[u.r0], eax
  3028                              <1> ;	mov	[u.error], eax
  3029                              <1> ;	jmp	error
  3030 00013C1B E93EF9FFFF          <1> 	jmp	sysaudio_err
  3031                              <1> 	
  3032                              <1> snd_update_0:
  3033 00013C20 8035[789C0100]01    <1> 	xor	byte [audio_flag], 1 ; update flag !!!
  3034 00013C27 3C01                <1> 	cmp	al, 1
  3035 00013C29 7202                <1> 	jb	short snd_update_2 ; dma half buffer 1
  3036                              <1> snd_update_1:
  3037                              <1> 	; dma half buffer 2
  3038 00013C2B 01CF                <1> 	add	edi, ecx
  3039                              <1> snd_update_2:
  3040                              <1> 	;rep	movsb
  3041 00013C2D C1E902              <1> 	shr	ecx, 2
  3042 00013C30 F3A5                <1> 	rep	movsd
  3043                              <1> snd_update_3:
  3044 00013C32 A3[64030300]        <1> 	mov	[u.r0], eax
  3045                              <1> 
  3046 00013C37 C3                  <1> 	retn
  3047                              <1> 	
  3048                              <1> set_irq_callback_service:
  3049                              <1> 	; 03/08/2020
  3050                              <1> 	; 10/06/2017
  3051                              <1> 	; 12/05/2017
  3052                              <1> 	; 24/04/2017
  3053                              <1> 	; 22/04/2017
  3054                              <1> 	; caller: 'syscalbac' or 'sysaudio' or ...
  3055                              <1> 	; 13/04/2017, 14/04/2017, 17/04/2017
  3056                              <1> 	; 24/02/2017, 26/02/2017, 28/02/2017
  3057                              <1> 	; 21/02/2017 - TRDOS 386 (TRDOS v2.0)
  3058                              <1> 	;
  3059                              <1> 	; Link or unlink IRQ callback service to/from user (ring 3)	
  3060                              <1> 	;
  3061                              <1> 	; INPUT ->
  3062                              <1> 	;	If AL = 0, the caller is 'syscalbac';
  3063                              <1> 	;	   otherwise, the caller is 'sysaudio' or ...
  3064                              <1> 	;	   (AL = user number) 
  3065                              <1> 	; 	 
  3066                              <1> 	;	BL = IRQ number (Hardware interrupt request number)
  3067                              <1> 	;	     (0 t0 15 but IRQ 0,1,2,6,8,14,15 are prohibited)
  3068                              <1> 	;	     IRQ numbers 3,4,5,7,9,10,11,12,13 are valid
  3069                              <1> 	;	     (numbers >15 are invalid)
  3070                              <1> 	;
  3071                              <1> 	;	BH = 0 = Unlink IRQ (in BL) from user (ring 3) service
  3072                              <1> 	;	     1 = Link IRQ by using Signal Response Byte method
  3073                              <1> 	;	     2 = Link IRQ by using Callback service method 		
  3074                              <1> 	;	     3 = Link IRQ by using Auto Increment S.R.B. method 	
  3075                              <1> 	;	    >3 = invalid 
  3076                              <1> 	;		 (syscallback version will return to user) 	
  3077                              <1> 	;	
  3078                              <1> 	;	CL = Signal Return/Response Byte value 
  3079                              <1> 	;
  3080                              <1> 	;	If BH = 3, kernel will put a counter value ; 03/08/2020
  3081                              <1> 	;	          (into the S.R.B. addr)
  3082                              <1> 	;		  between 0 to 255. (start value = CL+1)
  3083                              <1> 	;	
  3084                              <1> 	;	NOTE: counter value, for example: even and odd numbers
  3085                              <1> 	;	      may be used for -audio- DMA buffer switch 
  3086                              <1> 	;	      within double buffer method, etc. 		
  3087                              <1> 	;
  3088                              <1> 	;	EDX = Signal return (Response) byte address
  3089                              <1> 	;	       		  - or -
  3090                              <1> 	;	      Interrupt/Callback service/routine address
  3091                              <1> 	; 	
  3092                              <1> 	;	      (virtual address in user's memory space)
  3093                              <1> 	;
  3094                              <1> 	; OUTPUT ->
  3095                              <1> 	;	CF = 0 & EAX = 0 -> Successful setting
  3096                              <1> 	;	CF = 1 & EAX > 0 -> IRQ is prohibited or locked 
  3097                              <1> 	;			by another process
  3098                              <1> 	;		 eax = ERR_PERM_DENIED -> prohibited or locked
  3099                              <1> 	;		 eax = ERR_INV_PARAMETER -> 
  3100                              <1> 	;		       invalid parameter/option or bad address
  3101                              <1> 	;
  3102                              <1> 	; TRDOS 386 - IRQ CALLBACK structures (parameters):
  3103                              <1> 	;	
  3104                              <1> 	;	   [u.irqlock] = 1 word, IRQ flags (0-15) that indicates
  3105                              <1> 	;			which IRQs are locked by (that) user.
  3106                              <1> 	;		        Lock and unlock (by user) will change
  3107                              <1> 	;			these flags or 'terminate process' (sysexit)
  3108                              <1> 	;			will clear these flags and unlock those IRQs.
  3109                              <1> 	;			               
  3110                              <1> 	;		   	Bit 0 is for IRQ 0 and Bit 15 is for IRQ 15
  3111                              <1> 	;
  3112                              <1> 	;	   IRQ(x).owner	 : 1 byte, user, [u.uno], 0 = free (unlocked)	
  3113                              <1> 	;
  3114                              <1> 	;	   IRQ(x).method : 1 byte for callback method & status
  3115                              <1> 	;			   0 = Signal Response Byte method
  3116                              <1> 	;			   1 = Callback service method
  3117                              <1> 	;			   >1 = invalid for current 'syscalback'.
  3118                              <1> 	;			or(+) 80h = IRQ is in use by system (ring 0)
  3119                              <1> 	;			            function (audio etc.) or
  3120                              <1> 	;			   	    a device driver.	   	
  3121                              <1> 	;			(system function will ignore the lock/owner)
  3122                              <1> 	;
  3123                              <1> 	;	   IRQ(x).srb	: 1 byte, Signal Return/Response byte value
  3124                              <1> 	;			  (a fixed value by user or a counter value
  3125                              <1> 	;			 from 0 to 255, which is increased by every
  3126                              <1> 	;			 interrupt just before putting it into 
  3127                              <1> 	;			 the Signal Response byte address
  3128                              <1> 	;			 (This is not used in callback serv method)
  3129                              <1> 	;	    	  
  3130                              <1> 	;	   IRQ(x).addr	: 1 dword
  3131                              <1> 	;			  Signal Response Byte address (physical)
  3132                              <1> 	;			  		-or-
  3133                              <1> 	;			  Callback service address (virtual)
  3134                              <1> 	;
  3135                              <1> 	;	   IRQ(x).dev	: 1 byte
  3136                              <1> 	;			  0 = Default device or kernel function
  3137                              <1> 	;			  		-or-
  3138                              <1> 	;			  1-255 = Assigned device driver number
  3139                              <1> 	;
  3140                              <1> 	;	   (x) = 3,4,5,7,9,10,11,12,13
  3141                              <1> 	;
  3142                              <1> 	
  3143 00013C38 80FB0F              <1> 	cmp	bl, 15
  3144 00013C3B 7729                <1> 	ja	short scbs_2
  3145                              <1> 	
  3146 00013C3D 80FF03              <1> 	cmp	bh, 3
  3147 00013C40 7724                <1> 	ja	short scbs_2  ; invalid parameter
  3148                              <1> 
  3149 00013C42 0FB6FB              <1> 	movzx	edi, bl ; save IRQ number
  3150                              <1> 
  3151                              <1> 		;  IRQ 0,1,2,6,8,14,15 are prohibited
  3152                              <1> 	;IRQenum: ; 'trdosk9.s'
  3153                              <1> 	;	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
  3154                              <1> 
  3155 00013C45 0FB6B7[98490100]    <1> 	movzx	esi, byte [edi+IRQenum] ; IRQ availability 
  3156                              <1> 					; enumeration/index
  3157                              <1> 	;dec	esi
  3158 00013C4C 664E                <1> 	dec	si
  3159 00013C4E 780F                <1> 	js	short scbs_1 ;  0 -> 0FFFFh  
  3160                              <1> 
  3161                              <1> 	; ESI = IRQ callback parameters index number (0 to 8)
  3162                              <1> 
  3163 00013C50 08FF                <1> 	or	bh, bh
  3164 00013C52 7419                <1> 	jz	short scbs_4 ; unlink the IRQ (in BL)
  3165                              <1> 
  3166 00013C54 FECF                <1> 	dec	bh
  3167                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
  3168                              <1> 	;	      (2 = auto increment of signal response byte) 
  3169                              <1> 
  3170 00013C56 80BE[029C0100]00    <1> 	cmp	byte [esi+IRQ.owner], 0 ; locked ?
  3171 00013C5D 7637                <1> 	jna	short scbs_6	; no... OK...	
  3172                              <1> 
  3173                              <1> scbs_1:
  3174                              <1> 	; permission denied (prohibited IRQ)
  3175 00013C5F B80B000000          <1> 	mov	eax, ERR_PERM_DENIED
  3176 00013C64 F9                  <1> 	stc
  3177 00013C65 C3                  <1> 	retn
  3178                              <1> scbs_2:
  3179 00013C66 F9                  <1> 	stc
  3180                              <1> scbs_3:
  3181 00013C67 B817000000          <1> 	mov	eax, ERR_INV_PARAMETER
  3182 00013C6C C3                  <1> 	retn
  3183                              <1> 
  3184                              <1> scbs_4: ; unlink the requested IRQ (if it belongs to current user)
  3185                              <1> 	; 10/06/2017
  3186                              <1> 	; 22/04/2017
  3187                              <1> 	; 14/04/2017
  3188                              <1> 	; If AL = 0 -> The caller is 'syscalbac'
  3189 00013C6D 8AA6[029C0100]      <1> 	mov	ah, [esi+IRQ.owner]
  3190 00013C73 3A25[B3030300]      <1> 	cmp	ah, [u.uno]
  3191 00013C79 75E4                <1> 	jne	short scbs_1
  3192                              <1> 
  3193 00013C7B FE0D[D6030300]      <1> 	dec	byte [u.irqc] ; decrease IRQ count (in use)
  3194                              <1> 
  3195                              <1> 	;sub	ah, ah
  3196                              <1> 	;mov	[esi+IRQ.owner], ah ; 0 ; free !!!
  3197                              <1> 	;and	byte [esi+IRQ.method], 80h
  3198                              <1> 	;mov	[esi+IRQ.srb], ah ; 0
  3199                              <1> 	;mov	[esi+IRQ.dev], ah ; 0
  3200                              <1> 	;mov	dword [esi+IRQ.addr], 0
  3201                              <1> 	;mov	dword [u.r0], 0
  3202                              <1> 
  3203                              <1> 	;mov	byte [esi+IRQ.owner], 0
  3204                              <1> 
  3205                              <1> 	; 22/04/2017
  3206 00013C81 29C0                <1> 	sub	eax, eax
  3207 00013C83 8886[029C0100]      <1> 	mov	[esi+IRQ.owner], al ; 0
  3208                              <1> 	; 10/06/2017
  3209 00013C89 8686[149C0100]      <1> 	xchg	al, [esi+IRQ.method]
  3210 00013C8F 2480                <1> 	and	al, 80h
  3211 00013C91 745E                <1> 	jz	short scbs_12 
  3212                              <1> 	; Audio device must be disabled -later- ! ([IRQ.medhod] = 80h)
  3213                              <1> 
  3214                              <1> ;	cmp	byte [esi+IRQ.method], 80h ; device drv or kernel extension ?
  3215                              <1> ;	jb	short scbs_12 ; bh = 0 reset to default IRQ handler
  3216                              <1> ;
  3217                              <1> ;	and	al, al
  3218                              <1> ;	jz	short  scbs_5  ; the caller is 'syscalbac'
  3219                              <1> ;	; The caller is 'sysaudio' or ...
  3220 00013C93 30C0                <1> 	xor	al, al
  3221                              <1> ;	mov	[esi+IRQ.method], al ; 0 ; reset kernel extension flag
  3222                              <1> ;scbs_5:
  3223                              <1> ;	sub	ah, ah
  3224                              <1> 	;mov	[u.r0], eax ; 0
  3225 00013C95 C3                  <1> 	retn	
  3226                              <1> 
  3227                              <1> scbs_6:
  3228                              <1> 	; 14/04/2017
  3229 00013C96 20C0                <1> 	and	al, al
  3230 00013C98 7405                <1> 	jz	short scbs_7  ; the caller is 'syscalbac'
  3231                              <1> 	; AL = user number ([u.uno] or [audio.user] or ...)
  3232                              <1> 	; The caller is 'sysaudio' or ...
  3233                              <1> 	;	
  3234                              <1> 	; bh = method (0 = signal response byte, 1 = callback)
  3235                              <1> 	;	      (2 = auto increment of signal response byte) 
  3236                              <1> 
  3237 00013C9A 80CF80              <1> 	or	bh, 80h		; Kernel extension flag !
  3238 00013C9D EB0A                <1> 	jmp	short scbs_8
  3239                              <1> scbs_7:	
  3240 00013C9F 8A86[149C0100]      <1> 	mov	al, [esi+IRQ.method] ; >= 80h = kernel is using this IRQ
  3241 00013CA5 2480                <1> 	and	al, 80h ; use only bit 7 (kernel function flag)
  3242 00013CA7 08C7                <1> 	or	bh, al		 ; method 
  3243                              <1> 				 ; 0 = signal response byte, 1 = callback
  3244                              <1> 				 ; 2 = auto increment of s.r.b.
  3245                              <1> scbs_8:
  3246 00013CA9 A0[B3030300]        <1> 	mov	al, [u.uno] ; user (process) number (1 to 16)
  3247 00013CAE 8886[029C0100]      <1> 	mov	[esi+IRQ.owner], al ; lock the IRQ for user
  3248 00013CB4 88BE[149C0100]      <1> 	mov	[esi+IRQ.method], bh
  3249                              <1> 
  3250                              <1> ;	test	bh, 1
  3251                              <1> ;	jnz	short scbs_9 	 ; Callback method, CX will not be used 
  3252                              <1> ;			
  3253                              <1> ;	test	bh, 2		 ; use auto increment (counter) method
  3254                              <1> ;	jz	short scbs_10	 ; (count can be used for buffer switch)
  3255                              <1> ;scbs_9:
  3256                              <1> ;	xor	ecx, ecx ; 0
  3257                              <1> scbs_10:			      	
  3258                              <1> 	;mov	[esi+IRQ.method], bh
  3259 00013CBA 888E[1D9C0100]      <1> 	mov	[esi+IRQ.srb], cl
  3260 00013CC0 C686[0B9C0100]00    <1> 	mov	byte [esi+IRQ.dev], 0 ; device number is always 0 
  3261                              <1> 				 ; for this system call
  3262                              <1> 	;test	bh, 1
  3263 00013CC7 80E701              <1> 	and	bh, 1 ; 17/04/2017
  3264 00013CCA 7513                <1> 	jnz	short scbs_11	 ; callback method, use virtual address 
  3265                              <1> 
  3266 00013CCC 53                  <1> 	push	ebx ; IRQ number (in BL)
  3267 00013CCD 89D3                <1> 	mov	ebx, edx
  3268                              <1> 	; ebx = virtual address
  3269                              <1> 	; [u.pgdir] = page directory's physical address
  3270 00013CCF FE05[A29B0100]      <1> 	inc	 byte [no_page_swap] ; 1 
  3271                              <1> 			; Do not add this page to swap queue
  3272                              <1> 			; and remove it from swap queue if it is
  3273                              <1> 			; on the queue.
  3274 00013CD5 E80E26FFFF          <1> 	call	get_physical_addr
  3275 00013CDA 5B                  <1> 	pop	ebx
  3276 00013CDB 728A                <1> 	jc	scbs_3 ; invalid address !
  3277                              <1> 	; eax = physical address of the virtual address in user's space
  3278 00013CDD 89C2                <1> 	mov	edx, eax
  3279                              <1> scbs_11:
  3280 00013CDF 66C1E602            <1> 	shl	si, 2		; byte (index) to dword (offset)
  3281 00013CE3 8996[269C0100]      <1> 	mov	[esi+IRQ.addr], edx
  3282                              <1> 
  3283 00013CE9 FE05[D6030300]      <1> 	inc	byte [u.irqc]	; increase IRQ (in use) count
  3284                              <1> 
  3285 00013CEF FEC7                <1> 	inc	 bh ; 17/04/2017
  3286                              <1> 	; bh > 0 -> set to requested IRQ handler (IRQ_u_list)
  3287                              <1> scbs_12:
  3288 00013CF1 88D8                <1> 	mov	al, bl ; IRQ number
  3289 00013CF3 88FC                <1> 	mov	ah, bh ; 0 = reset, >0 = set
  3290 00013CF5 E8CFF3FFFF          <1> 	call	set_hardware_int_vector
  3291                              <1> 
  3292 00013CFA 31C0                <1> 	xor	eax, eax
  3293                              <1> 	;mov 	[u.r0], eax ; 0	
  3294                              <1> 
  3295 00013CFC C3                  <1> 	retn	; return with success (cf=0, eax=0)
  3296                              <1> 
  3297                              <1> 
  3298                              <1> sysdma: ; DMA FUNCTIONS
  3299                              <1> 	; 02/09/2017
  3300                              <1> 	; 28/08/2017
  3301                              <1> 	; 20/08/2017 - TRDOS 386 (TRDOS v2.0)
  3302                              <1> 	;
  3303                              <1> 	; Inputs:
  3304                              <1> 	;	BH = 0 -> Allocate DMA buffer
  3305                              <1> 	;	   BL = 0 -> Use the system's default DMA
  3306                              <1> 	;		     (SB16) Buffer
  3307                              <1> 	;	        Buffer Size (max.) = 65536 bytes
  3308                              <1> 	;	   BL > 0 -> Allocate (a new) DMA buffer
  3309                              <1>  	;	   ECX = DMA Buffer Size in bytes (<=128KB)
  3310                              <1> 	;	   EDX = Virtual Address of DMA buffer 	
  3311                              <1> 	;		
  3312                              <1> 	;	BH = 1 -> Initialize (Start) DMA service
  3313                              <1> 	;	     BL, bit 0 to 3 = Channel Number (0 to 7)	
  3314                              <1> 	;	     BL, bit 7 = Auto Initialized Mode 
  3315                              <1> 	;			(If bit 7 is set)
  3316                              <1> 	;		 bit 6 = Record (read) mode (0= playback)
  3317                              <1> 	;	     ECX = byte count (0 = use dma buffer size)
  3318                              <1> 	;	     EDX = physical buffer address
  3319                              <1> 	;	     	   (0 = use dma buffer -start- address)		
  3320                              <1> 	;
  3321                              <1> 	;	BH = 2 -> Get Current DMA Buffer Offset
  3322                              <1> 	;	     BL = DMA channel number	
  3323                              <1> 	;		
  3324                              <1> 	;	BH = 3 -> Get Current DMA count down value
  3325                              <1> 	;	     BL = DMA channel number (0 tO 7)	
  3326                              <1> 	;
  3327                              <1> 	;	BH = 4 -> Get Current DMA channel (in progress)
  3328                              <1> 	;
  3329                              <1> 	;	BH = 5 -> Get System's Default DMA Buffer Address
  3330                              <1> 	;
  3331                              <1> 	;	BH = 6 -> Get Current DMA Buffer Address	
  3332                              <1> 	;
  3333                              <1> 	;	BH = 7 -> Stop DMA service
  3334                              <1> 	;
  3335                              <1> 	;
  3336                              <1> 	; Outputs:
  3337                              <1> 	;
  3338                              <1> 	;	For BH = 0 ; Allocate DMA buffer
  3339                              <1> 	;	    EAX = Physical address of DMA buffer
  3340                              <1> 	;	    ECX = Allocated buffer size in bytes
  3341                              <1> 	;		  - page count * 4096 -
  3342                              <1> 	;		  (may be bigger than requested)	
  3343                              <1> 	;	    If BL input > 0,
  3344                              <1> 	;	       'sysalloc:' system call will be used with
  3345                              <1>   	;	       EBX (for 'sysalloc') = EDX (for 'sysdma')
  3346                              <1> 	;	       ECX is same, byte count (buffer size)
  3347                              <1> 	;	       EDX = 1024*1024*16 ; 16 MB upper limit	 		        	 
  3348                              <1> 	;	    If BL input = 0,
  3349                              <1> 	;	       Default DMA buffer (SB16 buffer) will be
  3350                              <1> 	;	       checked and if it is free, it's address
  3351                              <1> 	;	       will be returned in EAX and it's size
  3352                              <1> 	;	       will be returned in ECX (as 65536)
  3353                              <1> 	;
  3354                              <1> 	;	    If CF = 1, error code is in EAX
  3355                              <1> 	;	       EAX = -1 ; DMA buffer allocation error! 		
  3356                              <1> 	;	       EAX = 11 ; 'Permission Denied' error !
  3357                              <1> 	;
  3358                              <1> 	;	       Note: 'sysalloc' error return method
  3359                              <1> 	;		      will be applied if BL input > 0 !		
  3360                              <1> 	;
  3361                              <1> 	; 	 For BH = 1 ; Initialize (Start) DMA
  3362                              <1> 	;	     EAX = 0 (Successful)	
  3363                              <1> 	;	     If CF = 1, error code is in EAX
  3364                              <1> 	;
  3365                              <1> 	; 	 For BH = 2 ; Get Current DMA Buffer Offset
  3366                              <1> 	;	     EAX = DMA Buffer Offset (in bytes)
  3367                              <1> 	;	     ;
  3368                              <1> 	;	      AX = DMA buffer offset
  3369                              <1> 	;	     EAX bits 16 to 23 = Page register value
  3370                              <1> 	;		   	
  3371                              <1> 	; 	 For BH = 3 ; Get Current DMA count down value
  3372                              <1> 	;	     EAX = Count down value (remain bytes)
  3373                              <1> 	;	
  3374                              <1> 	;	 For BH = 4 ; Get Current DMA channel (in progress)
  3375                              <1> 	;	     EAX = DMA channel number (0 to 7)
  3376                              <1> 	;		AH = 0 if the owner is the caller process
  3377                              <1> 	;		AH > 0 if the dma channel is in use by
  3378                              <1> 	;		       another user/process
  3379                              <1> 	;	     EAX = -1 (0FFFFFFFFh) 
  3380                              <1> 	;		    if DMA service is not in use	    		
  3381                              <1> 	;	 	    (stopped or not initialized/started)	
  3382                              <1> 	;
  3383                              <1> 	;	 For BH = 5 ; Get System's Default DMA Buff Addr
  3384                              <1> 	;	     EAX = Default DMA Buffer Address (Physical)
  3385                              <1> 	;		 = offset 'sb16_dma_buffer:'	
  3386                              <1> 	;	     ECX = Buffer size
  3387                              <1> 	;		 = 65536 
  3388                              <1> 	;
  3389                              <1> 	;	 For BH = 6 ; Get Current DMA Buffer Address
  3390                              <1> 	;	     EAX = Current DMA buffer address (Physical)
  3391                              <1> 	;	     ECX = Current DMA buffer size (setting value)	   		  	 		
  3392                              <1> 	;	     Note: These values are for current dma channel
  3393                              <1> 	;		   settings for the user/process
  3394                              <1> 	;	     ** For now (for current TRDOS 386 version)
  3395                              <1> 	;		only one user/process can use only one
  3396                              <1> 	;		dma channel & one dma buffer at same time
  3397                              <1> 	;		(no multi tasking on DMA service) !!! **
  3398                              <1> 	;	     (Once, current DMA user must stop it's own DMA
  3399                              <1> 	;	      DMA service, than another user/program 
  3400                              <1> 	;	      can use DMA service with same dma channel 
  3401                              <1> 	;	      or with another DMA channel.)	 			      		
  3402                              <1> 	;
  3403                              <1> 	;	 For BH = 7 ; Stop DMA service (for current user
  3404                              <1> 	;	     and current DMA channel)	
  3405                              <1> 	;	     EAX = 0 ; successful
  3406                              <1> 	;	     CF = 1 & EAX > 0 (= -1) -> Error		
  3407                              <1> 
  3408 00013CFD 80FF07              <1> 	cmp	bh, 7
  3409 00013D00 7612                <1> 	jna	short sysdma_0
  3410                              <1> 
  3411                              <1> sysdma_err:
  3412 00013D02 31C0                <1> 	xor	eax, eax
  3413 00013D04 48                  <1> 	dec	eax ; -1
  3414                              <1> sysdma_perm_err:
  3415 00013D05 A3[64030300]        <1> 	mov	[u.r0], eax
  3416 00013D0A A3[C8030300]        <1> 	mov	[u.error], eax ; DMA service error !
  3417 00013D0F E9C89BFFFF          <1> 	jmp	error
  3418                              <1> 
  3419                              <1> sysdma_0:
  3420 00013D14 08FF                <1> 	or	bh, bh
  3421 00013D16 0F85BA000000        <1> 	jnz	sysdma_1
  3422                              <1> 	
  3423 00013D1C 20DB                <1> 	and	bl, bl
  3424 00013D1E 7416                <1> 	jz	short sysdma_01
  3425                              <1> 
  3426                              <1> 	; redirect system call to 'sysalloc'
  3427 00013D20 89D3                <1> 	mov	ebx, edx ; virtual address of DMA buffer
  3428                              <1> 	;ecx = Buffer size in bytes
  3429                              <1> 	; DMA buffer address <= 16MB upper limit
  3430 00013D22 BA00000001          <1> 	mov	edx, 1024*1024*16 ; 16MB limit for DMA buff
  3431                              <1> 
  3432 00013D27 C705[94A00100]FFFF- <1> 	mov	dword [dma_addr], 0FFFFFFFFh ; -1
  3432 00013D2F FFFF                <1>
  3433                              <1> 
  3434 00013D31 E9A3E5FFFF          <1> 	jmp	sysalloc
  3435                              <1> 
  3436                              <1> sysdma_01:
  3437 00013D36 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  3438                              <1> 
  3439 00013D3B 803D[519C0100]01    <1> 	cmp	byte [audio_device], 1
  3440 00013D42 722A                <1> 	jb	short sysdma_03
  3441                              <1> 
  3442 00013D44 3B05[709C0100]      <1> 	cmp	eax, [audio_dma_buff]
  3443 00013D4A 7507                <1> 	jne	short sysdma_02
  3444                              <1> 
  3445                              <1> sysdma_0_err:
  3446 00013D4C B80B000000          <1> 	mov	eax, ERR_PERM_DENIED
  3447 00013D51 EBB2                <1> 	jmp	short sysdma_perm_err
  3448                              <1> 
  3449                              <1> sysdma_02:
  3450                              <1> 	; Only one user is permitted for audio/dma functions
  3451                              <1> 
  3452 00013D53 833D[709C0100]00    <1> 	cmp	dword [audio_dma_buff], 0
  3453 00013D5A 7612                <1> 	jna	short sysdma_03
  3454                              <1> 
  3455 00013D5C 8A1D[799C0100]      <1> 	mov	bl, [audio_user]
  3456 00013D62 08DB                <1> 	or	bl, bl
  3457 00013D64 7408                <1> 	jz	short sysdma_03
  3458                              <1> 
  3459 00013D66 3A1D[B3030300]      <1> 	cmp	bl, [u.uno]
  3460 00013D6C 75DE                <1> 	jne	short sysdma_0_err
  3461                              <1> 
  3462                              <1> sysdma_03: 
  3463 00013D6E 8A1D[91A00100]      <1> 	mov	bl, [dma_user]
  3464 00013D74 20DB                <1> 	and	bl, bl
  3465 00013D76 750E                <1> 	jnz	short sysdma_04
  3466                              <1> 	
  3467 00013D78 8A1D[B3030300]      <1> 	mov	bl, [u.uno]
  3468 00013D7E 881D[91A00100]      <1> 	mov	[dma_user], bl
  3469                              <1> 
  3470 00013D84 EB15                <1> 	jmp	short sysdma_05
  3471                              <1> 
  3472                              <1> sysdma_04:
  3473 00013D86 8B35[94A00100]      <1> 	mov	esi, [dma_addr]
  3474 00013D8C 21F6                <1> 	and	esi, esi
  3475 00013D8E 740B                <1> 	jz	short sysdma_05
  3476                              <1> 
  3477 00013D90 46                  <1> 	inc	esi ; -1 -> 0
  3478 00013D91 7408                <1> 	jz	short sysdma_05
  3479                              <1> 
  3480 00013D93 3A1D[B3030300]      <1> 	cmp	bl, [u.uno]
  3481 00013D99 75B1                <1> 	jne	short sysdma_0_err
  3482                              <1> 	
  3483                              <1> sysdma_05:
  3484                              <1> 	; edx = virtual address (user's buffer address)
  3485                              <1> 	; 
  3486 00013D9B 81F900000100        <1> 	cmp	ecx, 65536   ; byte count (buffer size)
  3487 00013DA1 0F875BFFFFFF        <1> 	ja	sysdma_err	
  3488                              <1> 	;
  3489 00013DA7 81C1FF0F0000        <1> 	add	ecx, PAGE_SIZE-1 ; 4095
  3490 00013DAD 6681E100F0          <1> 	and	cx, ~PAGE_OFF ; not 4095
  3491                              <1> 	;cmp	ecx, 65536
  3492                              <1> 	;ja	sysdma_err ;
  3493 00013DB2 51                  <1> 	push	ecx	; buffer size (allocated pages * 4096) 
  3494 00013DB3 50                  <1> 	push	eax	; offset sb16_dma_buffer
  3495 00013DB4 89D3                <1> 	mov	ebx, edx
  3496 00013DB6 C1E90C              <1> 	shr	ecx, 12 ; byte count to page count
  3497                              <1> 	; eax = physical address of (audio) dma buffer
  3498                              <1> 	; ebx = virtual address of (audio) dma buffer (user's pgdir) 
  3499                              <1> 	; ecx = page count (>0)
  3500 00013DB9 E83C29FFFF          <1> 	call	direct_memory_access
  3501 00013DBE 58                  <1> 	pop	eax
  3502 00013DBF 59                  <1> 	pop	ecx
  3503 00013DC0 0F823CFFFFFF        <1> 	jc	sysdma_err
  3504                              <1> 
  3505 00013DC6 A3[94A00100]        <1> 	mov	[dma_addr], eax
  3506 00013DCB 890D[98A00100]      <1> 	mov	[dma_size], ecx ; dma buffer size (in bytes)
  3507                              <1> 
  3508                              <1> 	;mov	[u.r0], eax ; DMA Buffer Address (Physical)
  3509                              <1> 
  3510                              <1> 	;mov	ebp, [u.usp]  ; ebp points to user's registers
  3511                              <1> 	;mov	[ebp+24], ecx ; return to user with ecx value
  3512                              <1> 
  3513                              <1> 	;jmp	sysret
  3514                              <1> 
  3515                              <1> 	; 28/08/2017
  3516 00013DD1 E9C4000000          <1> 	jmp	sysdma_51
  3517                              <1> 
  3518                              <1> sysdma_1:
  3519 00013DD6 80FF01              <1> 	cmp	bh, 1
  3520 00013DD9 0F87A6000000        <1> 	ja	sysdma_5
  3521                              <1> 
  3522 00013DDF F6C340              <1> 	test	bl, 40h	; record (read) mode -BL, bit 6-
  3523 00013DE2 0F851AFFFFFF        <1> 	jnz	sysdma_err ; not ready yet!
  3524                              <1> 
  3525 00013DE8 A1[94A00100]        <1> 	mov	eax, [dma_addr] ; physical address of dma buffer
  3526 00013DED 21C0                <1> 	and	eax, eax
  3527 00013DEF 0F840DFFFFFF        <1> 	jz	sysdma_err
  3528                              <1> 
  3529 00013DF5 09D2                <1> 	or	edx, edx
  3530 00013DF7 7504                <1> 	jnz	short sysdma_11
  3531                              <1> 
  3532 00013DF9 89C2                <1> 	mov	edx, eax
  3533 00013DFB EB08                <1> 	jmp	short sysdma_12	
  3534                              <1> sysdma_11:
  3535 00013DFD 39C2                <1> 	cmp	edx, eax
  3536 00013DFF 0F82FDFEFFFF        <1> 	jb	sysdma_err
  3537                              <1> sysdma_12:
  3538 00013E05 21C9                <1> 	and	ecx, ecx
  3539 00013E07 7508                <1> 	jnz	short sysdma_13
  3540                              <1> 
  3541 00013E09 8B0D[98A00100]      <1> 	mov	ecx, [dma_size]
  3542 00013E0F EB0C                <1> 	jmp	short sysdma_14
  3543                              <1> sysdma_13:
  3544 00013E11 3B0D[98A00100]      <1> 	cmp	ecx, [dma_size]
  3545 00013E17 0F87E5FEFFFF        <1> 	ja	sysdma_err
  3546                              <1> sysdma_14:
  3547 00013E1D 89C6                <1> 	mov	esi, eax
  3548 00013E1F 0335[98A00100]      <1> 	add	esi, [dma_size]
  3549                              <1> 
  3550 00013E25 89D0                <1> 	mov	eax, edx
  3551 00013E27 01C8                <1> 	add	eax, ecx
  3552 00013E29 0F82D3FEFFFF        <1> 	jc	sysdma_err ; 02/09/2017	
  3553                              <1> 		
  3554 00013E2F 39F0                <1> 	cmp	eax, esi
  3555 00013E31 0F87CBFEFFFF        <1> 	ja	sysdma_err
  3556                              <1> 
  3557 00013E37 8B3D[709C0100]      <1> 	mov	edi, [audio_dma_buff]
  3558 00013E3D 8B35[94A00100]      <1> 	mov	esi, [dma_addr]
  3559                              <1> 
  3560 00013E43 09FF                <1> 	or	edi, edi
  3561 00013E45 7424                <1> 	jz	short sysdma_16
  3562                              <1> 	
  3563 00013E47 803D[519C0100]01    <1> 	cmp	byte [audio_device], 1
  3564 00013E4E 7208                <1> 	jb	short sysdma_15
  3565                              <1> 
  3566                              <1> 	; Sound Blaster 16
  3567 00013E50 39FE                <1> 	cmp	esi, edi
  3568 00013E52 0F84F4FEFFFF        <1> 	je	sysdma_0_err ; permmission denied !
  3569                              <1> 
  3570                              <1> sysdma_15:
  3571 00013E58 C605[93A00100]48    <1> 	mov	byte [dma_mode], 48h ; single mode playback	
  3572                              <1> 
  3573 00013E5F F6C380              <1> 	test	bl, 80h ; DMA mode - BL, bit 7, auto init -
  3574 00013E62 7407                <1> 	jz	short sysdma_16	
  3575                              <1> 	; Auto initialized playback (write) mode
  3576 00013E64 8005[93A00100]10    <1> 	add	byte [dma_mode], 10h ; = 58h
  3577                              <1> sysdma_16:
  3578 00013E6B 80E307              <1> 	and	bl, 07h
  3579 00013E6E 881D[92A00100]      <1> 	mov	[dma_channel], bl
  3580 00013E74 8915[9CA00100]      <1> 	mov	[dma_start], edx
  3581 00013E7A 890D[A0A00100]      <1> 	mov	[dma_count], ecx
  3582                              <1> 	 
  3583                              <1> 	; 28/08/2017
  3584                              <1> 	;call	dma_init
  3585                              <1> 	;jmp	sysret
  3586 00013E80 E94B010000          <1> 	jmp	dma_init
  3587                              <1> 
  3588                              <1> sysdma_5:
  3589 00013E85 80FF05              <1> 	cmp	bh, 5
  3590 00013E88 7223                <1> 	jb	short sysdma_3
  3591 00013E8A 0F87CE000000        <1> 	ja	sysdma_6	
  3592                              <1> 
  3593                              <1> 	; Get the system's default dma buffer addr and size
  3594 00013E90 B8[00000200]        <1> 	mov	eax, sb16_dma_buffer
  3595 00013E95 B900000100          <1> 	mov	ecx, 65536 ; Buffer size in bytes
  3596                              <1> 
  3597                              <1> sysdma_51:
  3598                              <1> 	; 0 = there is not a dma buffer (in use or available)
  3599 00013E9A A3[64030300]        <1> 	mov	[u.r0], eax
  3600                              <1> 
  3601 00013E9F 8B2D[60030300]      <1> 	mov	ebp, [u.usp]  ; ebp points to user's registers
  3602 00013EA5 894D18              <1> 	mov	[ebp+24], ecx ; return to user with ecx value
  3603                              <1> 
  3604 00013EA8 E94F9AFFFF          <1> 	jmp	sysret
  3605                              <1> 
  3606                              <1> sysdma_3:
  3607 00013EAD 80FF03              <1> 	cmp	bh, 3
  3608 00013EB0 7231                <1> 	jb	short sysdma_2
  3609 00013EB2 776B                <1> 	ja	short sysdma_4
  3610                              <1> 
  3611                              <1> 	; Get current dma count down value (remain bytes)
  3612                              <1> 	; 28/08/2017
  3613 00013EB4 0FB635[92A00100]    <1> 	movzx	esi, byte [dma_channel]
  3614 00013EBB 0FB696[D0490100]    <1> 	movzx	edx, byte [dma_flip+esi]
  3615 00013EC2 EE                  <1> 	out	dx, al			; flip-flop clear
  3616 00013EC3 8A96[B0490100]      <1> 	mov	dl, [dma_cnt+esi] ; dma count register addr
  3617 00013EC9 EC                  <1> 	in	al, dx
  3618 00013ECA 0FB6D8              <1> 	movzx	ebx, al	
  3619 00013ECD EC                  <1> 	in	al, dx
  3620 00013ECE 88C7                <1> 	mov     bh, al
  3621                              <1> 	
  3622 00013ED0 6683FE04            <1> 	cmp	si, 4 ; channel number ?
  3623 00013ED4 7202                <1> 	jb	short sysdma_31 ; 8 bit dma channel
  3624                              <1> 
  3625 00013ED6 D1E3                <1> 	shl	ebx, 1	; word count to byte count
  3626                              <1> 
  3627                              <1> sysdma_31:
  3628 00013ED8 891D[64030300]      <1> 	mov	[u.r0], ebx
  3629                              <1> 
  3630 00013EDE E9199AFFFF          <1> 	jmp	sysret	
  3631                              <1> 
  3632                              <1> sysdma_2:
  3633                              <1> 	; Get current dma buffer offset (& page)
  3634                              <1> 	; 28/08/2017
  3635 00013EE3 0FB635[92A00100]    <1> 	movzx	esi, byte [dma_channel]
  3636 00013EEA 0FB696[D0490100]    <1> 	movzx	edx, byte [dma_flip+esi]
  3637 00013EF1 EE                  <1> 	out	dx, al			; flip-flop clear
  3638 00013EF2 8A96[A8490100]      <1> 	mov	dl, [dma_adr+esi]
  3639 00013EF8 EC                  <1> 	in	al, dx			; get dma position
  3640 00013EF9 0FB6D8              <1> 	movzx	ebx, al
  3641 00013EFC EC                  <1> 	in	al, dx			
  3642 00013EFD 88C7                <1> 	mov	bh, al
  3643                              <1> 
  3644 00013EFF 6683FE04            <1> 	cmp	si, 4 ; channel number ?
  3645 00013F03 7202                <1> 	jb	short sysdma_21 ; 8 bit dma channel
  3646                              <1> 
  3647 00013F05 D1E3                <1> 	shl	ebx, 1	; word offset to byte offset
  3648                              <1> 
  3649                              <1> sysdma_21:
  3650 00013F07 891D[64030300]      <1> 	mov	[u.r0], ebx
  3651                              <1> 
  3652 00013F0D 8A96[B8490100]      <1> 	mov	dl, [dma_page+esi]
  3653 00013F13 EC                  <1> 	in	al, dx			; get dma page
  3654                              <1> 
  3655                              <1> 	;add	[u.ro+2], al
  3656 00013F14 0805[66030300]      <1> 	or	[u.r0+2], al
  3657                              <1> 
  3658 00013F1A E9DD99FFFF          <1> 	jmp	sysret
  3659                              <1> 
  3660                              <1> sysdma_4:
  3661                              <1> 	; Get current DMA channel number
  3662                              <1> 	; 28/08/2017
  3663 00013F1F 8A25[91A00100]      <1> 	mov	ah, [dma_user]
  3664 00013F25 20E4                <1> 	and	ah, ah
  3665 00013F27 750F                <1> 	jnz	short sysdma_42
  3666                              <1> 
  3667                              <1> sysdma_41:	
  3668                              <1> 	; Not a valid dma channel (in use)
  3669 00013F29 C705[64030300]FFFF- <1> 	mov	dword [u.r0], -1 ; 0FFFFFFFFh
  3669 00013F31 FFFF                <1>
  3670 00013F33 E9C499FFFF          <1> 	jmp	sysret
  3671                              <1> 
  3672                              <1> sysdma_42:
  3673 00013F38 8B35[94A00100]      <1> 	mov	esi, [dma_addr]
  3674 00013F3E 21F6                <1> 	and	esi, esi
  3675 00013F40 74E7                <1> 	jz	short sysdma_41
  3676                              <1> 
  3677 00013F42 46                  <1> 	inc	esi ; -1 -> 0
  3678 00013F43 74E4                <1> 	jz	short sysdma_41
  3679                              <1> 
  3680 00013F45 A0[92A00100]        <1> 	mov	al, [dma_channel]
  3681                              <1> 
  3682 00013F4A 3A25[B3030300]      <1> 	cmp	ah, [u.uno]
  3683 00013F50 7502                <1> 	jne	short sysdma_43
  3684                              <1> 
  3685 00013F52 30E4                <1> 	xor	ah, ah ; DMA channel in use by current user
  3686                              <1> 
  3687                              <1> sysdma_43:
  3688 00013F54 A3[64030300]        <1> 	mov	[u.r0], eax ; AL = dma channel number
  3689                              <1> 			    ; AH > 0 if the the channel
  3690                              <1> 			    ; in use by another user/process
  3691 00013F59 E99E99FFFF          <1> 	jmp	sysret
  3692                              <1> 
  3693                              <1> sysdma_6:
  3694 00013F5E 80FF06              <1> 	cmp	bh, 6
  3695 00013F61 7710                <1> 	ja	short sysdma_7
  3696                              <1> 
  3697                              <1> 	; 28/08/2017
  3698                              <1> 	; Get current DMA buffer addr and size
  3699 00013F63 A1[94A00100]        <1> 	mov	eax, [dma_addr] ; dma buffer address
  3700 00013F68 8B0D[98A00100]      <1> 	mov	ecx, [dma_size] ; dma buffer size (in bytes)
  3701                              <1> 
  3702 00013F6E E927FFFFFF          <1> 	jmp	sysdma_51
  3703                              <1> 
  3704                              <1> sysdma_7:
  3705                              <1> 	; DMA service STOP
  3706 00013F73 A0[B3030300]        <1> 	mov	al, [u.uno]
  3707 00013F78 3A05[91A00100]      <1> 	cmp	al, [dma_user]
  3708 00013F7E 751D                <1> 	jne	short sysdma_72
  3709                              <1> 	
  3710 00013F80 28C0                <1> 	sub	al, al ; 0
  3711                              <1> 
  3712 00013F82 A2[91A00100]        <1> 	mov	[dma_user], al ; clear user
  3713                              <1> 
  3714 00013F87 8605[93A00100]      <1> 	xchg	al, [dma_mode]
  3715 00013F8D 20C0                <1> 	and	al, al
  3716                              <1> 	;jz	short sysdma_err
  3717 00013F8F 7527                <1> 	jnz	short sysdma_73	
  3718                              <1> 
  3719                              <1> sysdma_71:
  3720 00013F91 31C0                <1> 	xor	eax, eax
  3721 00013F93 A3[64030300]        <1> 	mov	[u.r0], eax; 0
  3722 00013F98 E95F99FFFF          <1> 	jmp	sysret
  3723                              <1> 
  3724                              <1> sysdma_72:
  3725                              <1> 	; 28/08/2017
  3726 00013F9D 803D[91A00100]00    <1> 	cmp	byte [dma_user], 0
  3727 00013FA4 76EB                <1> 	jna	short sysdma_71 ; Nothing to do !
  3728                              <1> 
  3729 00013FA6 833D[94A00100]00    <1> 	cmp	dword [dma_addr], 0
  3730 00013FAD 0F8799FDFFFF        <1> 	ja	sysdma_0_err
  3731                              <1> 	
  3732 00013FB3 A2[91A00100]        <1> 	mov	[dma_user], al ; reset to current user
  3733                              <1> 
  3734                              <1> sysdma_73:
  3735                              <1> 	; 28/08/2017
  3736 00013FB8 0FB635[92A00100]    <1> 	movzx	esi, byte [dma_channel]
  3737 00013FBF 0FB696[C0490100]    <1> 	movzx	edx, byte [dma_mask+esi]
  3738 00013FC6 A0[92A00100]        <1> 	mov	al, [dma_channel]
  3739 00013FCB 0C04                <1> 	or	al, 4
  3740 00013FCD EE                  <1> 	out	dx, al
  3741                              <1> 
  3742 00013FCE EBC1                <1> 	jmp	short sysdma_71
  3743                              <1> 
  3744                              <1> dma_init:
  3745                              <1> 	; 28/08/2017
  3746                              <1> 	; 20/08/2017
  3747                              <1> 	; DMA initialization
  3748                              <1> 	; 14/08/2017
  3749                              <1> 	; 03/08/2017, 06/08/2017, 08/08/2017
  3750                              <1> 	; 02/07/2017, 13/07/2017, 16/07/2017, 30/07/2017
  3751                              <1> 	; (Derived from 'DMA_INIT' procedure in SB16MOD.ASM)
  3752                              <1> 	; Modified for TRDOS 386 DMA buffer allocation & initialization !
  3753                              <1> 
  3754 00013FD0 8B1D[9CA00100]      <1> 	mov	ebx, [dma_start]
  3755 00013FD6 8B0D[A0A00100]      <1> 	mov	ecx, [dma_count]
  3756                              <1> 
  3757 00013FDC 0FB635[92A00100]    <1> 	movzx	esi, byte [dma_channel]
  3758                              <1> 
  3759 00013FE3 6683FE04            <1> 	cmp	si, 4
  3760 00013FE7 7205                <1> 	jb	short gdmi1
  3761                              <1> 	; 08/08/2017
  3762 00013FE9 66D1E9              <1> 	shr	cx, 1 ; word count
  3763 00013FEC D1EB                <1> 	shr	ebx, 1 ; convert byte offset to word offset
  3764                              <1> gdmi1:
  3765                              <1> 	;mov	[dma_poff], bx ; 08/08/2017
  3766 00013FEE 6649                <1> 	dec	cx			; dma size = block size - 1
  3767                              <1> 	
  3768 00013FF0 0FB696[C0490100]    <1> 	movzx	edx, byte [dma_mask+esi] ; 30/07/2017
  3769 00013FF7 A0[92A00100]        <1> 	mov	al, [dma_channel]
  3770 00013FFC 0C04                <1> 	or	al, 4
  3771 00013FFE EE                  <1> 	out	dx, al			; dma channel mask
  3772                              <1> 
  3773 00013FFF 30C0                <1> 	xor	al, al ; 0 ; any value ! 08/08/2017
  3774 00014001 8A96[D0490100]      <1> 	mov	dl, [dma_flip+esi]
  3775 00014007 EE                  <1> 	out	dx, al			; flip-flop clear
  3776                              <1> 	
  3777 00014008 8A96[C8490100]      <1> 	mov	dl, [dma_mod+esi]
  3778 0001400E A0[92A00100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
  3779 00014013 2403                <1> 	and	al, 3
  3780                              <1> 	; 08/08/2017
  3781 00014015 0A05[93A00100]      <1> 	or	al, [dma_mode] ; 58h    ; dma mode for SB16
  3782 0001401B EE                  <1> 	out	dx, al			
  3783                              <1> 
  3784 0001401C 8A96[A8490100]      <1> 	mov	dl, [dma_adr+esi]	
  3785 00014022 88D8                <1> 	mov	al, bl			
  3786 00014024 EE                  <1> 	out	dx, al			; offset low
  3787                              <1> 
  3788 00014025 88F8                <1> 	mov	al, bh
  3789 00014027 EE                  <1> 	out	dx, al			; offset high
  3790                              <1> 
  3791 00014028 8A96[B0490100]      <1> 	mov	dl, [dma_cnt+esi]
  3792 0001402E 88C8                <1> 	mov	al, cl
  3793 00014030 EE                  <1> 	out	dx, al			; size low
  3794                              <1> 
  3795 00014031 88E8                <1> 	mov	al, ch
  3796 00014033 EE                  <1> 	out	dx, al			; size high
  3797                              <1> 
  3798 00014034 8A96[B8490100]      <1> 	mov	dl, [dma_page+esi]
  3799                              <1> 	; 14/08/2017 
  3800 0001403A 6683FE04            <1> 	cmp	si, 4
  3801 0001403E 7305                <1> 	jnb	short gdmi2
  3802 00014040 C1EB10              <1> 	shr	ebx, 16
  3803 00014043 EB06                <1> 	jmp	short gdmi3
  3804                              <1> gdmi2:
  3805                              <1> 	; 09/08/2017
  3806 00014045 C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
  3807 00014048 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary)
  3808                              <1> gdmi3:	
  3809 0001404B 88D8                <1> 	mov	al, bl
  3810 0001404D EE                  <1> 	out	dx, al			; page			
  3811                              <1> 	
  3812 0001404E 8A96[C0490100]      <1> 	mov	dl, [dma_mask+esi]
  3813 00014054 A0[92A00100]        <1> 	mov	al, [dma_channel]  ; 13/07/2017
  3814 00014059 2403                <1> 	and	al, 3
  3815 0001405B EE                  <1> 	out	dx, al			; dma channel unmask
  3816                              <1> 
  3817                              <1> 	;retn
  3818                              <1> 	; 28/08/2017
  3819 0001405C E99B98FFFF          <1> 	jmp	sysret
  3820                              <1> 
  3821                              <1> otty:
  3822                              <1> sret:
  3823                              <1> ocvt:
  3824                              <1> ctty:
  3825                              <1> cret:
  3826                              <1> ccvt:
  3827                              <1> rtty:
  3828                              <1> wtty:
  3829                              <1> rmem:
  3830                              <1> wmem:
  3831                              <1> rfd:
  3832                              <1> rhd:
  3833                              <1> wfd:
  3834                              <1> whd:
  3835                              <1> rlpt:
  3836                              <1> wlpt:
  3837                              <1> rcvt:
  3838                              <1> xmtt:
  3839 00014061 C3                  <1> 	retn
  3087                                  %include 'trdosk9.s' ; 04/01/2016
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.3) - INITIALIZED DATA : trdosk9.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 27/02/2021
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; ----------------------------------------------------------------------------
     9                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
    10                              <1> ; ----------------------------------------------------------------------------
    11                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    12                              <1> ; TRDOS2.ASM (09/11/2011)
    13                              <1> ; ****************************************************************************
    14                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
    15                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
    16                              <1> ; CMD_INTR.ASM [29/01/2005] Last Update: 09/11/2011
    17                              <1> ; FILE.ASM [29/10/2009] Last Update: 09/10/2011
    18                              <1> 
    19                              <1> ; 12/02/2016
    20                              <1> Last_DOS_DiskNo: 
    21 00014062 01                  <1> 		db 1 ; A: = 0 & B: = 1
    22                              <1> 
    23                              <1> Restore_CDIR:	
    24 00014063 FF                  <1> 		db 0FFh ; Initial value -> any number except 0
    25                              <1> 
    26                              <1> msg_CRLF_temp:  
    27 00014064 070D0A00            <1> 		db 07h, 0Dh, 0Ah, 0
    28                              <1> 
    29                              <1> Magic_Bytes:
    30 00014068 04                  <1> 		db 4
    31 00014069 01                  <1> 		db 1
    32                              <1> mainprog_Version:
    33 0001406A 07                  <1> 		db 7
    34 0001406B 5B5452444F535D204D- <1> 		db "[TRDOS] Main Program v2.0.270221"
    34 00014074 61696E2050726F6772- <1>
    34 0001407D 616D2076322E302E32- <1>
    34 00014086 3730323231          <1>
    35 0001408B 0D0A                <1> 		db 0Dh, 0Ah
    36 0001408D 286329204572646F67- <1> 		db "(c) Erdogan Tan 2005-2021"
    36 00014096 616E2054616E203230- <1>
    36 0001409F 30352D32303231      <1>
    37 000140A6 0D0A00              <1> 		db 0Dh, 0Ah, 0
    38                              <1> 
    39                              <1> MainProgCfgFile: ; 14/04/2016
    40 000140A9 4D41494E50524F472E- <1> 		db "MAINPROG.CFG", 0
    40 000140B2 43464700            <1>
    41                              <1> 
    42                              <1> TRDOSPromptLabel:
    43 000140B6 5452444F53          <1> 		db "TRDOS"
    44 000140BB 00                  <1> 		db 0
    45 000140BC 00<rept>            <1>                 times 5 db 0
    46 000140C1 00                  <1> 		db 0
    47                              <1> 
    48                              <1> ; INTERNAL COMMANDS
    49                              <1> Command_List:
    50 000140C2 44495200            <1> Cmd_Dir:	db "DIR", 0
    51 000140C6 434400              <1> Cmd_Cd:		db "CD", 0
    52 000140C9 433A00              <1> Cmd_Drive:	db "C:", 0
    53 000140CC 56455200            <1> Cmd_Ver:	db "VER", 0
    54 000140D0 4558495400          <1> Cmd_Exit:	db "EXIT", 0
    55 000140D5 50524F4D505400      <1> Cmd_Prompt:	db "PROMPT", 0
    56 000140DC 564F4C554D4500      <1> Cmd_Volume:	db "VOLUME", 0
    57 000140E3 4C4F4E474E414D4500  <1> Cmd_LongName:	db "LONGNAME", 0
    58 000140EC 4441544500          <1> Cmd_Date:	db "DATE", 0
    59 000140F1 54494D4500          <1> Cmd_Time:	db "TIME", 0
    60 000140F6 52554E00            <1> Cmd_Run:	db "RUN", 0
    61 000140FA 53455400            <1> Cmd_Set:	db "SET", 0 
    62 000140FE 434C5300            <1> Cmd_Cls:	db "CLS", 0
    63 00014102 53484F5700          <1> Cmd_Show:	db "SHOW", 0
    64 00014107 44454C00            <1> Cmd_Del:	db "DEL", 0
    65 0001410B 41545452494200      <1> Cmd_Attrib:	db "ATTRIB", 0
    66 00014112 52454E414D4500      <1> Cmd_Rename:	db "RENAME", 0
    67 00014119 524D44495200        <1> Cmd_Rmdir:	db "RMDIR", 0
    68 0001411F 4D4B44495200        <1> Cmd_Mkdir:	db "MKDIR", 0
    69 00014125 434F505900          <1> Cmd_Copy:	db "COPY", 0
    70 0001412A 4D4F564500          <1> Cmd_Move:	db "MOVE", 0
    71 0001412F 5041544800          <1> Cmd_Path:	db "PATH", 0
    72 00014134 4D454D00            <1> Cmd_Mem:	db "MEM", 0
    73 00014138 00                  <1> 		db 0
    74 00014139 46494E4400          <1> Cmd_Find:	db "FIND", 0
    75 0001413E 4543484F00          <1> Cmd_Echo:	db "ECHO", 0
    76 00014143 2A00                <1> Cmd_Remark:	db "*", 0
    77 00014145 3F00                <1> Cmd_Help:	db "?", 0
    78 00014147 44455649434500      <1> Cmd_Device:	db "DEVICE", 0
    79 0001414E 4445564C49535400    <1> Cmd_DevList:	db "DEVLIST", 0
    80 00014156 434844495200        <1> Cmd_Chdir:	db "CHDIR", 0
    81 0001415C 4245455000          <1> Cmd_Beep:	db "BEEP", 0
    82                              <1> 		
    83 00014161 00                  <1> 		db 0
    84                              <1> 
    85                              <1> ; 15/02/2016 (FILE.ASM, 09/10/2011)
    86                              <1> invalid_fname_chars:
    87 00014162 222728292A2B2C2F    <1> 		db 22h, 27h, 28h, 29h, 2Ah, 2Bh, 2Ch, 2Fh
    88 0001416A 3A3B3C3D3E3F40      <1> 		db 3Ah, 3Bh, 3Ch, 3Dh, 3Eh, 3Fh, 40h
    89 00014171 5B5C5D5E60          <1> 		db 5Bh, 5Ch, 5Dh, 5Eh, 60h
    90                              <1> sizeInvFnChars  equ ($ - invalid_fname_chars)                
    91                              <1> ;
    92                              <1> 
    93                              <1> Msg_Enter_Date:
    94 00014176 456E746572206E6577- <1>                 db 'Enter new date (dd-mm-yy): '
    94 0001417F 206461746520286464- <1>
    94 00014188 2D6D6D2D7979293A20  <1>
    95 00014191 00                  <1>                 db 0
    96                              <1> Msg_Show_Date:
    97 00014192 43757272656E742064- <1>                 db   'Current date is '
    97 0001419B 61746520697320      <1>
    98 000141A2 30                  <1> Day:            db   '0'
    99 000141A3 30                  <1> 		db   '0'
   100 000141A4 2F                  <1>                 db   '/'
   101 000141A5 30                  <1> Month:          db   '0'
   102 000141A6 30                  <1> 		db   '0'
   103 000141A7 2F                  <1>                 db   '/'
   104 000141A8 30                  <1> Century:        db   '0'
   105 000141A9 30                  <1>                 db   '0'
   106 000141AA 30                  <1> Year:           db   '0'
   107 000141AB 30                  <1> 		db   '0'
   108 000141AC 0D0A00              <1>                 db   0Dh, 0Ah, 0
   109                              <1> 
   110                              <1> Msg_Enter_Time:
   111 000141AF 456E746572206E6577- <1> 		db 'Enter new time: '
   111 000141B8 2074696D653A20      <1>
   112 000141BF 00                  <1> 		db 0
   113                              <1> Msg_Show_Time:
   114 000141C0 43757272656E742074- <1> 		db   'Current time is '
   114 000141C9 696D6520697320      <1>
   115 000141D0 30                  <1> Hour:           db   '0'
   116 000141D1 30                  <1> 		db   '0'
   117 000141D2 3A                  <1> 		db   ':'
   118 000141D3 30                  <1> Minute:         db   '0'
   119 000141D4 30                  <1> 		db   '0'
   120 000141D5 3A                  <1> 		db   ':'
   121 000141D6 30                  <1> Second:         db   '0'
   122 000141D7 30                  <1> 		db   '0'
   123 000141D8 0D0A00              <1> 		db   0Dh, 0Ah, 0
   124                              <1> 
   125                              <1> ;VolSize_Unit1:   dd 0
   126                              <1> ;VolSize_Unit2:   dd 0
   127                              <1> 
   128                              <1> VolSize_KiloBytes:
   129 000141DB 206B696C6F62797465- <1> 		db " kilobytes", 0Dh, 0Ah, 0
   129 000141E4 730D0A00            <1>
   130                              <1> VolSize_Bytes:
   131 000141E8 2062797465730D0A00  <1> 		db " bytes", 0Dh, 0Ah, 0
   132                              <1> Volume_in_drive:
   133 000141F1 0D0A                <1> 		db 0Dh, 0Ah
   134                              <1> Vol_FS_Name:
   135 000141F3 54522046533120      <1> 		db "TR FS1 "
   136 000141FA 566F6C756D6520696E- <1> 		db "Volume in drive "
   136 00014203 20647269766520      <1>
   137 0001420A 30                  <1> Vol_Drv_Name:   db 30h
   138 0001420B 3A                  <1> 		db ":"
   139 0001420C 20697320            <1> 		db " is "
   140 00014210 0D0A00              <1> 		db 0Dh, 0Ah, 0
   141                              <1> Dir_Drive_Str:
   142 00014213 54522D444F53204472- <1>                 db "TR-DOS Drive "
   142 0001421C 69766520            <1>
   143                              <1> Dir_Drive_Name:
   144 00014220 303A                <1>                 db "0:"
   145 00014222 0D0A                <1>                 db  0Dh, 0Ah
   146                              <1> Vol_Str_Header:
   147 00014224 566F6C756D65204E61- <1>                 db "Volume Name: "
   147 0001422D 6D653A20            <1>
   148                              <1> Vol_Name:
   149 00014231 00<rept>            <1> 		times 64 db 0
   150 00014271 00                  <1> 		db 0
   151                              <1> Vol_Serial_Header:
   152 00014272 0D0A                <1> 		db 0Dh, 0Ah
   153 00014274 566F6C756D65205365- <1> 		db "Volume Serial No: "
   153 0001427D 7269616C204E6F3A20  <1>
   154                              <1> Vol_Serial1:
   155 00014286 30303030            <1> 		db "0000"
   156 0001428A 2D                  <1> 		db "-"
   157                              <1> Vol_Serial2:
   158 0001428B 30303030            <1> 		db "0000"
   159 0001428F 0D0A00              <1> 		db 0Dh, 0Ah, 0
   160                              <1> 
   161                              <1> ;Vol_Tot_Sec_Str_Start:
   162                              <1> ;		dd 0
   163                              <1> Vol_Total_Sector_Header:
   164 00014292 0D0A                <1> 		db 0Dh, 0Ah
   165 00014294 566F6C756D65205369- <1> 		db "Volume Size : ", 0
   165 0001429D 7A65203A2000        <1>
   166                              <1> ;Vol_Tot_Sec_Str: 
   167                              <1> ;		db "0000000000"
   168                              <1> ;Vol_Tot_Sec_Str_End:
   169                              <1> ;		db 0
   170                              <1> ;Vol_Free_Sectors_Str_Start:
   171                              <1> ;		dd 0
   172                              <1> Vol_Free_Sectors_Header:
   173 000142A3 467265652053706163- <1> 		db "Free Space  : ", 0
   173 000142AC 6520203A2000        <1>
   174                              <1> ;Vol_Free_Sectors_Str:
   175                              <1> ;		db "0000000000"
   176                              <1> ;Vol_Free_Sectors_Str_End:
   177                              <1> ;		db 0
   178                              <1> 
   179                              <1> Dir_Str_Header:
   180 000142B2 4469726563746F7279- <1>                 db "Directory: "
   180 000142BB 3A20                <1>
   181 000142BD 2F                  <1> Dir_Str_Root:   db "/"
   182 000142BE 00<rept>            <1> Dir_Str:        times 64 db 0
   183 000142FE 00000000            <1>                 dd 0
   184 00014302 00                  <1>                 db 0
   185                              <1> 
   186                              <1> Msg_Bad_Command:
   187 00014303 42616420636F6D6D61- <1>                 db "Bad command or file name!"
   187 0001430C 6E64206F722066696C- <1>
   187 00014315 65206E616D6521      <1>
   188 0001431C 0D0A00              <1>                 db 0Dh, 0Ah, 0
   189                              <1> 
   190                              <1> msgl_drv_not_ready: 
   191 0001431F 070D0A              <1> 		db 07h, 0Dh, 0Ah
   192                              <1> 
   193                              <1> ; CMD_INTR.ASM - 09/11/2011 - Messages
   194                              <1> 
   195                              <1> Msg_Not_Ready_Read_Err:
   196 00014322 4472697665206E6F74- <1>                 db "Drive not ready or read error!"
   196 0001432B 207265616479206F72- <1>
   196 00014334 207265616420657272- <1>
   196 0001433D 6F7221              <1>
   197 00014340 0D0A00              <1>                 db 0Dh, 0Ah, 0
   198                              <1> 
   199                              <1> Msg_Not_Ready_Write_Err:
   200 00014343 4472697665206E6F74- <1>                 db "Drive not ready or write error!"
   200 0001434C 207265616479206F72- <1>
   200 00014355 207772697465206572- <1>
   200 0001435E 726F7221            <1>
   201 00014362 0D0A00              <1>                 db 0Dh, 0Ah, 0
   202                              <1> 
   203                              <1> Msg_Dir_Not_Found:
   204 00014365 4469726563746F7279- <1>                 db "Directory not found!"
   204 0001436E 206E6F7420666F756E- <1>
   204 00014377 6421                <1>
   205 00014379 0D0A00              <1>                 db 0Dh, 0Ah, 0
   206                              <1> 
   207                              <1> Msg_File_Not_Found:
   208 0001437C 46696C65206E6F7420- <1>                 db "File not found!"
   208 00014385 666F756E6421        <1>
   209 0001438B 0D0A00              <1>                 db 0Dh, 0Ah, 0
   210                              <1> 
   211                              <1> Msg_File_Directory_Not_Found:
   212 0001438E 46696C65206F722064- <1>                 db "File or directory not found!"
   212 00014397 69726563746F727920- <1>
   212 000143A0 6E6F7420666F756E64- <1>
   212 000143A9 21                  <1>
   213 000143AA 0D0A00              <1>                 db 0Dh, 0Ah, 0
   214                              <1> 
   215                              <1> Msg_LongName_Not_Found:
   216 000143AD 4C6F6E67206E616D65- <1>                 db "Long name not found!"
   216 000143B6 206E6F7420666F756E- <1>
   216 000143BF 6421                <1>
   217 000143C1 0D0A00              <1>                 db 0Dh, 0Ah, 0
   218                              <1> 
   219                              <1> beep_Insufficient_Memory: ; 20/02/2017
   220 000143C4 0D0A                <1> 		db 0Dh, 0Ah
   221 000143C6 07                  <1> 		db 07h
   222                              <1> Msg_Insufficient_Memory:
   223 000143C7 496E73756666696369- <1>                 db "Insufficient memory!"
   223 000143D0 656E74206D656D6F72- <1>
   223 000143D9 7921                <1>
   224 000143DB 0D0A00              <1>                 db 0Dh, 0Ah, 0
   225                              <1> 
   226                              <1> Msg_Error_Code:
   227 000143DE 436F6D6D616E642066- <1>                 db 'Command failed! Error code : '
   227 000143E7 61696C656421204572- <1>
   227 000143F0 726F7220636F646520- <1>
   227 000143F9 3A20                <1>
   228 000143FB 303068              <1> error_code_hex: db '00h'
   229 000143FE 0A0A00              <1>                 db 0Ah, 0Ah, 0
   230                              <1> 
   231 00014401 90                  <1> align 2
   232                              <1> 
   233                              <1> ; 10/02/2016
   234                              <1> ; DIR.ASM - 09/10/2011
   235                              <1> 
   236 00014402 3C4449523E20202020- <1> Type_Dir:       db '<DIR>     ' ; 10 bytes
   236 0001440B 20                  <1>
   237                              <1> 
   238                              <1> File_Name:
   239 0001440C 20<rept>            <1>                 times 12 db 20h
   240 00014418 20                  <1> 		db 20h
   241                              <1> Dir_Or_FileSize:
   242 00014419 20<rept>            <1>                 times 10 db 20h
   243 00014423 20                  <1> 		db 20h
   244                              <1> File_Attribute:
   245 00014424 20202020            <1> 		dd 20202020h
   246 00014428 20                  <1> 		db 20h
   247                              <1> File_Day:
   248 00014429 3030                <1>                 db '0','0'
   249 0001442B 2F                  <1> 		db '/'
   250                              <1> File_Month:
   251 0001442C 3030                <1>                 db '0','0'
   252 0001442E 2F                  <1> 		db '/'
   253                              <1> File_Year:
   254 0001442F 30303030            <1>                 db '0','0','0','0'
   255 00014433 20                  <1> 		db 20h
   256                              <1> File_Hour:
   257 00014434 3030                <1>                 db '0','0'
   258 00014436 3A                  <1> 		db ':'
   259                              <1> File_Minute:
   260 00014437 3030                <1>                 db '0','0'
   261 00014439 00                  <1> 		db 0
   262                              <1> 
   263                              <1> Decimal_File_Count_Header:
   264 0001443A 0D0A                <1> 		db 0Dh, 0Ah
   265                              <1> Decimal_File_Count:
   266 0001443C 00<rept>            <1> 		times 6 db 0
   267                              <1> 
   268 00014442 2066696C6528732920- <1> str_files:	db " file(s) & "
   268 0001444B 2620                <1>
   269                              <1> Decimal_Dir_Count: 
   270 0001444D 00<rept>            <1> 		times 6 db 0
   271                              <1> str_dirs:       
   272 00014453 206469726563746F72- <1> 		db " directory(s) "
   272 0001445C 7928732920          <1>
   273 00014461 0D0A00              <1> 		db 0Dh, 0Ah, 0
   274                              <1> 
   275 00014464 206279746528732920- <1> str_bytes:	db " byte(s) in file(s)"
   275 0001446D 696E2066696C652873- <1>
   275 00014476 29                  <1>
   276 00014477 0D0A00              <1> 		db 0Dh, 0Ah, 0
   277                              <1> 
   278                              <1> ; CMD_INTR.ASM - 09/11/2011
   279                              <1> ; 07/10/2010
   280                              <1> Msg_invalid_name_chars:
   281 0001447A 496E76616C69642066- <1>                 db "Invalid file or directory name characters!"
   281 00014483 696C65206F72206469- <1>
   281 0001448C 726563746F7279206E- <1>
   281 00014495 616D65206368617261- <1>
   281 0001449E 637465727321        <1>
   282 000144A4 0D0A00              <1>         	db 0Dh, 0Ah, 0
   283                              <1> ; 21/02/2016
   284 000144A7 46696C65206F722064- <1> Msg_Name_Exists: db "File or directory name exists!"
   284 000144B0 69726563746F727920- <1>
   284 000144B9 6E616D652065786973- <1>
   284 000144C2 747321              <1>
   285 000144C5 0D0A00              <1>                 db 0Dh, 0Ah, 0
   286                              <1> Msg_DoYouWantMkdir:
   287 000144C8 446F20796F75207761- <1>                 db "Do you want to make directory ", 0
   287 000144D1 6E7420746F206D616B- <1>
   287 000144DA 65206469726563746F- <1>
   287 000144E3 72792000            <1>
   288 000144E7 2028592F4E29203F20- <1> Msg_YesNo:      db " (Y/N) ? ", 0  
   288 000144F0 00                  <1>
   289 000144F1 000D0A00            <1> Y_N_nextline:	db 0, 0Dh, 0Ah, 0 
   290 000144F5 4F4B2E0D0A00        <1> Msg_OK:		db "OK.", 0Dh, 0Ah, 0
   291                              <1> 
   292                              <1> ; 27/02/2016
   293                              <1> Msg_DoYouWantRmDir:
   294 000144FB 446F20796F75207761- <1>                 db "Do you want to delete directory ", 0
   294 00014504 6E7420746F2064656C- <1>
   294 0001450D 657465206469726563- <1>
   294 00014516 746F72792000        <1>
   295                              <1> Msg_Dir_Not_Empty:
   296 0001451C 4469726563746F7279- <1>                 db "Directory not empty!"
   296 00014525 206E6F7420656D7074- <1>
   296 0001452E 7921                <1>
   297 00014530 0D0A00              <1>                 db 0Dh, 0Ah, 0
   298                              <1> 
   299                              <1> Msg_DoYouWantDelete:
   300 00014533 446F20796F75207761- <1>                 db "Do you want to delete file ",0
   300 0001453C 6E7420746F2064656C- <1>
   300 00014545 6574652066696C6520- <1>
   300 0001454E 00                  <1>
   301                              <1> 
   302 0001454F 44656C657465642E2E- <1> Msg_Deleted:    db "Deleted...", 0Dh, 0Ah, 0
   302 00014558 2E0D0A00            <1>
   303                              <1> 
   304                              <1> Msg_Permission_Denied:
   305 0001455C 07                  <1>                 db 7
   306 0001455D 5065726D697373696F- <1>                 db "Permission denied!", 0Dh, 0Ah, 0
   306 00014566 6E2064656E69656421- <1>
   306 0001456F 0D0A00              <1>
   307                              <1> 
   308                              <1> ; 04/03/2016
   309 00014572 4E657720            <1> Msg_New:        db "New "
   310 00014576 00                  <1>                 db 0
   311                              <1> Str_Attributes:
   312 00014577 417474726962757465- <1>                 db "Attributes : "
   312 00014580 73203A20            <1>
   313 00014584 4E4F524D414C        <1> Attr_Chars:     db "NORMAL"
   314 0001458A 00                  <1>                 db 0
   315                              <1> 
   316                              <1> ; 06/03/2016
   317                              <1> ; CMD_INTR.ASM - 16/11/2010 
   318                              <1> Msg_DoYouWantRename:
   319 0001458B 446F20796F75207761- <1>                 db "Do you want to rename ", 0
   319 00014594 6E7420746F2072656E- <1>
   319 0001459D 616D652000          <1>
   320 000145A2 66696C652000        <1> Rename_File:    db "file ", 0
   321 000145A8 6469726563746F7279- <1> Rename_Directory: db "directory ", 0
   321 000145B1 2000                <1>
   322 000145B3 00<rept>            <1> Rename_OldName: times 13 db 0
   323 000145C0 20617320            <1> Msg_File_rename_as: db " as "
   324 000145C4 00<rept>            <1> Rename_NewName: times 13 db 0
   325                              <1> 
   326                              <1> ; 08/03/2016
   327                              <1> ; CMD_INTR.ASM - 01/08/2010 - 23/04/2011
   328                              <1> msg_not_same_drv:
   329 000145D1 4E6F742073616D6520- <1>                 db "Not same drive!" 
   329 000145DA 647269766521        <1>
   330 000145E0 0D0A00              <1>                 db 0Dh, 0Ah, 0 
   331                              <1> 
   332                              <1> Msg_DoYouWantMoveFile:
   333 000145E3 446F20796F75207761- <1>                 db "Do you want to move file", 0
   333 000145EC 6E7420746F206D6F76- <1>
   333 000145F5 652066696C6500      <1>
   334                              <1> 
   335                              <1> msg_insufficient_disk_space:
   336 000145FC 496E73756666696369- <1>                 db "Insufficient disk space!" 
   336 00014605 656E74206469736B20- <1>
   336 0001460E 737061636521        <1>
   337 00014614 0D0A00              <1>                 db 0Dh, 0Ah, 0
   338                              <1> 
   339                              <1> ; 01/08/2010
   340                              <1> msg_source_file: 
   341 00014617 0D0A536F7572636520- <1> 		db 0Dh, 0Ah, "Source file name      :   "
   341 00014620 66696C65206E616D65- <1>
   341 00014629 2020202020203A2020- <1>
   341 00014632 20                  <1>
   342                              <1> msg_source_file_drv: 
   343 00014633 203A00              <1> 		db " :", 0
   344                              <1> msg_destination_file: 
   345 00014636 0D0A44657374696E61- <1> 		db 0Dh, 0Ah, "Destination file name :   "
   345 0001463F 74696F6E2066696C65- <1>
   345 00014648 206E616D65203A2020- <1>
   345 00014651 20                  <1>
   346                              <1> msg_destination_file_drv: 
   347 00014652 203A00              <1> 		db " :", 0
   348                              <1> msg_copy_nextline: 
   349 00014655 0D0A00              <1> 		db 0Dh, 0Ah, 0
   350                              <1> 
   351                              <1> ; 15/03/2016
   352                              <1> ; CMD_INTR.ASM
   353                              <1> 
   354                              <1> Msg_DoYouWantOverWriteFile:
   355 00014658 446F20796F75207761- <1>                 db "Do you want to overwrite file ",0
   355 00014661 6E7420746F206F7665- <1>
   355 0001466A 727772697465206669- <1>
   355 00014673 6C652000            <1>
   356                              <1>   
   357                              <1> Msg_DoYouWantCopyFile:
   358 00014677 446F20796F75207761- <1>                 db "Do you want to copy file",0
   358 00014680 6E7420746F20636F70- <1>
   358 00014689 792066696C6500      <1>
   359                              <1> 
   360                              <1> Msg_read_file_error_before_EOF:
   361 00014690 46696C652072656164- <1> 		db "File reading error! (before EOF)"
   361 00014699 696E67206572726F72- <1>
   361 000146A2 2120286265666F7265- <1>
   361 000146AB 20454F4629          <1>
   362 000146B0 0A0A00              <1> 		db 0Ah, 0Ah, 0
   363                              <1> 
   364                              <1> ; 18/03/2016
   365                              <1> ; TRDOS 386 (v2.0) mainprog copy procedure
   366                              <1> msg_reading:
   367 000146B3 52656164696E672E2E- <1> 		db "Reading... ", 0
   367 000146BC 2E2000              <1>
   368                              <1> msg_writing:
   369 000146BF 57726974696E672E2E- <1> 		db "Writing... ", 0
   369 000146C8 2E2000              <1>
   370                              <1> percentagestr:
   371 000146CB 2020202500          <1> 		db "   %", 0  ; "  0%" .. "100%"
   372                              <1> ; 11/04/2016
   373                              <1> Msg_No_Set_Space:
   374 000146D0 496E73756666696369- <1>                 db "Insufficient environment space!"
   374 000146D9 656E7420656E766972- <1>
   374 000146E2 6F6E6D656E74207370- <1>
   374 000146EB 61636521            <1>
   375 000146EF 0D0A00              <1>                 db 0Dh, 0Ah, 0
   376                              <1> ; 18/04/2016
   377                              <1> isc_msg:	
   378 000146F2 0D0A                <1> 		db 0Dh, 0Ah
   379 000146F4 494E56414C49442053- <1> 		db "INVALID SYSTEM CALL", 0
   379 000146FD 595354454D2043414C- <1>
   379 00014706 4C00                <1>
   380                              <1> usi_msg:
   381 00014708 0D0A                <1> 		db 0Dh, 0Ah
   382 0001470A 554E444546494E4544- <1> 		db "UNDEFINED SOFTWARE INTERRUPT", 0
   382 00014713 20534F465457415245- <1>
   382 0001471C 20494E544552525550- <1>
   382 00014725 5400                <1>
   383                              <1> ifc_msg:
   384 00014727 0D0A                <1> 		db 0Dh, 0Ah
   385 00014729 494E56414C49442046- <1> 		db "INVALID FUNCTION CALL"
   385 00014732 554E4354494F4E2043- <1>
   385 0001473B 414C4C              <1>
   386                              <1> inv_msg_for_trdos_v2:
   387 0001473E 20                  <1> 		db 20h
   388 0001473F 666F72205452444F53- <1> 		db "for TRDOS v2!"
   388 00014748 20763221            <1>
   389 0001474C 07                  <1> 		db 07h
   390 0001474D 0D0A                <1> 		db 0Dh, 0Ah
   391 0001474F 0D0A                <1> 		db 0Dh, 0Ah
   392 00014751 494E5420            <1> 		db "INT "
   393 00014755 303068              <1> int_num_str:	db "00h"
   394 00014758 0D0A                <1> 		db 0Dh, 0Ah
   395 0001475A 454158203A20        <1> 		db "EAX : "
   396 00014760 303030303030303068- <1> eax_str:	db "00000000h", 0Dh, 0Ah
   396 00014769 0D0A                <1>
   397 0001476B 454950203A20        <1> 		db "EIP : "
   398 00014771 303030303030303068- <1> eip_str:	db "00000000h", 0Dh, 0Ah, 0
   398 0001477A 0D0A00              <1>
   399                              <1> 
   400                              <1> ; 07/10/2016
   401                              <1> ; Device names & parameters (for kernel devices)
   402                              <1> 
   403 0001477D 90                  <1> align 2
   404                              <1> KDEV_NAME:
   405 0001477E 5454590000000000    <1> 		db 'TTY',0,0,0,0,0 ; 1
   406 00014786 4D454D0000000000    <1> 		db 'MEM',0,0,0,0,0 ; 2
   407 0001478E 4644300000000000    <1> 		db 'FD0',0,0,0,0,0 ; 3
   408 00014796 4644310000000000    <1> 		db 'FD1',0,0,0,0,0 ; 4
   409 0001479E 4844300000000000    <1> 		db 'HD0',0,0,0,0,0 ; 5
   410 000147A6 4844310000000000    <1> 		db 'HD1',0,0,0,0,0 ; 6
   411 000147AE 4844320000000000    <1> 		db 'HD2',0,0,0,0,0 ; 7
   412 000147B6 4844330000000000    <1> 		db 'HD3',0,0,0,0,0 ; 8
   413 000147BE 4C50540000000000    <1> 		db 'LPT',0,0,0,0,0 ; 9
   414 000147C6 5454593000000000    <1> 		db 'TTY0',0,0,0,0 ; 10
   415 000147CE 5454593100000000    <1> 		db 'TTY1',0,0,0,0 ; 11
   416 000147D6 5454593200000000    <1> 		db 'TTY2',0,0,0,0 ; 12
   417 000147DE 5454593300000000    <1> 		db 'TTY3',0,0,0,0 ; 13
   418 000147E6 5454593400000000    <1> 		db 'TTY4',0,0,0,0 ; 14
   419 000147EE 5454593500000000    <1> 		db 'TTY5',0,0,0,0 ; 15
   420 000147F6 5454593600000000    <1> 		db 'TTY6',0,0,0,0 ; 16
   421 000147FE 5454593700000000    <1> 		db 'TTY7',0,0,0,0 ; 17
   422 00014806 5454593800000000    <1> 		db 'TTY8',0,0,0,0 ; 18
   423 0001480E 5454593900000000    <1> 		db 'TTY9',0,0,0,0 ; 19
   424 00014816 434F4D3100000000    <1> 		db 'COM1',0,0,0,0 ; 18
   425 0001481E 434F4D3200000000    <1> 		db 'COM2',0,0,0,0 ; 19
   426                              <1> 		;db 'CONSOLE',0	  ; 1
   427                              <1> 		;db 'PRINTER',0   ; 9
   428                              <1> 		;db 'CDROM'	  ; 20
   429                              <1> 		;db 'CDROM0'	  ; 20
   430                              <1> 		;db 'CDROM1'	  ; 21		
   431                              <1> 		;db 'DVD'	  ; 22
   432                              <1> 		;db 'DVD0'	  ; 22
   433                              <1> 		;db 'DVD1'	  ; 23		
   434                              <1> 		;db 'USB'	  ; 24
   435                              <1> 		;db 'USB0'	  ; 24
   436                              <1> 		;db 'USB1'	  ; 25
   437                              <1> 		;db 'USB2'	  ; 26
   438                              <1> 		;db 'USB3'        ; 27
   439                              <1> 		;db 'KEYBOARD'	  ; 1	
   440                              <1> 		;db 'MOUSE'	  ; 28
   441                              <1> 		;db 'SOUND'	  ; 29
   442                              <1> 		;db 'VGA',0,0,0,0 ; 30
   443                              <1> 		;db 'CGA',0,0,0,0 ; 31
   444                              <1> 		;db 'AUDIO',0,0,0 ; 29
   445                              <1> 		;db 'VIDEO',0,0,0 ; 32
   446                              <1> 		;db 'MUSIC',0,0,0 ; 33
   447                              <1> 		;db 'ETHERNET'	  ; 34 		
   448                              <1> 		;db 'SD0',0,0,0,0,0 ; 35
   449                              <1> 		;db 'SD1',0,0,0,0,0 ; 36
   450                              <1> 		;db 'SD2',0,0,0,0,0 ; 37
   451                              <1> 		;db 'SD3',0,0,0,0,0 ; 38
   452                              <1> 		;db 'SATA0'	  ; 35
   453                              <1> 		;db 'SATA1'	  ; 36
   454                              <1> 		;db 'SATA2'        ; 37
   455                              <1> 		;db 'SATA3'        ; 38
   456                              <1> 		;db 'PATA0',0,0,0  ; 5
   457                              <1> 		;db 'PATA1',0,0,0  ; 6
   458                              <1> 		;db 'PATA2',0,0,0  ; 7
   459                              <1> 		;db 'PATA3',0,0,0  ; 8
   460                              <1> 		;db 'WIRELESS'	  ; 39
   461                              <1> 		;db 'HDMI',0,0,0,0 ; 40
   462 00014826 4E554C4C00000000    <1> 		db 'NULL',0,0,0,0 ; 0
   463                              <1> 
   464                              <1> NumOfKernelDevNames equ ($-KDEV_NAME) / 8 ; 20 (07/10/2016)
   465                              <1> 
   466                              <1> KDEV_NUMBER:
   467 0001482E 010203040506070809  <1> 		db 1,2,3,4,5,6,7,8,9
   468 00014837 0A0B0C0D0E0F101112- <1> 		db 10,11,12,13,14,15,16,17,18,19
   468 00014840 13                  <1>
   469 00014841 121300              <1> 		db 18,19,0
   470                              <1> 
   471                              <1> NumOfKernelDevices equ $ - KDEV_NUMBER
   472                              <1> 
   473                              <1> KDEV_OADDR:
   474 00014844 [61400100]          <1> 		dd otty ;tty  ; 1
   475 00014848 [61400100]          <1> 		dd sret ;mem  ; 2
   476 0001484C [61400100]          <1>  		dd sret ;fd0  ; 3
   477 00014850 [61400100]          <1>  		dd sret ;fd1  ; 4
   478 00014854 [61400100]          <1>  		dd sret ;hd0  ; 5
   479 00014858 [61400100]          <1>  		dd sret ;hd1  ; 6
   480 0001485C [61400100]          <1>  		dd sret ;hd2  ; 7
   481 00014860 [61400100]          <1>  		dd sret ;hd3  ; 8
   482 00014864 [61400100]          <1>  		dd sret ;lpt  ; 9
   483 00014868 [61400100]          <1>  		dd ocvt ;tty0 ; 10
   484 0001486C [61400100]          <1> 		dd ocvt ;tty1 ; 11
   485 00014870 [61400100]          <1>  		dd ocvt ;tty2 ; 12
   486 00014874 [61400100]          <1>  		dd ocvt ;tty3 ; 13
   487 00014878 [61400100]          <1>  		dd ocvt ;tty4 ; 14
   488 0001487C [61400100]          <1>  		dd ocvt ;tty5 ; 15
   489 00014880 [61400100]          <1>  		dd ocvt ;tty6 ; 16
   490 00014884 [61400100]          <1>  		dd ocvt ;tty7 ; 17
   491 00014888 [61400100]          <1>  		dd ocvt ;tty8 ; 18
   492 0001488C [61400100]          <1>  		dd ocvt ;tty9 ; 19
   493                              <1>  		;dd ocvt ;com1 ; 18
   494                              <1>  		;dd ocvt ;com2 ; 19
   495 00014890 [61400100]          <1> 		dd sret ;null ; 20  
   496                              <1> KDEV_CADDR:
   497 00014894 [61400100]          <1> 		dd ctty ;tty  ; 1
   498 00014898 [61400100]          <1> 		dd cret ;mem  ; 2
   499 0001489C [61400100]          <1>  		dd cret ;fd0  ; 3
   500 000148A0 [61400100]          <1>  		dd cret ;fd1  ; 4
   501 000148A4 [61400100]          <1>  		dd cret ;hd0  ; 5
   502 000148A8 [61400100]          <1>  		dd cret ;hd1  ; 6
   503 000148AC [61400100]          <1>  		dd cret ;hd2  ; 7
   504 000148B0 [61400100]          <1>  		dd cret ;hd3  ; 8
   505 000148B4 [61400100]          <1>  		dd cret ;lpt  ; 9
   506 000148B8 [61400100]          <1>  		dd ocvt ;tty0 ; 10
   507 000148BC [61400100]          <1> 		dd ccvt ;tty1 ; 11
   508 000148C0 [61400100]          <1>  		dd ccvt ;tty2 ; 12
   509 000148C4 [61400100]          <1>  		dd ccvt ;tty3 ; 13
   510 000148C8 [61400100]          <1>  		dd ccvt ;tty4 ; 14
   511 000148CC [61400100]          <1>  		dd ccvt ;tty5 ; 15
   512 000148D0 [61400100]          <1>  		dd ccvt ;tty6 ; 16
   513 000148D4 [61400100]          <1>  		dd ccvt ;tty7 ; 17
   514 000148D8 [61400100]          <1>  		dd ccvt ;tty8 ; 18
   515 000148DC [61400100]          <1>  		dd ccvt ;tty9 ; 19
   516                              <1>  		;dd ccvt ;com1 ; 18
   517                              <1>  		;dd ccvt ;com2 ; 19
   518 000148E0 [61400100]          <1> 		dd cret ;null ; 20
   519                              <1> 
   520                              <1> KDEV_RADDR:
   521 000148E4 [61400100]          <1> 		dd rtty ;tty  ; 1
   522 000148E8 [61400100]          <1> 		dd rmem ;mem  ; 2
   523 000148EC [61400100]          <1>  		dd rfd  ;fd0  ; 3
   524 000148F0 [61400100]          <1>  		dd rfd  ;fd1  ; 4
   525 000148F4 [61400100]          <1>  		dd rhd  ;hd0  ; 5
   526 000148F8 [61400100]          <1>  		dd rhd  ;hd1  ; 6
   527 000148FC [61400100]          <1>  		dd rhd  ;hd2  ; 7
   528 00014900 [61400100]          <1>  		dd rhd  ;hd3  ; 8
   529 00014904 [61400100]          <1>  		dd rlpt ;lpt  ; 9
   530 00014908 [61400100]          <1>  		dd rcvt ;tty0 ; 10
   531 0001490C [61400100]          <1> 		dd rcvt ;tty1 ; 11
   532 00014910 [61400100]          <1>  		dd rcvt ;tty2 ; 12
   533 00014914 [61400100]          <1>  		dd rcvt ;tty3 ; 13
   534 00014918 [61400100]          <1>  		dd rcvt ;tty4 ; 14
   535 0001491C [61400100]          <1>  		dd rcvt ;tty5 ; 15
   536 00014920 [61400100]          <1>  		dd rcvt ;tty6 ; 16
   537 00014924 [61400100]          <1>  		dd rcvt ;tty7 ; 17
   538 00014928 [61400100]          <1>  		dd rcvt ;tty8 ; 18
   539 0001492C [61400100]          <1>  		dd rcvt ;tty9 ; 19
   540                              <1>  		;dd rcvt ;com1 ; 18
   541                              <1>  		;dd rcvt ;com2 ; 19
   542 00014930 [45340100]          <1> 		dd rnull ;null ; 20  
   543                              <1> KDEV_WADDR:
   544 00014934 [61400100]          <1> 		dd wtty ;tty  ; 1
   545 00014938 [61400100]          <1> 		dd wmem ;mem  ; 2
   546 0001493C [61400100]          <1>  		dd wfd  ;fd0  ; 3
   547 00014940 [61400100]          <1>  		dd wfd  ;fd1  ; 4
   548 00014944 [61400100]          <1>  		dd whd  ;hd0  ; 5
   549 00014948 [61400100]          <1>  		dd whd  ;hd1  ; 6
   550 0001494C [61400100]          <1>  		dd whd  ;hd2  ; 7
   551 00014950 [61400100]          <1>  		dd whd  ;hd3  ; 8
   552 00014954 [61400100]          <1>  		dd wlpt ;lpt  ; 9
   553 00014958 [61400100]          <1>  		dd xmtt ;tty0 ; 10
   554 0001495C [61400100]          <1> 		dd xmtt ;tty1 ; 11
   555 00014960 [61400100]          <1>  		dd xmtt ;tty2 ; 12
   556 00014964 [61400100]          <1>  		dd xmtt ;tty3 ; 13
   557 00014968 [61400100]          <1>  		dd xmtt ;tty4 ; 14
   558 0001496C [61400100]          <1>  		dd xmtt ;tty5 ; 15
   559 00014970 [61400100]          <1>  		dd xmtt ;tty6 ; 16
   560 00014974 [61400100]          <1>  		dd xmtt ;tty7 ; 17
   561 00014978 [61400100]          <1>  		dd xmtt ;tty8 ; 18
   562 0001497C [61400100]          <1>  		dd xmtt ;tty9 ; 19
   563                              <1>  		;dd xmtt ;com1 ; 18
   564                              <1>  		;dd xmtt ;com2 ; 19
   565 00014980 [46340100]          <1> 		dd wnull ;null ; 20  
   566                              <1> 
   567                              <1> ; DEV_ACCESS bits:
   568                              <1> 	; bit 0 = accessable by normal users
   569                              <1> 	; bit 1 = read access permission
   570                              <1> 	; bit 2 = write access permission
   571                              <1> 	; bit 3 = IOCTL permission to users
   572                              <1> 	; bit 4 = block device if it is set
   573                              <1> 	; bit 5 = 16 bit or 1024 byte data
   574                              <1> 	; bit 6 = 32 bit or 2048 byte data
   575                              <1> 	; bit 7 = installable device driver	
   576                              <1> 
   577                              <1> KDEV_ACCESS: ; 08/10/2016
   578 00014984 07                  <1> 		db  00000111b	; tty, 1
   579 00014985 07                  <1> 		db  00000111b	; mem, 2	
   580 00014986 8F                  <1> 		db  10001111b	; fd0, 3	
   581 00014987 8F                  <1> 		db  10001111b	; fd1, 4
   582 00014988 8F                  <1> 		db  10001111b	; hd0, 5
   583 00014989 8F                  <1> 		db  10001111b	; hd1, 6
   584 0001498A 8F                  <1> 		db  10001111b	; hd2, 7
   585 0001498B 8F                  <1> 		db  10001111b	; hd3, 8
   586 0001498C 07                  <1> 		db  00000111b   ; lpt, 9
   587 0001498D 07                  <1> 		db  00000111b	; tty0, 10
   588 0001498E 07                  <1> 		db  00000111b	; tty1, 11
   589 0001498F 07                  <1> 		db  00000111b	; tty2, 12
   590 00014990 07                  <1> 		db  00000111b	; tty3, 13
   591 00014991 07                  <1> 		db  00000111b	; tty4, 14
   592 00014992 07                  <1> 		db  00000111b	; tty5, 15
   593 00014993 07                  <1> 		db  00000111b	; tty6, 16
   594 00014994 07                  <1> 		db  00000111b	; tty7, 17
   595 00014995 07                  <1> 		db  00000111b	; tty8, 18
   596 00014996 07                  <1> 		db  00000111b	; tty9, 19
   597                              <1> 		;db 00000111b	; com1, 18
   598                              <1> 		;db 00000111b	; com2, 19
   599 00014997 00                  <1> 		db  00000000b   ; null, 0
   600                              <1> 
   601                              <1> ; 07/10/2016
   602                              <1> NumOfInstallableDevices equ 8
   603                              <1> NUMIDEV		equ NumOfInstallableDevices ; 8
   604                              <1> NUMOFDEVICES	equ NumOfKernelDevices + NumOfInstallableDevices
   605                              <1> 
   606                              <1> ; 26/02/2017
   607                              <1> ; IRQ Callback (& Signal Response Byte) service availibity
   608                              <1> ; 'syscalbac'
   609                              <1> ; ***************************************************
   610                              <1> ; IRQ 00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15
   611                              <1> ; --- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
   612                              <1> ; --- 00 00 00 01 02 03 00 04 00 05 06 07 08 09 00 00
   613                              <1> ; ***************************************************
   614                              <1> IRQenum:
   615 00014998 000000010203000400- <1> 	db  0,0,0,1,2,3,0,4,0,5,6,7,8,9,0,0
   615 000149A1 05060708090000      <1>
   616                              <1> 
   617                              <1> ; 28/08/2017
   618                              <1> ; 20/08/2017
   619                              <1> ; DMA Registers (for 'sysdma')
   620                              <1> ; 02/07/2017 (sb16mod.s)
   621 000149A8 00020406C0C4C8CC    <1> dma_adr:	db 0,2,4,6,0C0h,0C4h,0C8h,0CCh
   622 000149B0 01030507C2C6CACE    <1> dma_cnt:	db 1,3,5,7,0C2h,0C6h,0CAh,0CEh
   623 000149B8 878381828F8B898A    <1> dma_page:	db 87h,83h,81h,82h,8Fh,8Bh,89h,8Ah ; 03/08/2017
   624 000149C0 0A0A0A0AD4D4D4D4    <1> dma_mask:	db 0Ah,0Ah,0Ah,0Ah,0D4h,0D4h,0D4h,0D4h
   625 000149C8 0B0B0B0BD6D6D6D6    <1> dma_mod:	db 0Bh,0Bh,0Bh,0Bh,0D6h,0D6h,0D6h,0D6h
   626 000149D0 0C0C0C0CD8D8D8D8    <1> dma_flip:	db 0Ch,0Ch,0Ch,0Ch,0D8h,0D8h,0D8h,0D8h	
  3088                                  
  3089                                  ; 27/08/2014
  3090                                  scr_row:
  3091 000149D8 E0810B00                	dd 0B8000h + 0A0h + 0A0h + 0A0h ; Row 3
  3092                                  scr_col:
  3093 000149DC 00000000                	dd 0
  3094                                  
  3095                                  Align 4
  3096                                  	; 15/04/2016
  3097                                  	; TRDOS 386 (TRDOS v2.0)
  3098                                  
  3099                                  	; 21/08/2014
  3100                                  ilist:
  3101                                  	;times 	32 dd cpu_except ; INT 0 to INT 1Fh
  3102                                  	;
  3103                                  	; Exception list
  3104                                  	; 25/08/2014	
  3105 000149E0 [E20B0000]              	dd	exc0	; 0h,  Divide-by-zero Error
  3106 000149E4 [E90B0000]              	dd	exc1	
  3107 000149E8 [F00B0000]              	dd 	exc2	
  3108 000149EC [F70B0000]              	dd	exc3	
  3109 000149F0 [FB0B0000]              	dd	exc4	
  3110 000149F4 [FF0B0000]              	dd	exc5	
  3111 000149F8 [030C0000]              	dd 	exc6	; 06h,  Invalid Opcode
  3112 000149FC [070C0000]              	dd	exc7	
  3113 00014A00 [0B0C0000]              	dd	exc8	
  3114 00014A04 [0F0C0000]              	dd	exc9	
  3115 00014A08 [130C0000]              	dd 	exc10	
  3116 00014A0C [170C0000]              	dd	exc11
  3117 00014A10 [1B0C0000]              	dd	exc12
  3118 00014A14 [1F0C0000]              	dd	exc13	; 0Dh, General Protection Fault
  3119 00014A18 [230C0000]              	dd 	exc14	; 0Eh, Page Fault
  3120 00014A1C [270C0000]              	dd	exc15
  3121 00014A20 [2B0C0000]              	dd	exc16
  3122 00014A24 [2F0C0000]              	dd	exc17
  3123 00014A28 [330C0000]              	dd 	exc18
  3124 00014A2C [370C0000]              	dd	exc19
  3125 00014A30 [3B0C0000]              	dd 	exc20
  3126 00014A34 [3F0C0000]              	dd	exc21
  3127 00014A38 [430C0000]              	dd	exc22
  3128 00014A3C [470C0000]              	dd	exc23
  3129 00014A40 [4B0C0000]              	dd 	exc24
  3130 00014A44 [4F0C0000]              	dd	exc25
  3131 00014A48 [530C0000]              	dd	exc26
  3132 00014A4C [570C0000]              	dd	exc27
  3133 00014A50 [5B0C0000]              	dd 	exc28
  3134 00014A54 [5F0C0000]              	dd	exc29
  3135 00014A58 [630C0000]              	dd 	exc30
  3136 00014A5C [670C0000]              	dd	exc31
  3137                                  IRQ_list: ; 28/02/2017 ('syscalbac')
  3138                                  	; Interrupt list
  3139 00014A60 [56090000]              	dd	timer_int	; INT 20h
  3140                                  		;dd	irq0	
  3141 00014A64 [CE100000]              	dd	kb_int		; 24/01/2016
  3142                                  		;dd	irq1
  3143 00014A68 [380B0000]              	dd	irq2
  3144                                  		; COM2 int
  3145 00014A6C [3C0B0000]              	dd	irq3
  3146                                  		; COM1 int
  3147 00014A70 [470B0000]              	dd	irq4
  3148 00014A74 [520B0000]              	dd	irq5
  3149                                  ;DISKETTE_INT: ;06/02/2015
  3150 00014A78 [D3510000]              	dd	fdc_int		; 16/02/2015, IRQ 6 handler	
  3151                                  		;dd	irq6
  3152                                  ; Default IRQ 7 handler against spurious IRQs (from master PIC)
  3153                                  ; 25/02/2015 (source: http://wiki.osdev.org/8259_PIC)
  3154 00014A7C [C10E0000]              	dd	default_irq7	; 25/02/2015
  3155                                  		;dd	irq7
  3156                                  ; Real Time Clock Interrupt
  3157 00014A80 [C10A0000]              	dd	rtc_int		; 23/02/2015, IRQ 8 handler
  3158                                  		;dd	irq8	; INT 28h
  3159 00014A84 [620B0000]              	dd	irq9
  3160 00014A88 [660B0000]              	dd	irq10
  3161 00014A8C [6A0B0000]              	dd	irq11
  3162 00014A90 [6E0B0000]              	dd	irq12
  3163 00014A94 [720B0000]              	dd	irq13
  3164                                  ;HDISK_INT1:  ;06/02/2015 	
  3165 00014A98 [865B0000]              	dd	hdc1_int 	; 21/02/2015, IRQ 14 handler		
  3166                                  		;dd	irq14
  3167                                  ;HDISK_INT2:  ;06/02/2015
  3168 00014A9C [AD5B0000]              	dd	hdc2_int 	; 21/02/2015, IRQ 15 handler		
  3169                                  		;dd	irq15	; INT 2Fh
  3170                                  		; 14/08/2015
  3171                                  	;dd	sysent		; INT 30h (system calls)
  3172                                  
  3173                                  	; 15/04/2016
  3174                                  	; TRDOS 386(TRDOS v2.0) Software Interrupts
  3175                                  
  3176 00014AA0 [FD4A0100]              	dd	int30h		; Reserved for
  3177                                  				; !!! Retro UNIX (RUNIX) !!!
  3178                                  				; !!! SINGLIX !!! System Calls
  3179 00014AA4 [C1170000]              	dd	int31h		; Video BIOS (IBM PC/AT, Int 10h)
  3180 00014AA8 [ED0E0000]              	dd	int32h		; Keyboard Functions (IBM PC/AT, Int 16h)
  3181 00014AAC [8A520000]              	dd	int33h		; DISK I/O (IBM PC/AT, Int 13h)
  3182 00014AB0 [F82C0100]              	dd	int34h		; #IOCTL# (I/O port access support for ring 3)
  3183 00014AB4 [3E6A0000]              	dd	int35h		; Time/Date Functions (IBM PC/AT, Int 1Ah)
  3184 00014AB8 [750D0000]              	dd	ignore_int	; INT 36h : Timer Functions	
  3185 00014ABC [750D0000]              	dd	ignore_int	; INT 37h	
  3186 00014AC0 [750D0000]              	dd	ignore_int	; INT 38h
  3187 00014AC4 [750D0000]              	dd	ignore_int	; INT 39h
  3188 00014AC8 [750D0000]              	dd	ignore_int	; INT 3Ah	
  3189 00014ACC [750D0000]              	dd	ignore_int	; INT 3Bh
  3190 00014AD0 [750D0000]              	dd	ignore_int	; INT 3Ch
  3191 00014AD4 [750D0000]              	dd	ignore_int	; INT 3Dh	
  3192 00014AD8 [750D0000]              	dd	ignore_int	; INT 3Eh
  3193 00014ADC [750D0000]              	dd	ignore_int	; INT 3Fh
  3194 00014AE0 [AAD70000]              	dd	sysent		; INT 40h : !!! TRDOS 386 System Calls !!!
  3195                                  	;dd	ignore_int
  3196 00014AE4 00000000                	dd	0
  3197                                  
  3198                                  ; 20/08/2014
  3199                                    ; /* This is the default interrupt "handler" :-) */ 
  3200                                    ; Linux v0.12 (head.s)
  3201                                  int_msg:
  3202 00014AE8 556E6B6E6F776E2069-     	db "Unknown interrupt ! ", 0
  3202 00014AF1 6E7465727275707420-
  3202 00014AFA 212000             
  3203                                  
  3204                                  ; 15/04/2016
  3205                                  ; TRDOS 386 (TRDOS v2.0)
  3206                                  
  3207                                  ; 29/04/2016
  3208                                  int30h:
  3209                                  trdos_isc_routine:
  3210                                  	; 02/05/2016
  3211                                  	; 01/05/2016
  3212                                  	; 29/04/2016
  3213                                  	; 18/04/2016
  3214                                  	; 15/04/2016 (TRDOS 386 = TRDOS v2.0)
  3215                                  	; 17/04/2011 (TRDOS v1.0, 'IFC.ASM')
  3216                                  	; 03/02/2011 ('trdos_ifc_routine')
  3217                                  	;
  3218 00014AFD 8B1C24                  	mov	ebx, [esp] ; EIP (next)
  3219 00014B00 83EB02                  	sub	ebx, 2 ; EIP (CD ##h)
  3220                                  
  3221 00014B03 89C1                    	mov	ecx, eax
  3222 00014B05 8A4301                  	mov	al, [ebx+1] ; CDh ##h
  3223                                  
  3224 00014B08 66BA1000                	mov	dx, KDATA
  3225 00014B0C 8EDA                    	mov	ds, dx
  3226 00014B0E 8EC2                    	mov	es, dx
  3227                                  
  3228 00014B10 FC                      	cld
  3229 00014B11 8B15[D0890100]          	mov	edx, [k_page_dir]
  3230 00014B17 0F22DA                  	mov	cr3, edx
  3231                                  
  3232 00014B1A E8AEF7FEFF              	call	bytetohex
  3233 00014B1F 66A3[55470100]          	mov	[int_num_str], ax
  3234                                  
  3235 00014B25 89D8                    	mov	eax, ebx ; EIP
  3236 00014B27 E8E1F7FEFF              	call	dwordtohex
  3237 00014B2C 8915[71470100]          	mov	[eip_str], edx
  3238 00014B32 A3[75470100]            	mov	[eip_str+4], eax
  3239                                  
  3240 00014B37 89C8                    	mov	eax, ecx
  3241 00014B39 E8CFF7FEFF              	call	dwordtohex
  3242 00014B3E 8915[60470100]          	mov	[eax_str], edx
  3243 00014B44 A3[64470100]            	mov	[eax_str+4], eax 	
  3244                                  
  3245 00014B49 43                      	inc	ebx
  3246 00014B4A 8A03                    	mov	al, [ebx] ; Interrupt number
  3247                                  
  3248                                  trdos_isc_handler:
  3249 00014B4C 80FE30                  	cmp	dh, 30h ; Retro UNIX, SINGLIX System calls
  3250 00014B4F 7507                    	jne	short trdos_usi_handler
  3251 00014B51 BE[F2460100]            	mov	esi, isc_msg
  3252 00014B56 EB05                    	jmp	short loc_write_inv_system_call_msg
  3253                                  
  3254                                  trdos_usi_handler:
  3255 00014B58 BE[08470100]            	mov	esi, usi_msg
  3256                                  
  3257                                  loc_write_inv_system_call_msg:
  3258 00014B5D E8F329FFFF              	call	print_msg
  3259                                  	; 29/04/2016
  3260 00014B62 BE[3E470100]            	mov	esi, inv_msg_for_trdos_v2
  3261 00014B67 E8E929FFFF              	call	print_msg
  3262                                  
  3263                                  loc_ifc_terminate_process:
  3264                                  	; u.uno = process number
  3265                                  	; 29/04/2016
  3266                                  
  3267                                  	; 02/05/2016
  3268 00014B6C FE05[5B030300]          	inc	byte [sysflg] ; 0FFh -> 0
  3269                                  
  3270 00014B72 B801000000              	mov	eax, 1
  3271 00014B77 E9078FFFFF              	jmp	sysexit
  3272                                  
  3273                                  ; 07/03/2015
  3274                                  ; Temporary Code
  3275                                  display_disks:
  3276 00014B7C 803D[FE6D0000]00        	cmp 	byte [fd0_type], 0
  3277 00014B83 7605                    	jna 	short ddsks1
  3278 00014B85 E87D000000              	call	pdskm
  3279                                  ddsks1:
  3280 00014B8A 803D[FF6D0000]00        	cmp	byte [fd1_type], 0
  3281 00014B91 760C                    	jna	short ddsks2
  3282 00014B93 C605[D74C0100]31        	mov	byte [dskx], '1'
  3283 00014B9A E868000000              	call	pdskm
  3284                                  ddsks2:
  3285 00014B9F 803D[006E0000]00        	cmp	byte [hd0_type], 0
  3286 00014BA6 7654                    	jna	short ddsk6
  3287 00014BA8 66C705[D54C0100]68-     	mov	word [dsktype], 'hd'
  3287 00014BB0 64                 
  3288 00014BB1 C605[D74C0100]30        	mov	byte [dskx], '0'
  3289 00014BB8 E84A000000              	call	pdskm
  3290                                  ddsks3:
  3291 00014BBD 803D[016E0000]00        	cmp	byte [hd1_type], 0
  3292 00014BC4 7636                    	jna	short ddsk6
  3293 00014BC6 C605[D74C0100]31        	mov	byte [dskx], '1'
  3294 00014BCD E835000000              	call	pdskm
  3295                                  ddsks4:
  3296 00014BD2 803D[026E0000]00        	cmp	byte [hd2_type], 0
  3297 00014BD9 7621                    	jna	short ddsk6
  3298 00014BDB C605[D74C0100]32        	mov	byte [dskx], '2'
  3299 00014BE2 E820000000              	call	pdskm
  3300                                  ddsks5:
  3301 00014BE7 803D[036E0000]00        	cmp	byte [hd3_type], 0
  3302 00014BEE 760C                    	jna	short ddsk6
  3303 00014BF0 C605[D74C0100]33        	mov	byte [dskx], '3'
  3304 00014BF7 E80B000000              	call	pdskm
  3305                                  ddsk6:
  3306 00014BFC BE[FF4C0100]            	mov	esi, nextline
  3307 00014C01 E806000000              	call	pdskml
  3308                                  pdskm_ok:
  3309 00014C06 C3                      	retn
  3310                                  pdskm:
  3311 00014C07 BE[D34C0100]            	mov	esi, dsk_ready_msg
  3312                                  pdskml:	
  3313 00014C0C AC                      	lodsb
  3314 00014C0D 08C0                    	or	al, al
  3315 00014C0F 74F5                    	jz	short pdskm_ok
  3316 00014C11 56                      	push	esi
  3317                                  	; 13/05/2016
  3318 00014C12 BB07000000                      mov     ebx, 7  ; Black background, 
  3319                                  			; light gray forecolor
  3320                                  			; Video page 0 (bh=0)
  3321 00014C17 E8E1D6FEFF              	call	_write_tty
  3322 00014C1C 5E                      	pop	esi
  3323 00014C1D EBED                    	jmp	short pdskml
  3324                                  
  3325 00014C1F 90                      Align 2
  3326                                  	; 21/08/2014
  3327                                  exc_msg:
  3328 00014C20 435055206578636570-     	db "CPU exception ! "
  3328 00014C29 74696F6E202120     
  3329                                  excnstr: 		; 25/08/2014
  3330 00014C30 3F3F68202045495020-     	db "??h", "  EIP : "
  3330 00014C39 3A20               
  3331                                  EIPstr: ; 29/08/2014
  3332 00014C3B 00<rept>                	times 12 db 0
  3333                                  
  3334                                  	; 23/02/2015
  3335                                  	; 25/08/2014
  3336                                  ;scounter:
  3337                                  ;	db 5
  3338                                  ;	db 19
  3339                                  
  3340                                  ; 06/11/2014
  3341                                  ; Memory Information message
  3342                                  ; 14/08/2015
  3343                                  msg_memory_info:
  3344 00014C47 07                      	db	07h
  3345 00014C48 0D0A                    	db	0Dh, 0Ah
  3346                                  	;db 	"MEMORY ALLOCATION INFO", 0Dh, 0Ah, 0Dh, 0Ah
  3347 00014C4A 546F74616C206D656D-     	db	"Total memory : "
  3347 00014C53 6F7279203A20       
  3348                                  mem_total_b_str: ; 10 digits
  3349 00014C59 303030303030303030-     	db	"0000000000 bytes", 0Dh, 0Ah
  3349 00014C62 302062797465730D0A 
  3350 00014C6B 202020202020202020-     	db	"               ", 20h, 20h, 20h
  3350 00014C74 202020202020202020 
  3351                                  mem_total_p_str: ; 7 digits
  3352 00014C7D 303030303030302070-     	db	"0000000 pages", 0Dh, 0Ah
  3352 00014C86 616765730D0A       
  3353 00014C8C 0D0A                    	db 	0Dh, 0Ah
  3354 00014C8E 46726565206D656D6F-     	db	"Free memory  : "
  3354 00014C97 727920203A20       
  3355                                  free_mem_b_str:  ; 10 digits
  3356 00014C9D 3F3F3F3F3F3F3F3F3F-     	db	"?????????? bytes", 0Dh, 0Ah
  3356 00014CA6 3F2062797465730D0A 
  3357 00014CAF 202020202020202020-     	db	"               ", 20h, 20h, 20h
  3357 00014CB8 202020202020202020 
  3358                                  free_mem_p_str:  ; 7 digits
  3359 00014CC1 3F3F3F3F3F3F3F2070-     	db	"??????? pages", 0Dh, 0Ah
  3359 00014CCA 616765730D0A       
  3360 00014CD0 0D0A00                  	db	0Dh, 0Ah, 0
  3361                                  
  3362                                  dsk_ready_msg:
  3363 00014CD3 0D0A                    	db 	0Dh, 0Ah
  3364                                  dsktype:
  3365 00014CD5 6664                    	db	'fd'
  3366                                  dskx:
  3367 00014CD7 30                      	db	'0'
  3368 00014CD8 20                      	db	20h
  3369 00014CD9 697320524541445920-     	db 	'is READY ...'
  3369 00014CE2 2E2E2E             
  3370 00014CE5 00                      	db 	0
  3371                                  
  3372                                  setup_error_msg:
  3373 00014CE6 0D0A                    	db 0Dh, 0Ah
  3374 00014CE8 4469736B2053657475-     	db 'Disk Setup Error !' 
  3374 00014CF1 70204572726F722021 
  3375 00014CFA 0D0A00                  	db 0Dh, 0Ah,0
  3376                                  
  3377                                  next2line: ; 08/02/2016
  3378 00014CFD 0D0A                    	db	0Dh, 0Ah
  3379                                  nextline:
  3380 00014CFF 0D0A00                  	db 	0Dh, 0Ah, 0
  3381                                  
  3382                                  ; temporary
  3383                                  ; 19/12/2020
  3384                                  msg_lfb_addr:
  3385                                  	;db	0Dh, 0Ah
  3386 00014D02 4C696E656172206672-     	db	"Linear frame buffer at "
  3386 00014D0B 616D65206275666665-
  3386 00014D14 7220617420         
  3387                                  lfb_addr_str: ; 8 (hex) digits
  3388 00014D19 303030303030303068-     	db	"00000000h", 0Dh, 0Ah
  3388 00014D22 0D0A               
  3389 00014D24 0D0A00                  	db	0Dh, 0Ah, 0
  3390                                  
  3391                                  ; KERNEL - SYSINIT Messages
  3392                                  ; 24/08/2015
  3393                                  ; 13/04/2015 - (Retro UNIX 386 v1 Beginning)
  3394                                  ; 14/07/2013
  3395                                  ;kernel_init_err_msg:
  3396                                  ;	db 0Dh, 0Ah
  3397                                  ;	db 07h
  3398                                  ;	db 'Kernel initialization ERROR !'
  3399                                  ;	db 0Dh, 0Ah, 0 
  3400                                  
  3401                                  ;welcome_msg: 
  3402                                  ;	db 0Dh, 0Ah
  3403                                  ;	db 07h
  3404                                  ;	db 'Welcome to TRDOS 386 Operating System !'
  3405                                  ;	db 0Dh, 0Ah
  3406                                  ;	db 'by Erdogan Tan - 31/12/2017 (v2.0.0)'
  3407                                  ;	db 0Dh, 0Ah, 0
  3408                                  
  3409                                  panic_msg:
  3410 00014D27 0D0A07                  	db 0Dh, 0Ah, 07h
  3411 00014D2A 4552524F523A204B65-     	db 'ERROR: Kernel Panic !'
  3411 00014D33 726E656C2050616E69-
  3411 00014D3C 632021             
  3412 00014D3F 0D0A00                  	db 0Dh, 0Ah, 0
  3413                                  
  3414                                  ;msgl_drv_not_ready: 
  3415                                  ;	db 07h, 0Dh, 0Ah
  3416                                  ;       db 'Drive not ready or read error !'
  3417                                  ;       db 0Dh, 0Ah, 0
  3418                                  
  3419                                  starting_msg:
  3420 00014D42 5475726B6973682052-     	db "Turkish Rational DOS v2.0 [27/02/2021] ...", 0
  3420 00014D4B 6174696F6E616C2044-
  3420 00014D54 4F532076322E30205B-
  3420 00014D5D 32372F30322F323032-
  3420 00014D66 315D202E2E2E00     
  3421                                  NextLine:
  3422 00014D6D 0D0A00                  	db 0Dh, 0Ah, 0
  3423                                  
  3424                                  %include 'audio.s' ; 03/04/2017
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.2 - audio.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 01/09/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 03/04/2017
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ****************************************************************************
    10                              <1> 
    11                              <1> ; AUDIO CONTROLLER & CODEC DEFINITIONS & CODE FOR TRDOS 386
    12                              <1> 
    13                              <1> ;=============================================================================
    14                              <1> ;               EQUATES
    15                              <1> ;=============================================================================
    16                              <1> 
    17                              <1> ; PCI EQUATES
    18                              <1> 
    19                              <1> BIT0  EQU 1
    20                              <1> BIT1  EQU 2
    21                              <1> BIT2  EQU 4
    22                              <1> BIT3  EQU 8
    23                              <1> BIT4  EQU 10h
    24                              <1> BIT5  EQU 20h
    25                              <1> BIT6  EQU 40h
    26                              <1> BIT7  EQU 80h
    27                              <1> BIT8  EQU 100h
    28                              <1> BIT9  EQU 200h
    29                              <1> BIT10 EQU 400h
    30                              <1> BIT11 EQU 800h
    31                              <1> BIT12 EQU 1000h
    32                              <1> BIT13 EQU 2000h
    33                              <1> BIT14 EQU 4000h
    34                              <1> BIT15 EQU 8000h
    35                              <1> BIT16 EQU 10000h
    36                              <1> BIT17 EQU 20000h
    37                              <1> BIT18 EQU 40000h
    38                              <1> BIT19 EQU 80000h
    39                              <1> BIT20 EQU 100000h
    40                              <1> BIT21 EQU 200000h
    41                              <1> BIT22 EQU 400000h
    42                              <1> BIT23 EQU 800000h
    43                              <1> BIT24 EQU 1000000h
    44                              <1> BIT25 EQU 2000000h
    45                              <1> BIT26 EQU 4000000h
    46                              <1> BIT27 EQU 8000000h
    47                              <1> BIT28 EQU 10000000h
    48                              <1> BIT29 EQU 20000000h
    49                              <1> BIT30 EQU 40000000h
    50                              <1> BIT31 EQU 80000000h
    51                              <1> NOT_BIT31 EQU 7FFFFFFFh
    52                              <1> 
    53                              <1> ; PCI equates
    54                              <1> ; PCI function address (PFA)
    55                              <1> ; bit 31 = 1
    56                              <1> ; bit 23:16 = bus number     (0-255)
    57                              <1> ; bit 15:11 = device number  (0-31)
    58                              <1> ; bit 10:8 = function number (0-7)
    59                              <1> ; bit 7:0 = register number  (0-255)
    60                              <1> 
    61                              <1> IO_ADDR_MASK    EQU     0FFFEh	; mask off bit 0 for reading BARs
    62                              <1> PCI_INDEX_PORT  EQU     0CF8h
    63                              <1> PCI_DATA_PORT   EQU     0CFCh
    64                              <1> PCI32           EQU     BIT31	; bitflag to signal 32bit access
    65                              <1> PCI16           EQU     BIT30	; bitflag for 16bit access
    66                              <1> NOT_PCI32_PCI16	EQU	03FFFFFFFh ; NOT BIT31+BIT30 ; 19/03/2017
    67                              <1> 
    68                              <1> PCI_FN0         EQU     0 << 8
    69                              <1> PCI_FN1         EQU     1 << 8
    70                              <1> PCI_FN2         EQU     2 << 8
    71                              <1> PCI_FN3         EQU     3 << 8
    72                              <1> PCI_FN4         EQU     4 << 8
    73                              <1> PCI_FN5         EQU     5 << 8
    74                              <1> PCI_FN6         EQU     6 << 8
    75                              <1> PCI_FN7         EQU     7 << 8
    76                              <1> 
    77                              <1> PCI_CMD_REG	EQU	04h	; reg 04, command reg
    78                              <1> IO_ENA		EQU	BIT0	; i/o decode enable
    79                              <1> MEM_ENA		EQU	BIT1	; memory decode enable
    80                              <1> BM_ENA		EQU     BIT2	; bus master enable
    81                              <1> 
    82                              <1> ; VIA VT8233 EQUATES
    83                              <1> 
    84                              <1> VIA_VID		equ 1106h	; VIA's PCI vendor ID
    85                              <1> VT8233_DID      equ 3059h	; VT8233 (VT8235) device ID
    86                              <1> 		
    87                              <1> PCI_IO_BASE          equ 10h
    88                              <1> AC97_INT_LINE        equ 3Ch
    89                              <1> VIA_ACLINK_CTRL      equ 41h
    90                              <1> VIA_ACLINK_STAT      equ 40h
    91                              <1> VIA_ACLINK_C00_READY equ 01h ; primary codec ready
    92                              <1> 	
    93                              <1> VIA_REG_AC97	     equ 80h ; dword
    94                              <1> 
    95                              <1> VIA_ACLINK_CTRL_ENABLE	equ   80h ; 0: disable, 1: enable
    96                              <1> VIA_ACLINK_CTRL_RESET	equ   40h ; 0: assert, 1: de-assert
    97                              <1> VIA_ACLINK_CTRL_SYNC	equ   20h ; 0: release SYNC, 1: force SYNC hi
    98                              <1> VIA_ACLINK_CTRL_VRA	equ   08h ; 0: disable VRA, 1: enable VRA
    99                              <1> VIA_ACLINK_CTRL_PCM	equ   04h ; 0: disable PCM, 1: enable PCM
   100                              <1> 					; 3D Audio Channel slots 3/4
   104                              <1> VIA_ACLINK_CTRL_INIT	equ  (VIA_ACLINK_CTRL_ENABLE +                               VIA_ACLINK_CTRL_RESET +                               VIA_ACLINK_CTRL_PCM +                               VIA_ACLINK_CTRL_VRA)
   105                              <1> 
   106                              <1> CODEC_AUX_VOL		equ   04h
   107                              <1> VIA_REG_AC97_BUSY	equ   01000000h ;(1<<24) 
   108                              <1> VIA_REG_AC97_CMD_SHIFT	equ   10h ; 16
   109                              <1> VIA_REG_AC97_PRIMARY_VALID equ 02000000h ;(1<<25)
   110                              <1> VIA_REG_AC97_READ	equ   00800000h ;(1<<23)
   111                              <1> VIA_REG_AC97_CODEC_ID_SHIFT   equ  1Eh ; 30
   112                              <1> VIA_REG_AC97_CODEC_ID_PRIMARY equ  0
   113                              <1> VIA_REG_AC97_DATA_SHIFT equ   0
   114                              <1> VIADEV_PLAYBACK         equ   0
   115                              <1> VIA_REG_OFFSET_STATUS   equ   0    ;; byte - channel status
   116                              <1> VIA_REG_OFFSET_CONTROL  equ   01h  ;; byte - channel control
   117                              <1> VIA_REG_CTRL_START	equ   80h  ;; WO
   118                              <1> VIA_REG_CTRL_TERMINATE  equ   40h  ;; WO
   119                              <1> VIA_REG_CTRL_PAUSE      equ   08h  ;; RW
   120                              <1> VIA_REG_CTRL_RESET      equ   01h  ;; RW - probably reset? undocumented
   121                              <1> VIA_REG_OFFSET_STOP_IDX equ   08h  ;; dword - stop index, channel type, sample rate
   122                              <1> VIA8233_REG_TYPE_16BIT  equ   200000h ;; RW
   123                              <1> VIA8233_REG_TYPE_STEREO equ   100000h ;; RW
   124                              <1> VIA_REG_OFFSET_CURR_INDEX equ 0Fh ;; byte - channel current index (for via8233 only)
   125                              <1> VIA_REG_OFFSET_TABLE_PTR equ  04h  ;; dword - channel table pointer
   126                              <1> VIA_REG_OFFSET_CURR_PTR equ   04h  ;; dword - channel current pointer
   127                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_L equ  02h ;; byte
   128                              <1> VIA_REG_OFS_PLAYBACK_VOLUME_R equ  03h ;; byte
   129                              <1> VIA_REG_CTRL_AUTOSTART	equ   20h
   130                              <1> VIA_REG_CTRL_INT_EOL	equ   02h
   131                              <1> VIA_REG_CTRL_INT_FLAG	equ   01h
   134                              <1> VIA_REG_CTRL_INT	equ  (VIA_REG_CTRL_INT_FLAG +                               VIA_REG_CTRL_INT_EOL +                               VIA_REG_CTRL_AUTOSTART)
   135                              <1> 
   136                              <1> VIA_REG_STAT_STOP_IDX	equ   10h    ;; RO ; 27/07/2020
   137                              <1> 				     ; current index = stop index
   138                              <1> VIA_REG_STAT_STOPPED	equ   04h    ;; RWC
   139                              <1> VIA_REG_STAT_EOL	equ   02h    ;; RWC
   140                              <1> VIA_REG_STAT_FLAG	equ   01h    ;; RWC
   141                              <1> VIA_REG_STAT_ACTIVE	equ   80h    ;; RO
   142                              <1> ; 28/11/2016
   143                              <1> VIA_REG_STAT_LAST	equ   40h    ;; RO
   144                              <1> VIA_REG_STAT_TRIGGER_QUEUED equ 08h  ;; RO
   145                              <1> VIA_REG_CTRL_INT_STOP	equ   04h  ; Interrupt on Current Index = Stop Index
   146                              <1> 		   		   ; and End of Block
   147                              <1> 
   148                              <1> VIA_REG_OFFSET_CURR_COUNT equ 0Ch ;; dword - channel current count, index
   149                              <1> 
   150                              <1> PORTB		EQU	061h
   151                              <1> REFRESH_STATUS	EQU	010h	; Refresh signal status
   152                              <1> 
   153                              <1> ; AC97 Codec registers.
   154                              <1> 
   155                              <1> ; 22/07/2020
   156                              <1> ; REALTEK ALC655 and ADI SOUNDMAX AD1980 CODEC MIXER REGISTERS
   157                              <1> 
   158                              <1> ; each codec/mixer register is 16bits
   159                              <1> 
   160                              <1> CODEC_RESET_REG                 equ     00h	; reset codec
   161                              <1> CODEC_MASTER_VOL_REG            equ     02h	; master volume
   162                              <1> CODEC_HP_VOL_REG                equ     04h	; headphone volume ; AD1980
   163                              <1> CODEC_MASTER_MONO_VOL_REG       equ     06h	; master mono volume (mono-out)
   164                              <1> ;CODEC_MASTER_TONE_REG          equ     08h	; master tone (R+L) ; (not used)
   165                              <1> CODEC_PCBEEP_VOL_REG            equ     0Ah	; PC beep volume ; ALC655
   166                              <1> CODEC_PHONE_VOL_REG             equ     0Ch	; phone volume
   167                              <1> CODEC_MIC_VOL_REG               equ     0Eh	; mic volume
   168                              <1> CODEC_LINE_IN_VOL_REG           equ     10h	; line in volume
   169                              <1> CODEC_CD_VOL_REG                equ     12h	; CD volume
   170                              <1> ;CODEC_VID_VOL_REG              equ     14h	; video volume ; (not used)
   171                              <1> CODEC_AUX_VOL_REG               equ     16h	; aux volume
   172                              <1> CODEC_PCM_OUT_REG               equ     18h	; PCM out volume
   173                              <1> CODEC_RECORD_SELECT_REG         equ     1Ah	; record select
   174                              <1> CODEC_RECORD_VOL_REG            equ     1Ch	; record volume (record gain)
   175                              <1> ;CODEC_RECORD_MIC_VOL_REG       equ     1Eh	; record mic volume ; (not used)
   176                              <1> CODEC_GP_REG                    equ     20h	; general purpose
   177                              <1> ;CODEC_3D_CONTROL_REG           equ     22h	; 3D control
   178                              <1> ;;CODEC_AUDIO_INT_PAGING_REG    equ	24h	; audio int & paging ; (not used) 
   179                              <1> CODEC_POWER_CTRL_REG            equ     26h	; power down control
   180                              <1> CODEC_EXT_AUDIO_REG             equ     28h	; extended audio ID
   181                              <1> CODEC_EXT_AUDIO_CTRL_REG        equ     2Ah	; extended audio status/control
   182                              <1> CODEC_PCM_FRONT_DACRATE_REG     equ     2Ch	; PCM front sample rate
   183                              <1> CODEC_PCM_SURND_DACRATE_REG     equ     2Eh	; PCM surround sample rate
   184                              <1> CODEC_PCM_LFE_DACRATE_REG       equ     30h	; PCM Center/LFE sample rate
   185                              <1> CODEC_LR_ADCRATE_REG            equ     32h	; PCM input sample rate
   186                              <1> CODEC_MIC_ADCRATE_REG           equ     34h	; mic in sample rate  ; AD1980
   187                              <1> CODEC_PCM_LFE_VOL_REG           equ     36h	; PCM Center/LFE volume
   188                              <1> CODEC_PCM_SURND_VOL_REG         equ     38h	; PCM surround volume
   189                              <1> ;CODEC_SPDIF_CTRL_REG           equ     3Ah	; S/PDIF control
   190                              <1> ; 22/07/2020
   191                              <1> CODEC_MISC_CRTL_BITS_REG	equ	76h	; misc control bits ; AD1980
   192                              <1> ;	
   193                              <1> CODEC_VENDOR_ID1		equ	7Ch	; REALTEK: 414Ch, ADI: 4144h	
   194                              <1> CODEC_VENDOR_ID2		equ	7Eh	; REALTEK: 4760h, ADI: 5370h	
   195                              <1> 
   196                              <1> ; VT8233 SGD bits (21/04/2017)
   197                              <1> FLAG	EQU BIT30
   198                              <1> EOL	EQU BIT31
   199                              <1> 
   200                              <1> ; INTEL ICH EQUATES
   201                              <1> ; 28/05/2017
   202                              <1> INTEL_VID	equ	8086h	; Intel's PCI vendor ID
   203                              <1> ICH_DID		equ	2415h	; ICH (82801AA) device ID
   204                              <1> NAMBAR_REG      equ	10h	; native audio mixer Base Address Register
   205                              <1> NABMBAR_REG     equ	14h	; native audio bus mastering Base Addr Reg
   206                              <1> 
   207                              <1> PI_CR_REG       equ     0Bh     ; PCM in Control Register
   208                              <1> PO_CR_REG	equ     1Bh     ; PCM out Control Register
   209                              <1> MC_CR_REG	equ     2Bh     ; MIC in Control Register
   210                              <1> 
   211                              <1> PI_SR_REG	equ     6       ; PCM in Status register
   212                              <1> PO_SR_REG	equ     16h     ; PCM out Status register
   213                              <1> MC_SR_REG	equ     26h     ; MIC in Status register
   214                              <1> 
   215                              <1> IOCE 		equ     BIT4    ; interrupt on complete enable.
   216                              <1> FEIFE		equ     BIT3    ; set if you want an interrupt to fire
   217                              <1> LVBIE		equ     BIT2    ; last valid buffer interrupt enable.
   218                              <1> RR 		equ     BIT1    ; reset registers. Nukes all regs
   219                              <1>                                 ; except bits 4:2 of this register.
   220                              <1>                                 ; Only set this bit if BIT 0 is 0
   221                              <1> RPBM		equ     BIT0    ; Run/Pause
   222                              <1> 				; set this bit to start the codec!
   223                              <1> 
   224                              <1> PI_BDBAR_REG	equ     0       ; PCM in buffer descriptor BAR
   225                              <1> PO_BDBAR_REG	equ     10h     ; PCM out buffer descriptor BAR
   226                              <1> MC_BDBAR_REG	equ     20h     ; MIC in buffer descriptor BAR
   227                              <1> 
   228                              <1> PI_CIV_REG	equ     4       ; PCM in current Index value (RO)
   229                              <1> PO_CIV_REG	equ     14h     ; PCM out current Index value (RO)
   230                              <1> MC_CIV_REG 	equ     24h     ; MIC in current Index value (RO)
   231                              <1> 
   232                              <1> PI_LVI_REG	equ     5       ; PCM in Last Valid Index
   233                              <1> PO_LVI_REG	equ     15h     ; PCM out Last Valid Index
   234                              <1> MC_LVI_REG	equ     25h     ; MIC in Last Valid Index
   235                              <1> 
   236                              <1> IOC		equ     BIT31	; Fire an interrupt whenever this
   237                              <1>                 		; buffer is complete.
   238                              <1> BUP		equ     BIT30	; Buffer Underrun Policy.
   239                              <1> 
   240                              <1> GLOB_CNT_REG	equ     2Ch     ; Global Control Register
   241                              <1> GLOB_STS_REG	equ     30h     ; Global Status register (RO)
   242                              <1> 
   243                              <1> CTRL_ST_CREADY	equ   BIT8+BIT9+BIT28 ; Primary Codec Ready
   244                              <1> 
   245                              <1> CODEC_REG_POWERDOWN   equ 26h
   246                              <1> CODEC_REG_ST          equ 26h
   247                              <1> 
   248                              <1> ; 22/06/2017
   249                              <1> PO_PICB_REG	equ 18h	; PCM Out Position In Current Buffer Register
   250                              <1> 
   251                              <1> ;=============================================================================
   252                              <1> ;               CODE
   253                              <1> ;=============================================================================
   254                              <1> 
   255                              <1> ; CODE for INTEL ICH AC'97 AUDIO CONTROLLER
   256                              <1> 
   257                              <1> DetectICH:
   258                              <1> 	; 10/06/2017
   259                              <1> 	; 05/06/2017
   260                              <1> 	; 29/05/2017
   261                              <1> 	; 28/05/2017
   262 00014D70 B886801524          <1> 	mov     eax, (ICH_DID << 16) + INTEL_VID
   263 00014D75 E876000000          <1>         call    pciFindDevice
   264 00014D7A 730D                <1>         jnc     short d_ac97_1
   265                              <1> d_ac97_0:
   266                              <1> ; couldn't find the audio device!
   267 00014D7C C3                  <1> 	retn
   268                              <1> 
   269                              <1> ; CODE for VIA VT8233 AUDIO CONTROLLER
   270                              <1> 
   271                              <1> DetectVT8233:
   272                              <1> 	; 10/06/2017
   273                              <1> 	; 05/06/2017
   274                              <1> 	; 29/05/2017
   275                              <1> 	; 03/04/2017
   276 00014D7D B806115930          <1> 	mov     eax, (VT8233_DID << 16) + VIA_VID
   277 00014D82 E869000000          <1>         call    pciFindDevice
   278                              <1> ;       jnc     short d_vt8233_0
   279                              <1> ; couldn't find the audio device!
   280                              <1> ;	retn
   281 00014D87 72F3                <1> 	jc	short d_ac97_0  ; 28/05/2017
   282                              <1> d_vt8233_0:
   283                              <1> 	; 24/03/2017 ('player.asm')
   284                              <1> 	; 12/11/2016 
   285                              <1> 	; Erdogan Tan - 8/11/2016
   286                              <1> 	; References: Kolibrios - vt823x.asm (2016)
   287                              <1> 	;	      VIA VT8235 V-Link South Bridge (VT8235-VIA.PDF)(2002)
   288                              <1> 	;	      lowlevel.eu - AC97 (2016)
   289                              <1> 	;	      .wav player for DOS by Jeff Leyda (2002) -this file-
   290                              <1> 	;	      Linux kernel - via82xx.c (2016)
   291                              <1> d_ac97_1:
   292                              <1> 	; eax = BUS/DEV/FN
   293                              <1> 	;	00000000BBBBBBBBDDDDDFFF00000000
   294                              <1> 	; edx = DEV/VENDOR
   295                              <1> 	;	DDDDDDDDDDDDDDDDVVVVVVVVVVVVVVVV
   296                              <1> 
   297 00014D89 A3[589C0100]        <1> 	mov	[audio_dev_id], eax
   298 00014D8E 8915[5C9C0100]      <1> 	mov	[audio_vendor], edx
   299                              <1> 
   300                              <1> 	; init controller
   301 00014D94 B004                <1> 	mov	al, PCI_CMD_REG ; command register (04h)
   302 00014D96 E8E2000000          <1> 	call	pciRegRead32
   303                              <1> 
   304                              <1> 	; eax = BUS/DEV/FN/REG
   305                              <1> 	; edx = STATUS/COMMAND
   306                              <1> 	; 	SSSSSSSSSSSSSSSSCCCCCCCCCCCCCCCC
   307 00014D9B 8915[609C0100]      <1> 	mov	[audio_stats_cmd], edx
   308                              <1> 
   309 00014DA1 B010                <1> 	mov	al, PCI_IO_BASE ; IO base address register (10h)
   310                              <1> 	;mov	al, NAMBAR_REG	; Native Audio Mixer BAR (10h)
   311 00014DA3 E8D5000000          <1> 	call	pciRegRead32
   312                              <1> 
   313 00014DA8 66813D[5C9C0100]86- <1> 	cmp	word [audio_vendor], 8086h ; AC'97 ?
   313 00014DB0 80                  <1>
   314 00014DB1 751F                <1> 	jne	short d_vt8233_1
   315                              <1> 
   316 00014DB3 6683E2FE            <1> 	and	dx, 0FFFEh ; Audio Codec IO_ADDR_MASK
   317 00014DB7 668915[889C0100]    <1> 	mov	[NAMBAR], dx
   318                              <1> 
   319 00014DBE B014                <1> 	mov	al, NABMBAR_REG ; Native Audio Bus Mastering BAR (14h)
   320 00014DC0 E8B8000000          <1> 	call	pciRegRead32	
   321                              <1> 
   322 00014DC5 6683E2C0            <1> 	and	dx, 0FFC0h ; Audio Controller IO_ADDR_MASK
   323 00014DC9 668915[8A9C0100]    <1> 	mov	[NABMBAR], dx
   324                              <1>         ;mov	[audio_io_base], dx
   325                              <1> 	
   326 00014DD0 EB0B                <1> 	jmp	short d_ac97_2
   327                              <1> 
   328                              <1> d_vt8233_1:
   329 00014DD2 6683E2C0            <1> 	and     dx, 0FFC0h ; Audio Controller IO_ADDR_MASK 
   330 00014DD6 668915[569C0100]    <1>         mov     [audio_io_base], dx
   331                              <1> 
   332                              <1> d_ac97_2:
   333                              <1> 	; 10/06/2017
   334 00014DDD B03C                <1> 	mov	al, AC97_INT_LINE ; Interrupt Line Register (3Ch)
   335                              <1> 	;call	pciRegRead32
   336 00014DDF E886000000          <1> 	call	pciRegRead8
   337                              <1> 
   338                              <1> 	;and 	edx, 0FFh
   339 00014DE4 6681E2FF00          <1> 	and	dx, 0FFh
   340                              <1> 
   341 00014DE9 8815[539C0100]      <1>   	mov     [audio_intr], dl
   342                              <1> 
   343 00014DEF C3                  <1> 	retn
   344                              <1> 
   345                              <1> 	;; (Note: Interrupts are already enabled by TRDOS 386 kernel!)
   346                              <1> 	;mov	cx, dx
   347                              <1> 	
   348                              <1> 	;in	al, 0A1h ; irq 8-15
   349                              <1> 	;mov	ah, al
   350                              <1> 	;in	al, 21h  ; irq 0-7 
   351                              <1> 	;btr	ax, dx	 ; unmask ; 17/03/2017
   352                              <1> 	;;bts	ax, dx   ; MASK interrupt ; 10/06/2017 
   353                              <1> 	;out	21h, al  ; irq <= 7
   354                              <1> 	;mov	al, ah
   355                              <1> 	;out	0A1h, al ; irq > 7
   356                              <1> 	;
   357                              <1> 	
   358                              <1> 	; 10/06/2017
   359                              <1> 	; === Intel ICH I/O Controller Hub Datasheet, Section 8.1.16 ===
   360                              <1> 	; PRQ[n]_ROUT Register (61h, PRQB) Bit 7:
   361                              <1> 	; Interrupt Routing Enable (IRQEN).
   362                              <1> 	; 0 = The corresponding PIRQ is routed to one of the ISA-compatible
   363                              <1> 	;     interrupts specified in bits[3:0].
   364                              <1> 	; 1 = The PIRQ is not routed to the 8259.
   365                              <1> 	; Note: If the PIRQ is intended to cause an interrupt to the ICHs 
   366                              <1> 	;	integrated I/O APIC, then this bit should be set to 0 and 
   367                              <1> 	;	the APIC_EN bit should be set to 1. 
   368                              <1> 	;	The IRQEN must be set to 0 and the PIRQ routed to 
   369                              <1> 	;	an 8259 interrupt via the IRQ Routing filed (bits[3:0).
   370                              <1> 	;	The corresponding 8259 interrupt must be masked via the 
   371                              <1> 	;	appropriated bit in the 8259s OCW1 (Interrupt Mask)
   372                              <1> 	;	register. The IOAPIC must then be enabled by setting 
   373                              <1> 	;	the APIC_EN bit in the GEN_CNTL register.
   374                              <1> 
   375                              <1> 	;mov	eax, 0F861h  ; D31:F0
   376                              <1> 		;AL=61h : PIRQ[B] Routing Control Reg, LPC interface
   377                              <1> 	;;mov	dl, [audio_intr]
   378                              <1> 	;call	pciRegWrite8
   379                              <1> 	;;mov	al, 0D0h ; General Control Register (GEN_CTL)
   380                              <1> 	;;call	pciRegRead32
   381                              <1> 	;;or	edx, 100h ; Bit 8, APIC_EN (Enable I/O APIC) 
   382                              <1> 	;;;call	pciRegWrite32
   383                              <1> 	;;and	edx, ~100h
   384                              <1> 	;;call	pciRegWrite32 ; ; Bit 8, APIC_EN (Disable I/O APIC) 
   385                              <1> 	;
   386                              <1> 
   387                              <1> 	;mov	dx, 4D1h	; 8259 ELCR2
   388                              <1>     	;in	al, dx
   389                              <1> 	;mov	ah, al
   390                              <1> 	;;mov	dx, 4D0h 	; 8259 ELCR1
   391                              <1> 	;dec	dl
   392                              <1> 	;in	al, dx
   393                              <1> 	;bts	ax, cx
   394                              <1> 	;;mov	dx, 4D0h
   395                              <1> 	;out	dx, al		; set level-triggered mode
   396                              <1> 	;mov	al, ah ; 29/05/2017
   397                              <1> 	;;mov	dx, 4D1h
   398                              <1> 	;inc	dl
   399                              <1> 	;out	dx, al		; set level-triggered mode
   400                              <1> 
   401                              <1> 	;xor	eax, eax ; 0
   402                              <1> 
   403                              <1> 	;retn
   404                              <1> 
   405                              <1> ; CODE for PCI
   406                              <1> 
   407                              <1> pciFindDevice:
   408                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
   409                              <1> 	;
   410                              <1> 	; scan through PCI space looking for a device+vendor ID
   411                              <1> 	;
   412                              <1> 	; Entry: EAX=Device+Vendor ID
   413                              <1> 	;
   414                              <1> 	; Exit: EAX=PCI address if device found
   415                              <1> 	;	 EDX=Device+Vendor ID
   416                              <1> 	;        CY clear if found, set if not found. EAX invalid if CY set.
   417                              <1> 	;
   418                              <1> 	; Destroys: ebx, esi, edi, cl
   419                              <1> 	;
   420                              <1> 
   421                              <1> 	;push	ecx
   422 00014DF0 50                  <1> 	push	eax
   423                              <1> 	;push	esi
   424                              <1> 	;push	edi
   425                              <1> 
   426 00014DF1 89C6                <1>         mov     esi, eax                ; save off vend+device ID
   427 00014DF3 BF00FFFF7F          <1>         mov     edi, (80000000h - 100h) ; start with bus 0, dev 0 func 0
   428                              <1> 
   429                              <1> nextPCIdevice:
   430 00014DF8 81C700010000        <1>         add     edi, 100h
   431 00014DFE 81FF00F8FF80        <1>         cmp     edi, 80FFF800h		; scanned all devices?
   432 00014E04 F9                  <1>         stc
   433 00014E05 740C                <1>         je      short PCIScanExit       ; not found
   434                              <1> 
   435 00014E07 89F8                <1>         mov     eax, edi                ; read PCI registers
   436 00014E09 E86F000000          <1>         call    pciRegRead32
   437 00014E0E 39F2                <1>         cmp     edx, esi                ; found device?
   438 00014E10 75E6                <1>         jne     short nextPCIdevice
   439 00014E12 F8                  <1>         clc
   440                              <1> 
   441                              <1> PCIScanExit:
   442 00014E13 9C                  <1> 	pushf
   443 00014E14 B8FFFFFF7F          <1> 	mov	eax, NOT_BIT31 	; 19/03/2017
   444 00014E19 21F8                <1> 	and	eax, edi	; return only bus/dev/fn #
   445 00014E1B 9D                  <1> 	popf
   446                              <1> 
   447                              <1> 	;pop	edi
   448                              <1> 	;pop	esi
   449 00014E1C 5A                  <1> 	pop	edx
   450                              <1> 	;pop	ecx
   451 00014E1D C3                  <1> 	retn
   452                              <1> 
   453                              <1> pciRegRead:
   454                              <1> 	; 03/04/2017 ('pci.asm', 20/03/2017)
   455                              <1> 	;
   456                              <1> 	; 8/16/32bit PCI reader
   457                              <1> 	;
   458                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
   459                              <1> 	;           BIT30 set if 32 bit access requested
   460                              <1> 	;           BIT29 set if 16 bit access requested
   461                              <1> 	;           otherwise defaults to 8 bit read
   462                              <1> 	;
   463                              <1> 	; Exit:  DL,DX,EDX register data depending on requested read size
   464                              <1> 	;
   465                              <1> 	; Note1: this routine is meant to be called via pciRegRead8,
   466                              <1> 	;	 pciRegread16 or pciRegRead32, listed below.
   467                              <1> 	;
   468                              <1> 	; Note2: don't attempt to read 32 bits of data from a non dword
   469                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit reads from
   470                              <1> 	;	 non word aligned reg #
   471                              <1> 	
   472 00014E1E 53                  <1> 	push	ebx
   473 00014E1F 51                  <1> 	push	ecx
   474 00014E20 89C3                <1>         mov     ebx, eax		; save eax, dh
   475 00014E22 88F1                <1>         mov     cl, dh
   476                              <1> 
   477 00014E24 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
   478 00014E29 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
   479 00014E2E 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
   480                              <1> 
   481 00014E30 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
   482 00014E34 EF                  <1>         out	dx, eax			; write PCI selector
   483                              <1> 	
   484 00014E35 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
   485 00014E39 88D8                <1>         mov     al, bl
   486 00014E3B 2403                <1>         and     al, 3			; figure out which port to
   487 00014E3D 00C2                <1>         add     dl, al			; read to
   488                              <1> 
   489 00014E3F F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
   490 00014E45 7507                <1>         jnz     short _pregr0
   491 00014E47 EC                  <1> 	in	al, dx			; return 8 bits of data
   492 00014E48 88C2                <1>         mov	dl, al
   493 00014E4A 88CE                <1> 	mov     dh, cl			; restore dh for 8 bit read
   494 00014E4C EB12                <1> 	jmp	short _pregr2
   495                              <1> _pregr0:	
   496 00014E4E F7C300000080        <1> 	test    ebx, PCI32
   497 00014E54 7507                <1>         jnz	short _pregr1
   498 00014E56 66ED                <1> 	in	ax, dx
   499 00014E58 6689C2              <1>         mov     dx, ax			; return 16 bits of data
   500 00014E5B EB03                <1> 	jmp	short _pregr2
   501                              <1> _pregr1:
   502 00014E5D ED                  <1> 	in	eax, dx			; return 32 bits of data
   503 00014E5E 89C2                <1> 	mov	edx, eax
   504                              <1> _pregr2:
   505 00014E60 89D8                <1> 	mov     eax, ebx		; restore eax
   506 00014E62 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
   507 00014E67 59                  <1> 	pop	ecx
   508 00014E68 5B                  <1> 	pop	ebx
   509 00014E69 C3                  <1> 	retn
   510                              <1> 
   511                              <1> pciRegRead8:
   512 00014E6A 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit read size
   513 00014E6F EBAD                <1>         jmp     short pciRegRead	; call generic PCI access
   514                              <1> 
   515                              <1> pciRegRead16:
   516 00014E71 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit read size
   517 00014E76 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
   518 00014E7B EBA1                <1>         jmp     short pciRegRead
   519                              <1> 
   520                              <1> pciRegRead32:
   521 00014E7D 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit read size
   522 00014E82 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
   523 00014E87 EB95                <1>         jmp     pciRegRead
   524                              <1> 
   525                              <1> pciRegWrite:
   526                              <1> 	; 03/04/2017 ('pci.asm', 29/11/2016)
   527                              <1> 	;
   528                              <1> 	; 8/16/32bit PCI writer
   529                              <1> 	;
   530                              <1> 	; Entry: EAX=PCI Bus/Device/fn/register number
   531                              <1> 	;           BIT31 set if 32 bit access requested
   532                              <1> 	;           BIT30 set if 16 bit access requested
   533                              <1> 	;           otherwise defaults to 8bit read
   534                              <1> 	;        DL/DX/EDX data to write depending on size
   535                              <1> 	;
   536                              <1> 	; Note1: this routine is meant to be called via pciRegWrite8, 
   537                              <1> 	;	 pciRegWrite16 or pciRegWrite32 as detailed below.
   538                              <1> 	;
   539                              <1> 	; Note2: don't attempt to write 32bits of data from a non dword
   540                              <1> 	;	 aligned reg number. Likewise, don't do 16 bit writes from
   541                              <1> 	;	 non word aligned reg #
   542                              <1> 
   543 00014E89 53                  <1> 	push	ebx
   544 00014E8A 51                  <1> 	push	ecx
   545 00014E8B 89C3                <1>         mov     ebx, eax		; save eax, edx
   546 00014E8D 89D1                <1>         mov     ecx, edx
   547 00014E8F 25FFFFFF3F          <1> 	and     eax, NOT_PCI32_PCI16	; clear out data size request
   548 00014E94 0D00000080          <1>         or      eax, BIT31		; make a PCI access request
   549 00014E99 24FC                <1>         and     al, ~3 ; NOT 3		; force index to be dword
   550                              <1> 
   551 00014E9B 66BAF80C            <1>         mov     dx, PCI_INDEX_PORT
   552 00014E9F EF                  <1>         out	dx, eax			; write PCI selector
   553                              <1> 	
   554 00014EA0 66BAFC0C            <1>         mov     dx, PCI_DATA_PORT
   555 00014EA4 88D8                <1>         mov     al, bl
   556 00014EA6 2403                <1>         and     al, 3			; figure out which port to
   557 00014EA8 00C2                <1>         add     dl, al			; write to
   558                              <1> 
   559 00014EAA F7C3000000C0        <1> 	test    ebx, PCI32+PCI16
   560 00014EB0 7505                <1>         jnz     short _pregw0
   561 00014EB2 88C8                <1> 	mov	al, cl 			; put data into al
   562 00014EB4 EE                  <1> 	out	dx, al
   563 00014EB5 EB12                <1> 	jmp	short _pregw2
   564                              <1> _pregw0:
   565 00014EB7 F7C300000080        <1> 	test    ebx, PCI32
   566 00014EBD 7507                <1>         jnz     short _pregw1
   567 00014EBF 6689C8              <1> 	mov	ax, cx			; put data into ax
   568 00014EC2 66EF                <1> 	out	dx, ax
   569 00014EC4 EB03                <1> 	jmp	short _pregw2
   570                              <1> _pregw1:
   571 00014EC6 89C8                <1> 	mov	eax, ecx		; put data into eax 		
   572 00014EC8 EF                  <1> 	out	dx, eax
   573                              <1> _pregw2:
   574 00014EC9 89D8                <1>         mov     eax, ebx		; restore eax
   575 00014ECB 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; clear out data size request
   576 00014ED0 89CA                <1>         mov     edx, ecx		; restore dx
   577 00014ED2 59                  <1> 	pop	ecx
   578 00014ED3 5B                  <1> 	pop	ebx
   579 00014ED4 C3                  <1> 	retn
   580                              <1> 
   581                              <1> pciRegWrite8:
   582 00014ED5 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 8 bit write size
   583 00014EDA EBAD                <1>         jmp	short pciRegWrite	; call generic PCI access
   584                              <1> 
   585                              <1> pciRegWrite16:
   586 00014EDC 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 16 bit write size
   587 00014EE1 0D00000040          <1>         or      eax, PCI16		; call generic PCI access
   588 00014EE6 EBA1                <1>         jmp	short pciRegWrite
   589                              <1> 
   590                              <1> pciRegWrite32:
   591 00014EE8 25FFFFFF3F          <1>         and     eax, NOT_PCI32_PCI16	; set up 32 bit write size
   592 00014EED 0D00000080          <1>         or      eax, PCI32		; call generic PCI access
   593 00014EF2 EB95                <1>         jmp	pciRegWrite
   594                              <1> 
   595                              <1> init_codec:
   596                              <1> 	; 05/06/2017
   597                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   598                              <1> 	;
   599 00014EF4 A1[589C0100]        <1> 	mov	eax, [audio_dev_id]	
   600 00014EF9 B041                <1> 	mov	al, VIA_ACLINK_CTRL
   601 00014EFB E86AFFFFFF          <1> 	call	pciRegRead8
   602                              <1> 	; ?
   603 00014F00 B040                <1> 	mov	al, VIA_ACLINK_STAT
   604 00014F02 E863FFFFFF          <1> 	call	pciRegRead8
   605 00014F07 F6C201              <1> 	test	dl, VIA_ACLINK_C00_READY
   606 00014F0A 7508                <1>         jnz     short _codec_ready_1
   607 00014F0C E80E000000          <1> 	call	reset_codec
   608 00014F11 7306                <1> 	jnc	short _codec_ready_2 ; eax = 1
   609 00014F13 C3                  <1> 	retn
   610                              <1> _codec_ready_1:
   611 00014F14 B801000000          <1> 	mov	eax, 1
   612                              <1> _codec_ready_2:
   613 00014F19 E886000000          <1> 	call	codec_io_w16
   614                              <1> detect_codec:
   615 00014F1E C3                  <1> 	retn
   616                              <1> 
   617                              <1> reset_codec:
   618                              <1> 	; 16/04/2017
   619                              <1> 	; 23/03/2017 
   620                              <1> 	; ('codec.asm')
   621                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   622 00014F1F A1[589C0100]        <1> 	mov	eax, [audio_dev_id]
   623 00014F24 B041                <1>  	mov	al, VIA_ACLINK_CTRL
   624 00014F26 B2E0                <1>        	mov	dl, VIA_ACLINK_CTRL_ENABLE + VIA_ACLINK_CTRL_RESET + VIA_ACLINK_CTRL_SYNC
   625 00014F28 E8A8FFFFFF          <1> 	call	pciRegWrite8
   626                              <1> 
   627 00014F2D E849000000          <1> 	call	delay_100ms 	; wait 100 ms
   628                              <1> _rc_cold:
   629 00014F32 E814000000          <1>         call    cold_reset
   630 00014F37 7301                <1>         jnc     short _reset_codec_ok
   631                              <1> 	
   632                              <1> 	; 16/04/2017
   633                              <1>         ;xor     eax, eax         ; timeout error
   634                              <1>        	;stc
   635 00014F39 C3                  <1> 	retn
   636                              <1> 
   637                              <1> _reset_codec_ok:
   638                              <1> 	; 01/09/2020
   639                              <1> 	; 15/08/2020
   640                              <1> 	; 27/07/2020
   641                              <1> 	; also reset codec by using index control register 0 of AD1980 or ALC655
   642                              <1> 	; (to fix line out -2 channels audio playing- problem on AD1980 codec)  
   643                              <1> 
   644 00014F3A 29C0                <1> 	sub	eax, eax
   645 00014F3C BA00000000          <1> 	mov	edx, CODEC_RESET_REG ; 00h ; Reset register
   646 00014F41 E8CA000000          <1> 	call	codec_write
   647                              <1> 
   648                              <1> 	;sub	eax, eax
   649                              <1> 	; 01/09/2020
   650                              <1> 	; 15/08/2020
   651                              <1> 	; AD1980 BugFix
   652                              <1> 	; (set HPSEL -headphone amp to be driven from mixer- and
   653                              <1> 	;      CLDIS - center and LFE disable- bits)	
   654                              <1> 	;mov	eax, 0C00h ; HPSEL = bit 10, CLDIS = bit 11 ; 01/09/2020
   655                              <1>  	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h ; Misc Ctrl Bits ; AD1980
   656                              <1> 	;call	codec_write
   657                              <1> 
   658 00014F46 31C0                <1>         xor     eax, eax
   659                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
   660 00014F48 FEC0                <1>         inc	al
   661 00014F4A C3                  <1> 	retn
   662                              <1> 
   663                              <1> cold_reset:
   664                              <1> 	; 16/04/2017
   665                              <1> 	; 23/03/2017
   666                              <1> 	; ('codec.asm')
   667                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   668                              <1> 	;mov	eax, [audio_dev_id]
   669                              <1> 	;mov	al, VIA_ACLINK_CTRL
   670 00014F4B 30D2                <1> 	xor	dl, dl ; 0
   671 00014F4D E883FFFFFF          <1> 	call	pciRegWrite8
   672                              <1> 
   673 00014F52 E824000000          <1> 	call	delay_100ms 	; wait 100 ms
   674                              <1> 
   675                              <1> 	;; ACLink on, deassert ACLink reset, VSR, SGD data out
   676                              <1>         ;; note - FM data out has trouble with non VRA codecs !!
   677                              <1>         
   678                              <1> 	;mov	eax, [audio_dev_id]
   679                              <1> 	;mov	al, VIA_ACLINK_CTRL
   680 00014F57 B2CC                <1> 	mov	dl, VIA_ACLINK_CTRL_INIT
   681 00014F59 E877FFFFFF          <1> 	call	pciRegWrite8
   682                              <1> 
   683 00014F5E B910000000          <1> 	mov	ecx, 16	; total 2s
   684                              <1> 
   685                              <1> _crst_wait:
   686                              <1> 	;mov	eax, [audio_dev_id]
   687 00014F63 B040                <1> 	mov	al, VIA_ACLINK_STAT
   688 00014F65 E800FFFFFF          <1> 	call	pciRegRead8	
   689                              <1> 
   690 00014F6A F6C201              <1>         test    dl, VIA_ACLINK_C00_READY
   691 00014F6D 750B                <1>         jnz     short _crst_ok
   692                              <1> 
   693 00014F6F 51                  <1> 	push	ecx
   694 00014F70 E806000000          <1> 	call	delay_100ms
   695 00014F75 59                  <1> 	pop	ecx
   696                              <1> 
   697 00014F76 49                  <1>         dec     ecx
   698 00014F77 75EA                <1>         jnz     short _crst_wait
   699                              <1> 
   700                              <1> _crst_fail:
   701 00014F79 F9                  <1>         stc
   702                              <1> _crst_ok:
   703 00014F7A C3                  <1> 	retn
   704                              <1> 
   705                              <1> delay_100ms:
   706                              <1> 	; 29/05/2017
   707                              <1> 	; 24/03/2017 ('codec.asm')
   708                              <1> 	; wait 100 ms
   709 00014F7B B990010000          <1> 	mov	ecx, 400  ; 400*0.25ms
   710                              <1> _delay_x_ms:
   711 00014F80 E803000000          <1> 	call	delay1_4ms
   712 00014F85 E2F9                <1>         loop	_delay_x_ms
   713 00014F87 C3                  <1> 	retn
   714                              <1> 
   715                              <1> ;       delay1_4ms - Delay for 1/4 millisecond.
   716                              <1> ;	    1mS = 1000us
   717                              <1> ;       Entry:
   718                              <1> ;         None
   719                              <1> ;       Exit:
   720                              <1> ;	  None
   721                              <1> ;
   722                              <1> ;       Modified:
   723                              <1> ;         None
   724                              <1> ;
   725                              <1> 
   726                              <1> 	; 29/05/2017
   727                              <1> 	; 23/04/2017
   728                              <1> 	; 05/03/2017 (TRDOS 386)
   729                              <1> 	; ('UTILS.ASM')
   730                              <1> delay1_4ms:
   731 00014F88 50                  <1>         push    eax 
   732 00014F89 51                  <1>         push    ecx
   733 00014F8A B110                <1>         mov	cl, 16		; close enough.
   734                              <1> 
   735 00014F8C E461                <1> 	in	al, PORTB ; 61h
   736                              <1> 		
   737 00014F8E 2410                <1> 	and	al, REFRESH_STATUS ; 10h
   738 00014F90 88C5                <1> 	mov	ch, al		; Start toggle state
   739                              <1> _d4ms1:	
   740 00014F92 E461                <1> 	in	al, PORTB	; Read system control port
   741                              <1> 	
   742 00014F94 2410                <1> 	and	al, REFRESH_STATUS ; Refresh toggles 15.085 microseconds
   743 00014F96 38C5                <1> 	cmp	ch, al
   744 00014F98 74F8                <1> 	je	short _d4ms1	; Wait for state change
   745                              <1> 
   746 00014F9A 88C5                <1> 	mov	ch, al		; Update with new state
   747 00014F9C FEC9                <1> 	dec	cl
   748 00014F9E 75F2                <1> 	jnz	short _d4ms1
   749                              <1> 
   750 00014FA0 F8                  <1> 	clc	; 29/05/2017
   751                              <1> 
   752 00014FA1 59                  <1>         pop     ecx
   753 00014FA2 58                  <1>         pop     eax
   754 00014FA3 C3                  <1>         retn
   755                              <1> 
   756                              <1> ; 10/04/2017 (TRDOS 386)
   757                              <1> ; 12/11/2016
   758                              <1> 
   759                              <1> codec_io_w16: ;w32
   760                              <1> 	; ('codec.asm')
   761 00014FA4 668B15[569C0100]    <1>         mov	dx, [audio_io_base]
   762 00014FAB 6681C28000          <1>         add     dx, VIA_REG_AC97
   763 00014FB0 EF                  <1> 	out	dx, eax
   764 00014FB1 C3                  <1>         retn
   765                              <1> 
   766                              <1> codec_io_r16: ;r32
   767                              <1> 	; ('codec.asm')
   768 00014FB2 668B15[569C0100]    <1>         mov     dx, [audio_io_base]
   769 00014FB9 6681C28000          <1>         add     dx, VIA_REG_AC97
   770 00014FBE ED                  <1>         in	eax, dx
   771 00014FBF C3                  <1>         retn
   772                              <1> 
   773                              <1> ctrl_io_w8:
   774                              <1> 	; ('codec.asm')
   775 00014FC0 660315[569C0100]    <1>         add     dx, [audio_io_base]
   776 00014FC7 EE                  <1>         out	dx, al
   777 00014FC8 C3                  <1>         retn
   778                              <1> 
   779                              <1> ctrl_io_r8:
   780                              <1> 	; ('codec.asm')
   781 00014FC9 660315[569C0100]    <1>         add     dx, [audio_io_base]
   782 00014FD0 EC                  <1>         in	al, dx
   783 00014FD1 C3                  <1>         retn
   784                              <1> 
   785                              <1> ctrl_io_w32:
   786                              <1> 	; ('codec.asm')
   787 00014FD2 660315[569C0100]    <1>         add     dx, [audio_io_base]
   788 00014FD9 EF                  <1>         out	dx, eax
   789 00014FDA C3                  <1>         retn
   790                              <1> 
   791                              <1> ctrl_io_r32:
   792                              <1> 	; ('codec.asm')
   793 00014FDB 660315[569C0100]    <1>         add	dx, [audio_io_base]
   794 00014FE2 ED                  <1> 	in	eax, dx
   795 00014FE3 C3                  <1>         retn
   796                              <1> 
   797                              <1> codec_read:
   798                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   799                              <1>         ; Use only primary codec.
   800                              <1>         ; eax = register
   801 00014FE4 C1E010              <1>         shl     eax, VIA_REG_AC97_CMD_SHIFT
   802 00014FE7 0D00008002          <1>         or      eax, VIA_REG_AC97_PRIMARY_VALID + VIA_REG_AC97_READ
   803                              <1> 
   804 00014FEC E8B3FFFFFF          <1> 	call    codec_io_w16
   805                              <1> 
   806                              <1>       	; codec_valid
   807 00014FF1 E831000000          <1> 	call	codec_check_ready
   808 00014FF6 7301                <1>         jnc	short _cr_ok
   809                              <1> 
   810 00014FF8 C3                  <1> 	retn
   811                              <1> 
   812                              <1> _cr_ok:
   813                              <1> 	; wait 25 ms
   814 00014FF9 B950000000          <1> 	mov	ecx, 80 ; (100*0.25 ms)
   815                              <1> _cr_wloop:
   816 00014FFE E885FFFFFF          <1> 	call	delay1_4ms
   817 00015003 E2F9                <1> 	loop	_cr_wloop
   818                              <1> 
   819 00015005 E8A8FFFFFF          <1>         call    codec_io_r16
   820 0001500A 25FFFF0000          <1>         and     eax, 0FFFFh
   821 0001500F C3                  <1>         retn
   822                              <1> 
   823                              <1> codec_write:
   824                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   825                              <1>         ; Use only primary codec.
   826                              <1>         
   827                              <1> 	; eax = data (volume)
   828                              <1> 	; edx = register (mixer register)
   829                              <1> 	
   830 00015010 C1E210              <1> 	shl     edx, VIA_REG_AC97_CMD_SHIFT
   831                              <1> 
   832 00015013 C1E000              <1>         shl     eax, VIA_REG_AC97_DATA_SHIFT ; shl eax, 0
   833 00015016 09C2                <1>         or      edx, eax
   834                              <1> 
   835 00015018 B800000000          <1>         mov     eax, VIA_REG_AC97_CODEC_ID_PRIMARY
   836 0001501D C1E01E              <1>         shl     eax, VIA_REG_AC97_CODEC_ID_SHIFT
   837 00015020 09D0                <1>         or      eax, edx
   838                              <1> 
   839 00015022 E87DFFFFFF          <1>         call    codec_io_w16
   840                              <1>         ;mov    [codec.regs+esi], ax
   841                              <1> 
   842                              <1>         ;call	codec_check_ready
   843                              <1>        	;retn
   844                              <1> 	;jmp	short _codec_check_ready	
   845                              <1> 
   846                              <1> codec_check_ready:
   847                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
   848                              <1> 
   849                              <1> _codec_check_ready:
   850 00015027 B914000000          <1> 	mov	ecx, 20	; total 2s
   851                              <1> _ccr_wait:
   852 0001502C 51                  <1> 	push	ecx
   853                              <1> 
   854 0001502D E880FFFFFF          <1>         call    codec_io_r16
   855 00015032 A900000001          <1>         test    eax, VIA_REG_AC97_BUSY
   856 00015037 740B                <1>         jz      short _ccr_ok
   857                              <1> 
   858 00015039 E83DFFFFFF          <1> 	call	delay_100ms
   859                              <1> 
   860 0001503E 59                  <1> 	pop	ecx
   861                              <1> 
   862 0001503F 49                  <1> 	dec     ecx
   863 00015040 75EA                <1>         jnz     short _ccr_wait
   864                              <1> 
   865 00015042 F9                  <1>         stc
   866 00015043 C3                  <1>         retn
   867                              <1> 
   868                              <1> _ccr_ok:
   869 00015044 59                  <1> 	pop	ecx
   870 00015045 25FFFF0000          <1> 	and     eax, 0FFFFh
   871 0001504A C3                  <1>         retn
   872                              <1> 
   873                              <1> codec_config:
   874                              <1> 	; 10/06/2017
   875                              <1> 	; 29/05/2017
   876                              <1> 	; 24/04/2017
   877                              <1> 	; 21/04/2017
   878                              <1> 	; 16/04/2017 (TRDOS 386 Kernel) 
   879                              <1> 	; 15/11/2016 ('codec.asm', 'player.com')
   880                              <1> 	; 14/11/2016
   881                              <1> 	; 12/11/2016 - Erdogan Tan
   882                              <1> 	;	     (Ref: KolibriOS, 'setup_codec', codec.inc)
   883                              <1> 
   884 0001504B B802020000          <1> 	mov     eax, 0202h
   885 00015050 66A3[869C0100]      <1> 	mov	[audio_master_volume], ax
   886 00015056 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
   887 0001505A BA02000000          <1> 	mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
   888 0001505F E8ACFFFFFF          <1> 	call	codec_write
   889                              <1> 	;jc	short cconfig_error
   890                              <1> 
   891                              <1>  	;mov    eax, 0202h
   892 00015064 66B80202            <1> 	mov     ax, 0202h
   893 00015068 BA18000000          <1> 	mov	edx, CODEC_PCM_OUT_REG ; 18h ; Wave Output (Stereo)
   894 0001506D E89EFFFFFF          <1> 	call	codec_write
   895                              <1> 	;jc	short cconfig_error
   896                              <1>       
   897                              <1>  	;mov    eax, 0202h
   898 00015072 66B80202            <1> 	mov	ax, 0202h
   899 00015076 BA04000000          <1> 	mov	edx, CODEC_AUX_VOL ; 04h ; CODEC_HP_VOL_REG ; HeadPhone
   900 0001507B E890FFFFFF          <1> 	call	codec_write
   901                              <1> 	;jc	short cconfig_error
   902                              <1> 
   903                              <1>  	;mov    eax, 08h
   904                              <1>         ;mov    ax,  08h
   905 00015080 66B80880            <1> 	mov	ax, 8008h ; Mute
   906 00015084 BA0C000000          <1> 	mov	edx, 0Ch  ; AC97_PHONE_VOL ; TAD Input (Mono)
   907 00015089 E882FFFFFF          <1> 	call	codec_write
   908                              <1> 	;jc	short cconfig_error
   909                              <1> 
   910                              <1>  	;mov    eax, 0808h
   911 0001508E 66B80808            <1>         mov     ax,  0808h
   912 00015092 BA10000000          <1>         mov	edx, CODEC_LINE_IN_VOL_REG ; 10h ; Line Input (Stereo)	
   913 00015097 E874FFFFFF          <1> 	call	codec_write
   914                              <1> 	;jc	short cconfig_error
   915                              <1> 
   916                              <1>  	;mov    eax, 0808h
   917 0001509C 66B80808            <1> 	mov     ax,  0808h
   918 000150A0 BA12000000          <1>         mov	edx, CODEC_CD_VOL_REG ; 12h ; CR Input (Stereo)
   919 000150A5 E866FFFFFF          <1> 	call	codec_write
   920                              <1> 	;jc	short cconfig_error
   921                              <1> 
   922                              <1>  	;mov    eax, 0808h
   923 000150AA 66B80808            <1> 	mov     ax,  0808h
   924 000150AE BA16000000          <1>         mov	edx, CODEC_AUX_VOL_REG ; 16h ; Aux Input (Stereo)
   925                              <1> 	;call	codec_write
   926                              <1> 	;;jc	short cconfig_error
   927 000150B3 E958FFFFFF          <1> 	jmp	codec_write ; 10/06/2017
   928                              <1> 
   929                              <1> ;	; Extended Audio Status (2Ah)
   930                              <1> ;	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
   931                              <1> ;	call	codec_read
   932                              <1> ;	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
   933                              <1> ;	;or     eax, 1			; set VRA (BIT0)
   934                              <1> ;	or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
   935                              <1> ;	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
   936                              <1> ;	call	codec_write
   937                              <1> ;	;jc	short cconfig_error
   938                              <1> ;
   939                              <1> ;set_sample_rate:
   940                              <1> ;	;movzx	eax, word [audio_freq]
   941                              <1> ;	mov	ax, [audio_freq]
   942                              <1> ;	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
   943                              <1> ;	;call	codec_write
   944                              <1> ;	;retn
   945                              <1> ;	jmp	codec_write
   946                              <1> 	
   947                              <1> ;cconfig_error:
   948                              <1> ;	retn
   949                              <1> 
   950                              <1> vt8233_int_handler:
   951                              <1> 	; 27/07/2020
   952                              <1> 	; 22/07/2020
   953                              <1> 	; Interrupt Handler for VIA VT8237R Audio Controller
   954                              <1> 	; Note: called by 'dev_IRQ_service'
   955                              <1> 	; 14/10/2017 
   956                              <1> 	; 09/10/2017, 10/10/2017, 12/10/2017
   957                              <1> 	; 13/06/2017
   958                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
   959                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('player.asm') 
   960                              <1> 
   961                              <1> 	;push	eax ; * must be saved !
   962                              <1> 	;push	edx
   963                              <1> 	;push	ecx
   964                              <1> 	;push	ebx ; * must be saved !
   965                              <1> 	;push	esi
   966                              <1> 	;push	edi
   967                              <1> 
   968                              <1> 	;cmp	byte [audio_busy], 1
   969                              <1> 	;jnb	short _ih0 ; 09/10/2017
   970                              <1> 
   971                              <1> 	;mov	byte [audio_flag_eol], 0
   972                              <1> 
   973 000150B8 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
   974 000150BC E808FFFFFF          <1>         call    ctrl_io_r8
   975                              <1> 
   976 000150C1 A880                <1> 	test    al, VIA_REG_STAT_ACTIVE
   977 000150C3 7417                <1>         jz      short _ih0 ; 09/10/2017
   978                              <1> 
   979 000150C5 2407                <1>         and     al, VIA_REG_STAT_EOL + VIA_REG_STAT_FLAG + VIA_REG_STAT_STOPPED
   980 000150C7 A2[859C0100]        <1> 	mov	[audio_flag_eol], al
   981 000150CC 740E                <1>         jz	short _ih0 ; 09/10/2017
   982                              <1> 
   983                              <1> 	; 09/10/2017
   984                              <1> 	;mov	byte [audio_busy], 1
   985                              <1> 
   986 000150CE 803D[849C0100]01    <1> 	cmp	byte [audio_play_cmd], 1
   987 000150D5 7315                <1> 	jnb	short _ih1 ; 10/10/2017
   988                              <1> 
   989 000150D7 E84A000000          <1> 	call	channel_reset
   990                              <1> _ih0:
   991                              <1> 	; 09/10/2017
   992 000150DC A0[859C0100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
   993 000150E1 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
   994 000150E5 E8D6FEFFFF          <1>         call    ctrl_io_w8
   995 000150EA EB39                <1> 	jmp	short _ih4
   996                              <1> _ih1:
   997                              <1> vt8233_tuneLoop:
   998 000150EC A0[859C0100]        <1>         mov     al, [audio_flag_eol]   ;; ack ;;
   999 000150F1 66BA0000            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STATUS
  1000 000150F5 E8C6FEFFFF          <1>         call    ctrl_io_w8
  1001                              <1> 
  1002                              <1> 	; 22/07/2020
  1003                              <1> 	;; 12/10/2017
  1004                              <1> 	;mov	byte [audio_flag], 0 ; Reset	
  1005                              <1> 
  1006                              <1> 	; 10/10/2017
  1007                              <1> 	; 09/10/2017
  1008                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_FLAG
  1009                              <1> 	;jz	short _ih2 ; EOL
  1010                              <1> 
  1011                              <1> 	; 22/07/2020
  1012                              <1> 	; 14/10/2017
  1013                              <1> 	;test	byte [audio_flag_eol], VIA_REG_STAT_EOL
  1014                              <1> 	;jnz	short _ih2 ; EOL
  1015                              <1> 	;		   ; (Half Buffer 2 has been completed 
  1016                              <1> 	;		   ; and Half Buffer 1 will be played.)
  1017                              <1> 	
  1018                              <1> 	; FLAG  
  1019                              <1> 	; (Half Buffer 1 has been completed 
  1020                              <1> 	;  and Half Buffer 2 will be played.)
  1021                              <1> 
  1022                              <1> 	; 14/10/2017
  1023                              <1> 	;; (Continue to play.)
  1024                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1025                              <1>        	;or	al, VIA_REG_CTRL_START
  1026                              <1>        	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1027                              <1>         ;call	ctrl_io_w8
  1028                              <1> 	; 12/10/2017
  1029                              <1> 	;mov	byte [audio_flag], 1 
  1030                              <1> 
  1031                              <1> 	; 22/07/2020
  1032                              <1> 	;inc	byte [audio_flag] ; = 1
  1033                              <1> _ih2: 
  1034                              <1> 	; 10/10/2017
  1035 000150FA 8B3D[709C0100]      <1> 	mov	edi, [audio_dma_buff]
  1036 00015100 8B0D[749C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  1037 00015106 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  1038                              <1> 	
  1039                              <1> 	; 22/07/2020
  1040                              <1> 	; 12/10/2017
  1041                              <1> 	;cmp	byte [audio_flag], 0
  1042                              <1> 	;ja	short _ih3 ; Playing Half Buffer 2 (Current: FLAG)
  1043                              <1> 	
  1044                              <1> 	; 27/07/2020
  1045                              <1> 	; 22/07/2020
  1046 00015108 F605[789C0100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
  1047 0001510F 7402                <1> 	jz	short _ih3 ; Half Buffer 1 must be filled
  1048                              <1> 
  1049                              <1> 	; Half Buffer 2 must be filled
  1050 00015111 01CF                <1> 	add	edi, ecx
  1051                              <1> _ih3:
  1052                              <1> 	; Update half buffer 2 while playing half buffer 1
  1053                              <1> 	; Update half buffer 1 while playing half buffer 2
  1054                              <1> 
  1055 00015113 8B35[689C0100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  1056 00015119 C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  1057 0001511C F3A5                <1> 	rep	movsd
  1058                              <1> 
  1059                              <1> 	; switch flag value ;
  1060 0001511E 8035[789C0100]01    <1> 	xor	byte [audio_flag], 1
  1061                              <1> 	; 12/10/2017
  1062                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2
  1063                              <1> 			   ; Next buffer (to update) is dma half buff 1
  1064                              <1> 	; 	       = 1 : Playing dma half buffer 1
  1065                              <1> 			   ; Next buffer (to update) is dma half buff 2
  1066                              <1> _ih4:	
  1067                              <1> 	; 28/05/2017
  1068                              <1> 	;mov	byte [audio_busy], 0 ; 09/10/2017
  1069                              <1> 	;
  1070                              <1> 	;pop	edi
  1071                              <1> 	;pop	esi
  1072                              <1> 	;pop	ebx ; * must be restored !
  1073                              <1> 	;pop	ecx
  1074                              <1> 	;pop	edx
  1075                              <1> 	;pop	eax ; * must be restored !
  1076                              <1> 
  1077 00015125 C3                  <1> 	retn
  1078                              <1> 
  1079                              <1> channel_reset:
  1080                              <1> 	; 24/06/2017
  1081                              <1> 	; 29/05/2017
  1082                              <1> 	; 23/03/2017
  1083                              <1> 	; 14/11/2016 - Erdogan Tan
  1084                              <1> 	; 12/11/2016 - Erdogan Tan (Ref: KolibriOS, vt823x.asm)
  1085 00015126 BA01000000          <1>         mov	edx, VIA_REG_OFFSET_CONTROL
  1086                              <1>         ;mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE + VIA_REG_CTRL_RESET
  1087 0001512B B848000000          <1>         mov	eax, VIA_REG_CTRL_PAUSE + VIA_REG_CTRL_TERMINATE ; 24/06/2017       
  1088 00015130 E88BFEFFFF          <1> 	call    ctrl_io_w8
  1089                              <1> 
  1090                              <1>         ;mov	edx, VIA_REG_OFFSET_CONTROL
  1091                              <1>         ;call   ctrl_io_r8
  1092                              <1> 
  1093                              <1> 	; wait for 50 ms
  1094 00015135 B9A0000000          <1> 	mov	ecx, 160 ; (200*0.25 ms) ; 29/05/2017	
  1095                              <1> _ch_rst_wait:
  1096 0001513A E849FEFFFF          <1> 	call	delay1_4ms
  1097 0001513F 49                  <1> 	dec	ecx
  1098 00015140 75F8                <1> 	jnz	short _ch_rst_wait     
  1099                              <1> 
  1100                              <1>         ; disable interrupts
  1101 00015142 BA01000000          <1>         mov	edx, VIA_REG_OFFSET_CONTROL
  1102 00015147 31C0                <1>         xor     eax, eax
  1103 00015149 E872FEFFFF          <1>         call    ctrl_io_w8
  1104                              <1> 
  1105                              <1>         ; clear interrupts
  1106 0001514E BA00000000          <1>         mov	edx, VIA_REG_OFFSET_STATUS
  1107 00015153 B803000000          <1> 	mov	eax, 3
  1108 00015158 E863FEFFFF          <1>         call	ctrl_io_w8
  1109                              <1> 
  1110                              <1> 	;mov	edx, VIA_REG_OFFSET_CURR_PTR
  1111                              <1> 	;xor	eax, eax
  1112                              <1> 	;call	ctrl_io_w32
  1113                              <1> 
  1114 0001515D C3                  <1>         retn	
  1115                              <1> 
  1116                              <1> vt8233_stop: ; 22/04/2017
  1117 0001515E C605[849C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  1118                              <1> _tlp2:
  1119                              <1> 	; 24/06/2017
  1120                              <1>         ; finished with song, stop everything
  1121                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1122                              <1>         ;or	al, VIA_REG_CTRL_TERMINATE
  1123                              <1> 	;mov	dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1124                              <1>         ;call	ctrl_io_w8
  1125                              <1> 
  1126                              <1>         ;call	channel_reset
  1127                              <1> 	;retn
  1128                              <1> 
  1129 00015165 EBBF                <1> 	jmp	short channel_reset
  1130                              <1> 
  1131                              <1> set_vt8233_bdl: ; Set VT8237R Buffer Descriptor List
  1132                              <1> 	; 22/07/2020 - TRDOS 386 v2.0.2
  1133                              <1> 	; 28/05/2017
  1134                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1135                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  1136                              <1> 	
  1137                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
  1138                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
  1139                              <1> 
  1140 00015167 D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
  1141 00015169 89CE                <1> 	mov	esi, ecx
  1142                              <1> 
  1143 0001516B BF[8C9C0100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
  1144 00015170 B910000000          <1>         mov     ecx, 32 / 2		; make 32 entries in BDL
  1145                              <1> 
  1146 00015175 EB05                <1> 	jmp	short s_vt8233_bdl1 
  1147                              <1> 
  1148                              <1> s_vt8233_bdl0:
  1149                              <1> 	; set buffer descriptor 0 to start of data file in memory
  1150                              <1> 
  1151 00015177 A1[709C0100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
  1152                              <1>  
  1153                              <1> s_vt8233_bdl1:
  1154 0001517C AB                  <1> 	stosd				; store dmabuffer1 address
  1155                              <1> 
  1156 0001517D 89C2                <1> 	mov	edx, eax
  1157                              <1> 
  1158                              <1> ; VIA VT8235.PDF: (Page 110) (Erdogan Tan, 29/11/2016)
  1159                              <1> 	;
  1160                              <1> 	; 	Audio SGD Table Format
  1161                              <1> 	;	-------------------------------
  1162                              <1> 	;	63   62    61-56    55-32  31-0
  1163                              <1> 	;	--   --   --------  -----  ----
  1164                              <1> 	;	EOL FLAG -reserved- Base   Base
  1165                              <1> 	;		    	    Count  Address
  1166                              <1> 	;		            [23:0] [31:0]
  1167                              <1> 	;	EOL: End Of Link. 
  1168                              <1> 	;	     1 indicates this block is the last of the link.
  1169                              <1> 	;	     If the channel Interrupt on EOL bit is set, then
  1170                              <1> 	;	     an interrupt is generated at the end of the transfer.
  1171                              <1> 	;
  1172                              <1> 	;	FLAG: Block Flag. If set, transfer pauses at the end of this
  1173                              <1> 	;	      block. If the channel Interrupt on FLAG bit is set,
  1174                              <1> 	;	      then an interrupt is generated at the end of this block.
  1175                              <1> 
  1176 0001517F 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  1177 00015181 01C2                <1> 	add	edx, eax
  1178 00015183 0D00000040          <1> 	or	eax, FLAG
  1179                              <1> 	;or	eax, EOL
  1180 00015188 AB                  <1> 	stosd
  1181                              <1> 
  1182                              <1> ; 2nd buffer:
  1183                              <1> 
  1184 00015189 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
  1185 0001518B AB                  <1> 	stosd		 ; store dmabuffer2 address
  1186                              <1> 
  1187                              <1> ; set length to [audio_dmabuff_size]/2
  1188                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
  1189                              <1> ; 
  1190 0001518C 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  1191                              <1> 	; 22/07/2020
  1192                              <1> 	;or	eax, EOL
  1193 0001518E 0D00000040          <1> 	or	eax, FLAG
  1194 00015193 AB                  <1> 	stosd
  1195                              <1> 
  1196 00015194 E2E1                <1> 	loop    s_vt8233_bdl0
  1197                              <1> 
  1198                              <1> 	; 22/07/2020
  1199 00015196 814FFC00000080      <1> 	or	dword [edi-4], EOL
  1200                              <1> 	
  1201 0001519D C3                  <1> 	retn
  1202                              <1> 
  1203                              <1> vt8233_start_play:
  1204                              <1> 	; 01/09/2020 
  1205                              <1> 	; 22/07/2020 
  1206                              <1> 	; start to play audio data via VT8233 audio controller
  1207                              <1> 	; 13/06/2017
  1208                              <1> 	; 10/06/2017
  1209                              <1> 	; 24/04/2017 
  1210                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1211                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  1212                              <1> 	; write buffer descriptor list address
  1213                              <1> 
  1214                              <1> 	; Extended Audio Status (2Ah)
  1215 0001519E B82A000000          <1> 	mov	eax, CODEC_EXT_AUDIO_CTRL_REG ; 2Ah 
  1216 000151A3 E83CFEFFFF          <1> 	call	codec_read
  1217 000151A8 25FDFF0000          <1> 	and     eax, 0FFFFh - 2		; clear DRA (BIT1)
  1218                              <1> 	;or     eax, 1			; set VRA (BIT0)
  1219                              <1> 	;or	eax, 5  	; VRA (BIT0) & S/PDIF (BIT2) ; 14/11/2016
  1220 000151AD 0C05                <1> 	or	al, 5
  1221                              <1> 	; 01/09/2020	
  1222                              <1> 	;or	eax, 3805h ; AD1980 (PRK, PRJ, PRI = 1 .. only front DAC)
  1223                              <1> 	; 01/09/2020
  1224                              <1> 	;mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  1225                              <1> 	;cmp	word [audio_freq], 0BB80h ; 48 kHz
  1226                              <1> 	;jne	short set_extd_audio_status_1
  1227                              <1> 	;and	al, 0FEh ; disable VRA bit (set sample rate to 48000 Hz)
  1228                              <1> 	;jmp	short set_extd_audio_status_2
  1229                              <1> ;set_extd_audio_status_1:
  1230 000151AF BA2A000000          <1> 	mov	edx, CODEC_EXT_AUDIO_CTRL_REG
  1231 000151B4 E857FEFFFF          <1> 	call	codec_write
  1232                              <1> 	;jc	short cconfig_error
  1233                              <1> 
  1234                              <1> set_sample_rate:
  1235                              <1> 	;movzx	eax, word [audio_freq]
  1236 000151B9 66A1[829C0100]      <1> 	mov	ax, [audio_freq]
  1237 000151BF BA2C000000          <1> 	mov	edx, CODEC_PCM_FRONT_DACRATE_REG ; 2Ch ; PCM Front DAC Rate
  1238                              <1> ;set_extd_audio_status_2:
  1239 000151C4 E847FEFFFF          <1> 	call	codec_write
  1240                              <1> 
  1241                              <1> 	; 01/09/2020
  1242                              <1> 	; set AD1980 MCB register (Index 76h) to 0C00h
  1243                              <1> 	; (CLDIS, HPSEL)
  1244                              <1> 	;mov	ax, 0C00h
  1245                              <1> 	;mov	edx, CODEC_MISC_CRTL_BITS_REG ; 76h 
  1246                              <1> 	;			; Miscellaneous Control Bit Register
  1247                              <1> 	;call	codec_write
  1248                              <1> 	;
  1249                              <1> 
  1250 000151C9 B8[8C9C0100]        <1>         mov	eax, audio_bdl_buff
  1251                              <1>   
  1252                              <1> 	; 12/11/2016 - Erdogan Tan 
  1253                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
  1254 000151CE BA04000000          <1> 	mov	edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_TABLE_PTR
  1255 000151D3 E8FAFDFFFF          <1>         call	ctrl_io_w32
  1256                              <1> 
  1257                              <1> 	;call	codec_check_ready
  1258                              <1> 
  1259 000151D8 66BA0200            <1>   	mov	dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_L
  1260                              <1>         ;mov	eax, 2	; 31
  1261 000151DC B01F                <1> 	mov	al, 31
  1262 000151DE 2A05[869C0100]      <1>         sub	al, [audio_master_volume_l]
  1263 000151E4 E8D7FDFFFF          <1> 	call	ctrl_io_w8
  1264                              <1> 
  1265                              <1> 	;call	codec_check_ready
  1266                              <1> 
  1267 000151E9 66BA0300            <1>         mov     dx, VIADEV_PLAYBACK + VIA_REG_OFS_PLAYBACK_VOLUME_R
  1268                              <1>         ;mov	ax, 2	; 31
  1269 000151ED B01F                <1> 	mov	al, 31
  1270 000151EF 2A05[879C0100]      <1>         sub	al, [audio_master_volume_r]
  1271 000151F5 E8C6FDFFFF          <1> 	call    ctrl_io_w8
  1272                              <1> 
  1273                              <1> 	;call	codec_check_ready
  1274                              <1> ;
  1275                              <1> ;
  1276                              <1> ; All set. Let's play some music.
  1277                              <1> ;
  1278                              <1> ;
  1279                              <1>        	;mov    dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  1280                              <1>         ;mov    ax, VIA8233_REG_TYPE_16BIT or VIA8233_REG_TYPE_STEREO or 0xfffff or 0xff000000
  1281                              <1>         ;call   ctrl_io_w32
  1282                              <1> 
  1283                              <1> 	;call	codec_check_ready
  1284                              <1> 
  1285                              <1> 	; 08/12/2016
  1286                              <1> 	; 07/10/2016
  1287                              <1>         ;;mov    al, 1
  1288                              <1>         ;mov	al, 31
  1289                              <1> 	; 22/07/2020
  1290 000151FA B0FF                <1> 	mov	al, 0FFh
  1291 000151FC E813000000          <1> 	call    set_VT8233_LastValidIndex
  1292                              <1> 
  1293 00015201 C605[849C0100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  1294                              <1> 
  1295                              <1> 	; 22/07/2020
  1296                              <1> 	;mov	byte [audio_flag], 0  ; clear half buffer flag
  1297                              <1> 
  1298                              <1> vt8233_play: ; continue to play
  1299                              <1> 	; 22/04/2017
  1300                              <1> 	;mov	al, VIA_REG_CTRL_INT
  1301                              <1>        	;or	al, VIA_REG_CTRL_START
  1302                              <1>         ;;mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START
  1303                              <1> 	; 22/07/2020	
  1304 00015208 B0A1                <1> 	mov	al, VIA_REG_CTRL_AUTOSTART + VIA_REG_CTRL_START + VIA_REG_CTRL_INT_FLAG
  1305                              <1> 
  1306 0001520A 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1307 0001520E E8ADFDFFFF          <1>         call    ctrl_io_w8
  1308                              <1> 	;call	codec_check_ready
  1309                              <1> 	;retn
  1310                              <1> 	;jmp	codec_check_ready
  1311 00015213 C3                  <1> 	retn
  1312                              <1> 
  1313                              <1> ;input AL = index # to stop on
  1314                              <1> set_VT8233_LastValidIndex:
  1315                              <1> 	; 23/07/2020
  1316                              <1> 	; 10/06/2017
  1317                              <1> 	; 21/04/2017 (TRDOS 386 kernel, 'audio.s')
  1318                              <1> 	; 24/03/2017 - 'PLAYER.COM' ('via_wav.asm' - 29/11/2016) 
  1319                              <1> 	; 19/11/2016
  1320                              <1> 	; 14/11/2016 - Erdogan Tan (Ref: VIA VT8235.PDF, Page 110)
  1321                              <1> 	; 12/11/2016 - Erdogan Tan
  1322                              <1> 	; (Ref: KolibriOS, vt823x.asm, 'create_primary_buff')
  1323                              <1> 	;push	edx
  1324                              <1> 	;push	ax
  1325 00015214 50                  <1> 	push	eax ; 23/07/2020
  1326                              <1> 	;push	ecx
  1327 00015215 0FB705[829C0100]    <1> 	movzx	eax, word [audio_freq] ; Hertz
  1328 0001521C BA00001000          <1> 	mov	edx, 100000h ; 2^20 = 1048576
  1329 00015221 F7E2                <1> 	mul	edx
  1330 00015223 B980BB0000          <1> 	mov	ecx, 48000	
  1331 00015228 F7F1                <1> 	div	ecx
  1332                              <1> 	;and	eax, 0FFFFFh
  1333                              <1> 	;pop	ecx
  1334                              <1> 	;pop	dx 
  1335 0001522A 5A                  <1> 	pop	edx ; 23/07/2020
  1336 0001522B C1E218              <1> 	shl	edx, 24  ; STOP Index Setting: Bit 24 to 31
  1337 0001522E 09D0                <1> 	or	eax, edx
  1338                              <1> 	; 19/11/2016
  1339 00015230 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16
  1340 00015237 7505                <1> 	jne	short sLVI_1
  1341 00015239 0D00002000          <1> 	or	eax, VIA8233_REG_TYPE_16BIT
  1342                              <1> sLVI_1:
  1343 0001523E 803D[819C0100]02    <1> 	cmp	byte [audio_stmo], 2
  1344 00015245 7505                <1> 	jne	short sLVI_2
  1345 00015247 0D00001000          <1> 	or	eax, VIA8233_REG_TYPE_STEREO
  1346                              <1> sLVI_2:
  1347 0001524C BA08000000          <1> 	mov     edx, VIADEV_PLAYBACK + VIA_REG_OFFSET_STOP_IDX
  1348 00015251 E87CFDFFFF          <1>         call    ctrl_io_w32
  1349                              <1> 	;call	codec_check_ready
  1350                              <1> 	;pop	edx
  1351 00015256 C3                  <1> 	retn
  1352                              <1> 
  1353                              <1> vt8233_pause: ; pause
  1354                              <1> 	; 10/06/2017
  1355                              <1> 	; 22/04/2017
  1356                              <1> 	;mov     al, VIA_REG_CTRL_INT
  1357                              <1>         ;or      al, VIA_REG_CTRL_PAUSE
  1358                              <1> 	; 23/07/2020
  1359 00015257 B029                <1> 	mov	al, VIA_REG_CTRL_PAUSE+VIA_REG_CTRL_INT_FLAG+VIA_REG_CTRL_AUTOSTART
  1360                              <1> 	
  1361 00015259 66BA0100            <1> 	mov     dx, VIADEV_PLAYBACK + VIA_REG_OFFSET_CONTROL
  1362 0001525D E85EFDFFFF          <1>         call    ctrl_io_w8
  1363                              <1> 	;call	codec_check_ready
  1364                              <1> 	;retn
  1365                              <1> 	;jmp	codec_check_ready
  1366 00015262 C3                  <1> 	retn
  1367                              <1> 
  1368                              <1> vt8233_reset: 
  1369                              <1> 	; 22/04/2017
  1370                              <1> 	; reset VT8237R (vt8233) Audio Controller
  1371                              <1> 	;cmp	byte [audio_play_cmd], 1
  1372                              <1> 	;jna	short vt8233_rst_0
  1373 00015263 C605[849C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  1374                              <1> vt8233_rst_0:
  1375 0001526A E8B0FCFFFF          <1> 	call	reset_codec
  1376 0001526F 720A                <1> 	jc	short vt8233_rst_1 ; codec error !
  1377                              <1> 	; eax = 1
  1378 00015271 E82EFDFFFF          <1> 	call	codec_io_w16 ; w32
  1379 00015276 E8ABFEFFFF          <1> 	call	channel_reset
  1380                              <1> vt8233_rst_1:
  1381 0001527B C3                  <1> 	retn
  1382                              <1> 
  1383                              <1> vt8233_volume:
  1384                              <1> 	; set VT8237R (vt8233) sound volume level
  1385                              <1> 	; 24/04/2017
  1386                              <1> 	; 22/04/2017
  1387                              <1> 	; bl = component (0 = master/playback/lineout volume)
  1388                              <1> 	; cl = left channel volume level (0 to 31)
  1389                              <1> 	; ch = right channel volume level (0 to 31)
  1390                              <1> 
  1391 0001527C 08DB                <1> 	or	bl, bl
  1392 0001527E 7520                <1> 	jnz	short vt8233_vol_1 ; temporary !
  1393 00015280 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  1394 00015284 38C1                <1> 	cmp	cl, al
  1395 00015286 7718                <1> 	ja	short vt8233_vol_1 ; temporary !
  1396 00015288 38E5                <1> 	cmp	ch, ah
  1397 0001528A 7714                <1> 	ja	short vt8233_vol_1 ; temporary !
  1398 0001528C 66890D[869C0100]    <1> 	mov	[audio_master_volume], cx
  1399 00015293 6629C8              <1> 	sub	ax, cx
  1400 00015296 BA02000000          <1> 	mov	edx, CODEC_MASTER_VOL_REG ; 02h ; Line Out
  1401 0001529B E870FDFFFF          <1> 	call	codec_write
  1402                              <1> vt8233_vol_1:
  1403 000152A0 C3                  <1> 	retn
  1404                              <1> 
  1405                              <1> ; CODE for SOUND BLASTER 16
  1406                              <1> 
  1407                              <1> DetectSB:
  1408                              <1> 	; 24/04/2017
  1409                              <1> 	;pushad
  1410                              <1> ScanPort:
  1411 000152A1 66BB1002            <1> 	mov     bx, 210h	; start scanning ports
  1412                              <1> 				; 210h, 220h, .. 260h
  1413                              <1> ResetDSP:       
  1414 000152A5 6689DA              <1> 	mov     dx, bx		; try to reset the DSP.
  1415 000152A8 6683C206            <1> 	add     dx, 06h
  1416 000152AC B001                <1> 	mov	al, 1
  1417 000152AE EE                  <1> 	out	dx, al
  1418                              <1> 
  1419 000152AF EC                  <1> 	in	al, dx
  1420 000152B0 EC                  <1> 	in	al, dx
  1421 000152B1 EC                  <1> 	in	al, dx
  1422 000152B2 EC                  <1> 	in	al, dx
  1423                              <1> 
  1424 000152B3 30C0                <1> 	xor     al, al
  1425 000152B5 EE                  <1> 	out	dx, al
  1426                              <1> 
  1427 000152B6 6683C208            <1> 	add     dx, 08h
  1428 000152BA 66B96400            <1> 	mov	cx, 100
  1429                              <1> WaitID:
  1430 000152BE EC                  <1> 	in	al, dx
  1431 000152BF 08C0                <1> 	or      al, al
  1432 000152C1 7804                <1> 	js      short GetID
  1433 000152C3 E2F9                <1> 	loop    WaitID
  1434 000152C5 EB0F                <1> 	jmp     short NextPort
  1435                              <1> GetID:          
  1436 000152C7 6683EA04            <1> 	sub     dx, 04h
  1437 000152CB EC                  <1> 	in	al, dx
  1438 000152CC 3CAA                <1> 	cmp     al, 0AAh
  1439 000152CE 7413                <1> 	je      short Found
  1440 000152D0 6683C204            <1> 	add     dx, 04h
  1441 000152D4 E2E8                <1> 	loop    WaitID
  1442                              <1> NextPort:
  1443 000152D6 6683C310            <1> 	add     bx, 10h		; if not response,
  1444 000152DA 6681FB6002          <1> 	cmp     bx, 260h	; try the next port.
  1445 000152DF 76C4                <1> 	jbe     short ResetDSP
  1446 000152E1 F9                  <1> 	stc
  1447 000152E2 C3                  <1> 	retn
  1448                              <1> Found:
  1449 000152E3 66891D[569C0100]    <1> 	mov     [audio_io_base], bx	; SB Port Address Found!
  1450                              <1> ScanIRQ:
  1451                              <1> SetIrqs:
  1452 000152EA 28C0                <1> 	sub 	al, al ; 0
  1453 000152EC A2[4E9C0100]        <1> 	mov 	[IRQnum], al ; reset
  1454 000152F1 A2[539C0100]        <1> 	mov	[audio_intr], al ; reset
  1455                              <1> 
  1456                              <1> 	; ah > 0 -> set IRQ vector
  1457                              <1> 	; al = IRQ number
  1458                              <1> 	;mov	ax, 103h ; IRQ 3
  1459                              <1> 	;call	set_hardware_int_vector
  1460                              <1> 	;mov	ax, 104h ; IRQ 4
  1461                              <1> 	;call	set_hardware_int_vector
  1462 000152F6 66B80501            <1> 	mov	ax, 105h ; IRQ 5
  1463 000152FA E8CADDFFFF          <1> 	call	set_hardware_int_vector
  1464 000152FF 66B80701            <1> 	mov	ax, 107h ; IRQ 7
  1465 00015303 E8C1DDFFFF          <1> 	call	set_hardware_int_vector
  1466                              <1> 
  1467 00015308 668B15[569C0100]    <1> 	mov     dx, [audio_io_base] ; tells to the SB to
  1468 0001530F 6683C20C            <1> 	add     dx, 0Ch		    ; generate a IRQ!
  1469                              <1> WaitSb:
  1470 00015313 EC                  <1> 	in	al, dx
  1471 00015314 08C0                <1> 	or      al, al
  1472 00015316 78FB                <1> 	js      short WaitSb
  1473 00015318 B0F2                <1> 	mov     al, 0F2h
  1474 0001531A EE                  <1> 	out	dx, al
  1475                              <1> 
  1476 0001531B 31C9                <1> 	xor     ecx, ecx	; wait until IRQ level
  1477                              <1> WaitIRQ: 
  1478 0001531D A0[4E9C0100]        <1> 	mov	al, [IRQnum]
  1479 00015322 3C00                <1> 	cmp     al, 0 ; is changed or timeout.
  1480 00015324 7706                <1> 	ja	short IrqOk
  1481 00015326 6649                <1> 	dec	cx
  1482 00015328 75F3                <1> 	jnz	short WaitIRQ
  1483 0001532A EB15                <1> 	jmp	short RestoreIrqs
  1484                              <1> IrqOk:
  1485 0001532C A2[539C0100]        <1> 	mov	[audio_intr], al ; set   
  1486 00015331 668B15[569C0100]    <1> 	mov     dx, [audio_io_base]
  1487 00015338 6683C20E            <1> 	add     dx, 0Eh
  1488 0001533C EC                  <1> 	in	al, dx	; SB acknowledge.
  1489 0001533D B020                <1> 	mov	al, 20h
  1490 0001533F E620                <1> 	out	20h, al	; Hardware acknowledge.
  1491                              <1> 
  1492                              <1> RestoreIrqs:
  1493                              <1> 	; ah = 0 -> reset IRQ vector
  1494                              <1> 	; al = IRQ number
  1495                              <1> 	;mov	ax, 3 ; IRQ 3
  1496                              <1> 	;call	set_hardware_int_vector
  1497                              <1> 	;mov	ax, 4 ; IRQ 4
  1498                              <1> 	;call	set_hardware_int_vector
  1499 00015341 66B80500            <1> 	mov	ax, 5 ; IRQ 5
  1500 00015345 E87FDDFFFF          <1> 	call	set_hardware_int_vector
  1501 0001534A 66B80700            <1> 	mov	ax, 7 ; IRQ 7
  1502 0001534E E876DDFFFF          <1> 	call	set_hardware_int_vector
  1503                              <1> 
  1504 00015353 31D2                <1> 	xor	edx, edx
  1505 00015355 8915[589C0100]      <1> 	mov	[audio_dev_id], edx ; 0
  1506 0001535B 8915[5C9C0100]      <1> 	mov	[audio_vendor], edx ; 0
  1507 00015361 8915[609C0100]      <1> 	mov	[audio_stats_cmd], edx ; 0
  1508                              <1> 
  1509                              <1> 	;popad
  1510                              <1> 
  1511 00015367 803D[539C0100]01    <1> 	cmp     byte [audio_intr], 1 ; IRQ level was changed?
  1512                              <1> 	
  1513 0001536E C3                  <1> 	retn
  1514                              <1> 
  1515                              <1> %macro	SbOut	1
  1516                              <1> %%Wait:
  1517                              <1> 	in	al, dx
  1518                              <1> 	or	al, al
  1519                              <1> 	js	short %%Wait
  1520                              <1> 	mov	al, %1
  1521                              <1> 	out	dx, al
  1522                              <1> %endmacro
  1523                              <1> 
  1524                              <1> SbInit_play:
  1525                              <1> 	; 22/10/2017
  1526                              <1> 	; 20/10/2017
  1527                              <1> 	; 06/10/2017
  1528                              <1> 	; 13/07/2017, 09/08/2017
  1529                              <1> 	; 24/04/2017, 15/05/2017, 24/06/2017
  1530                              <1> 	;pushad
  1531                              <1> SetBuffer:
  1532                              <1> 	;mov	byte [DmaFlag], 0
  1533                              <1> 
  1534 0001536F 8B1D[709C0100]      <1> 	mov	ebx, [audio_dma_buff] ; physical addr of DMA buff
  1535 00015375 89DF                <1> 	mov	edi, ebx
  1536 00015377 8B0D[749C0100]      <1> 	mov     ecx, [audio_dmabuff_size]
  1537                              <1> 
  1538 0001537D 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16
  1539 00015384 7531                <1> 	jne	short sbInit_0 ; set 8 bit DMA buffer
  1540                              <1> 	
  1541                              <1> 	; 09/08/2017
  1542                              <1> 	; convert byte count to word count
  1543 00015386 D1E9                <1> 	shr	ecx, 1
  1544 00015388 49                  <1> 	dec	ecx ; word count - 1
  1545                              <1> 	; convert byte offset to word offset
  1546 00015389 D1EB                <1> 	shr	ebx, 1
  1547                              <1> 
  1548                              <1> 	; 16 bit DMA buffer setting (DMA channel 5)
  1549 0001538B B005                <1> 	mov     al, 05h  ; set mask bit for channel 5  (4+1)
  1550 0001538D E6D4                <1> 	out	0D4h, al
  1551                              <1> 	
  1552 0001538F 30C0                <1> 	xor     al, al   ; stops all DMA processes on selected channel
  1553 00015391 E6D8                <1> 	out	0D8h, al ; clear selected channel register
  1554                              <1> 
  1555 00015393 88D8                <1> 	mov     al, bl	 ; byte 0 of DMA buffer offset in words (physical) 
  1556 00015395 E6C4                <1> 	out	0C4h, al ; DMA channel 5 port number
  1557                              <1> 
  1558 00015397 88F8                <1> 	mov     al, bh   ; byte 1 of DMA buffer offset in words (physical)   
  1559 00015399 E6C4                <1> 	out	0C4h, al
  1560                              <1> 	
  1561                              <1> 	; 09/08/2017
  1562 0001539B C1EB0F              <1> 	shr	ebx, 15	 ; complete 16 bit shift
  1563 0001539E 80E3FE              <1> 	and	bl, 0FEh ; clear bit 0 (not necessary, it will be ignored)
  1564                              <1> 
  1565 000153A1 88D8                <1> 	mov     al, bl   ; byte 2 of DMA buffer address (physical) 
  1566 000153A3 E68B                <1> 	out	8Bh, al  ; page register port addr for channel 5 ; 13/07/2017
  1567                              <1> 
  1568 000153A5 88C8                <1> 	mov     al, cl   ; low byte of DMA count - 1
  1569 000153A7 E6C6                <1> 	out	0C6h, al ; count register port addr for channel 1
  1570                              <1> 
  1571 000153A9 88E8                <1> 	mov     al, ch   ; high byte of DMA count - 1
  1572 000153AB E6C6                <1> 	out	0C6h, al
  1573                              <1> 
  1574                              <1> 	; channel 5, read, autoinitialized, single mode
  1575                              <1> 	;mov	al, 49h
  1576 000153AD B059                <1> 	mov	al, 59h  ; 06/10/2017 
  1577 000153AF E6D6                <1> 	out	0D6h, al ; DMA mode register port address
  1578                              <1> 
  1579 000153B1 B001                <1> 	mov     al, 01h  ; clear mask bit for channel 1
  1580 000153B3 E6D4                <1> 	out	0D4h, al ; DMA mask register port address
  1581                              <1> 
  1582 000153B5 EB28                <1> 	jmp	short ClearBuffer
  1583                              <1> 
  1584                              <1> sbInit_0:    
  1585 000153B7 49                  <1> 	dec     ecx ; 09/08/2017
  1586                              <1> 
  1587                              <1> 	; 8 bit DMA buffer setting (DMA channel 1)
  1588 000153B8 B005                <1> 	mov     al, 05h ; set mask bit for channel 1  (4+1)
  1589 000153BA E60A                <1> 	out	0Ah, al ; DMA mask register
  1590                              <1> 
  1591 000153BC 30C0                <1> 	xor     al, al  ; stops all DMA processes on selected channel
  1592 000153BE E60C                <1> 	out	0Ch, al ; clear selected channel register
  1593                              <1> 
  1594 000153C0 88D8                <1> 	mov     al, bl	; byte 0 of DMA buffer address (physical)   
  1595 000153C2 E602                <1> 	out	02h, al ; DMA channel 1 port number
  1596                              <1> 
  1597 000153C4 88F8                <1> 	mov     al, bh  ; byte 1 of DMA buffer address (physical)   
  1598 000153C6 E602                <1> 	out	02h, al
  1599                              <1> 
  1600 000153C8 C1EB10              <1> 	shr	ebx, 16
  1601                              <1> 
  1602 000153CB 88D8                <1> 	mov     al, bl  ; byte 2 of DMA buffer address (physical)   
  1603 000153CD E683                <1> 	out	83h, al ; page register port addr for channel 1
  1604                              <1> 
  1605 000153CF 88C8                <1> 	mov     al, cl  ; low byte of DMA count - 1
  1606 000153D1 E603                <1> 	out	03h, al ; count register port addr for channel 1
  1607                              <1> 
  1608 000153D3 88E8                <1> 	mov     al, ch  ; high byte of DMA count - 1
  1609 000153D5 E603                <1> 	out	03h, al
  1610                              <1> 
  1611                              <1> 	; channel 1, read, autoinitialized, single mode
  1612                              <1> 	;mov	al, 49h
  1613 000153D7 B059                <1> 	mov	al, 59h ; 06/10/2017 
  1614 000153D9 E60B                <1> 	out	0Bh, al ; DMA mode register port address
  1615                              <1> 
  1616 000153DB B001                <1> 	mov     al, 01h ; clear mask bit for channel 1
  1617 000153DD E60A                <1> 	out	0Ah, al ; DMA mask register port address
  1618                              <1> 
  1619                              <1> ClearBuffer:
  1620                              <1> 	;;mov	edi, [audio_dma_buff]
  1621                              <1> 	;;mov	ecx, [audio_dmabuff_size]
  1622                              <1> 	;inc	ecx
  1623                              <1> 	;mov     al, 80h
  1624                              <1> 	;;cld
  1625                              <1> 	;rep     stosb
  1626                              <1> SetIrq:
  1627                              <1> 	;mov	ebx, SbIrqhandler
  1628                              <1> 	;mov	al, [audio_intr] ; IRQ number	
  1629                              <1> 	;call	set_dev_IRQ_service
  1630                              <1> 	;; SETUP (audio) INTERRUPT CALLBACK SERVICE
  1631                              <1> 	;mov	bl, [audio_intr] ; IRQ number
  1632                              <1> 	;mov	bh, [audio_cb_mode]
  1633                              <1> 	;inc	bh  ; 1 = Signal Response Byte method (fixed value)
  1634                              <1> 	;	    ; 2 = Callback service method
  1635                              <1> 	;	    ; 3 = Auto Increment S.R.B. method 	
  1636                              <1> 	;mov	cl, [audio_srb]
  1637                              <1> 	;mov	edx, [audio_cb_addr]
  1638                              <1> 	;mov	al, [audio_user]
  1639                              <1>  	;call	set_irq_callback_service
  1640                              <1> ResetDsp:
  1641 000153DF 668B15[569C0100]    <1> 	mov     dx, [audio_io_base]
  1642 000153E6 6683C206            <1> 	add     dx, 06h
  1643 000153EA B001                <1> 	mov     al, 1
  1644 000153EC EE                  <1> 	out	dx, al
  1645                              <1> 
  1646 000153ED EC                  <1> 	in	al, dx
  1647 000153EE EC                  <1> 	in	al, dx
  1648 000153EF EC                  <1> 	in	al, dx
  1649 000153F0 EC                  <1> 	in	al, dx
  1650                              <1> 
  1651 000153F1 30C0                <1> 	xor     al, al
  1652 000153F3 EE                  <1> 	out	dx, al
  1653                              <1> 
  1654 000153F4 66B96400            <1> 	mov     cx, 100
  1655 000153F8 28E4                <1> 	sub	ah, ah ; 0
  1656                              <1> WaitId:         
  1657 000153FA 668B15[569C0100]    <1> 	mov     dx, [audio_io_base]
  1658 00015401 6683C20E            <1> 	add     dx, 0Eh
  1659 00015405 EC                  <1> 	in	al, dx
  1660 00015406 08C0                <1> 	or      al, al
  1661 00015408 7807                <1> 	js      short sb_GetId
  1662 0001540A E2EE                <1> 	loop    WaitId
  1663 0001540C E9B4000000          <1> 	jmp     sb_Exit
  1664                              <1> sb_GetId:
  1665 00015411 668B15[569C0100]    <1> 	mov     dx, [audio_io_base]
  1666 00015418 6683C20A            <1> 	add     dx, 0Ah
  1667 0001541C EC                  <1> 	in	al, dx
  1668 0001541D 3CAA                <1> 	cmp     al, 0AAh
  1669 0001541F 7407                <1> 	je      short SbOk
  1670 00015421 E2D7                <1> 	loop    WaitId
  1671 00015423 E99D000000          <1> 	jmp	sb_Exit
  1672                              <1> SbOk:
  1673 00015428 668B15[569C0100]    <1> 	mov     dx, [audio_io_base]
  1674 0001542F 6683C20C            <1> 	add     dx, 0Ch
  1675                              <1> 	SbOut   0D1h ; Turn on speaker
  1675                              <2> %%Wait:
  1675 00015433 EC                  <2>  in al, dx
  1675 00015434 08C0                <2>  or al, al
  1675 00015436 78FB                <2>  js short %%Wait
  1675 00015438 B0D1                <2>  mov al, %1
  1675 0001543A EE                  <2>  out dx, al
  1676                              <1> 	SbOut   41h ; 8 bit or 16 bit transfer
  1676                              <2> %%Wait:
  1676 0001543B EC                  <2>  in al, dx
  1676 0001543C 08C0                <2>  or al, al
  1676 0001543E 78FB                <2>  js short %%Wait
  1676 00015440 B041                <2>  mov al, %1
  1676 00015442 EE                  <2>  out dx, al
  1677 00015443 668B1D[829C0100]    <1> 	mov	bx, [audio_freq] ; sampling rate (Hz)
  1678                              <1> 	SbOut	bh ; sampling rate high byte
  1678                              <2> %%Wait:
  1678 0001544A EC                  <2>  in al, dx
  1678 0001544B 08C0                <2>  or al, al
  1678 0001544D 78FB                <2>  js short %%Wait
  1678 0001544F 88F8                <2>  mov al, %1
  1678 00015451 EE                  <2>  out dx, al
  1679                              <1> 	SbOut	bl ; sampling rate low byte
  1679                              <2> %%Wait:
  1679 00015452 EC                  <2>  in al, dx
  1679 00015453 08C0                <2>  or al, al
  1679 00015455 78FB                <2>  js short %%Wait
  1679 00015457 88D8                <2>  mov al, %1
  1679 00015459 EE                  <2>  out dx, al
  1680                              <1> 
  1681                              <1> 	; 22/05/2017
  1682 0001545A E8C0000000          <1> 	call	sb16_volume_initial ; 15/05/2017
  1683                              <1> 	; 20/05/2017
  1684                              <1> 	;call	sb16_volume
  1685                              <1> 
  1686                              <1> StartDma:  
  1687                              <1> 	; autoinitialized mode
  1688 0001545F 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  1689 00015466 7411                <1> 	je	short sb_play_1
  1690                              <1> 	; 8 bit samples
  1691 00015468 66BBC600            <1> 	mov	bx, 0C6h ; 8 bit output (0C6h)
  1692 0001546C 803D[819C0100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
  1693 00015473 7214                <1> 	jb	short sb_play_2
  1694 00015475 B720                <1> 	mov	bh, 20h	; 8 bit stereo (20h)
  1695 00015477 EB10                <1> 	jmp	short sb_play_2
  1696                              <1> sb_play_1:
  1697                              <1> 	; 16 bit samples
  1698 00015479 66BBB610            <1> 	mov	bx, 10B6h ; 16 bit output (0B6h)
  1699 0001547D 803D[819C0100]02    <1> 	cmp	byte [audio_stmo], 2 ; 1 = mono, 2 = stereo
  1700 00015484 7203                <1> 	jb	short sb_play_2
  1701 00015486 80C720              <1> 	add	bh, 20h	; 16 bit stereo (30h)
  1702                              <1> sb_play_2:     
  1703                              <1> 	; PCM output (8/16 bit mono autoinitialized transfer)
  1704                              <1> 	SbOut   bl ; bCommand
  1704                              <2> %%Wait:
  1704 00015489 EC                  <2>  in al, dx
  1704 0001548A 08C0                <2>  or al, al
  1704 0001548C 78FB                <2>  js short %%Wait
  1704 0001548E 88D8                <2>  mov al, %1
  1704 00015490 EE                  <2>  out dx, al
  1705                              <1> 	SbOut	bh ; bMode
  1705                              <2> %%Wait:
  1705 00015491 EC                  <2>  in al, dx
  1705 00015492 08C0                <2>  or al, al
  1705 00015494 78FB                <2>  js short %%Wait
  1705 00015496 88F8                <2>  mov al, %1
  1705 00015498 EE                  <2>  out dx, al
  1706 00015499 8B1D[749C0100]      <1> 	mov	ebx, [audio_dmabuff_size]  ; 15/05/2017
  1707 0001549F D1EB                <1> 	shr	ebx, 1 ; half buffer size
  1708                              <1> 	; 20/10/2017	
  1709 000154A1 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit DMA
  1710 000154A8 7502                <1> 	jne	short sb_play_3
  1711 000154AA D1EB                <1> 	shr	ebx, 1 ; byte count to word count
  1712                              <1> sb_play_3: 
  1713 000154AC 664B                <1> 	dec	bx  ; wBlkSize is one less than the actual size 
  1714                              <1> 	SbOut   bl
  1714                              <2> %%Wait:
  1714 000154AE EC                  <2>  in al, dx
  1714 000154AF 08C0                <2>  or al, al
  1714 000154B1 78FB                <2>  js short %%Wait
  1714 000154B3 88D8                <2>  mov al, %1
  1714 000154B5 EE                  <2>  out dx, al
  1715                              <1> 	SbOut   bh
  1715                              <2> %%Wait:
  1715 000154B6 EC                  <2>  in al, dx
  1715 000154B7 08C0                <2>  or al, al
  1715 000154B9 78FB                <2>  js short %%Wait
  1715 000154BB 88F8                <2>  mov al, %1
  1715 000154BD EE                  <2>  out dx, al
  1716                              <1> 
  1717 000154BE C605[849C0100]01    <1> 	mov	byte [audio_play_cmd], 1 ; playing !
  1718                              <1> 
  1719                              <1> 	;; Set Voice and master volumes
  1720                              <1> 	;mov	dx, [audio_io_base]
  1721                              <1> 	;add	dl, 4 ; Mixer chip Register Address Port
  1722                              <1> 	;SbOut	30h   ; select Master Volume Register (L)
  1723                              <1> 	;inc	dl    ; Mixer chip Register Data Port
  1724                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  1725                              <1> 	;dec	dl
  1726                              <1> 	;SbOut	31h   ; select Master Volume Register (R)
  1727                              <1> 	;inc	dl
  1728                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  1729                              <1> 	;dec	dl
  1730                              <1> 	;SbOut	32h   ; select Voice Volume Register (L)
  1731                              <1> 	;inc	dl
  1732                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)
  1733                              <1> 	;dec	dl
  1734                              <1> 	;SbOut	33h   ; select Voice Volume Register (R)
  1735                              <1> 	;inc	dl
  1736                              <1> 	;SbOut	0F8h  ; Max. volume value is 31 (31*8)	
  1737                              <1> 	;;
  1738                              <1> 	;dec	dl
  1739                              <1> 	;SbOut	44h   ; select Treble Register (L)
  1740                              <1> 	;inc	dl
  1741                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
  1742                              <1> 	;dec	dl
  1743                              <1> 	;SbOut	45h   ; select Treble Register (R)
  1744                              <1> 	;inc	dl
  1745                              <1> 	;SbOut	0F0h  ; Max. Treble value is 15 (15*16)
  1746                              <1> 	;dec	dl
  1747                              <1> 	;SbOut	46h   ; select Bass Register (L)
  1748                              <1> 	;inc	dl
  1749                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)
  1750                              <1> 	;dec	dl
  1751                              <1> 	;SbOut	47h   ; select Bass Register (R)
  1752                              <1> 	;inc	dl
  1753                              <1> 	;SbOut	0F0h  ; Max. Bass value is 15 (15*16)	
  1754                              <1> 
  1755                              <1> sb_Exit:           
  1756                              <1> 	;popad
  1757 000154C5 C3                  <1> 	retn
  1758                              <1> 
  1759                              <1> sb16_int_handler:
  1760                              <1> 	; Interrupt Handler for Sound Blaster 16 Audio Card
  1761                              <1> 	; Note: called by 'dev_IRQ_service'
  1762                              <1> 	; 20/10/2017
  1763                              <1> 	; 12/10/2017
  1764                              <1> 	; 10/10/2017 
  1765                              <1> 	; 12/05/2017, 09/10/2017
  1766                              <1> 	; 24/04/2017 (TRDOS 386 kernel, 'audio.s')
  1767                              <1> 	; 10/03/2017 - 'PLAYWAV.PRG' ('playwav.s') 
  1768                              <1> 
  1769                              <1> 	;push	eax ; * must be saved !
  1770                              <1> 	;push	ebx ; * must be saved !
  1771                              <1> 	;push	ecx
  1772                              <1> 	;push	edx
  1773                              <1> 	;push	esi
  1774                              <1> 	;push	edi
  1775                              <1> 
  1776 000154C6 668B15[569C0100]    <1> 	mov     dx, [audio_io_base]
  1777                              <1> 	; 20/10/2017
  1778 000154CD 80C20F              <1> 	add     dl, 0Fh ; 2xFh (DSP 16 bit intr ack)
  1779 000154D0 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16
  1780 000154D7 7402                <1> 	je	short sb_irq_16bit_ack
  1781                              <1> sb_irq_8bit_ack:
  1782 000154D9 FECA                <1> 	dec	dl  ; 2xEh (DSP 8 bit intr ack)
  1783                              <1> sb_irq_16bit_ack:
  1784 000154DB EC                  <1> 	in	al, dx
  1785                              <1> 
  1786                              <1> 	;cmp	byte [audio_busy], 0
  1787                              <1> 	;ja	short sb_irq_h3
  1788                              <1> 
  1789                              <1> 	;mov	byte [audio_busy], 1
  1790                              <1> 
  1791 000154DC 803D[849C0100]01    <1> 	cmp	byte [audio_play_cmd], 1
  1792 000154E3 7307                <1> 	jnb	short sb_irq_h1
  1793                              <1> sb_irq_h0:
  1794 000154E5 E8A9000000          <1> 	call	sb16_stop
  1795 000154EA EB2B                <1> 	jmp	short sb_irq_h3
  1796                              <1> sb_irq_h1:
  1797                              <1> 	;call	sb16_tuneloop
  1798                              <1> 	; 09/10/2017
  1799                              <1> sb16_tuneloop:
  1800 000154EC 8B3D[709C0100]      <1> 	mov	edi, [audio_dma_buff]
  1801 000154F2 8B0D[749C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  1802 000154F8 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  1803                              <1> 
  1804                              <1> 	; 22/05/2017
  1805 000154FA F605[789C0100]01    <1> 	test	byte [audio_flag], 1  ; Current flag value
  1806 00015501 7402                <1> 	jz	short sb_tlp1 ; EOL (Half Buffer 1 must be filled)
  1807                              <1> 	; FLAG (Half Buffer 2 must be filled)
  1808 00015503 01CF                <1> 	add	edi, ecx
  1809                              <1> 	; 15/05/2017
  1810                              <1> sb_tlp1: 
  1811 00015505 8B35[689C0100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  1812                              <1> 	;rep	movsb
  1813 0001550B C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  1814 0001550E F3A5                <1> 	rep	movsd 
  1815                              <1> 	;retn
  1816                              <1> 
  1817                              <1> 	; 10/10/2017
  1818                              <1> 	; switch flag value
  1819 00015510 8035[789C0100]01    <1> 	xor	byte [audio_flag], 1
  1820                              <1> 
  1821                              <1> 	; 12/10/2017
  1822                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (odd intr count)
  1823                              <1> 			   ; Next buffer (to update) is dma half buff 1
  1824                              <1> 	; 	       = 1 : Playing dma half buffer 1 (even intr count)
  1825                              <1> 			   ; Next buffer (to update) is dma half buff 2
  1826                              <1> 
  1827                              <1> sb_irq_h3:
  1828                              <1> 	;mov	byte [audio_busy], 0
  1829                              <1> 
  1830                              <1> 	;pop	edi
  1831                              <1> 	;pop	esi
  1832                              <1> 	;pop	edx
  1833                              <1> 	;pop	ecx
  1834                              <1> 	;pop	ebx ; * must be restored !
  1835                              <1> 	;pop	eax ; * must be restored !
  1836                              <1> 	
  1837 00015517 C3                  <1> 	retn
  1838                              <1> 
  1839                              <1> sb16_volume:
  1840                              <1> 	; 22/10/2017
  1841                              <1> 	; mov [audio_master_volume_l], cl 
  1842                              <1> 	; mov [audio_master_volume_h], ch 
  1843 00015518 66890D[869C0100]    <1> 	mov	[audio_master_volume], cx
  1844                              <1> sb16_volume_initial:
  1845 0001551F 6652                <1> 	push	dx ; DX (port address) must be saved
  1846 00015521 668B15[569C0100]    <1> 	mov	dx, [audio_io_base]
  1847 00015528 6683C204            <1> 	add	dx, 4 ; Mixer chip address port
  1848 0001552C B022                <1> 	mov	al, 22h ; master volume
  1849 0001552E EE                  <1> 	out	dx, al
  1850 0001552F 6642                <1> 	inc	dx
  1851 00015531 8A25[869C0100]      <1> 	mov	ah, [audio_master_volume_l]
  1852 00015537 C0EC02              <1> 	shr	ah, 2 ; 32 -> 8 level
  1853 0001553A C0E405              <1> 	shl	ah, 5 ; bit 5 to 7
  1854 0001553D A0[879C0100]        <1> 	mov	al, [audio_master_volume_r]	
  1855 00015542 C0E802              <1> 	shr	al, 2 ; 32 -> 8 level
  1856                              <1> 	;and	al, 0Fh
  1857 00015545 D0E0                <1> 	shl	al, 1 ; bit 1 to 3
  1858 00015547 08E0                <1> 	or	al, ah
  1859 00015549 EE                  <1> 	out	dx, al
  1860 0001554A 665A                <1> 	pop	dx ; DX (port address) must be restored
  1861 0001554C C3                  <1> 	retn
  1862                              <1> 
  1863                              <1> sb16_pause:
  1864 0001554D 668B15[569C0100]    <1> 	mov	dx, [audio_io_base]
  1865 00015554 6683C20C            <1> 	add	dx, 0Ch ; Command & Data Port
  1866 00015558 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  1867 0001555F 7404                <1> 	je	short sb_pause_1
  1868                              <1> 	; 8 bit samples
  1869 00015561 B3D0                <1> 	mov	bl, 0D0h ; 8 bit DMA mode
  1870 00015563 EB02                <1> 	jmp	short sb_pause_2
  1871                              <1> sb_pause_1:
  1872                              <1> 	; 16 bit samples
  1873 00015565 B3D5                <1> 	mov	bl, 0D5h ; 16 bit DMA mode
  1874                              <1> sb_pause_2:     
  1875                              <1> 	SbOut   bl ; bCommand
  1875                              <2> %%Wait:
  1875 00015567 EC                  <2>  in al, dx
  1875 00015568 08C0                <2>  or al, al
  1875 0001556A 78FB                <2>  js short %%Wait
  1875 0001556C 88D8                <2>  mov al, %1
  1875 0001556E EE                  <2>  out dx, al
  1876                              <1> sb_pause_3:
  1877 0001556F C3                  <1> 	retn
  1878                              <1> 
  1879                              <1> sb16_continue:
  1880 00015570 668B15[569C0100]    <1> 	mov	dx, [audio_io_base]
  1881 00015577 6683C20C            <1> 	add	dx, 0Ch ; Command & Data Port
  1882 0001557B 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  1883 00015582 7404                <1> 	je	short sb_cont_1
  1884                              <1> 	; 8 bit samples
  1885 00015584 B3D4                <1> 	mov	bl, 0D4h ; 8 bit DMA mode
  1886 00015586 EB02                <1> 	jmp	short sb_cont_2
  1887                              <1> sb_cont_1:
  1888                              <1> 	; 16 bit samples
  1889 00015588 B3D6                <1> 	mov	bl, 0D6h ; 16 bit DMA mode
  1890                              <1> sb_cont_2:     
  1891                              <1> 	SbOut   bl ; bCommand
  1891                              <2> %%Wait:
  1891 0001558A EC                  <2>  in al, dx
  1891 0001558B 08C0                <2>  or al, al
  1891 0001558D 78FB                <2>  js short %%Wait
  1891 0001558F 88D8                <2>  mov al, %1
  1891 00015591 EE                  <2>  out dx, al
  1892                              <1> sb_cont_3:
  1893 00015592 C3                  <1> 	retn
  1894                              <1> 
  1895                              <1> sb16_stop:
  1896                              <1> 	; 24/04/2017
  1897 00015593 803D[849C0100]00    <1> 	cmp	byte [audio_play_cmd], 0
  1898 0001559A 7648                <1> 	jna	short sb16_stop_4
  1899                              <1> 
  1900                              <1> 	; 22/05/2017
  1901 0001559C 668B15[569C0100]    <1> 	mov	dx, [audio_io_base]
  1902 000155A3 6683C20C            <1> 	add	dx, 0Ch
  1903                              <1> 
  1904 000155A7 B3D9                <1> 	mov	bl, 0D9h ; exit auto-initialize 16 bit transfer
  1905                              <1> 	; stop  autoinitialized DMA transfer mode 
  1906 000155A9 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  1907 000155B0 7402                <1> 	je	short sb16_stop_1
  1908                              <1> 	;mov	bl, 0DAh ; exit auto-initialize 8 bit transfer
  1909 000155B2 FEC3                <1> 	inc	bl
  1910                              <1> sb16_stop_1:
  1911                              <1> 	SbOut	bl ; exit auto-initialize transfer command
  1911                              <2> %%Wait:
  1911 000155B4 EC                  <2>  in al, dx
  1911 000155B5 08C0                <2>  or al, al
  1911 000155B7 78FB                <2>  js short %%Wait
  1911 000155B9 88D8                <2>  mov al, %1
  1911 000155BB EE                  <2>  out dx, al
  1912                              <1> 
  1913 000155BC 30C0                <1> 	xor     al, al ; stops all DMA processes on selected channel
  1914                              <1> 
  1915 000155BE 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16 ; 16 bit samples
  1916 000155C5 7404                <1> 	je	short sb16_stop_2
  1917 000155C7 E60C                <1> 	out	0Ch, al ; clear selected channel register
  1918 000155C9 EB02                <1> 	jmp	short sb16_stop_3
  1919                              <1> 
  1920                              <1> sb16_stop_2:
  1921 000155CB E6D8                <1> 	out	0D8h, al ; clear selected channel register
  1922                              <1> 
  1923                              <1> sb16_stop_3:
  1924 000155CD C605[849C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  1925                              <1> SbDone:
  1926                              <1> 	;mov	dx, [audio_io_base]
  1927                              <1> 	;add	dx, 0Ch
  1928                              <1> 	SbOut   0D0h
  1928                              <2> %%Wait:
  1928 000155D4 EC                  <2>  in al, dx
  1928 000155D5 08C0                <2>  or al, al
  1928 000155D7 78FB                <2>  js short %%Wait
  1928 000155D9 B0D0                <2>  mov al, %1
  1928 000155DB EE                  <2>  out dx, al
  1929                              <1> 	SbOut   0D3h
  1929                              <2> %%Wait:
  1929 000155DC EC                  <2>  in al, dx
  1929 000155DD 08C0                <2>  or al, al
  1929 000155DF 78FB                <2>  js short %%Wait
  1929 000155E1 B0D3                <2>  mov al, %1
  1929 000155E3 EE                  <2>  out dx, al
  1930                              <1> sb16_stop_4:
  1931 000155E4 C3                  <1> 	retn
  1932                              <1> 
  1933                              <1> sb16_reset:
  1934                              <1> 	; 24/04/2017      
  1935 000155E5 668B15[569C0100]    <1> 	mov     dx, [audio_io_base] ; try to reset the DSP.
  1936 000155EC 6683C206            <1> 	add     dx, 06h
  1937 000155F0 B001                <1> 	mov	al, 1
  1938 000155F2 EE                  <1> 	out	dx, al
  1939                              <1> 
  1940 000155F3 EC                  <1> 	in	al, dx
  1941 000155F4 EC                  <1> 	in	al, dx
  1942 000155F5 EC                  <1> 	in	al, dx
  1943 000155F6 EC                  <1> 	in	al, dx
  1944                              <1> 
  1945 000155F7 30C0                <1> 	xor     al, al
  1946 000155F9 EE                  <1> 	out	dx, al
  1947                              <1> 
  1948 000155FA 6683C208            <1> 	add     dx, 08h
  1949 000155FE 66B96400            <1> 	mov	cx, 100
  1950                              <1> sbrstWaitID:
  1951 00015602 EC                  <1> 	in	al, dx
  1952 00015603 08C0                <1> 	or      al, al
  1953 00015605 7804                <1> 	js      short sbrstGetID
  1954 00015607 E2F9                <1> 	loop    sbrstWaitID
  1955 00015609 F9                  <1> 	stc
  1956 0001560A C3                  <1> 	retn
  1957                              <1> sbrstGetID:          
  1958 0001560B 6683EA04            <1> 	sub     dx, 04h
  1959 0001560F EC                  <1> 	in	al, dx
  1960 00015610 3CAA                <1> 	cmp     al, 0AAh
  1961 00015612 7406                <1> 	je      short sb_rst_retn
  1962 00015614 6683C204            <1> 	add     dx, 04h
  1963 00015618 E2E8                <1> 	loop    sbrstWaitID
  1964                              <1> sb_rst_retn:
  1965 0001561A C3                  <1> 	retn
  1966                              <1> 
  1967                              <1> ac97_codec_config:
  1968                              <1> 	; 10/06/2017
  1969                              <1> 	; 05/06/2017
  1970                              <1> 	; 29/05/2017
  1971                              <1> 	; 28/05/2017 (TRDOS 386, 'audio.s')
  1972                              <1> 	; 07/11/2016 (Erdogan Tan)
  1973                              <1> 	; Derived from 'codecConfig' procedure in 'CODEC.ASM'
  1974                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  1975                              <1> 
  1976                              <1> 	;; 'PLAYER.ASM'
  1977                              <1> 	;; get ICH base address regs for mixer and bus master
  1978                              <1> 
  1979                              <1> init_ac97_controller: ; 10/06/2017
  1980 0001561B A1[589C0100]        <1> 	mov	eax, [audio_dev_id]
  1981                              <1>         ;mov	al, NAMBAR_REG
  1982                              <1>         ;;call  pciRegRead16			; read PCI registers 10-11
  1983                              <1>         ;call	pciRegRead32
  1984                              <1> 	;and	dx, IO_ADDR_MASK 		; mask off BIT0
  1985                              <1> 	;;and	edx, IO_ADDR_MASK 
  1986                              <1> 
  1987                              <1>         ;mov	[NAMBAR], dx			; save audio mixer base addr
  1988                              <1> 
  1989                              <1>         ;mov    al, NABMBAR_REG
  1990                              <1>         ;;call	pciRegRead16
  1991                              <1>         ;call	pciRegRead32
  1992                              <1> 	;and	dx, 0FFC0h ; IO_ADDR_MASK
  1993                              <1> 	;;and	edx, 0FFC0h
  1994                              <1> 
  1995                              <1>         ;mov    [NABMBAR], dx			; save bus master base addr
  1996                              <1> 
  1997                              <1> 	;mov	eax, [audio_dev_id]
  1998 00015620 B004                <1>         mov     al, PCI_CMD_REG
  1999                              <1>         ;call	pciRegRead8			; read PCI command register
  2000 00015622 E84AF8FFFF          <1>         call	pciRegRead16
  2001 00015627 80CA05              <1> 	or      dl, IO_ENA+BM_ENA               ; enable IO and bus master
  2002                              <1>         ;call 	pciRegWrite8
  2003 0001562A E8ADF8FFFF          <1> 	call	pciRegWrite16
  2004                              <1> 
  2005                              <1> 	; 'CODEC.ASM'
  2006                              <1> 
  2007                              <1> 	; enable codec, unmute stuff, set output rate
  2008                              <1> ;	; entry: [audio_freq] = desired sample rate
  2009                              <1> 		
  2010                              <1> ;	mov    	dx, [NAMBAR]               	
  2011                              <1> ;	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
  2012                              <1> ;	in     	ax, dx
  2013                              <1> ;	or	ax, 1
  2014                              <1> ;	out	dx, ax 				; Enable variable rate audio
  2015                              <1> 
  2016                              <1> ;       ;call    delay1_4ms
  2017                              <1> ;       ;call    delay1_4ms
  2018                              <1> ;       ;call    delay1_4ms
  2019                              <1> ;       ;call    delay1_4ms
  2020                              <1> 
  2021                              <1> ;	mov	ax, [audio_freq]		; sample rate
  2022                              <1> 
  2023                              <1> ;	mov    	dx, [NAMBAR]               	
  2024                              <1> ;	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  2025                              <1> ;	out	dx, ax 				; out sample rate
  2026                              <1> 		
  2027                              <1> ;       ;call	delay1_4ms
  2028                              <1> ;       ;call	delay1_4ms
  2029                              <1> ;       ;call	delay1_4ms
  2030                              <1> ;       ;call	delay1_4ms
  2031                              <1> 
  2032                              <1> 	;mov	dx, [NAMBAR]			; mixer base address
  2033                              <1>         ;add	dx, CODEC_RESET_REG  		; reset register
  2034                              <1>         ;mov	ax, 42
  2035                              <1> 	;out	dx, ax                          ; reset
  2036                              <1> 
  2037                              <1> 	;mov    dx, [NABMBAR]			; bus master base address
  2038                              <1>         ;add	dx, GLOB_STS_REG
  2039                              <1>         ;mov	ax, 2
  2040                              <1> 	;out	dx, ax                         
  2041                              <1> 
  2042 0001562F E847F9FFFF          <1>         call    delay_100ms ; 29/05/2017
  2043                              <1> 
  2044                              <1> init_ac97_codec:
  2045                              <1> 	; 10/06/2017
  2046                              <1> 	; 29/05/2017
  2047                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2048                              <1> 	;	
  2049 00015634 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2050 00015638 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2051 0001563F ED                  <1> 	in	eax, dx
  2052                              <1> 	; ?
  2053 00015640 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  2054 00015644 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2055 0001564B ED                  <1> 	in	eax, dx
  2056                              <1> 
  2057 0001564C 83F8FF              <1> 	cmp	eax, 0FFFFFFFFh ; -1
  2058 0001564F 744B                <1> 	je	short init_ac97_codec_err1
  2059                              <1> 
  2060 00015651 A900030010          <1> 	test	eax, CTRL_ST_CREADY
  2061 00015656 7507                <1> 	jnz	short _ac97_codec_ready
  2062                              <1> 
  2063 00015658 E8EF020000          <1> 	call	reset_ac97_codec
  2064 0001565D 723E                <1> 	jc	short init_ac97_codec_err2
  2065                              <1> 
  2066                              <1> _ac97_codec_ready:
  2067 0001565F 668B15[889C0100]    <1> 	mov	dx, [NAMBAR]
  2068                              <1> 	;add	dx, 0 ; ac_reg_0 ; reset register
  2069 00015666 66EF                <1> 	out	dx, ax
  2070                              <1> 
  2071 00015668 31C0                <1> 	xor	eax, eax ; 0
  2072 0001566A 668B15[889C0100]    <1> 	mov	dx, [NAMBAR]
  2073 00015671 6683C226            <1> 	add	dx, CODEC_REG_POWERDOWN	
  2074 00015675 66EF                <1> 	out	dx, ax
  2075                              <1> 
  2076                              <1> 	; 10/06/2017
  2077                              <1> 	; 29/05/2017
  2078                              <1> 	; wait for 1 second
  2079 00015677 B9E8030000          <1> 	mov	ecx, 1000 ; 1000*0.25ms = 1s
  2080                              <1> _ac97_codec_rloop:
  2081 0001567C E807F9FFFF          <1> 	call	delay1_4ms
  2082 00015681 E802F9FFFF          <1> 	call	delay1_4ms
  2083 00015686 E8FDF8FFFF          <1> 	call	delay1_4ms
  2084 0001568B E8F8F8FFFF          <1> 	call	delay1_4ms
  2085                              <1> 	;mov	dx, [NAMBAR]
  2086                              <1> 	;add	dx, CODEC_REG_POWERDOWN
  2087 00015690 66ED                <1> 	in	ax, dx	
  2088 00015692 6683E00F            <1> 	and	ax, 0Fh
  2089 00015696 3C0F                <1> 	cmp	al, 0Fh
  2090 00015698 7404                <1> 	je	short _ac97_codec_init_ok
  2091 0001569A E2E0                <1> 	loop	_ac97_codec_rloop 
  2092                              <1> 
  2093                              <1> init_ac97_codec_err1:
  2094 0001569C F9                  <1> 	stc
  2095                              <1> init_ac97_codec_err2:
  2096 0001569D C3                  <1> 	retn
  2097                              <1> 
  2098                              <1> _ac97_codec_init_ok:
  2099 0001569E B002                <1>         mov     al, 2 ; force set 16-bit 2-channel PCM
  2100 000156A0 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2101 000156A4 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2102 000156AB EF                  <1> 	out	dx, eax
  2103                              <1> 
  2104                              <1> 	;call	delay1_4ms
  2105                              <1> 
  2106                              <1> 	; 10/06/2017
  2107 000156AC E849020000          <1> 	call 	reset_ac97_controller
  2108                              <1> 
  2109                              <1> ;	call 	setup_ac97_codec
  2110                              <1> ;
  2111                              <1> ;detect_ac97_codec:
  2112                              <1> ;	retn
  2113                              <1> 
  2114                              <1> setup_ac97_codec:
  2115                              <1> 	; 22/07/2020
  2116                              <1> 	; 10/06/2017
  2117                              <1> 	; 29/05/2017
  2118 000156B1 B802020000          <1> 	mov     eax, 0202h
  2119 000156B6 66A3[869C0100]      <1> 	mov	[audio_master_volume], ax
  2120 000156BC 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31, 31
  2121                              <1> 	
  2122 000156C0 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2123 000156C7 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG	;02h 
  2124 000156CB 6631C0              <1>   	xor	ax, ax 	; volume attenuation = 0 (max. volume)
  2125 000156CE 66EF                <1>   	out     dx, ax
  2126                              <1>  
  2127 000156D0 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2128 000156D7 6683C206            <1>   	add     dx, CODEC_MASTER_MONO_VOL_REG	;06h 
  2129                              <1> 	;xor	ax, ax
  2130 000156DB 66EF                <1>   	out     dx, ax
  2131                              <1> 
  2132 000156DD 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2133 000156E4 6683C20A            <1>   	add     dx, CODEC_PCBEEP_VOL_REG	;0Ah 
  2134                              <1>   	;xor    ax, ax
  2135 000156E8 66EF                <1>   	out     dx, ax
  2136                              <1> 
  2137 000156EA 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2138 000156F1 6683C218            <1>   	add     dx, CODEC_PCM_OUT_REG		;18h 
  2139                              <1>   	;xor    ax, ax
  2140 000156F5 66EF                <1>   	out     dx, ax
  2141                              <1> 
  2142 000156F7 66B80880            <1> 	mov     ax, 8008h ; Mute
  2143 000156FB 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2144                              <1> 	; 22/07/2020
  2145 00015702 6683C20C            <1> 	add	dx, CODEC_PHONE_VOL_REG		;0Ch
  2146                              <1> 				 ; AC97_PHONE_VOL ; TAD Input (Mono)
  2147 00015706 66EF                <1>   	out     dx, ax
  2148                              <1> 
  2149 00015708 66B80808            <1>         mov	ax, 0808h
  2150 0001570C 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2151 00015713 6683C210            <1>         add	dx, CODEC_LINE_IN_VOL_REG ;10h ; Line Input (Stereo)	
  2152 00015717 66EF                <1>   	out     dx, ax
  2153                              <1> 
  2154                              <1> 	;mov	ax, 0808h
  2155 00015719 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2156 00015720 6683C212            <1>         add	dx, CODEC_CD_VOL_REG ;12h ; CR Input (Stereo)
  2157 00015724 66EF                <1>   	out     dx, ax
  2158                              <1> 
  2159                              <1> 	;mov	ax, 0808h
  2160 00015726 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2161 0001572D 6683C216            <1>         add	dx, CODEC_AUX_VOL_REG ;16h ; Aux Input (Stereo)
  2162 00015731 66EF                <1>   	out     dx, ax
  2163                              <1> 
  2164                              <1>         ;call    delay1_4ms
  2165                              <1>         ;call    delay1_4ms
  2166                              <1>         ;call    delay1_4ms
  2167                              <1>         ;call    delay1_4ms
  2168                              <1> 
  2169                              <1> detect_ac97_codec:
  2170 00015733 C3                  <1>         retn
  2171                              <1> 
  2172                              <1> set_ac97_bdl: ; Set AC97 (ICH) Buffer Descriptor List
  2173                              <1> 	; 17/06/2017
  2174                              <1> 	; 11/06/2017
  2175                              <1> 	; 28/05/2017
  2176                              <1> 	; eax = dma buffer address = [audio_DMA_buff]
  2177                              <1> 	; ecx = dma buffer buffer size = [audio_dmabuff_size]
  2178                              <1> 
  2179 00015734 D1E9                <1> 	shr	ecx, 1 ; dma half buffer size
  2180 00015736 89CE                <1> 	mov	esi, ecx
  2181                              <1> 
  2182 00015738 BF[8C9C0100]        <1>         mov     edi, audio_bdl_buff	; get BDL address
  2183 0001573D B910000000          <1>         mov     ecx, 32 / 2		; make 32 entries in BDL
  2184                              <1> 
  2185 00015742 EB05                <1> 	jmp	short s_ac97_bdl1 
  2186                              <1> 
  2187                              <1> s_ac97_bdl0:
  2188                              <1> 	; set buffer descriptor 0 to start of data file in memory
  2189                              <1> 
  2190 00015744 A1[709C0100]        <1>  	mov	eax, [audio_dma_buff]	; Physical address of DMA buffer
  2191                              <1>  
  2192                              <1> s_ac97_bdl1:
  2193 00015749 AB                  <1> 	stosd				; store dmabuffer1 address
  2194                              <1> 
  2195 0001574A 89C2                <1> 	mov	edx, eax
  2196                              <1> 
  2197                              <1> ;
  2198                              <1> ; Buffer Descriptors List
  2199                              <1> ; As stated earlier, each buffer descriptor list is a set of (up to) 32 
  2200                              <1> ; descriptors, each 8 bytes in length. Bytes 0-3 of a descriptor entry point
  2201                              <1> ; to a chunk of memory to either play from or record to. Bytes 4-7 of an
  2202                              <1> ; entry describe various control things detailed below.
  2203                              <1> ; 
  2204                              <1> ; Buffer pointers must always be aligned on a Dword boundry.
  2205                              <1> ;
  2206                              <1> ;
  2207                              <1> 
  2208                              <1> ;IOC                     equ     BIT31	; Fire an interrupt whenever this
  2209                              <1>                                         ; buffer is complete.
  2210                              <1> 
  2211                              <1> ;BUP                     equ     BIT30  ; Buffer Underrun Policy.
  2212                              <1>                                         ; if this buffer is the last buffer
  2213                              <1>                                         ; in a playback, fill the remaining
  2214                              <1>                                         ; samples with 0 (silence) or not.
  2215                              <1>                                         ; It's a good idea to set this to 1
  2216                              <1>                                         ; for the last buffer in playback,
  2217                              <1>                                         ; otherwise you're likely to get a lot
  2218                              <1>                                         ; of noise at the end of the sound.
  2219                              <1> 
  2220                              <1> ;
  2221                              <1> ; Bits 15:0 contain the length of the buffer, in number of samples, which
  2222                              <1> ; are 16 bits each, coupled in left and right pairs, or 32bits each.
  2223                              <1> ; Luckily for us, that's the same format as .wav files.
  2224                              <1> ;
  2225                              <1> ; A value of FFFF is 65536 samples. Running at 44.1Khz, that's just about
  2226                              <1> ; 1.5 seconds of sample time. FFFF * 32bits is 1FFFFh bytes or 128k of data.
  2227                              <1> ;
  2228                              <1> ; A value of 0 in these bits means play no samples.
  2229                              <1> ;
  2230                              <1> 
  2231 0001574C 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  2232 0001574E 01C2                <1> 	add	edx, eax
  2233 00015750 D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
  2234                              <1> 	;or	eax, IOC+BUP
  2235 00015752 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
  2236 00015757 AB                  <1> 	stosd
  2237                              <1> 
  2238                              <1> ; 2nd buffer:
  2239                              <1> 
  2240 00015758 89D0                <1>         mov	eax, edx ; Physical address of the 2nd half of DMA buffer	
  2241 0001575A AB                  <1> 	stosd		 ; store dmabuffer2 address
  2242                              <1> 
  2243                              <1> ; set length to [audio_dmabuff_size]/2
  2244                              <1> ; Set control (bits 31:16) to BUP, bits 15:0=number of samples
  2245                              <1> ; 
  2246 0001575B 89F0                <1> 	mov	eax, esi ; DMA half buffer size
  2247 0001575D D1E8                <1> 	shr	eax, 1 ; count of 16 bit samples
  2248                              <1> 	;or	eax, IOC+BUP
  2249 0001575F 0D00000080          <1> 	or	eax, IOC ; 11/06/2017
  2250 00015764 AB                  <1> 	stosd
  2251                              <1> 
  2252 00015765 E2DD                <1> 	loop    s_ac97_bdl0
  2253                              <1> 	
  2254 00015767 C3                  <1> 	retn
  2255                              <1> 
  2256                              <1> ac97_start_play:  
  2257                              <1> 	; 28/05/2017
  2258                              <1> 	; Derived from 'playWav' procedure in 'ICHWAV.ASM'
  2259                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  2260                              <1> 
  2261                              <1> 	; set output rate
  2262                              <1> 	; entry: [audio_freq] = desired sample rate
  2263                              <1> 		
  2264 00015768 668B15[889C0100]    <1> 	mov    	dx, [NAMBAR]               	
  2265 0001576F 6683C22A            <1> 	add    	dx, CODEC_EXT_AUDIO_CTRL_REG  	; 2Ah  	  
  2266 00015773 66ED                <1> 	in     	ax, dx
  2267 00015775 6683C801            <1> 	or	ax, 1
  2268 00015779 66EF                <1> 	out	dx, ax 				; Enable variable rate audio
  2269                              <1> 
  2270                              <1>        ;call    delay1_4ms
  2271                              <1>        ;call    delay1_4ms
  2272                              <1>        ;call    delay1_4ms
  2273                              <1>        ;call    delay1_4ms
  2274                              <1> 
  2275 0001577B 66A1[829C0100]      <1> 	mov	ax, [audio_freq]		; sample rate
  2276                              <1> 
  2277 00015781 668B15[889C0100]    <1> 	mov    	dx, [NAMBAR]               	
  2278 00015788 6683C22C            <1> 	add    	dx, CODEC_PCM_FRONT_DACRATE_REG	; 2Ch  	  
  2279 0001578C 66EF                <1> 	out	dx, ax 				; out sample rate
  2280                              <1> 		
  2281                              <1>        ;call    delay1_4ms
  2282                              <1>        ;call    delay1_4ms
  2283                              <1>        ;call    delay1_4ms
  2284                              <1>        ;call    delay1_4ms
  2285                              <1> 
  2286                              <1> ;
  2287                              <1> ; register reset the DMA engine. This may cause a pop noise on the output
  2288                              <1> ; lines when the device is reset. Prolly a better idea to mute output, then
  2289                              <1> ; reset.
  2290                              <1> ;
  2291 0001578E 668B15[8A9C0100]    <1>         mov     dx, [NABMBAR]
  2292 00015795 6683C21B            <1>         add     dx, PO_CR_REG                  ; set pointer to Cntl reg
  2293 00015799 B002                <1>         mov     al, RR                         ; set reset
  2294 0001579B EE                  <1>         out     dx, al                         ; self clearing bit
  2295                              <1> ;
  2296                              <1> ;	mov	edi, audio_bdl_buff
  2297                              <1> ;	mov	edx, [audio_dmabuff_size]
  2298                              <1> ;	shr	edx, 1
  2299                              <1> ;	mov	ecx, 32/2
  2300                              <1> ;ac97_set_bdl_buffer:
  2301                              <1> ;	; 1st half of DMA buffer
  2302                              <1> ;	mov	eax, [audio_dma_buff]
  2303                              <1> ;	push	eax
  2304                              <1> ;	stosd
  2305                              <1> ;	mov	eax, edx ; dma buffer size / 2
  2306                              <1> ;	or	eax, IOC+BUP
  2307                              <1> ;	stosd
  2308                              <1> ;	pop	eax
  2309                              <1> ;	; 2nd half of DMA buffer
  2310                              <1> ;	add	eax, edx
  2311                              <1> ;	stosd
  2312                              <1> ;	mov	eax, edx ; dma buffer size / 2
  2313                              <1> ;	or	eax, IOC+BUP
  2314                              <1> ;	stosd
  2315                              <1> ;	loop	ac97_set_bdl_buffer
  2316                              <1>  	
  2317                              <1> ; tell the DMA engine where to find our list of Buffer Descriptors.
  2318                              <1> ; this 32bit value is a flat mode memory offset (ie no segment:offset)
  2319                              <1> ;
  2320                              <1> ; write NABMBAR+10h with offset of buffer descriptor list
  2321                              <1> ;
  2322 0001579C B8[8C9C0100]        <1>         mov	eax, audio_bdl_buff
  2323 000157A1 668B15[8A9C0100]    <1> 	mov	dx, [NABMBAR]
  2324 000157A8 6683C210            <1> 	add	dx, PO_BDBAR_REG
  2325 000157AC EF                  <1> 	out	dx, eax
  2326                              <1> ;
  2327                              <1> ; All set. Let's play some music.
  2328                              <1> ;
  2329                              <1> ;
  2330 000157AD B81F000000          <1> 	mov	eax, 31
  2331 000157B2 E816000000          <1> 	call    set_ac97_LastValidIndex
  2332                              <1> 
  2333 000157B7 C605[849C0100]01    <1> 	mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  2334                              <1> 
  2335                              <1> ac97_play: ; continue to play (after pause)
  2336                              <1> 	; 11/06/2017
  2337                              <1> 	; 29/05/2017
  2338                              <1> 	; 28/05/2017
  2339 000157BE 668B15[8A9C0100]    <1>         mov     dx, [NABMBAR]
  2340 000157C5 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
  2341 000157C9 B011                <1>         mov	al, IOCE+RPBM ; 29/05/2017
  2342                              <1>         ;mov	al, 1Dh ; (Ref: KolibriOS, intelac97.asm, 'play:')
  2343 000157CB EE                  <1> 	out     dx, al			; set start!
  2344                              <1> 
  2345                              <1> 	;mov	byte [audio_play_cmd], 1 ; play command (do not stop) !
  2346                              <1> 
  2347 000157CC C3                  <1> 	retn
  2348                              <1> 
  2349                              <1> ;input AL = index # to stop on
  2350                              <1> set_ac97_LastValidIndex:
  2351                              <1> 	; 28/05/2017
  2352                              <1> 	; Derived from 'setLastValidIndex' procedure in 'ICHWAV.ASM'
  2353                              <1> 	; .wav player for DOS by Jeff Leyda (02/09/2002)
  2354 000157CD 668B15[8A9C0100]    <1> 	mov	dx, [NABMBAR]
  2355 000157D4 6683C215            <1> 	add	dx, PO_LVI_REG
  2356 000157D8 EE                  <1>         out     dx, al
  2357                              <1> 	;mov	[audio_lvi], al ; for ac97_int_handler
  2358 000157D9 C3                  <1> 	retn
  2359                              <1> 
  2360                              <1> ac97_volume:
  2361                              <1> 	; 28/05/2017
  2362                              <1> 	; bl = component (0 = master/playback/lineout volume)
  2363                              <1> 	; cl = left channel volume level (0 to 31)
  2364                              <1> 	; ch = right channel volume level (0 to 31)
  2365                              <1> 
  2366 000157DA 08DB                <1> 	or	bl, bl
  2367 000157DC 7523                <1> 	jnz	short ac97_vol_1 ; temporary !
  2368 000157DE 66B81F1F            <1> 	mov	ax, 1F1Fh ; 31,31
  2369 000157E2 38C1                <1> 	cmp	cl, al
  2370 000157E4 771B                <1> 	ja	short ac97_vol_1 ; temporary !
  2371 000157E6 38E5                <1> 	cmp	ch, ah
  2372 000157E8 7717                <1> 	ja	short ac97_vol_1 ; temporary !
  2373 000157EA 66890D[869C0100]    <1> 	mov	[audio_master_volume], cx
  2374 000157F1 6629C8              <1> 	sub	ax, cx
  2375 000157F4 668B15[889C0100]    <1>   	mov     dx, [NAMBAR]
  2376 000157FB 6683C202            <1>   	add     dx, CODEC_MASTER_VOL_REG  ; 02h ; Line Out 
  2377 000157FF 66EF                <1>   	out     dx, ax
  2378                              <1> ac97_vol_1:
  2379 00015801 C3                  <1> 	retn
  2380                              <1> 
  2381                              <1> ac97_int_handler:
  2382                              <1> 	; 12/10/2017
  2383                              <1> 	; 10/10/2017
  2384                              <1> 	; 09/10/2017
  2385                              <1> 	; 13/06/2017, 13/06/2017
  2386                              <1> 	; 10/06/2017, 11/06/2017
  2387                              <1> 	; Interrupt Handler for AC97 (ICH) Audio Controller
  2388                              <1> 	; Note: called by 'dev_IRQ_service' 
  2389                              <1> 	; 28/05/2017
  2390                              <1> 
  2391                              <1> 	;push	eax ; * must be saved !
  2392                              <1> 	;push	edx
  2393                              <1> 	;push	ecx
  2394                              <1> 	;push	ebx ; * must be saved !
  2395                              <1> 	;push	esi
  2396                              <1> 	;push	edi
  2397                              <1> 
  2398                              <1> 	;cmp	byte [audio_busy], 1
  2399                              <1> 	;jnb	_ac97_ih2	; busy !
  2400                              <1> 
  2401 00015802 66BA3000            <1>         mov     dx, GLOB_STS_REG
  2402 00015806 660315[8A9C0100]    <1>         add	dx, [NABMBAR]
  2403 0001580D ED                  <1> 	in	eax, dx
  2404                              <1> 
  2405 0001580E 83F8FF              <1>         cmp     eax, 0FFFFFFFFh ; -1
  2406 00015811 0F849A000000        <1>         je      _ac97_ih3 ; exit
  2407                              <1> 
  2408 00015817 A940000000          <1>         test    eax, 40h ; PCM Out Interrupt
  2409 0001581C 750E                <1>         jnz     short _ac97_ih0
  2410                              <1> 
  2411 0001581E 85C0                <1> 	test	eax, eax
  2412 00015820 0F848B000000        <1> 	jz	_ac97_ih3 ; exit
  2413                              <1> 
  2414                              <1>  	;mov	dx, GLOB_STS_REG
  2415                              <1>         ;add	dx, [NABMBAR]
  2416 00015826 EF                  <1> 	out	dx, eax
  2417                              <1> 
  2418 00015827 E985000000          <1> 	jmp	_ac97_ih3 ; exit
  2419                              <1> 
  2420                              <1> _ac97_ih0:
  2421 0001582C 50                  <1> 	push	eax
  2422                              <1> 	; 09/10/2017
  2423 0001582D 803D[849C0100]01    <1> 	cmp	byte [audio_play_cmd], 1
  2424 00015834 727C                <1> 	jb	short _ac97_ih4 ; stop command !
  2425                              <1> 
  2426                              <1> 	;mov	byte [audio_busy], 1
  2427                              <1> 
  2428                              <1> 	;mov	al, 10h
  2429                              <1> 	;mov	dx, PO_CR_REG
  2430                              <1>         ;add	dx, [NABMBAR]
  2431                              <1> 	;out	dx, al
  2432                              <1> 
  2433 00015836 66B81C00            <1> 	mov	ax, 1Ch ; FIFOE(=16)+BCIS(=8)+LVBCI(=4)
  2434 0001583A 66BA1600            <1> 	mov	dx, PO_SR_REG
  2435 0001583E 660315[8A9C0100]    <1>         add	dx, [NABMBAR]
  2436 00015845 66EF                <1> 	out	dx, ax
  2437                              <1> 
  2438 00015847 66BA1400            <1> 	mov	dx, PO_CIV_REG
  2439 0001584B 660315[8A9C0100]    <1>         add	dx, [NABMBAR]
  2440 00015852 EC                  <1> 	in	al, dx
  2441                              <1> 
  2442                              <1> 	;cmp	al, [audio_civ] ; [audio_flag]
  2443                              <1> 	;je	short _ac97_ih2
  2444                              <1> 
  2445 00015853 A2[859C0100]        <1> 	mov	[audio_civ], al
  2446 00015858 FEC8                <1> 	dec	al
  2447                              <1> 	;inc	al ; 11/06/2017
  2448 0001585A 241F                <1> 	and	al, 1Fh
  2449                              <1> 
  2450 0001585C 66BA1500            <1>         mov     dx, PO_LVI_REG
  2451 00015860 660315[8A9C0100]    <1>         add	dx, [NABMBAR]
  2452 00015867 EE                  <1>         out	dx, al
  2453                              <1> 
  2454                              <1> 	; 12/10/2017
  2455 00015868 A0[859C0100]        <1> 	mov	al, [audio_civ]
  2456 0001586D FEC0                <1> 	inc	al
  2457 0001586F 2401                <1> 	and	al, 1
  2458 00015871 A2[789C0100]        <1> 	mov	[audio_flag], al 
  2459                              <1> 	;; [audio_flag] : 0 = Buffer 1, 1 = Buffer 2
  2460                              <1> 	;
  2461 00015876 58                  <1> 	pop	eax
  2462                              <1> 	;
  2463 00015877 83E040              <1> 	and     eax, 40h
  2464 0001587A 668B15[8A9C0100]    <1>         mov	dx, [NABMBAR]
  2465 00015881 6683C230            <1> 	add	dx, GLOB_STS_REG
  2466 00015885 EF                  <1> 	out	dx, eax
  2467                              <1> 
  2468                              <1> 	;; 13/06/2017
  2469                              <1> 	;mov	al, 11h ; IOCE + RPBM
  2470                              <1> 	;mov	dx, PO_CR_REG
  2471                              <1>         ;add	dx, [NABMBAR]
  2472                              <1> 	;out	dx, al
  2473                              <1> 
  2474                              <1> ac97_tuneloop:
  2475                              <1> 	; 09/10/2017
  2476 00015886 8B3D[709C0100]      <1> 	mov	edi, [audio_dma_buff]
  2477 0001588C 8B0D[749C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  2478 00015892 D1E9                <1> 	shr	ecx, 1 ; dma buff size / 2 = half buffer size
  2479                              <1> 
  2480                              <1> 	; 12/10/2017
  2481 00015894 803D[789C0100]00    <1> 	cmp 	byte [audio_flag], 0
  2482 0001589B 7702                <1> 	ja	short _ac97_ih1  ; Playing Half Buffer 2 (Current: FLAG)
  2483                              <1> 	; Playing Half Buffer 1 (Current: EOL)	
  2484 0001589D 01CF                <1> 	add	edi, ecx
  2485                              <1> _ac97_ih1: 
  2486                              <1> 	; Update half buffer 2 while playing half buffer 1 (next: FLAG)
  2487                              <1> 	; Update half buffer 1 while playing half buffer 2 (next: EOL)
  2488                              <1> 
  2489 0001589F 8B35[689C0100]      <1> 	mov	esi, [audio_p_buffer] ; phy addr of audio buff
  2490 000158A5 C1E902              <1> 	shr	ecx, 2 ; half buff size / 4
  2491 000158A8 F3A5                <1> 	rep	movsd 
  2492                              <1> 
  2493                              <1> 	; 10/10/2017
  2494                              <1> 	; switch flag value
  2495 000158AA 8035[789C0100]01    <1> 	xor	byte [audio_flag], 1
  2496                              <1> 	; 12/10/2017
  2497                              <1> 	; [audio_flag] = 0 : Playing dma half buffer 2 (even index value)
  2498                              <1> 			   ; Next buffer (to update) is dma half buff 1
  2499                              <1> 	; 	       = 1 : Playing dma half buffer 1 (odd index value)
  2500                              <1> 			   ; Next buffer (to update) is dma half buff 2
  2501                              <1> 
  2502                              <1> _ac97_ih2:
  2503                              <1> 	;mov	byte [audio_busy], 0
  2504                              <1> _ac97_ih3:
  2505                              <1> 	;pop	edi
  2506                              <1> 	;pop	esi
  2507                              <1> 	;pop	ebx ; * must be restored !
  2508                              <1> 	;pop	ecx
  2509                              <1> 	;pop	edx
  2510                              <1> 	;pop	eax ; * must be restored !
  2511                              <1> 
  2512 000158B1 C3                  <1> 	retn
  2513                              <1> 
  2514                              <1> _ac97_ih4:
  2515                              <1> 	; 09/10/2017
  2516 000158B2 E818000000          <1> 	call	_ac97_stop
  2517                              <1> 	;
  2518 000158B7 58                  <1> 	pop	eax
  2519                              <1> 	;
  2520 000158B8 83E040              <1> 	and     eax, 40h
  2521 000158BB 668B15[8A9C0100]    <1>         mov	dx, [NABMBAR]
  2522 000158C2 6683C230            <1> 	add	dx, GLOB_STS_REG
  2523 000158C6 EF                  <1> 	out	dx, eax
  2524                              <1> 
  2525                              <1> 	;; 13/06/2017
  2526                              <1> 	;mov	al, 11h ; IOCE + RPBM
  2527                              <1> 	;dx, PO_CR_REG
  2528                              <1>         ;add	dx, [NABMBAR]
  2529                              <1> 	;out	dx, al
  2530                              <1> 
  2531                              <1> 	; 10/10/2017
  2532                              <1> 	;jmp	short _ac97_ih3  ; exit
  2533 000158C7 C3                  <1> 	retn
  2534                              <1> 
  2535                              <1> ac97_stop: 
  2536                              <1> 	; 28/05/2017
  2537 000158C8 C605[849C0100]00    <1> 	mov	byte [audio_play_cmd], 0 ; stop !
  2538                              <1> _ac97_stop: ; 09/10/2017
  2539                              <1> 	; 29/05/2017
  2540                              <1> 	;mov	dx, [NABMBAR]
  2541                              <1> 	;add	dx, PO_CR_REG
  2542                              <1> 	;mov	al, 0
  2543                              <1> 	;out	dx, al
  2544                              <1> 
  2545                              <1> 	; 11/06/2017
  2546 000158CF 30C0                <1> 	xor	al, al ; 0
  2547 000158D1 E813000000          <1> 	call	ac97_po_cmd
  2548                              <1> 
  2549                              <1> 	; (Ref: KolibriOS, intelac97.asm, 'stop:')
  2550                              <1> 	; Clear FIFOE, BCIS, LVBCI (Ref: Intel ICH hub manual)
  2551 000158D6 66B81C00            <1> 	mov     ax, 1Ch
  2552 000158DA 668B15[8A9C0100]    <1> 	mov     dx, [NABMBAR]
  2553 000158E1 6683C216            <1> 	add     dx, PO_SR_REG
  2554 000158E5 66EF                <1> 	out     dx, ax
  2555                              <1> 
  2556                              <1> 	;retn
  2557                              <1> 
  2558                              <1> 	; 11/06/2017
  2559 000158E7 B002                <1> 	mov     al, RR
  2560                              <1> ac97_po_cmd:
  2561                              <1> 	 ;11/06/2017
  2562                              <1> 	; 29/05/2017
  2563 000158E9 668B15[8A9C0100]    <1> 	mov     dx, [NABMBAR]
  2564 000158F0 6683C21B            <1>         add     dx, PO_CR_REG		; PCM out control register
  2565 000158F4 EE                  <1> 	out	dx, al
  2566 000158F5 C3                  <1> 	retn
  2567                              <1> 
  2568                              <1> ac97_pause:
  2569                              <1> 	; 11/06/2017
  2570                              <1> 	; 29/05/2017
  2571 000158F6 B010                <1> 	mov 	al, IOCE
  2572 000158F8 EBEF                <1> 	jmp	short ac97_po_cmd
  2573                              <1> 
  2574                              <1> reset_ac97_controller:
  2575                              <1> 	; 10/06/2017
  2576                              <1> 	; 29/05/2017
  2577                              <1> 	; 28/05/2017
  2578                              <1> 	; reset AC97 audio controller registers
  2579 000158FA 31C0                <1> 	xor     eax, eax
  2580 000158FC 66BA0B00            <1>         mov	dx, PI_CR_REG
  2581 00015900 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2582 00015907 EE                  <1> 	out     dx, al
  2583                              <1> 
  2584 00015908 66BA1B00            <1>         mov     dx, PO_CR_REG
  2585 0001590C 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2586 00015913 EE                  <1> 	out     dx, al
  2587                              <1> 
  2588 00015914 66BA2B00            <1>         mov     dx, MC_CR_REG
  2589 00015918 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2590 0001591F EE                  <1> 	out     dx, al
  2591                              <1> 
  2592 00015920 B002                <1>         mov     al, RR
  2593 00015922 66BA0B00            <1>         mov     dx, PI_CR_REG
  2594 00015926 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2595 0001592D EE                  <1> 	out     dx, al
  2596                              <1> 
  2597 0001592E 66BA1B00            <1>         mov     dx, PO_CR_REG
  2598 00015932 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2599 00015939 EE                  <1> 	out     dx, al
  2600                              <1> 
  2601 0001593A 66BA2B00            <1>         mov     dx, MC_CR_REG
  2602 0001593E 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2603 00015945 EE                  <1> 	out     dx, al
  2604                              <1> 
  2605 00015946 C3                  <1> 	retn
  2606                              <1> 
  2607                              <1> ac97_reset:
  2608                              <1> 	; 10/06/2017
  2609                              <1> 	; 29/05/2017
  2610                              <1> 	; 28/05/2017
  2611 00015947 E8AEFFFFFF          <1> 	call	reset_ac97_controller
  2612                              <1> 	; 29/05/2017
  2613                              <1> 	;jmp	reset_ac97_codec
  2614                              <1> reset_ac97_codec:
  2615                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2616 0001594C 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2617 00015950 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2618 00015957 ED                  <1> 	in	eax, dx
  2619                              <1> 
  2620 00015958 A902000000          <1> 	test	eax, 2
  2621 0001595D 7407                <1> 	jz	short _r_ac97codec_cold	
  2622                              <1> 
  2623 0001595F E80F000000          <1> 	call	warm_ac97codec_reset
  2624 00015964 7308                <1> 	jnc	short _r_ac97codec_ok
  2625                              <1> _r_ac97codec_cold:
  2626 00015966 E83D000000          <1>         call    cold_ac97codec_reset
  2627 0001596B 7301                <1>         jnc     short _r_ac97codec_ok
  2628                              <1> 	
  2629                              <1> 	; 16/04/2017
  2630                              <1>         ;xor     eax, eax         ; timeout error
  2631                              <1>        	;stc
  2632 0001596D C3                  <1> 	retn
  2633                              <1> 
  2634                              <1> _r_ac97codec_ok:
  2635 0001596E 31C0                <1>         xor     eax, eax
  2636                              <1>         ;mov	al, VIA_ACLINK_C00_READY ; 1
  2637 00015970 FEC0                <1>         inc	al
  2638 00015972 C3                  <1> 	retn
  2639                              <1> 
  2640                              <1> warm_ac97codec_reset:
  2641                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2642 00015973 B806000000          <1>         mov     eax, 6
  2643 00015978 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2644 0001597C 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2645 00015983 EF                  <1> 	out	dx, eax
  2646                              <1> 
  2647 00015984 B90A000000          <1> 	mov	ecx, 10	; total 1s
  2648                              <1> _warm_ac97c_rst_wait:
  2649 00015989 51                  <1> 	push	ecx
  2650 0001598A E8ECF5FFFF          <1> 	call	delay_100ms
  2651 0001598F 59                  <1> 	pop	ecx
  2652                              <1> 
  2653 00015990 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  2654 00015994 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2655 0001599B ED                  <1> 	in	eax, dx
  2656                              <1> 
  2657 0001599C A900030010          <1> 	test	eax, CTRL_ST_CREADY
  2658 000159A1 7504                <1> 	jnz	short _warm_ac97c_rst_ok
  2659                              <1> 
  2660 000159A3 49                  <1>         dec     ecx
  2661 000159A4 75E3                <1>         jnz     short _warm_ac97c_rst_wait
  2662                              <1> 
  2663                              <1> _warm_ac97c_rst_fail:
  2664 000159A6 F9                  <1>         stc
  2665                              <1> _warm_ac97c_rst_ok:
  2666 000159A7 C3                  <1> 	retn
  2667                              <1> 
  2668                              <1> cold_ac97codec_reset:
  2669                              <1> 	; 28/05/2017 - Erdogan Tan (Ref: KolibriOS, intelac97.asm)
  2670 000159A8 B802000000          <1>         mov     eax, 2
  2671 000159AD 66BA2C00            <1> 	mov	dx, GLOB_CNT_REG ; 2Ch
  2672 000159B1 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2673 000159B8 EF                  <1> 	out	dx, eax
  2674                              <1> 
  2675 000159B9 E8BDF5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2676 000159BE E8B8F5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2677 000159C3 E8B3F5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2678 000159C8 E8AEF5FFFF          <1> 	call	delay_100ms 	; wait 100 ms
  2679                              <1> 
  2680 000159CD B910000000          <1> 	mov	ecx, 16	; total 20*100 ms = 2s
  2681                              <1> _cold_ac97c_rst_wait:
  2682 000159D2 66BA3000            <1> 	mov	dx, GLOB_STS_REG ; 30h
  2683 000159D6 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2684 000159DD ED                  <1> 	in	eax, dx
  2685                              <1> 
  2686 000159DE A900030010          <1> 	test	eax, CTRL_ST_CREADY
  2687 000159E3 750B                <1> 	jnz	short _cold_ac97c_rst_ok
  2688                              <1> 
  2689 000159E5 51                  <1> 	push	ecx
  2690 000159E6 E890F5FFFF          <1> 	call	delay_100ms
  2691 000159EB 59                  <1> 	pop	ecx
  2692                              <1> 
  2693 000159EC 49                  <1>         dec     ecx
  2694 000159ED 75E3                <1>         jnz     short _cold_ac97c_rst_wait
  2695                              <1> 
  2696                              <1> _cold_ac97c_rst_fail:
  2697 000159EF F9                  <1>         stc
  2698                              <1> _cold_ac97c_rst_ok:
  2699 000159F0 C3                  <1> 	retn
  2700                              <1> 
  2701                              <1> sb16_current_sound_data:
  2702                              <1> 	; 20/08/2017
  2703                              <1> 	; 24/06/2017
  2704                              <1> 	; 22/06/2017
  2705                              <1> 	; get current sound (PCM out) data for graphics
  2706                              <1> 	; (for Sound Blaster 16)
  2707                              <1> 	; ebx = Physical address (on page boundary)
  2708                              <1> 	; ecx = Byte count
  2709                              <1> 	; [audio_buff_size]
  2710                              <1> 
  2711                              <1> 	;;mov	edi, [audio_buff_size]
  2712                              <1> 	;mov	edi, [audio_dmabuff_size]
  2713                              <1> 	;mov	esi, [audio_dma_buff]
  2714 000159F1 39CF                <1> 	cmp	edi, ecx
  2715 000159F3 7302                <1> 	jnb	short sb16_gcd_0
  2716 000159F5 89F9                <1> 	mov	ecx, edi
  2717                              <1> sb16_gcd_0:
  2718                              <1> 	; 20/08/2017
  2719 000159F7 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16
  2720 000159FE 750F                <1> 	jne	short sb16_gcd_1 ; 8 bit DMA channel
  2721 00015A00 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
  2722 00015A02 88C2                <1> 	mov	dl, al	
  2723 00015A04 E4C6                <1> 	in	al, 0C6h
  2724 00015A06 88C6                <1> 	mov     dh, al
  2725 00015A08 0FB7C2              <1> 	movzx	eax, dx
  2726 00015A0B D1E0                <1> 	shl	eax, 1 ; word count -> byte count
  2727 00015A0D EB4E                <1> 	jmp	short sb16_gcd_2	
  2728                              <1> sb16_gcd_1:
  2729 00015A0F E403                <1> 	in	al, 03h ; DMA channel 1 count register
  2730 00015A11 88C2                <1> 	mov	dl, al	
  2731 00015A13 E403                <1> 	in	al, 03h
  2732 00015A15 88C6                <1> 	mov     dh, al
  2733 00015A17 0FB7C2              <1> 	movzx	eax, dx
  2734 00015A1A EB41                <1> 	jmp	short sb16_gcd_2
  2735                              <1> ;sb16_gcd_2:	
  2736                              <1> ;	cmp	eax, ecx
  2737                              <1> ;	jnb	short sb16_gcd_3 
  2738                              <1> ;	; remain count < graphics bytes
  2739                              <1> ;	mov	eax, ecx ; fix remain count to data size
  2740                              <1> ;sb16_gcd_3:	
  2741                              <1> ;	sub	edi, eax
  2742                              <1> ;	jna	short sb16_gcd_4
  2743                              <1> ;	add	esi, edi ; dma buffer offset
  2744                              <1> ;sb16_gcd_4:
  2745                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
  2746                              <1> ;	mov	[u.r0], ecx
  2747                              <1> ;	rep	movsb
  2748                              <1> ;	retn
  2749                              <1> 
  2750                              <1> get_current_sound_data:
  2751                              <1> 	; 24/06/2017
  2752                              <1> 	; 22/06/2017
  2753                              <1> 	; get current sound (PCM out) data for graphics
  2754                              <1> 	;
  2755                              <1> 	; ebx = Physical address (on page boundary)
  2756                              <1> 	; ecx = Byte count
  2757                              <1> 	; [audio_buff_size]
  2758                              <1> 
  2759                              <1> 	;mov	edi, [audio_buff_size]
  2760 00015A1C 8B3D[749C0100]      <1> 	mov	edi, [audio_dmabuff_size]
  2761 00015A22 8B35[709C0100]      <1> 	mov	esi, [audio_dma_buff]
  2762 00015A28 803D[519C0100]02    <1> 	cmp	byte [audio_device], 2
  2763 00015A2F 72C0                <1> 	jb	short sb16_current_sound_data ; = 1
  2764 00015A31 D1EF                <1> 	shr	edi, 1
  2765 00015A33 39CF                <1> 	cmp	edi, ecx
  2766 00015A35 7302                <1> 	jnb	short gcd_0
  2767 00015A37 89F9                <1> 	mov	ecx, edi
  2768                              <1> gcd_0:
  2769 00015A39 803D[519C0100]03    <1> 	cmp	byte [audio_device], 3
  2770 00015A40 7232                <1> 	jb	short ac97_current_sound_data ; = 2
  2771                              <1> 	; = 3
  2772                              <1> vt8233_current_sound_data:
  2773                              <1> 	; 22/06/2017
  2774                              <1> 	; 21/06/2017
  2775                              <1> 	; get current sound (PCM out) data for graphics
  2776                              <1> 	; (for VT 8233, VT 8237R)
  2777                              <1> 	; ebx = Physical address (on page boundary)
  2778                              <1> 	; ecx = Byte count
  2779                              <1> 	; [audio_buff_size]
  2780                              <1> 	
  2781                              <1> 	;;mov	edi, [audio_buff_size]
  2782                              <1> 	;mov	edi, [audio_dmabuff_size]
  2783                              <1> 	;mov	esi, [audio_dma_buff]
  2784                              <1> 	;shr	edi, 1
  2785                              <1> 	;cmp	edi, ecx
  2786                              <1> 	;jnb	short vt8233_gcd_1
  2787                              <1> 	;mov	ecx, edi
  2788                              <1> vt8233_gcd_1:
  2789 00015A42 BA0C000000          <1> 	mov	edx, VIA_REG_OFFSET_CURR_COUNT
  2790 00015A47 E88FF5FFFF          <1> 	call	ctrl_io_r32
  2791 00015A4C 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
  2792                              <1> 			 ; SGD index (bits 31-24) 
  2793 00015A4E 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
  2794 00015A54 7402                <1> 	jz	short vt8233_gcd_2
  2795                              <1> 	; the second half of DMA buffer
  2796 00015A56 01FE                <1> 	add	esi, edi 
  2797                              <1> vt8233_gcd_2:	
  2798 00015A58 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
  2799                              <1> ac97_gcd_2:
  2800                              <1> sb16_gcd_2:
  2801 00015A5D 39C8                <1> 	cmp	eax, ecx
  2802 00015A5F 7302                <1> 	jnb	short vt8233_gcd_3 
  2803                              <1> 	; remain count < graphics bytes
  2804 00015A61 89C8                <1> 	mov	eax, ecx ; fix remain count to data size
  2805                              <1> vt8233_gcd_3:
  2806 00015A63 29C7                <1> 	sub	edi, eax
  2807 00015A65 7602                <1> 	jna	short vt8233_gcd_4
  2808 00015A67 01FE                <1> 	add	esi, edi ; dma buffer offset
  2809                              <1> vt8233_gcd_4:
  2810 00015A69 89DF                <1> 	mov	edi, ebx ; buffer address (for graphics) 
  2811 00015A6B 890D[64030300]      <1> 	mov	[u.r0], ecx
  2812 00015A71 F3A4                <1> 	rep	movsb
  2813                              <1> vt8233_gcd_5:
  2814 00015A73 C3                  <1> 	retn
  2815                              <1> 
  2816                              <1> ac97_current_sound_data:
  2817                              <1> 	; 23/06/2017
  2818                              <1> 	; 22/06/2017
  2819                              <1> 	; get current sound (PCM out) data for graphics
  2820                              <1> 	; (for AC'97, ICH)
  2821                              <1> 	; ebx = Physical address (on page boundary)
  2822                              <1> 	; ecx = Byte count
  2823                              <1> 	; [audio_buff_size]
  2824                              <1> 	
  2825                              <1> 	;;mov	edi, [audio_buff_size]
  2826                              <1> 	;mov	edi, [audio_dmabuff_size]
  2827                              <1> 	;mov	esi, [audio_dma_buff]
  2828                              <1> 	;shr	edi, 1
  2829                              <1> 	;cmp	edi, ecx
  2830                              <1> 	;jnb	short ac97_gcd_0
  2831                              <1> 	;mov	ecx, edi
  2832                              <1> ac97_gcd_0:
  2833 00015A74 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
  2834 00015A78 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2835 00015A7F EC                  <1> 	in	al, dx ; current index value
  2836 00015A80 A801                <1> 	test	al, 1
  2837 00015A82 7402                <1> 	jz	short ac97_gcd_1
  2838 00015A84 01FE                <1> 	add	esi, edi
  2839                              <1> ac97_gcd_1:
  2840 00015A86 31C0                <1> 	xor	eax, eax
  2841 00015A88 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
  2842 00015A8C 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2843 00015A93 66ED                <1> 	in	ax, dx ; remain dwords
  2844 00015A95 C1E002              <1> 	shl	eax, 2 ; remain bytes ; 23/06/2017 
  2845 00015A98 EBC3                <1> 	jmp	short ac97_gcd_2
  2846                              <1> ;	cmp	eax, ecx
  2847                              <1> ;	jnb	short ac97_gcd_2 
  2848                              <1> ;	; remain count < graphics bytes
  2849                              <1> ;	mov	eax, ecx ; fix remain count to data size
  2850                              <1> ;ac97_gcd_2:	
  2851                              <1> ;	sub	edi, eax
  2852                              <1> ;	jna	short ac97_gcd_3
  2853                              <1> ;	add	esi, edi ; dma buffer offset
  2854                              <1> ;ac97_gcd_3:
  2855                              <1> ;	mov	edi, ebx ; buffer address (for graphics) 
  2856                              <1> ;	mov	[u.r0], ecx
  2857                              <1> ;	rep	movsb
  2858                              <1> ;	retn
  2859                              <1> 
  2860                              <1> sb16_get_dma_buff_off:
  2861                              <1> 	; 28/10/2017
  2862                              <1> 	; 24/06/2017
  2863                              <1> 	; 22/06/2017
  2864                              <1> 	; get current (PCM OUT DMA buffer) pointer
  2865                              <1> 	; (for Sound Blaster 16)
  2866                              <1> 
  2867                              <1> 	;mov	ecx, [audio_dmabuff_size]
  2868                              <1> 	;xor	ebx, ebx
  2869                              <1> 	;shr	ecx, 1
  2870                              <1> sb16_gdmabo_0:
  2871                              <1> 	; 28/10/2017
  2872 00015A9A 803D[809C0100]10    <1> 	cmp	byte [audio_bps], 16
  2873 00015AA1 750F                <1> 	jne	short sb16_gdmabo_1 ; 8 bit DMA channel
  2874                              <1> 	; 16 bit DMA channel
  2875 00015AA3 E4C6                <1> 	in	al, 0C6h ; DMA channel 5 count register
  2876 00015AA5 88C2                <1> 	mov	dl, al	
  2877 00015AA7 E4C6                <1> 	in	al, 0C6h
  2878 00015AA9 88C6                <1> 	mov     dh, al
  2879 00015AAB 0FB7C2              <1> 	movzx	eax, dx
  2880 00015AAE D1E0                <1> 	shl	eax, 1 ; word count -> byte count
  2881 00015AB0 EB3D                <1> 	jmp	short sb16_gdmabo_2	
  2882                              <1> sb16_gdmabo_1:
  2883 00015AB2 E403                <1> 	in	al, 03h ; DMA channel 1 count register
  2884 00015AB4 88C2                <1> 	mov	dl, al	
  2885 00015AB6 E403                <1> 	in	al, 03h
  2886 00015AB8 88C6                <1> 	mov     dh, al
  2887 00015ABA 0FB7C2              <1> 	movzx	eax, dx
  2888 00015ABD EB30                <1> 	jmp	short sb16_gdmabo_2
  2889                              <1> 
  2890                              <1> get_dma_buffer_offset:
  2891                              <1> 	; 24/06/2017
  2892                              <1> 	; 22/06/2017
  2893                              <1> 	; get current sound (PCM out) data for graphics
  2894                              <1> 	;
  2895                              <1> 	; ebx = Physical address (on page boundary)
  2896                              <1> 	; ecx = Byte count
  2897                              <1> 	; [audio_buff_size]
  2898                              <1> 
  2899 00015ABF 8B0D[749C0100]      <1> 	mov	ecx, [audio_dmabuff_size]
  2900 00015AC5 31DB                <1> 	xor	ebx, ebx
  2901                              <1> gdmabo_0:
  2902 00015AC7 803D[519C0100]02    <1> 	cmp	byte [audio_device], 2
  2903 00015ACE 72CA                <1> 	jb	short sb16_get_dma_buff_off
  2904 00015AD0 742A                <1> 	je	short ac97_get_dma_buff_off
  2905                              <1> 
  2906                              <1> vt8233_get_dma_buff_off:
  2907                              <1> 	; 24/06/2017
  2908                              <1> 	; 22/06/2017
  2909                              <1> 	; get current (PCM OUT DMA buffer) pointer
  2910                              <1> 	; (for VT 8233, VT 8237R)
  2911                              <1> 	
  2912                              <1> 	;mov	ecx, [audio_dmabuff_size]
  2913                              <1> 	;xor	ebx, ebx
  2914 00015AD2 D1E9                <1> 	shr	ecx, 1
  2915                              <1> vt8233_gdmabo_0:
  2916 00015AD4 BA0C000000          <1> 	mov	edx, VIA_REG_OFFSET_CURR_COUNT
  2917 00015AD9 E8FDF4FFFF          <1> 	call	ctrl_io_r32
  2918 00015ADE 89C2                <1> 	mov	edx, eax ; remain count (bits 23-0),
  2919                              <1> 			 ; SGD index (bits 31-24) 
  2920 00015AE0 81E200000001        <1> 	and	edx, 1000000h ; SGD index (0 = 1st half)
  2921 00015AE6 7402                <1> 	jz	short vt8233_gdmabo_1
  2922                              <1> 	; the second half of DMA buffer
  2923 00015AE8 89CB                <1> 	mov	ebx, ecx 
  2924                              <1> vt8233_gdmabo_1:	
  2925 00015AEA 25FFFFFF00          <1> 	and	eax, 0FFFFFFh ; bits 23-0
  2926                              <1> sb16_gdmabo_2:
  2927                              <1> ac97_gdmabo_2:
  2928 00015AEF 29C1                <1> 	sub	ecx, eax
  2929 00015AF1 7602                <1> 	jna	short vt8233_gdmabo_2
  2930 00015AF3 01CB                <1> 	add	ebx, ecx ; dma buffer offset
  2931                              <1> vt8233_gdmabo_2:
  2932 00015AF5 891D[64030300]      <1> 	mov	[u.r0], ebx
  2933 00015AFB C3                  <1> 	retn
  2934                              <1> 
  2935                              <1> ac97_get_dma_buff_off:
  2936                              <1> 	; 24/06/2017
  2937                              <1> 	; 22/06/2017
  2938                              <1> 	; get current (PCM OUT DMA buffer) pointer
  2939                              <1> 	; (for AC'97, ICH)
  2940                              <1> 	; ebx = Physical address (on page boundary)
  2941                              <1> 	; ecx = Byte count
  2942                              <1> 	; [audio_buff_size]
  2943                              <1> 	
  2944                              <1> 	;mov	ecx, [audio_dmabuff_size]
  2945                              <1> 	;xor	ebx, ebx
  2946 00015AFC D1E9                <1> 	shr	ecx, 1
  2947                              <1> ac97_gdmabo_0:
  2948 00015AFE 66BA1400            <1> 	mov	dx, PO_CIV_REG ; Position In Current Buff Reg
  2949 00015B02 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2950 00015B09 EC                  <1> 	in	al, dx ; current index value
  2951 00015B0A A801                <1> 	test	al, 1
  2952 00015B0C 7402                <1> 	jz	short ac97_gdmabo_1
  2953 00015B0E 89CB                <1> 	mov	ebx, ecx
  2954                              <1> ac97_gdmabo_1:
  2955 00015B10 31C0                <1> 	xor	eax, eax
  2956 00015B12 66BA1800            <1> 	mov	dx, PO_PICB_REG ; Position In Current Buff Reg
  2957 00015B16 660315[8A9C0100]    <1> 	add	dx, [NABMBAR]
  2958 00015B1D 66ED                <1> 	in	ax, dx ; remain dwords
  2959 00015B1F EBCE                <1> 	jmp	short ac97_gdmabo_2
  3425                                  
  3426 00015B21 90<rept>                align 4
  3427                                  
  3428                                  %include 'vgadata.s' ; 04/07/2016
     1                              <1> ; ****************************************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.3 - vgadata.s  (palette and font data)
     3                              <1> ; -----------------------------------------------------------------------------
     4                              <1> ; Last Update: 01/01/2021
     5                              <1> ; -----------------------------------------------------------------------------
     6                              <1> ; Beginning: 16/01/2016
     7                              <1> ; -----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.15 (trdos386.s)
     9                              <1> ; -----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Plex86/Bochs VGABios' source code, vgabios-0.7a (2011)
    14                              <1> ; by the LGPL VGABios Developers Team (2001-2008), 'vgatables.h'
    15                              <1> ;
    16                              <1> ; Oracle VirtualBox 5.0.24 VGABios Source Code 
    17                              <1> ; ('vgabios.c', 'vgatables.h', 'vgafonts.h', 'vgarom.asm')
    18                              <1> ;
    19                              <1> ; Palette and font data in assembly language format:
    20                              <1> ; 'VBoxVgaBiosAlternative.asm'
    21                              <1> 
    22                              <1> ; ****************************************************************************************************
    23                              <1> 
    24                              <1> ; 25/11/2020 (TRDOS 386 v2.0.3)
    25                              <1> ; ('vgatables.h' - 30/12/2019 - vruppert)
    26                              <1>  
    27                              <1> ; 04/07/2016
    28                              <1> ; COLOR DATA
    29                              <1> 
    30                              <1> palette0: ; (63+1)*3
    31 00015B24 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
    31 00015B2D 00000000000000      <1>
    32 00015B34 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    32 00015B3D 2A2A2A2A2A2A2A      <1>
    33 00015B44 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    33 00015B4D 2A2A2A2A2A2A2A      <1>
    34 00015B54 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    34 00015B5D 2A2A2A2A2A2A2A      <1>
    35 00015B64 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    35 00015B6D 3F3F3F3F3F3F3F      <1>
    36 00015B74 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    36 00015B7D 3F3F3F3F3F3F3F      <1>
    37 00015B84 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
    37 00015B8D 00000000000000      <1>
    38 00015B94 00000000000000002A- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    38 00015B9D 2A2A2A2A2A2A2A      <1>
    39 00015BA4 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    39 00015BAD 2A2A2A2A2A2A2A      <1>
    40 00015BB4 2A2A2A2A2A2A2A2A2A- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah
    40 00015BBD 2A2A2A2A2A2A2A      <1>
    41 00015BC4 2A2A2A2A2A2A2A2A3F- <1>     db  02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 02ah, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    41 00015BCD 3F3F3F3F3F3F3F      <1>
    42 00015BD4 3F3F3F3F3F3F3F3F3F- <1>     db  03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh, 03fh
    42 00015BDD 3F3F3F3F3F3F3F      <1>
    43                              <1> palette1: ; (63+1)*3	
    44 00015BE4 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    44 00015BED 002A2A2A00002A      <1>
    45 00015BF4 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
    45 00015BFD 000000002A002A      <1>
    46 00015C04 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
    46 00015C0D 2A2A15002A2A2A      <1>
    47 00015C14 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
    47 00015C1D 153F3F3F15153F      <1>
    48 00015C24 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    48 00015C2D 151515153F153F      <1>
    49 00015C34 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    49 00015C3D 3F3F3F153F3F3F      <1>
    50 00015C44 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    50 00015C4D 002A2A2A00002A      <1>
    51 00015C54 002A2A15002A2A2A00- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah
    51 00015C5D 000000002A002A      <1>
    52 00015C64 00002A2A2A00002A00- <1>     db  000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah, 000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah
    52 00015C6D 2A2A15002A2A2A      <1>
    53 00015C74 15151515153F153F15- <1>     db  015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh, 015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh
    53 00015C7D 153F3F3F15153F      <1>
    54 00015C84 153F3F3F153F3F3F15- <1>     db  015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    54 00015C8D 151515153F153F      <1>
    55 00015C94 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    55 00015C9D 3F3F3F153F3F3F      <1>
    56                              <1> palette2: ; (63+1)*3
    57 00015CA4 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    57 00015CAD 002A2A2A00002A      <1>
    58 00015CB4 002A2A2A002A2A2A00- <1>     db  000h, 02ah, 02ah, 02ah, 000h, 02ah, 02ah, 02ah, 000h, 000h, 015h, 000h, 000h, 03fh, 000h, 02ah
    58 00015CBD 001500003F002A      <1>
    59 00015CC4 15002A3F2A00152A00- <1>     db  015h, 000h, 02ah, 03fh, 02ah, 000h, 015h, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 02ah, 02ah, 03fh
    59 00015CCD 3F2A2A152A2A3F      <1>
    60 00015CD4 00150000152A003F00- <1>     db  000h, 015h, 000h, 000h, 015h, 02ah, 000h, 03fh, 000h, 000h, 03fh, 02ah, 02ah, 015h, 000h, 02ah
    60 00015CDD 003F2A2A15002A      <1>
    61 00015CE4 152A2A3F002A3F2A00- <1>     db  015h, 02ah, 02ah, 03fh, 000h, 02ah, 03fh, 02ah, 000h, 015h, 015h, 000h, 015h, 03fh, 000h, 03fh
    61 00015CED 151500153F003F      <1>
    62 00015CF4 15003F3F2A15152A15- <1>     db  015h, 000h, 03fh, 03fh, 02ah, 015h, 015h, 02ah, 015h, 03fh, 02ah, 03fh, 015h, 02ah, 03fh, 03fh
    62 00015CFD 3F2A3F152A3F3F      <1>
    63 00015D04 15000015002A152A00- <1>     db  015h, 000h, 000h, 015h, 000h, 02ah, 015h, 02ah, 000h, 015h, 02ah, 02ah, 03fh, 000h, 000h, 03fh
    63 00015D0D 152A2A3F00003F      <1>
    64 00015D14 002A3F2A003F2A2A15- <1>     db  000h, 02ah, 03fh, 02ah, 000h, 03fh, 02ah, 02ah, 015h, 000h, 015h, 015h, 000h, 03fh, 015h, 02ah
    64 00015D1D 001515003F152A      <1>
    65 00015D24 15152A3F3F00153F00- <1>     db  015h, 015h, 02ah, 03fh, 03fh, 000h, 015h, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 03fh, 02ah, 03fh
    65 00015D2D 3F3F2A153F2A3F      <1>
    66 00015D34 15150015152A153F00- <1>     db  015h, 015h, 000h, 015h, 015h, 02ah, 015h, 03fh, 000h, 015h, 03fh, 02ah, 03fh, 015h, 000h, 03fh
    66 00015D3D 153F2A3F15003F      <1>
    67 00015D44 152A3F3F003F3F2A15- <1>     db  015h, 02ah, 03fh, 03fh, 000h, 03fh, 03fh, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    67 00015D4D 151515153F153F      <1>
    68 00015D54 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    68 00015D5D 3F3F3F153F3F3F      <1>
    69                              <1> palette3: ; 256*3
    70 00015D64 00000000002A002A00- <1>     db  000h, 000h, 000h, 000h, 000h, 02ah, 000h, 02ah, 000h, 000h, 02ah, 02ah, 02ah, 000h, 000h, 02ah
    70 00015D6D 002A2A2A00002A      <1>
    71 00015D74 002A2A15002A2A2A15- <1>     db  000h, 02ah, 02ah, 015h, 000h, 02ah, 02ah, 02ah, 015h, 015h, 015h, 015h, 015h, 03fh, 015h, 03fh
    71 00015D7D 151515153F153F      <1>
    72 00015D84 15153F3F3F15153F15- <1>     db  015h, 015h, 03fh, 03fh, 03fh, 015h, 015h, 03fh, 015h, 03fh, 03fh, 03fh, 015h, 03fh, 03fh, 03fh
    72 00015D8D 3F3F3F153F3F3F      <1>
    73 00015D94 000000050505080808- <1>     db  000h, 000h, 000h, 005h, 005h, 005h, 008h, 008h, 008h, 00bh, 00bh, 00bh, 00eh, 00eh, 00eh, 011h
    73 00015D9D 0B0B0B0E0E0E11      <1>
    74 00015DA4 11111414141818181C- <1>     db  011h, 011h, 014h, 014h, 014h, 018h, 018h, 018h, 01ch, 01ch, 01ch, 020h, 020h, 020h, 024h, 024h
    74 00015DAD 1C1C2020202424      <1>
    75 00015DB4 242828282D2D2D3232- <1>     db  024h, 028h, 028h, 028h, 02dh, 02dh, 02dh, 032h, 032h, 032h, 038h, 038h, 038h, 03fh, 03fh, 03fh
    75 00015DBD 323838383F3F3F      <1>
    76 00015DC4 00003F10003F1F003F- <1>     db  000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 03fh, 03fh
    76 00015DCD 2F003F3F003F3F      <1>
    77 00015DD4 002F3F001F3F00103F- <1>     db  000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh
    77 00015DDD 00003F10003F1F      <1>
    78 00015DE4 003F2F003F3F002F3F- <1>     db  000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h, 02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 000h
    78 00015DED 001F3F00103F00      <1>
    79 00015DF4 003F00003F10003F1F- <1>     db  000h, 03fh, 000h, 000h, 03fh, 010h, 000h, 03fh, 01fh, 000h, 03fh, 02fh, 000h, 03fh, 03fh, 000h
    79 00015DFD 003F2F003F3F00      <1>
    80 00015E04 2F3F001F3F00103F1F- <1>     db  02fh, 03fh, 000h, 01fh, 03fh, 000h, 010h, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh
    80 00015E0D 1F3F271F3F2F1F      <1>
    81 00015E14 3F371F3F3F1F3F3F1F- <1>     db  03fh, 037h, 01fh, 03fh, 03fh, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h
    81 00015E1D 373F1F2F3F1F27      <1>
    82 00015E24 3F1F1F3F271F3F2F1F- <1>     db  03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh, 02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h
    82 00015E2D 3F371F3F3F1F37      <1>
    83 00015E34 3F1F2F3F1F273F1F1F- <1>     db  03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh, 01fh, 01fh, 03fh, 01fh, 01fh, 03fh, 027h, 01fh, 03fh
    83 00015E3D 3F1F1F3F271F3F      <1>
    84 00015E44 2F1F3F371F3F3F1F37- <1>     db  02fh, 01fh, 03fh, 037h, 01fh, 03fh, 03fh, 01fh, 037h, 03fh, 01fh, 02fh, 03fh, 01fh, 027h, 03fh
    84 00015E4D 3F1F2F3F1F273F      <1>
    85 00015E54 2D2D3F312D3F362D3F- <1>     db  02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03fh, 03fh
    85 00015E5D 3A2D3F3F2D3F3F      <1>
    86 00015E64 2D3A3F2D363F2D313F- <1>     db  02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h
    86 00015E6D 2D2D3F312D3F36      <1>
    87 00015E74 2D3F3A2D3F3F2D3A3F- <1>     db  02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh, 03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 02dh
    87 00015E7D 2D363F2D313F2D      <1>
    88 00015E84 2D3F2D2D3F312D3F36- <1>     db  02dh, 03fh, 02dh, 02dh, 03fh, 031h, 02dh, 03fh, 036h, 02dh, 03fh, 03ah, 02dh, 03fh, 03fh, 02dh
    88 00015E8D 2D3F3A2D3F3F2D      <1>
    89 00015E94 3A3F2D363F2D313F00- <1>     db  03ah, 03fh, 02dh, 036h, 03fh, 02dh, 031h, 03fh, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h
    89 00015E9D 001C07001C0E00      <1>
    90 00015EA4 1C15001C1C001C1C00- <1>     db  01ch, 015h, 000h, 01ch, 01ch, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h
    90 00015EAD 151C000E1C0007      <1>
    91 00015EB4 1C00001C07001C0E00- <1>     db  01ch, 000h, 000h, 01ch, 007h, 000h, 01ch, 00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h
    91 00015EBD 1C15001C1C0015      <1>
    92 00015EC4 1C000E1C00071C0000- <1>     db  01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch, 000h, 000h, 01ch, 000h, 000h, 01ch, 007h, 000h, 01ch
    92 00015ECD 1C00001C07001C      <1>
    93 00015ED4 0E001C15001C1C0015- <1>     db  00eh, 000h, 01ch, 015h, 000h, 01ch, 01ch, 000h, 015h, 01ch, 000h, 00eh, 01ch, 000h, 007h, 01ch
    93 00015EDD 1C000E1C00071C      <1>
    94 00015EE4 0E0E1C110E1C150E1C- <1>     db  00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 01ch, 01ch
    94 00015EED 180E1C1C0E1C1C      <1>
    95 00015EF4 0E181C0E151C0E111C- <1>     db  00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h
    95 00015EFD 0E0E1C110E1C15      <1>
    96 00015F04 0E1C180E1C1C0E181C- <1>     db  00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh, 018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 00eh
    96 00015F0D 0E151C0E111C0E      <1>
    97 00015F14 0E1C0E0E1C110E1C15- <1>     db  00eh, 01ch, 00eh, 00eh, 01ch, 011h, 00eh, 01ch, 015h, 00eh, 01ch, 018h, 00eh, 01ch, 01ch, 00eh
    97 00015F1D 0E1C180E1C1C0E      <1>
    98 00015F24 181C0E151C0E111C14- <1>     db  018h, 01ch, 00eh, 015h, 01ch, 00eh, 011h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h
    98 00015F2D 141C16141C1814      <1>
    99 00015F34 1C1A141C1C141C1C14- <1>     db  01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h
    99 00015F3D 1A1C14181C1416      <1>
   100 00015F44 1C14141C16141C1814- <1>     db  01ch, 014h, 014h, 01ch, 016h, 014h, 01ch, 018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah
   100 00015F4D 1C1A141C1C141A      <1>
   101 00015F54 1C14181C14161C1414- <1>     db  01ch, 014h, 018h, 01ch, 014h, 016h, 01ch, 014h, 014h, 01ch, 014h, 014h, 01ch, 016h, 014h, 01ch
   101 00015F5D 1C14141C16141C      <1>
   102 00015F64 18141C1A141C1C141A- <1>     db  018h, 014h, 01ch, 01ah, 014h, 01ch, 01ch, 014h, 01ah, 01ch, 014h, 018h, 01ch, 014h, 016h, 01ch
   102 00015F6D 1C14181C14161C      <1>
   103 00015F74 000010040010080010- <1>     db  000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h, 010h, 010h
   103 00015F7D 0C001010001010      <1>
   104 00015F84 000C10000810000410- <1>     db  000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h
   104 00015F8D 00001004001008      <1>
   105 00015F94 00100C001010000C10- <1>     db  000h, 010h, 00ch, 000h, 010h, 010h, 000h, 00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 000h
   105 00015F9D 00081000041000      <1>
   106 00015FA4 001000001004001008- <1>     db  000h, 010h, 000h, 000h, 010h, 004h, 000h, 010h, 008h, 000h, 010h, 00ch, 000h, 010h, 010h, 000h
   106 00015FAD 00100C00101000      <1>
   107 00015FB4 0C1000081000041008- <1>     db  00ch, 010h, 000h, 008h, 010h, 000h, 004h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h
   107 00015FBD 08100A08100C08      <1>
   108 00015FC4 100E08101008101008- <1>     db  010h, 00eh, 008h, 010h, 010h, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah
   108 00015FCD 0E10080C10080A      <1>
   109 00015FD4 100808100A08100C08- <1>     db  010h, 008h, 008h, 010h, 00ah, 008h, 010h, 00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh
   109 00015FDD 100E081010080E      <1>
   110 00015FE4 10080C10080A100808- <1>     db  010h, 008h, 00ch, 010h, 008h, 00ah, 010h, 008h, 008h, 010h, 008h, 008h, 010h, 00ah, 008h, 010h
   110 00015FED 100808100A0810      <1>
   111 00015FF4 0C08100E081010080E- <1>     db  00ch, 008h, 010h, 00eh, 008h, 010h, 010h, 008h, 00eh, 010h, 008h, 00ch, 010h, 008h, 00ah, 010h
   111 00015FFD 10080C10080A10      <1>
   112 00016004 0B0B100C0B100D0B10- <1>     db  00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 010h, 010h
   112 0001600D 0F0B10100B1010      <1>
   113 00016014 0B0F100B0D100B0C10- <1>     db  00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh
   113 0001601D 0B0B100C0B100D      <1>
   114 00016024 0B100F0B10100B0F10- <1>     db  00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh, 00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 00bh
   114 0001602D 0B0D100B0C100B      <1>
   115 00016034 0B100B0B100C0B100D- <1>     db  00bh, 010h, 00bh, 00bh, 010h, 00ch, 00bh, 010h, 00dh, 00bh, 010h, 00fh, 00bh, 010h, 010h, 00bh
   115 0001603D 0B100F0B10100B      <1>
   116 00016044 0F100B0D100B0C1000- <1>     db  00fh, 010h, 00bh, 00dh, 010h, 00bh, 00ch, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   116 0001604D 00000000000000      <1>
   117 00016054 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   117 0001605D 00000000000000      <1>
   118                              <1> 
   119                              <1> 
   120                              <1> ; 04/07/2016
   121                              <1> ; FONT DATA
   122                              <1> 
   123                              <1> CRT_CHAR_GEN:
   124                              <1> vgafont8: 
   125 00016064 00000000000000007E- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 081h, 0a5h, 081h, 0bdh, 099h, 081h, 07eh
   125 0001606D 81A581BD99817E      <1>
   126 00016074 7EFFDBFFC3E7FF7E6C- <1>     db  07eh, 0ffh, 0dbh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 06ch, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h
   126 0001607D FEFEFE7C381000      <1>
   127 00016084 10387CFE7C38100038- <1>     db  010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 038h, 07ch, 038h, 0feh, 0feh, 07ch, 038h, 07ch
   127 0001608D 7C38FEFE7C387C      <1>
   128 00016094 1010387CFE7C387C00- <1>     db  010h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 07ch, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h
   128 0001609D 00183C3C180000      <1>
   129 000160A4 FFFFE7C3C3E7FFFF00- <1>     db  0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h
   129 000160AD 3C664242663C00      <1>
   130 000160B4 FFC399BDBD99C3FF0F- <1>     db  0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 00fh, 007h, 00fh, 07dh, 0cch, 0cch, 0cch, 078h
   130 000160BD 070F7DCCCCCC78      <1>
   131 000160C4 3C6666663C187E183F- <1>     db  03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 03fh, 033h, 03fh, 030h, 030h, 070h, 0f0h, 0e0h
   131 000160CD 333F303070F0E0      <1>
   132 000160D4 7F637F636367E6C099- <1>     db  07fh, 063h, 07fh, 063h, 063h, 067h, 0e6h, 0c0h, 099h, 05ah, 03ch, 0e7h, 0e7h, 03ch, 05ah, 099h
   132 000160DD 5A3CE7E73C5A99      <1>
   133 000160E4 80E0F8FEF8E0800002- <1>     db  080h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 080h, 000h, 002h, 00eh, 03eh, 0feh, 03eh, 00eh, 002h, 000h
   133 000160ED 0E3EFE3E0E0200      <1>
   134 000160F4 183C7E18187E3C1866- <1>     db  018h, 03ch, 07eh, 018h, 018h, 07eh, 03ch, 018h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 000h
   134 000160FD 66666666006600      <1>
   135 00016104 7FDBDB7B1B1B1B003E- <1>     db  07fh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 000h, 03eh, 063h, 038h, 06ch, 06ch, 038h, 0cch, 078h
   135 0001610D 63386C6C38CC78      <1>
   136 00016114 000000007E7E7E0018- <1>     db  000h, 000h, 000h, 000h, 07eh, 07eh, 07eh, 000h, 018h, 03ch, 07eh, 018h, 07eh, 03ch, 018h, 0ffh
   136 0001611D 3C7E187E3C18FF      <1>
   137 00016124 183C7E181818180018- <1>     db  018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h
   137 0001612D 1818187E3C1800      <1>
   138 00016134 00180CFE0C18000000- <1>     db  000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h
   138 0001613D 3060FE60300000      <1>
   139 00016144 0000C0C0C0FE000000- <1>     db  000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h
   139 0001614D 2466FF66240000      <1>
   140 00016154 00183C7EFFFF000000- <1>     db  000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 000h, 000h, 000h, 0ffh, 0ffh, 07eh, 03ch, 018h, 000h, 000h
   140 0001615D FFFF7E3C180000      <1>
   141 00016164 000000000000000030- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 078h, 078h, 030h, 030h, 000h, 030h, 000h
   141 0001616D 78783030003000      <1>
   142 00016174 6C6C6C00000000006C- <1>     db  06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 0feh, 06ch, 06ch, 000h
   142 0001617D 6CFE6CFE6C6C00      <1>
   143 00016184 307CC0780CF8300000- <1>     db  030h, 07ch, 0c0h, 078h, 00ch, 0f8h, 030h, 000h, 000h, 0c6h, 0cch, 018h, 030h, 066h, 0c6h, 000h
   143 0001618D C6CC183066C600      <1>
   144 00016194 386C3876DCCC760060- <1>     db  038h, 06ch, 038h, 076h, 0dch, 0cch, 076h, 000h, 060h, 060h, 0c0h, 000h, 000h, 000h, 000h, 000h
   144 0001619D 60C00000000000      <1>
   145 000161A4 183060606030180060- <1>     db  018h, 030h, 060h, 060h, 060h, 030h, 018h, 000h, 060h, 030h, 018h, 018h, 018h, 030h, 060h, 000h
   145 000161AD 30181818306000      <1>
   146 000161B4 00663CFF3C66000000- <1>     db  000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 000h
   146 000161BD 3030FC30300000      <1>
   147 000161C4 000000000030306000- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 060h, 000h, 000h, 000h, 0fch, 000h, 000h, 000h, 000h
   147 000161CD 0000FC00000000      <1>
   148 000161D4 000000000030300006- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 030h, 000h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h
   148 000161DD 0C183060C08000      <1>
   149 000161E4 7CC6CEDEF6E67C0030- <1>     db  07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 07ch, 000h, 030h, 070h, 030h, 030h, 030h, 030h, 0fch, 000h
   149 000161ED 7030303030FC00      <1>
   150 000161F4 78CC0C3860CCFC0078- <1>     db  078h, 0cch, 00ch, 038h, 060h, 0cch, 0fch, 000h, 078h, 0cch, 00ch, 038h, 00ch, 0cch, 078h, 000h
   150 000161FD CC0C380CCC7800      <1>
   151 00016204 1C3C6CCCFE0C1E00FC- <1>     db  01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 01eh, 000h, 0fch, 0c0h, 0f8h, 00ch, 00ch, 0cch, 078h, 000h
   151 0001620D C0F80C0CCC7800      <1>
   152 00016214 3860C0F8CCCC7800FC- <1>     db  038h, 060h, 0c0h, 0f8h, 0cch, 0cch, 078h, 000h, 0fch, 0cch, 00ch, 018h, 030h, 030h, 030h, 000h
   152 0001621D CC0C1830303000      <1>
   153 00016224 78CCCC78CCCC780078- <1>     db  078h, 0cch, 0cch, 078h, 0cch, 0cch, 078h, 000h, 078h, 0cch, 0cch, 07ch, 00ch, 018h, 070h, 000h
   153 0001622D CCCC7C0C187000      <1>
   154 00016234 003030000030300000- <1>     db  000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 000h, 000h, 030h, 030h, 060h
   154 0001623D 30300000303060      <1>
   155 00016244 183060C06030180000- <1>     db  018h, 030h, 060h, 0c0h, 060h, 030h, 018h, 000h, 000h, 000h, 0fch, 000h, 000h, 0fch, 000h, 000h
   155 0001624D 00FC0000FC0000      <1>
   156 00016254 6030180C1830600078- <1>     db  060h, 030h, 018h, 00ch, 018h, 030h, 060h, 000h, 078h, 0cch, 00ch, 018h, 030h, 000h, 030h, 000h
   156 0001625D CC0C1830003000      <1>
   157 00016264 7CC6DEDEDEC0780030- <1>     db  07ch, 0c6h, 0deh, 0deh, 0deh, 0c0h, 078h, 000h, 030h, 078h, 0cch, 0cch, 0fch, 0cch, 0cch, 000h
   157 0001626D 78CCCCFCCCCC00      <1>
   158 00016274 FC66667C6666FC003C- <1>     db  0fch, 066h, 066h, 07ch, 066h, 066h, 0fch, 000h, 03ch, 066h, 0c0h, 0c0h, 0c0h, 066h, 03ch, 000h
   158 0001627D 66C0C0C0663C00      <1>
   159 00016284 F86C6666666CF800FE- <1>     db  0f8h, 06ch, 066h, 066h, 066h, 06ch, 0f8h, 000h, 0feh, 062h, 068h, 078h, 068h, 062h, 0feh, 000h
   159 0001628D 6268786862FE00      <1>
   160 00016294 FE6268786860F0003C- <1>     db  0feh, 062h, 068h, 078h, 068h, 060h, 0f0h, 000h, 03ch, 066h, 0c0h, 0c0h, 0ceh, 066h, 03eh, 000h
   160 0001629D 66C0C0CE663E00      <1>
   161 000162A4 CCCCCCFCCCCCCC0078- <1>     db  0cch, 0cch, 0cch, 0fch, 0cch, 0cch, 0cch, 000h, 078h, 030h, 030h, 030h, 030h, 030h, 078h, 000h
   161 000162AD 30303030307800      <1>
   162 000162B4 1E0C0C0CCCCC7800E6- <1>     db  01eh, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 0e6h, 066h, 06ch, 078h, 06ch, 066h, 0e6h, 000h
   162 000162BD 666C786C66E600      <1>
   163 000162C4 F06060606266FE00C6- <1>     db  0f0h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 000h
   163 000162CD EEFEFED6C6C600      <1>
   164 000162D4 C6E6F6DECEC6C60038- <1>     db  0c6h, 0e6h, 0f6h, 0deh, 0ceh, 0c6h, 0c6h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h
   164 000162DD 6CC6C6C66C3800      <1>
   165 000162E4 FC66667C6060F00078- <1>     db  0fch, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 078h, 0cch, 0cch, 0cch, 0dch, 078h, 01ch, 000h
   165 000162ED CCCCCCDC781C00      <1>
   166 000162F4 FC66667C6C66E60078- <1>     db  0fch, 066h, 066h, 07ch, 06ch, 066h, 0e6h, 000h, 078h, 0cch, 0e0h, 070h, 01ch, 0cch, 078h, 000h
   166 000162FD CCE0701CCC7800      <1>
   167 00016304 FCB4303030307800CC- <1>     db  0fch, 0b4h, 030h, 030h, 030h, 030h, 078h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 0fch, 000h
   167 0001630D CCCCCCCCCCFC00      <1>
   168 00016314 CCCCCCCCCC783000C6- <1>     db  0cch, 0cch, 0cch, 0cch, 0cch, 078h, 030h, 000h, 0c6h, 0c6h, 0c6h, 0d6h, 0feh, 0eeh, 0c6h, 000h
   168 0001631D C6C6D6FEEEC600      <1>
   169 00016324 C6C66C38386CC600CC- <1>     db  0c6h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 030h, 078h, 000h
   169 0001632D CCCC7830307800      <1>
   170 00016334 FEC68C183266FE0078- <1>     db  0feh, 0c6h, 08ch, 018h, 032h, 066h, 0feh, 000h, 078h, 060h, 060h, 060h, 060h, 060h, 078h, 000h
   170 0001633D 60606060607800      <1>
   171 00016344 C06030180C06020078- <1>     db  0c0h, 060h, 030h, 018h, 00ch, 006h, 002h, 000h, 078h, 018h, 018h, 018h, 018h, 018h, 078h, 000h
   171 0001634D 18181818187800      <1>
   172 00016354 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   172 0001635D 000000000000FF      <1>
   173 00016364 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 076h, 000h
   173 0001636D 00780C7CCC7600      <1>
   174 00016374 E060607C6666DC0000- <1>     db  0e0h, 060h, 060h, 07ch, 066h, 066h, 0dch, 000h, 000h, 000h, 078h, 0cch, 0c0h, 0cch, 078h, 000h
   174 0001637D 0078CCC0CC7800      <1>
   175 00016384 1C0C0C7CCCCC760000- <1>     db  01ch, 00ch, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
   175 0001638D 0078CCFCC07800      <1>
   176 00016394 386C60F06060F00000- <1>     db  038h, 06ch, 060h, 0f0h, 060h, 060h, 0f0h, 000h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 0f8h
   176 0001639D 0076CCCC7C0CF8      <1>
   177 000163A4 E0606C766666E60030- <1>     db  0e0h, 060h, 06ch, 076h, 066h, 066h, 0e6h, 000h, 030h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   177 000163AD 00703030307800      <1>
   178 000163B4 0C000C0C0CCCCC78E0- <1>     db  00ch, 000h, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 0e0h, 060h, 066h, 06ch, 078h, 06ch, 0e6h, 000h
   178 000163BD 60666C786CE600      <1>
   179 000163C4 703030303030780000- <1>     db  070h, 030h, 030h, 030h, 030h, 030h, 078h, 000h, 000h, 000h, 0cch, 0feh, 0feh, 0d6h, 0c6h, 000h
   179 000163CD 00CCFEFED6C600      <1>
   180 000163D4 0000F8CCCCCCCC0000- <1>     db  000h, 000h, 0f8h, 0cch, 0cch, 0cch, 0cch, 000h, 000h, 000h, 078h, 0cch, 0cch, 0cch, 078h, 000h
   180 000163DD 0078CCCCCC7800      <1>
   181 000163E4 0000DC66667C60F000- <1>     db  000h, 000h, 0dch, 066h, 066h, 07ch, 060h, 0f0h, 000h, 000h, 076h, 0cch, 0cch, 07ch, 00ch, 01eh
   181 000163ED 0076CCCC7C0C1E      <1>
   182 000163F4 0000DC766660F00000- <1>     db  000h, 000h, 0dch, 076h, 066h, 060h, 0f0h, 000h, 000h, 000h, 07ch, 0c0h, 078h, 00ch, 0f8h, 000h
   182 000163FD 007CC0780CF800      <1>
   183 00016404 10307C303034180000- <1>     db  010h, 030h, 07ch, 030h, 030h, 034h, 018h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 076h, 000h
   183 0001640D 00CCCCCCCC7600      <1>
   184 00016414 0000CCCCCC78300000- <1>     db  000h, 000h, 0cch, 0cch, 0cch, 078h, 030h, 000h, 000h, 000h, 0c6h, 0d6h, 0feh, 0feh, 06ch, 000h
   184 0001641D 00C6D6FEFE6C00      <1>
   185 00016424 0000C66C386CC60000- <1>     db  000h, 000h, 0c6h, 06ch, 038h, 06ch, 0c6h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 07ch, 00ch, 0f8h
   185 0001642D 00CCCCCC7C0CF8      <1>
   186 00016434 0000FC983064FC001C- <1>     db  000h, 000h, 0fch, 098h, 030h, 064h, 0fch, 000h, 01ch, 030h, 030h, 0e0h, 030h, 030h, 01ch, 000h
   186 0001643D 3030E030301C00      <1>
   187 00016444 1818180018181800E0- <1>     db  018h, 018h, 018h, 000h, 018h, 018h, 018h, 000h, 0e0h, 030h, 030h, 01ch, 030h, 030h, 0e0h, 000h
   187 0001644D 30301C3030E000      <1>
   188 00016454 76DC00000000000000- <1>     db  076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h
   188 0001645D 10386CC6C6FE00      <1>
   189 00016464 78CCC0CC78180C7800- <1>     db  078h, 0cch, 0c0h, 0cch, 078h, 018h, 00ch, 078h, 000h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   189 0001646D CC00CCCCCC7E00      <1>
   190 00016474 1C0078CCFCC078007E- <1>     db  01ch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 07eh, 0c3h, 03ch, 006h, 03eh, 066h, 03fh, 000h
   190 0001647D C33C063E663F00      <1>
   191 00016484 CC00780C7CCC7E00E0- <1>     db  0cch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 0e0h, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h
   191 0001648D 00780C7CCC7E00      <1>
   192 00016494 3030780C7CCC7E0000- <1>     db  030h, 030h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 000h, 000h, 078h, 0c0h, 0c0h, 078h, 00ch, 038h
   192 0001649D 0078C0C0780C38      <1>
   193 000164A4 7EC33C667E603C00CC- <1>     db  07eh, 0c3h, 03ch, 066h, 07eh, 060h, 03ch, 000h, 0cch, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h
   193 000164AD 0078CCFCC07800      <1>
   194 000164B4 E00078CCFCC07800CC- <1>     db  0e0h, 000h, 078h, 0cch, 0fch, 0c0h, 078h, 000h, 0cch, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   194 000164BD 00703030307800      <1>
   195 000164C4 7CC6381818183C00E0- <1>     db  07ch, 0c6h, 038h, 018h, 018h, 018h, 03ch, 000h, 0e0h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   195 000164CD 00703030307800      <1>
   196 000164D4 C6386CC6FEC6C60030- <1>     db  0c6h, 038h, 06ch, 0c6h, 0feh, 0c6h, 0c6h, 000h, 030h, 030h, 000h, 078h, 0cch, 0fch, 0cch, 000h
   196 000164DD 300078CCFCCC00      <1>
   197 000164E4 1C00FC607860FC0000- <1>     db  01ch, 000h, 0fch, 060h, 078h, 060h, 0fch, 000h, 000h, 000h, 07fh, 00ch, 07fh, 0cch, 07fh, 000h
   197 000164ED 007F0C7FCC7F00      <1>
   198 000164F4 3E6CCCFECCCCCE0078- <1>     db  03eh, 06ch, 0cch, 0feh, 0cch, 0cch, 0ceh, 000h, 078h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h
   198 000164FD CC0078CCCC7800      <1>
   199 00016504 00CC0078CCCC780000- <1>     db  000h, 0cch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 0e0h, 000h, 078h, 0cch, 0cch, 078h, 000h
   199 0001650D E00078CCCC7800      <1>
   200 00016514 78CC00CCCCCC7E0000- <1>     db  078h, 0cch, 000h, 0cch, 0cch, 0cch, 07eh, 000h, 000h, 0e0h, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   200 0001651D E000CCCCCC7E00      <1>
   201 00016524 00CC00CCCC7C0CF8C3- <1>     db  000h, 0cch, 000h, 0cch, 0cch, 07ch, 00ch, 0f8h, 0c3h, 018h, 03ch, 066h, 066h, 03ch, 018h, 000h
   201 0001652D 183C66663C1800      <1>
   202 00016534 CC00CCCCCCCC780018- <1>     db  0cch, 000h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 018h, 018h, 07eh, 0c0h, 0c0h, 07eh, 018h, 018h
   202 0001653D 187EC0C07E1818      <1>
   203 00016544 386C64F060E6FC00CC- <1>     db  038h, 06ch, 064h, 0f0h, 060h, 0e6h, 0fch, 000h, 0cch, 0cch, 078h, 0fch, 030h, 0fch, 030h, 030h
   203 0001654D CC78FC30FC3030      <1>
   204 00016554 F8CCCCFAC6CFC6C70E- <1>     db  0f8h, 0cch, 0cch, 0fah, 0c6h, 0cfh, 0c6h, 0c7h, 00eh, 01bh, 018h, 03ch, 018h, 018h, 0d8h, 070h
   204 0001655D 1B183C1818D870      <1>
   205 00016564 1C00780C7CCC7E0038- <1>     db  01ch, 000h, 078h, 00ch, 07ch, 0cch, 07eh, 000h, 038h, 000h, 070h, 030h, 030h, 030h, 078h, 000h
   205 0001656D 00703030307800      <1>
   206 00016574 001C0078CCCC780000- <1>     db  000h, 01ch, 000h, 078h, 0cch, 0cch, 078h, 000h, 000h, 01ch, 000h, 0cch, 0cch, 0cch, 07eh, 000h
   206 0001657D 1C00CCCCCC7E00      <1>
   207 00016584 00F800F8CCCCCC00FC- <1>     db  000h, 0f8h, 000h, 0f8h, 0cch, 0cch, 0cch, 000h, 0fch, 000h, 0cch, 0ech, 0fch, 0dch, 0cch, 000h
   207 0001658D 00CCECFCDCCC00      <1>
   208 00016594 3C6C6C3E007E000038- <1>     db  03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h
   208 0001659D 6C6C38007C0000      <1>
   209 000165A4 30003060C0CC780000- <1>     db  030h, 000h, 030h, 060h, 0c0h, 0cch, 078h, 000h, 000h, 000h, 000h, 0fch, 0c0h, 0c0h, 000h, 000h
   209 000165AD 0000FCC0C00000      <1>
   210 000165B4 000000FC0C0C0000C3- <1>     db  000h, 000h, 000h, 0fch, 00ch, 00ch, 000h, 000h, 0c3h, 0c6h, 0cch, 0deh, 033h, 066h, 0cch, 00fh
   210 000165BD C6CCDE3366CC0F      <1>
   211 000165C4 C3C6CCDB376FCF0318- <1>     db  0c3h, 0c6h, 0cch, 0dbh, 037h, 06fh, 0cfh, 003h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 000h
   211 000165CD 18001818181800      <1>
   212 000165D4 003366CC6633000000- <1>     db  000h, 033h, 066h, 0cch, 066h, 033h, 000h, 000h, 000h, 0cch, 066h, 033h, 066h, 0cch, 000h, 000h
   212 000165DD CC663366CC0000      <1>
   213 000165E4 228822882288228855- <1>     db  022h, 088h, 022h, 088h, 022h, 088h, 022h, 088h, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
   213 000165ED AA55AA55AA55AA      <1>
   214 000165F4 DB77DBEEDB77DBEE18- <1>     db  0dbh, 077h, 0dbh, 0eeh, 0dbh, 077h, 0dbh, 0eeh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   214 000165FD 18181818181818      <1>
   215 00016604 18181818F818181818- <1>     db  018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h
   215 0001660D 18F818F8181818      <1>
   216 00016614 36363636F636363600- <1>     db  036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h
   216 0001661D 000000FE363636      <1>
   217 00016624 0000F818F818181836- <1>     db  000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h
   217 0001662D 36F606F6363636      <1>
   218 00016634 363636363636363600- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h
   218 0001663D 00FE06F6363636      <1>
   219 00016644 3636F606FE00000036- <1>     db  036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h
   219 0001664D 363636FE000000      <1>
   220 00016654 1818F818F800000000- <1>     db  018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h
   220 0001665D 000000F8181818      <1>
   221 00016664 181818181F00000018- <1>     db  018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h
   221 0001666D 181818FF000000      <1>
   222 00016674 00000000FF18181818- <1>     db  000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h
   222 0001667D 1818181F181818      <1>
   223 00016684 00000000FF00000018- <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h
   223 0001668D 181818FF181818      <1>
   224 00016694 18181F181F18181836- <1>     db  018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h
   224 0001669D 36363637363636      <1>
   225 000166A4 363637303F00000000- <1>     db  036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h
   225 000166AD 003F3037363636      <1>
   226 000166B4 3636F700FF00000000- <1>     db  036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h
   226 000166BD 00FF00F7363636      <1>
   227 000166C4 363637303736363600- <1>     db  036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
   227 000166CD 00FF00FF000000      <1>
   228 000166D4 3636F700F736363618- <1>     db  036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h
   228 000166DD 18FF00FF000000      <1>
   229 000166E4 36363636FF00000000- <1>     db  036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h
   229 000166ED 00FF00FF181818      <1>
   230 000166F4 00000000FF36363636- <1>     db  000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h
   230 000166FD 3636363F000000      <1>
   231 00016704 18181F181F00000000- <1>     db  018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h
   231 0001670D 001F181F181818      <1>
   232 00016714 000000003F36363636- <1>     db  000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h
   232 0001671D 363636FF363636      <1>
   233 00016724 1818FF18FF18181818- <1>     db  018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h
   233 0001672D 181818F8000000      <1>
   234 00016734 000000001F181818FF- <1>     db  000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   234 0001673D FFFFFFFFFFFFFF      <1>
   235 00016744 00000000FFFFFFFFF0- <1>     db  000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   235 0001674D F0F0F0F0F0F0F0      <1>
   236 00016754 0F0F0F0F0F0F0F0FFF- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h
   236 0001675D FFFFFF00000000      <1>
   237 00016764 000076DCC8DC760000- <1>     db  000h, 000h, 076h, 0dch, 0c8h, 0dch, 076h, 000h, 000h, 078h, 0cch, 0f8h, 0cch, 0f8h, 0c0h, 0c0h
   237 0001676D 78CCF8CCF8C0C0      <1>
   238 00016774 00FCCCC0C0C0C00000- <1>     db  000h, 0fch, 0cch, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
   238 0001677D FE6C6C6C6C6C00      <1>
   239 00016784 FCCC603060CCFC0000- <1>     db  0fch, 0cch, 060h, 030h, 060h, 0cch, 0fch, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 070h, 000h
   239 0001678D 007ED8D8D87000      <1>
   240 00016794 00666666667C60C000- <1>     db  000h, 066h, 066h, 066h, 066h, 07ch, 060h, 0c0h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 000h
   240 0001679D 76DC1818181800      <1>
   241 000167A4 FC3078CCCC7830FC38- <1>     db  0fch, 030h, 078h, 0cch, 0cch, 078h, 030h, 0fch, 038h, 06ch, 0c6h, 0feh, 0c6h, 06ch, 038h, 000h
   241 000167AD 6CC6FEC66C3800      <1>
   242 000167B4 386CC6C66C6CEE001C- <1>     db  038h, 06ch, 0c6h, 0c6h, 06ch, 06ch, 0eeh, 000h, 01ch, 030h, 018h, 07ch, 0cch, 0cch, 078h, 000h
   242 000167BD 30187CCCCC7800      <1>
   243 000167C4 00007EDBDB7E000006- <1>     db  000h, 000h, 07eh, 0dbh, 0dbh, 07eh, 000h, 000h, 006h, 00ch, 07eh, 0dbh, 0dbh, 07eh, 060h, 0c0h
   243 000167CD 0C7EDBDB7E60C0      <1>
   244 000167D4 3860C0F8C060380078- <1>     db  038h, 060h, 0c0h, 0f8h, 0c0h, 060h, 038h, 000h, 078h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 000h
   244 000167DD CCCCCCCCCCCC00      <1>
   245 000167E4 00FC00FC00FC000030- <1>     db  000h, 0fch, 000h, 0fch, 000h, 0fch, 000h, 000h, 030h, 030h, 0fch, 030h, 030h, 000h, 0fch, 000h
   245 000167ED 30FC303000FC00      <1>
   246 000167F4 603018306000FC0018- <1>     db  060h, 030h, 018h, 030h, 060h, 000h, 0fch, 000h, 018h, 030h, 060h, 030h, 018h, 000h, 0fch, 000h
   246 000167FD 3060301800FC00      <1>
   247 00016804 0E1B1B181818181818- <1>     db  00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 070h
   247 0001680D 18181818D8D870      <1>
   248 00016814 303000FC0030300000- <1>     db  030h, 030h, 000h, 0fch, 000h, 030h, 030h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h
   248 0001681D 76DC0076DC0000      <1>
   249 00016824 386C6C380000000000- <1>     db  038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h
   249 0001682D 00001818000000      <1>
   250 00016834 00000000180000000F- <1>     db  000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 0ech, 06ch, 03ch, 01ch
   250 0001683D 0C0C0CEC6C3C1C      <1>
   251 00016844 786C6C6C6C00000070- <1>     db  078h, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 070h, 018h, 030h, 060h, 078h, 000h, 000h, 000h
   251 0001684D 18306078000000      <1>
   252 00016854 00003C3C3C3C000000- <1>     db  000h, 000h, 03ch, 03ch, 03ch, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   252 0001685D 00000000000000      <1>
   253                              <1> vgafont14:
   254 00016864 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   254 0001686D 00000000000000      <1>
   255 00016874 7E81A58181BD99817E- <1>     db  07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 07eh, 000h, 000h, 000h, 000h, 000h, 07eh, 0ffh
   255 0001687D 00000000007EFF      <1>
   256 00016884 DBFFFFC3E7FF7E0000- <1>     db  0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 0feh, 0feh
   256 0001688D 000000006CFEFE      <1>
   257 00016894 FEFE7C381000000000- <1>     db  0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch
   257 0001689D 000010387CFE7C      <1>
   258 000168A4 381000000000000018- <1>     db  038h, 010h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h
   258 000168AD 3C3CE7E7E71818      <1>
   259 000168B4 3C0000000000183C7E- <1>     db  03ch, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h
   259 000168BD FFFF7E18183C00      <1>
   260 000168C4 00000000000000183C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
   260 000168CD 3C180000000000      <1>
   261 000168D4 FFFFFFFFFFE7C3C3E7- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h
   261 000168DD FFFFFFFFFF0000      <1>
   262 000168E4 00003C664242663C00- <1>     db  000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh
   262 000168ED 000000FFFFFFFF      <1>
   263 000168F4 C399BDBD99C3FFFFFF- <1>     db  0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 01eh, 00eh, 01ah, 032h
   263 000168FD FF00001E0E1A32      <1>
   264 00016904 78CCCCCC7800000000- <1>     db  078h, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 066h, 066h, 03ch, 018h
   264 0001690D 003C6666663C18      <1>
   265 00016914 7E181800000000003F- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 070h, 0f0h
   265 0001691D 333F30303070F0      <1>
   266 00016924 E000000000007F637F- <1>     db  0e0h, 000h, 000h, 000h, 000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h
   266 0001692D 63636367E7E6C0      <1>
   267 00016934 000000001818DB3CE7- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h
   267 0001693D 3CDB1818000000      <1>
   268 00016944 000080C0E0F8FEF8E0- <1>     db  000h, 000h, 080h, 0c0h, 0e0h, 0f8h, 0feh, 0f8h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h, 000h
   268 0001694D C0800000000000      <1>
   269 00016954 02060E3EFE3E0E0602- <1>     db  002h, 006h, 00eh, 03eh, 0feh, 03eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch
   269 0001695D 0000000000183C      <1>
   270 00016964 7E1818187E3C180000- <1>     db  07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h
   270 0001696D 00000066666666      <1>
   271 00016974 666600666600000000- <1>     db  066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh
   271 0001697D 007FDBDBDB7B1B      <1>
   272 00016984 1B1B1B000000007CC6- <1>     db  01bh, 01bh, 01bh, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h
   272 0001698D 60386CC6C66C38      <1>
   273 00016994 0CC67C000000000000- <1>     db  00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 000h
   273 0001699D 000000FEFEFE00      <1>
   274 000169A4 00000000183C7E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h
   274 000169AD 187E3C187E0000      <1>
   275 000169B4 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   275 000169BD 18180000000000      <1>
   276 000169C4 1818181818187E3C18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   276 000169CD 00000000000000      <1>
   277 000169D4 180CFE0C1800000000- <1>     db  018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 030h, 060h
   277 000169DD 00000000003060      <1>
   278 000169E4 FE6030000000000000- <1>     db  0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h
   278 000169ED 00000000C0C0C0      <1>
   279 000169F4 FE0000000000000000- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 028h, 06ch, 0feh, 06ch, 028h, 000h
   279 000169FD 00286CFE6C2800      <1>
   280 00016A04 000000000000001038- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h
   280 00016A0D 387C7CFEFE0000      <1>
   281 00016A14 0000000000FEFE7C7C- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h
   281 00016A1D 38381000000000      <1>
   282 00016A24 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   282 00016A2D 00000000000000      <1>
   283 00016A34 183C3C3C1818001818- <1>     db  018h, 03ch, 03ch, 03ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 066h, 066h, 066h
   283 00016A3D 00000000666666      <1>
   284 00016A44 240000000000000000- <1>     db  024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch
   284 00016A4D 0000006C6CFE6C      <1>
   285 00016A54 6C6CFE6C6C00000018- <1>     db  06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h
   285 00016A5D 187CC6C2C07C06      <1>
   286 00016A64 86C67C181800000000- <1>     db  086h, 0c6h, 07ch, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 066h
   286 00016A6D 00C2C60C183066      <1>
   287 00016A74 C60000000000386C6C- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 076h, 000h
   287 00016A7D 3876DCCCCC7600      <1>
   288 00016A84 000000303030600000- <1>     db  000h, 000h, 000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   288 00016A8D 00000000000000      <1>
   289 00016A94 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h, 000h
   289 00016A9D 180C0000000000      <1>
   290 00016AA4 30180C0C0C0C0C1830- <1>     db  030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   290 00016AAD 00000000000000      <1>
   291 00016AB4 663CFF3C6600000000- <1>     db  066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
   291 00016ABD 00000000001818      <1>
   292 00016AC4 7E1818000000000000- <1>     db  07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   292 00016ACD 00000000000000      <1>
   293 00016AD4 181818300000000000- <1>     db  018h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h
   293 00016ADD 000000FE000000      <1>
   294 00016AE4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
   294 00016AED 00000000181800      <1>
   295 00016AF4 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
   295 00016AFD 60C08000000000      <1>
   296 00016B04 00007CC6CEDEF6E6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0ceh, 0deh, 0f6h, 0e6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   296 00016B0D C67C0000000000      <1>
   297 00016B14 18387818181818187E- <1>     db  018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h
   297 00016B1D 00000000007CC6      <1>
   298 00016B24 060C183060C6FE0000- <1>     db  006h, 00ch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 006h, 006h
   298 00016B2D 0000007CC60606      <1>
   299 00016B34 3C0606C67C00000000- <1>     db  03ch, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh
   299 00016B3D 000C1C3C6CCCFE      <1>
   300 00016B44 0C0C1E0000000000FE- <1>     db  00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 0c6h
   300 00016B4D C0C0C0FC0606C6      <1>
   301 00016B54 7C00000000003860C0- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 07ch, 000h
   301 00016B5D C0FCC6C6C67C00      <1>
   302 00016B64 00000000FEC6060C18- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c6h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h
   302 00016B6D 30303030000000      <1>
   303 00016B74 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   303 00016B7D C67C0000000000      <1>
   304 00016B84 7CC6C6C67E06060C78- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h, 000h, 000h, 018h
   304 00016B8D 00000000000018      <1>
   305 00016B94 180000001818000000- <1>     db  018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h
   305 00016B9D 00000000181800      <1>
   306 00016BA4 000018183000000000- <1>     db  000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h
   306 00016BAD 00060C18306030      <1>
   307 00016BB4 180C06000000000000- <1>     db  018h, 00ch, 006h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h
   307 00016BBD 00007E00007E00      <1>
   308 00016BC4 000000000000603018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h
   308 00016BCD 0C060C18306000      <1>
   309 00016BD4 000000007CC6C60C18- <1>     db  000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h
   309 00016BDD 18001818000000      <1>
   310 00016BE4 00007CC6C6DEDEDEDC- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h, 000h
   310 00016BED C07C0000000000      <1>
   311 00016BF4 10386CC6C6FEC6C6C6- <1>     db  010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h, 0fch, 066h
   311 00016BFD 0000000000FC66      <1>
   312 00016C04 66667C666666FC0000- <1>     db  066h, 066h, 07ch, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h
   312 00016C0D 0000003C66C2C0      <1>
   313 00016C14 C0C0C2663C00000000- <1>     db  0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h
   313 00016C1D 00F86C66666666      <1>
   314 00016C24 666CF80000000000FE- <1>     db  066h, 06ch, 0f8h, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 062h, 066h
   314 00016C2D 66626878686266      <1>
   315 00016C34 FE0000000000FE6662- <1>     db  0feh, 000h, 000h, 000h, 000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 0f0h, 000h
   315 00016C3D 6878686060F000      <1>
   316 00016C44 000000003C66C2C0C0- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 066h, 03ah, 000h, 000h, 000h
   316 00016C4D DEC6663A000000      <1>
   317 00016C54 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
   317 00016C5D C6C60000000000      <1>
   318 00016C64 3C181818181818183C- <1>     db  03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 01eh, 00ch
   318 00016C6D 00000000001E0C      <1>
   319 00016C74 0C0C0C0CCCCC780000- <1>     db  00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h, 000h, 0e6h, 066h, 06ch, 06ch
   319 00016C7D 000000E6666C6C      <1>
   320 00016C84 786C6C66E600000000- <1>     db  078h, 06ch, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h
   320 00016C8D 00F06060606060      <1>
   321 00016C94 6266FE0000000000C6- <1>     db  062h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 0c6h, 0eeh, 0feh, 0feh, 0d6h, 0c6h, 0c6h, 0c6h
   321 00016C9D EEFEFED6C6C6C6      <1>
   322 00016CA4 C60000000000C6E6F6- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h
   322 00016CAD FEDECEC6C6C600      <1>
   323 00016CB4 00000000386CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h
   323 00016CBD C6C66C38000000      <1>
   324 00016CC4 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h
   324 00016CCD 60F00000000000      <1>
   325 00016CD4 7CC6C6C6C6D6DE7C0C- <1>     db  07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h, 000h, 000h, 0fch, 066h
   325 00016CDD 0E00000000FC66      <1>
   326 00016CE4 66667C6C6666E60000- <1>     db  066h, 066h, 07ch, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 060h
   326 00016CED 0000007CC6C660      <1>
   327 00016CF4 380CC6C67C00000000- <1>     db  038h, 00ch, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 07eh, 07eh, 05ah, 018h, 018h, 018h
   327 00016CFD 007E7E5A181818      <1>
   328 00016D04 18183C0000000000C6- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h
   328 00016D0D C6C6C6C6C6C6C6      <1>
   329 00016D14 7C0000000000C6C6C6- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 010h, 000h
   329 00016D1D C6C6C66C381000      <1>
   330 00016D24 00000000C6C6C6C6D6- <1>     db  000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 07ch, 06ch, 000h, 000h, 000h
   330 00016D2D D6FE7C6C000000      <1>
   331 00016D34 0000C6C66C3838386C- <1>     db  000h, 000h, 0c6h, 0c6h, 06ch, 038h, 038h, 038h, 06ch, 0c6h, 0c6h, 000h, 000h, 000h, 000h, 000h
   331 00016D3D C6C60000000000      <1>
   332 00016D44 666666663C1818183C- <1>     db  066h, 066h, 066h, 066h, 03ch, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h
   332 00016D4D 0000000000FEC6      <1>
   333 00016D54 8C183060C2C6FE0000- <1>     db  08ch, 018h, 030h, 060h, 0c2h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 03ch, 030h, 030h, 030h
   333 00016D5D 0000003C303030      <1>
   334 00016D64 303030303C00000000- <1>     db  030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch
   334 00016D6D 0080C0E070381C      <1>
   335 00016D74 0E060200000000003C- <1>     db  00eh, 006h, 002h, 000h, 000h, 000h, 000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch
   335 00016D7D 0C0C0C0C0C0C0C      <1>
   336 00016D84 3C00000010386CC600- <1>     db  03ch, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   336 00016D8D 00000000000000      <1>
   337 00016D94 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h
   337 00016D9D 0000000000FF00      <1>
   338 00016DA4 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   338 00016DAD 00000000000000      <1>
   339 00016DB4 000000780C7CCCCC76- <1>     db  000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0e0h, 060h
   339 00016DBD 0000000000E060      <1>
   340 00016DC4 60786C6666667C0000- <1>     db  060h, 078h, 06ch, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
   340 00016DCD 0000000000007C      <1>
   341 00016DD4 C6C0C0C67C00000000- <1>     db  0c6h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch
   341 00016DDD 001C0C0C3C6CCC      <1>
   342 00016DE4 CCCC76000000000000- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h
   342 00016DED 00007CC6FEC0C6      <1>
   343 00016DF4 7C0000000000386C64- <1>     db  07ch, 000h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 0f0h, 000h
   343 00016DFD 60F0606060F000      <1>
   344 00016E04 0000000000000076CC- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
   344 00016E0D CCCC7C0CCC7800      <1>
   345 00016E14 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h
   345 00016E1D 66E60000000000      <1>
   346 00016E24 18180038181818183C- <1>     db  018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 006h, 006h
   346 00016E2D 00000000000606      <1>
   347 00016E34 000E0606060666663C- <1>     db  000h, 00eh, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h, 000h, 000h, 0e0h, 060h, 060h, 066h
   347 00016E3D 000000E0606066      <1>
   348 00016E44 6C786C66E600000000- <1>     db  06ch, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h
   348 00016E4D 00381818181818      <1>
   349 00016E54 18183C000000000000- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ech, 0feh, 0d6h, 0d6h, 0d6h
   349 00016E5D 0000ECFED6D6D6      <1>
   350 00016E64 C60000000000000000- <1>     db  0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 000h
   350 00016E6D DC666666666600      <1>
   351 00016E74 000000000000007CC6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h
   351 00016E7D C6C6C67C000000      <1>
   352 00016E84 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h, 000h, 000h
   352 00016E8D 7C6060F0000000      <1>
   353 00016E94 00000076CCCCCC7C0C- <1>     db  000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h, 000h
   353 00016E9D 0C1E0000000000      <1>
   354 00016EA4 00DC76666060F00000- <1>     db  000h, 0dch, 076h, 066h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch
   354 00016EAD 0000000000007C      <1>
   355 00016EB4 C6701CC67C00000000- <1>     db  0c6h, 070h, 01ch, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h
   355 00016EBD 00103030FC3030      <1>
   356 00016EC4 30361C000000000000- <1>     db  030h, 036h, 01ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch
   356 00016ECD 0000CCCCCCCCCC      <1>
   357 00016ED4 760000000000000000- <1>     db  076h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 03ch, 018h, 000h
   357 00016EDD 666666663C1800      <1>
   358 00016EE4 00000000000000C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0d6h, 0d6h, 0feh, 06ch, 000h, 000h, 000h
   358 00016EED D6D6FE6C000000      <1>
   359 00016EF4 0000000000C66C3838- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 06ch, 038h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h
   359 00016EFD 6CC60000000000      <1>
   360 00016F04 000000C6C6C6C67E06- <1>     db  000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h, 000h, 000h, 000h, 000h
   360 00016F0D 0CF80000000000      <1>
   361 00016F14 00FECC183066FE0000- <1>     db  000h, 0feh, 0cch, 018h, 030h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h, 00eh, 018h, 018h, 018h
   361 00016F1D 0000000E181818      <1>
   362 00016F24 701818180E00000000- <1>     db  070h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h
   362 00016F2D 00181818180018      <1>
   363 00016F34 181818000000000070- <1>     db  018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h
   363 00016F3D 1818180E181818      <1>
   364 00016F44 70000000000076DC00- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   364 00016F4D 00000000000000      <1>
   365 00016F54 00000000000010386C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   365 00016F5D C6C6FE00000000      <1>
   366 00016F64 00003C66C2C0C0C266- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h, 000h
   366 00016F6D 3C0C067C000000      <1>
   367 00016F74 CCCC00CCCCCCCCCC76- <1>     db  0cch, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h
   367 00016F7D 000000000C1830      <1>
   368 00016F84 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 078h
   368 00016F8D 000010386C0078      <1>
   369 00016F94 0C7CCCCC7600000000- <1>     db  00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 000h, 078h, 00ch, 07ch
   369 00016F9D 00CCCC00780C7C      <1>
   370 00016FA4 CCCC76000000006030- <1>     db  0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch
   370 00016FAD 1800780C7CCCCC      <1>
   371 00016FB4 7600000000386C3800- <1>     db  076h, 000h, 000h, 000h, 000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h
   371 00016FBD 780C7CCCCC7600      <1>
   372 00016FC4 0000000000003C6660- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 03ch, 066h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h
   372 00016FCD 663C0C063C0000      <1>
   373 00016FD4 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   373 00016FDD C67C0000000000      <1>
   374 00016FE4 CCCC007CC6FEC0C67C- <1>     db  0cch, 0cch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h
   374 00016FED 00000000603018      <1>
   375 00016FF4 007CC6FEC0C67C0000- <1>     db  000h, 07ch, 0c6h, 0feh, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 000h, 038h
   375 00016FFD 00000066660038      <1>
   376 00017004 181818183C00000000- <1>     db  018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h
   376 0001700D 183C6600381818      <1>
   377 00017014 18183C000000006030- <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h
   377 0001701D 18003818181818      <1>
   378 00017024 3C00000000C6C61038- <1>     db  03ch, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h
   378 0001702D 6CC6C6FEC6C600      <1>
   379 00017034 0000386C3800386CC6- <1>     db  000h, 000h, 038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 000h, 000h, 000h
   379 0001703D C6FEC6C6000000      <1>
   380 00017044 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 066h, 0feh, 000h, 000h, 000h, 000h, 000h
   380 0001704D 66FE0000000000      <1>
   381 00017054 0000CC76367ED8D86E- <1>     db  000h, 000h, 0cch, 076h, 036h, 07eh, 0d8h, 0d8h, 06eh, 000h, 000h, 000h, 000h, 000h, 03eh, 06ch
   381 0001705D 00000000003E6C      <1>
   382 00017064 CCCCFECCCCCCCE0000- <1>     db  0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h, 010h, 038h, 06ch, 000h, 07ch
   382 0001706D 000010386C007C      <1>
   383 00017074 C6C6C6C67C00000000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h, 07ch, 0c6h, 0c6h
   383 0001707D 00C6C6007CC6C6      <1>
   384 00017084 C6C67C000000006030- <1>     db  0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h
   384 0001708D 18007CC6C6C6C6      <1>
   385 00017094 7C000000003078CC00- <1>     db  07ch, 000h, 000h, 000h, 000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h
   385 0001709D CCCCCCCCCC7600      <1>
   386 000170A4 00000060301800CCCC- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h
   386 000170AD CCCCCC76000000      <1>
   387 000170B4 0000C6C600C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h, 000h, 0c6h
   387 000170BD 7E060C780000C6      <1>
   388 000170C4 C6386CC6C6C6C66C38- <1>     db  0c6h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 000h
   388 000170CD 00000000C6C600      <1>
   389 000170D4 C6C6C6C6C6C67C0000- <1>     db  0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 018h, 03ch, 066h, 060h
   389 000170DD 000018183C6660      <1>
   390 000170E4 60663C181800000000- <1>     db  060h, 066h, 03ch, 018h, 018h, 000h, 000h, 000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h
   390 000170ED 386C6460F06060      <1>
   391 000170F4 60E6FC000000000066- <1>     db  060h, 0e6h, 0fch, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 03ch, 018h, 07eh, 018h, 07eh, 018h
   391 000170FD 663C187E187E18      <1>
   392 00017104 1800000000F8CCCCF8- <1>     db  018h, 000h, 000h, 000h, 000h, 0f8h, 0cch, 0cch, 0f8h, 0c4h, 0cch, 0deh, 0cch, 0cch, 0c6h, 000h
   392 0001710D C4CCDECCCCC600      <1>
   393 00017114 0000000E1B1818187E- <1>     db  000h, 000h, 000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h
   393 0001711D 18181818D87000      <1>
   394 00017124 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 00ch
   394 0001712D CC76000000000C      <1>
   395 00017134 18300038181818183C- <1>     db  018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h
   395 0001713D 00000000183060      <1>
   396 00017144 007CC6C6C6C67C0000- <1>     db  000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 018h, 030h, 060h, 000h, 0cch
   396 0001714D 000018306000CC      <1>
   397 00017154 CCCCCCCC7600000000- <1>     db  0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h
   397 0001715D 0076DC00DC6666      <1>
   398 00017164 66666600000076DC00- <1>     db  066h, 066h, 066h, 000h, 000h, 000h, 076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h
   398 0001716D C6E6F6FEDECEC6      <1>
   399 00017174 C6000000003C6C6C3E- <1>     db  0c6h, 000h, 000h, 000h, 000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h
   399 0001717D 007E0000000000      <1>
   400 00017184 000000386C6C38007C- <1>     db  000h, 000h, 000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   400 0001718D 00000000000000      <1>
   401 00017194 0000303000303060C6- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h, 000h
   401 0001719D C67C0000000000      <1>
   402 000171A4 00000000FEC0C0C000- <1>     db  000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   402 000171AD 00000000000000      <1>
   403 000171B4 0000FE060606000000- <1>     db  000h, 000h, 0feh, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h
   403 000171BD 0000C0C0C6CCD8      <1>
   404 000171C4 3060DC860C183E0000- <1>     db  030h, 060h, 0dch, 086h, 00ch, 018h, 03eh, 000h, 000h, 0c0h, 0c0h, 0c6h, 0cch, 0d8h, 030h, 066h
   404 000171CD C0C0C6CCD83066      <1>
   405 000171D4 CE9E3E060600000018- <1>     db  0ceh, 09eh, 03eh, 006h, 006h, 000h, 000h, 000h, 018h, 018h, 000h, 018h, 018h, 03ch, 03ch, 03ch
   405 000171DD 180018183C3C3C      <1>
   406 000171E4 180000000000000036- <1>     db  018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h
   406 000171ED 6CD86C36000000      <1>
   407 000171F4 000000000000D86C36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h
   407 000171FD 6CD80000000000      <1>
   408 00017204 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 055h, 0aah
   408 0001720D 441144114455AA      <1>
   409 00017214 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 0ddh, 077h, 0ddh, 077h
   409 0001721D AA55AADD77DD77      <1>
   410 00017224 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 018h, 018h, 018h, 018h, 018h, 018h
   410 0001722D 77181818181818      <1>
   411 00017234 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h
   411 0001723D 181818181818F8      <1>
   412 00017244 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h
   412 0001724D 1818F818F81818      <1>
   413 00017254 181818183636363636- <1>     db  018h, 018h, 018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h
   413 0001725D 3636F636363636      <1>
   414 00017264 363600000000000000- <1>     db  036h, 036h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h
   414 0001726D FE363636363636      <1>
   415 00017274 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 036h, 036h
   415 0001727D 18181818183636      <1>
   416 00017284 363636F606F6363636- <1>     db  036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   416 0001728D 36363636363636      <1>
   417 00017294 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0feh
   417 0001729D 360000000000FE      <1>
   418 000172A4 06F636363636363636- <1>     db  006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh
   418 000172AD 36363636F606FE      <1>
   419 000172B4 000000000000363636- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h
   419 000172BD 36363636FE0000      <1>
   420 000172C4 000000001818181818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h
   420 000172CD F818F800000000      <1>
   421 000172D4 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h
   421 000172DD F8181818181818      <1>
   422 000172E4 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h
   422 000172ED 00000000001818      <1>
   423 000172F4 1818181818FF000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   423 000172FD 00000000000000      <1>
   424 00017304 000000FF1818181818- <1>     db  000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   424 0001730D 18181818181818      <1>
   425 00017314 181F18181818181800- <1>     db  018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   425 0001731D 000000000000FF      <1>
   426 00017324 000000000000181818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h
   426 0001732D 18181818FF1818      <1>
   427 00017334 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h
   427 0001733D 1F181F18181818      <1>
   428 00017344 181836363636363636- <1>     db  018h, 018h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h
   428 0001734D 37363636363636      <1>
   429 00017354 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   429 0001735D 00000000000000      <1>
   430 00017364 0000003F3037363636- <1>     db  000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   430 0001736D 36363636363636      <1>
   431 00017374 36F700FF0000000000- <1>     db  036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   431 0001737D 000000000000FF      <1>
   432 00017384 00F736363636363636- <1>     db  000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h
   432 0001738D 36363636373037      <1>
   433 00017394 363636363636000000- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h
   433 0001739D 0000FF00FF0000      <1>
   434 000173A4 000000003636363636- <1>     db  000h, 000h, 000h, 000h, 036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h
   434 000173AD F700F736363636      <1>
   435 000173B4 36361818181818FF00- <1>     db  036h, 036h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h
   435 000173BD FF000000000000      <1>
   436 000173C4 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   436 000173CD 00000000000000      <1>
   437 000173D4 000000FF00FF181818- <1>     db  000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   437 000173DD 18181800000000      <1>
   438 000173E4 000000FF3636363636- <1>     db  000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   438 000173ED 36363636363636      <1>
   439 000173F4 363F00000000000018- <1>     db  036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh
   439 000173FD 181818181F181F      <1>
   440 00017404 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h
   440 0001740D 00001F181F1818      <1>
   441 00017414 181818180000000000- <1>     db  018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h
   441 0001741D 00003F36363636      <1>
   442 00017424 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h
   442 0001742D FF363636363636      <1>
   443 00017434 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   443 0001743D 18181818181818      <1>
   444 00017444 1818181818F8000000- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   444 0001744D 00000000000000      <1>
   445 00017454 0000001F1818181818- <1>     db  000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   445 0001745D 18FFFFFFFFFFFF      <1>
   446 00017464 FFFFFFFFFFFFFFFF00- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh
   446 0001746D 000000000000FF      <1>
   447 00017474 FFFFFFFFFFFFF0F0F0- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   447 0001747D F0F0F0F0F0F0F0      <1>
   448 00017484 F0F0F0F00F0F0F0F0F- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
   448 0001748D 0F0F0F0F0F0F0F      <1>
   449 00017494 0F0FFFFFFFFFFFFFFF- <1>     db  00fh, 00fh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   449 0001749D 00000000000000      <1>
   450 000174A4 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h, 000h
   450 000174AD DC760000000000      <1>
   451 000174B4 00007CC6FCC6C6FCC0- <1>     db  000h, 000h, 07ch, 0c6h, 0fch, 0c6h, 0c6h, 0fch, 0c0h, 0c0h, 040h, 000h, 000h, 000h, 0feh, 0c6h
   451 000174BD C040000000FEC6      <1>
   452 000174C4 C6C0C0C0C0C0C00000- <1>     db  0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 06ch
   452 000174CD 0000000000FE6C      <1>
   453 000174D4 6C6C6C6C6C00000000- <1>     db  06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h
   453 000174DD 00FEC660301830      <1>
   454 000174E4 60C6FE000000000000- <1>     db  060h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h
   454 000174ED 00007ED8D8D8D8      <1>
   455 000174F4 700000000000000066- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h
   455 000174FD 6666667C6060C0      <1>
   456 00017504 00000000000076DC18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h
   456 0001750D 18181818000000      <1>
   457 00017514 00007E183C6666663C- <1>     db  000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h, 000h
   457 0001751D 187E0000000000      <1>
   458 00017524 386CC6C6FEC6C66C38- <1>     db  038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 038h, 06ch
   458 0001752D 0000000000386C      <1>
   459 00017534 C6C6C66C6C6CEE0000- <1>     db  0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h, 000h, 01eh, 030h, 018h, 00ch
   459 0001753D 0000001E30180C      <1>
   460 00017544 3E6666663C00000000- <1>     db  03eh, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh
   460 0001754D 000000007EDBDB      <1>
   461 00017554 7E0000000000000003- <1>     db  07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h
   461 0001755D 067EDBDBF37E60      <1>
   462 00017564 C000000000001C3060- <1>     db  0c0h, 000h, 000h, 000h, 000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 030h, 01ch, 000h
   462 0001756D 607C6060301C00      <1>
   463 00017574 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h
   463 0001757D C6C6C6C6000000      <1>
   464 00017584 000000FE0000FE0000- <1>     db  000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
   464 0001758D FE000000000000      <1>
   465 00017594 0018187E18180000FF- <1>     db  000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 030h, 018h
   465 0001759D 00000000003018      <1>
   466 000175A4 0C060C1830007E0000- <1>     db  00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00ch, 018h, 030h, 060h
   466 000175AD 0000000C183060      <1>
   467 000175B4 30180C007E00000000- <1>     db  030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h
   467 000175BD 000E1B1B181818      <1>
   468 000175C4 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h
   468 000175CD 1818181818D8D8      <1>
   469 000175D4 700000000000001818- <1>     db  070h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h
   469 000175DD 007E0018180000      <1>
   470 000175E4 00000000000076DC00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h
   470 000175ED 76DC0000000000      <1>
   471 000175F4 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   471 000175FD 00000000000000      <1>
   472 00017604 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   472 0001760D 00000000000000      <1>
   473 00017614 000000180000000000- <1>     db  000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 00fh, 00ch, 00ch, 00ch, 00ch
   473 0001761D 00000F0C0C0C0C      <1>
   474 00017624 0CEC6C3C1C00000000- <1>     db  00ch, 0ech, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h
   474 0001762D D86C6C6C6C6C00      <1>
   475 00017634 0000000000000070D8- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h
   475 0001763D 3060C8F8000000      <1>
   476 00017644 00000000000000007C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h
   476 0001764D 7C7C7C7C7C0000      <1>
   477 00017654 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   477 0001765D 00000000000000      <1>
   478                              <1> vgafont16:
   479 00017664 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   479 0001766D 00000000000000      <1>
   480 00017674 00007E81A58181BD99- <1>     db  000h, 000h, 07eh, 081h, 0a5h, 081h, 081h, 0bdh, 099h, 081h, 081h, 07eh, 000h, 000h, 000h, 000h
   480 0001767D 81817E00000000      <1>
   481 00017684 00007EFFDBFFFFC3E7- <1>     db  000h, 000h, 07eh, 0ffh, 0dbh, 0ffh, 0ffh, 0c3h, 0e7h, 0ffh, 0ffh, 07eh, 000h, 000h, 000h, 000h
   481 0001768D FFFF7E00000000      <1>
   482 00017694 000000006CFEFEFEFE- <1>     db  000h, 000h, 000h, 000h, 06ch, 0feh, 0feh, 0feh, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h
   482 0001769D 7C381000000000      <1>
   483 000176A4 0000000010387CFE7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 07ch, 0feh, 07ch, 038h, 010h, 000h, 000h, 000h, 000h, 000h
   483 000176AD 38100000000000      <1>
   484 000176B4 000000183C3CE7E7E7- <1>     db  000h, 000h, 000h, 018h, 03ch, 03ch, 0e7h, 0e7h, 0e7h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   484 000176BD 18183C00000000      <1>
   485 000176C4 000000183C7EFFFF7E- <1>     db  000h, 000h, 000h, 018h, 03ch, 07eh, 0ffh, 0ffh, 07eh, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   485 000176CD 18183C00000000      <1>
   486 000176D4 000000000000183C3C- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 018h, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   486 000176DD 18000000000000      <1>
   487 000176E4 FFFFFFFFFFFFE7C3C3- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0e7h, 0c3h, 0c3h, 0e7h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   487 000176ED E7FFFFFFFFFFFF      <1>
   488 000176F4 00000000003C664242- <1>     db  000h, 000h, 000h, 000h, 000h, 03ch, 066h, 042h, 042h, 066h, 03ch, 000h, 000h, 000h, 000h, 000h
   488 000176FD 663C0000000000      <1>
   489 00017704 FFFFFFFFFFC399BDBD- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0c3h, 099h, 0bdh, 0bdh, 099h, 0c3h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   489 0001770D 99C3FFFFFFFFFF      <1>
   490 00017714 00001E0E1A3278CCCC- <1>     db  000h, 000h, 01eh, 00eh, 01ah, 032h, 078h, 0cch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
   490 0001771D CCCC7800000000      <1>
   491 00017724 00003C666666663C18- <1>     db  000h, 000h, 03ch, 066h, 066h, 066h, 066h, 03ch, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
   491 0001772D 7E181800000000      <1>
   492 00017734 00003F333F30303030- <1>     db  000h, 000h, 03fh, 033h, 03fh, 030h, 030h, 030h, 030h, 070h, 0f0h, 0e0h, 000h, 000h, 000h, 000h
   492 0001773D 70F0E000000000      <1>
   493 00017744 00007F637F63636363- <1>     db  000h, 000h, 07fh, 063h, 07fh, 063h, 063h, 063h, 063h, 067h, 0e7h, 0e6h, 0c0h, 000h, 000h, 000h
   493 0001774D 67E7E6C0000000      <1>
   494 00017754 0000001818DB3CE73C- <1>     db  000h, 000h, 000h, 018h, 018h, 0dbh, 03ch, 0e7h, 03ch, 0dbh, 018h, 018h, 000h, 000h, 000h, 000h
   494 0001775D DB181800000000      <1>
   495 00017764 0080C0E0F0F8FEF8F0- <1>     db  000h, 080h, 0c0h, 0e0h, 0f0h, 0f8h, 0feh, 0f8h, 0f0h, 0e0h, 0c0h, 080h, 000h, 000h, 000h, 000h
   495 0001776D E0C08000000000      <1>
   496 00017774 0002060E1E3EFE3E1E- <1>     db  000h, 002h, 006h, 00eh, 01eh, 03eh, 0feh, 03eh, 01eh, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
   496 0001777D 0E060200000000      <1>
   497 00017784 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h, 000h
   497 0001778D 3C180000000000      <1>
   498 00017794 000066666666666666- <1>     db  000h, 000h, 066h, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 066h, 066h, 000h, 000h, 000h, 000h
   498 0001779D 00666600000000      <1>
   499 000177A4 00007FDBDBDB7B1B1B- <1>     db  000h, 000h, 07fh, 0dbh, 0dbh, 0dbh, 07bh, 01bh, 01bh, 01bh, 01bh, 01bh, 000h, 000h, 000h, 000h
   499 000177AD 1B1B1B00000000      <1>
   500 000177B4 007CC660386CC6C66C- <1>     db  000h, 07ch, 0c6h, 060h, 038h, 06ch, 0c6h, 0c6h, 06ch, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h
   500 000177BD 380CC67C000000      <1>
   501 000177C4 0000000000000000FE- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0feh, 0feh, 0feh, 000h, 000h, 000h, 000h
   501 000177CD FEFEFE00000000      <1>
   502 000177D4 0000183C7E1818187E- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 07eh, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
   502 000177DD 3C187E00000000      <1>
   503 000177E4 0000183C7E18181818- <1>     db  000h, 000h, 018h, 03ch, 07eh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   503 000177ED 18181800000000      <1>
   504 000177F4 000018181818181818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 03ch, 018h, 000h, 000h, 000h, 000h
   504 000177FD 7E3C1800000000      <1>
   505 00017804 0000000000180CFE0C- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 00ch, 0feh, 00ch, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   505 0001780D 18000000000000      <1>
   506 00017814 00000000003060FE60- <1>     db  000h, 000h, 000h, 000h, 000h, 030h, 060h, 0feh, 060h, 030h, 000h, 000h, 000h, 000h, 000h, 000h
   506 0001781D 30000000000000      <1>
   507 00017824 000000000000C0C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0c0h, 0c0h, 0c0h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h
   507 0001782D FE000000000000      <1>
   508 00017834 00000000002466FF66- <1>     db  000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h
   508 0001783D 24000000000000      <1>
   509 00017844 000000001038387C7C- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 038h, 07ch, 07ch, 0feh, 0feh, 000h, 000h, 000h, 000h, 000h
   509 0001784D FEFE0000000000      <1>
   510 00017854 00000000FEFE7C7C38- <1>     db  000h, 000h, 000h, 000h, 0feh, 0feh, 07ch, 07ch, 038h, 038h, 010h, 000h, 000h, 000h, 000h, 000h
   510 0001785D 38100000000000      <1>
   511 00017864 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   511 0001786D 00000000000000      <1>
   512 00017874 0000183C3C3C181818- <1>     db  000h, 000h, 018h, 03ch, 03ch, 03ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   512 0001787D 00181800000000      <1>
   513 00017884 006666662400000000- <1>     db  000h, 066h, 066h, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   513 0001788D 00000000000000      <1>
   514 00017894 0000006C6CFE6C6C6C- <1>     db  000h, 000h, 000h, 06ch, 06ch, 0feh, 06ch, 06ch, 06ch, 0feh, 06ch, 06ch, 000h, 000h, 000h, 000h
   514 0001789D FE6C6C00000000      <1>
   515 000178A4 18187CC6C2C07C0606- <1>     db  018h, 018h, 07ch, 0c6h, 0c2h, 0c0h, 07ch, 006h, 006h, 086h, 0c6h, 07ch, 018h, 018h, 000h, 000h
   515 000178AD 86C67C18180000      <1>
   516 000178B4 00000000C2C60C1830- <1>     db  000h, 000h, 000h, 000h, 0c2h, 0c6h, 00ch, 018h, 030h, 060h, 0c6h, 086h, 000h, 000h, 000h, 000h
   516 000178BD 60C68600000000      <1>
   517 000178C4 0000386C6C3876DCCC- <1>     db  000h, 000h, 038h, 06ch, 06ch, 038h, 076h, 0dch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   517 000178CD CCCC7600000000      <1>
   518 000178D4 003030306000000000- <1>     db  000h, 030h, 030h, 030h, 060h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   518 000178DD 00000000000000      <1>
   519 000178E4 00000C183030303030- <1>     db  000h, 000h, 00ch, 018h, 030h, 030h, 030h, 030h, 030h, 030h, 018h, 00ch, 000h, 000h, 000h, 000h
   519 000178ED 30180C00000000      <1>
   520 000178F4 000030180C0C0C0C0C- <1>     db  000h, 000h, 030h, 018h, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 018h, 030h, 000h, 000h, 000h, 000h
   520 000178FD 0C183000000000      <1>
   521 00017904 0000000000663CFF3C- <1>     db  000h, 000h, 000h, 000h, 000h, 066h, 03ch, 0ffh, 03ch, 066h, 000h, 000h, 000h, 000h, 000h, 000h
   521 0001790D 66000000000000      <1>
   522 00017914 000000000018187E18- <1>     db  000h, 000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h
   522 0001791D 18000000000000      <1>
   523 00017924 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 018h, 030h, 000h, 000h, 000h
   523 0001792D 18181830000000      <1>
   524 00017934 00000000000000FE00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   524 0001793D 00000000000000      <1>
   525 00017944 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   525 0001794D 00181800000000      <1>
   526 00017954 0000000002060C1830- <1>     db  000h, 000h, 000h, 000h, 002h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 080h, 000h, 000h, 000h, 000h
   526 0001795D 60C08000000000      <1>
   527 00017964 00003C66C3C3DBDBC3- <1>     db  000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h, 000h, 000h
   527 0001796D C3663C00000000      <1>
   528 00017974 000018387818181818- <1>     db  000h, 000h, 018h, 038h, 078h, 018h, 018h, 018h, 018h, 018h, 018h, 07eh, 000h, 000h, 000h, 000h
   528 0001797D 18187E00000000      <1>
   529 00017984 00007CC6060C183060- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 00ch, 018h, 030h, 060h, 0c0h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   529 0001798D C0C6FE00000000      <1>
   530 00017994 00007CC606063C0606- <1>     db  000h, 000h, 07ch, 0c6h, 006h, 006h, 03ch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   530 0001799D 06C67C00000000      <1>
   531 000179A4 00000C1C3C6CCCFE0C- <1>     db  000h, 000h, 00ch, 01ch, 03ch, 06ch, 0cch, 0feh, 00ch, 00ch, 00ch, 01eh, 000h, 000h, 000h, 000h
   531 000179AD 0C0C1E00000000      <1>
   532 000179B4 0000FEC0C0C0FC0606- <1>     db  000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0fch, 006h, 006h, 006h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   532 000179BD 06C67C00000000      <1>
   533 000179C4 00003860C0C0FCC6C6- <1>     db  000h, 000h, 038h, 060h, 0c0h, 0c0h, 0fch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   533 000179CD C6C67C00000000      <1>
   534 000179D4 0000FEC606060C1830- <1>     db  000h, 000h, 0feh, 0c6h, 006h, 006h, 00ch, 018h, 030h, 030h, 030h, 030h, 000h, 000h, 000h, 000h
   534 000179DD 30303000000000      <1>
   535 000179E4 00007CC6C6C67CC6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   535 000179ED C6C67C00000000      <1>
   536 000179F4 00007CC6C6C67E0606- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 07eh, 006h, 006h, 006h, 00ch, 078h, 000h, 000h, 000h, 000h
   536 000179FD 060C7800000000      <1>
   537 00017A04 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   537 00017A0D 18180000000000      <1>
   538 00017A14 000000001818000000- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 018h, 018h, 030h, 000h, 000h, 000h, 000h
   538 00017A1D 18183000000000      <1>
   539 00017A24 000000060C18306030- <1>     db  000h, 000h, 000h, 006h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 006h, 000h, 000h, 000h, 000h
   539 00017A2D 180C0600000000      <1>
   540 00017A34 00000000007E00007E- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 000h, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   540 00017A3D 00000000000000      <1>
   541 00017A44 0000006030180C060C- <1>     db  000h, 000h, 000h, 060h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 060h, 000h, 000h, 000h, 000h
   541 00017A4D 18306000000000      <1>
   542 00017A54 00007CC6C60C181818- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 00ch, 018h, 018h, 018h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   542 00017A5D 00181800000000      <1>
   543 00017A64 0000007CC6C6DEDEDE- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0deh, 0deh, 0deh, 0dch, 0c0h, 07ch, 000h, 000h, 000h, 000h
   543 00017A6D DCC07C00000000      <1>
   544 00017A74 000010386CC6C6FEC6- <1>     db  000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   544 00017A7D C6C6C600000000      <1>
   545 00017A84 0000FC6666667C6666- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 066h, 066h, 066h, 066h, 0fch, 000h, 000h, 000h, 000h
   545 00017A8D 6666FC00000000      <1>
   546 00017A94 00003C66C2C0C0C0C0- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 000h, 000h, 000h, 000h
   546 00017A9D C2663C00000000      <1>
   547 00017AA4 0000F86C6666666666- <1>     db  000h, 000h, 0f8h, 06ch, 066h, 066h, 066h, 066h, 066h, 066h, 06ch, 0f8h, 000h, 000h, 000h, 000h
   547 00017AAD 666CF800000000      <1>
   548 00017AB4 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
   548 00017ABD 6266FE00000000      <1>
   549 00017AC4 0000FE666268786860- <1>     db  000h, 000h, 0feh, 066h, 062h, 068h, 078h, 068h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   549 00017ACD 6060F000000000      <1>
   550 00017AD4 00003C66C2C0C0DEC6- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0deh, 0c6h, 0c6h, 066h, 03ah, 000h, 000h, 000h, 000h
   550 00017ADD C6663A00000000      <1>
   551 00017AE4 0000C6C6C6C6FEC6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   551 00017AED C6C6C600000000      <1>
   552 00017AF4 00003C181818181818- <1>     db  000h, 000h, 03ch, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   552 00017AFD 18183C00000000      <1>
   553 00017B04 00001E0C0C0C0C0CCC- <1>     db  000h, 000h, 01eh, 00ch, 00ch, 00ch, 00ch, 00ch, 0cch, 0cch, 0cch, 078h, 000h, 000h, 000h, 000h
   553 00017B0D CCCC7800000000      <1>
   554 00017B14 0000E666666C78786C- <1>     db  000h, 000h, 0e6h, 066h, 066h, 06ch, 078h, 078h, 06ch, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   554 00017B1D 6666E600000000      <1>
   555 00017B24 0000F0606060606060- <1>     db  000h, 000h, 0f0h, 060h, 060h, 060h, 060h, 060h, 060h, 062h, 066h, 0feh, 000h, 000h, 000h, 000h
   555 00017B2D 6266FE00000000      <1>
   556 00017B34 0000C3E7FFFFDBC3C3- <1>     db  000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
   556 00017B3D C3C3C300000000      <1>
   557 00017B44 0000C6E6F6FEDECEC6- <1>     db  000h, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   557 00017B4D C6C6C600000000      <1>
   558 00017B54 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   558 00017B5D C6C67C00000000      <1>
   559 00017B64 0000FC6666667C6060- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   559 00017B6D 6060F000000000      <1>
   560 00017B74 00007CC6C6C6C6C6C6- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0d6h, 0deh, 07ch, 00ch, 00eh, 000h, 000h
   560 00017B7D D6DE7C0C0E0000      <1>
   561 00017B84 0000FC6666667C6C66- <1>     db  000h, 000h, 0fch, 066h, 066h, 066h, 07ch, 06ch, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   561 00017B8D 6666E600000000      <1>
   562 00017B94 00007CC6C660380C06- <1>     db  000h, 000h, 07ch, 0c6h, 0c6h, 060h, 038h, 00ch, 006h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   562 00017B9D C6C67C00000000      <1>
   563 00017BA4 0000FFDB9918181818- <1>     db  000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   563 00017BAD 18183C00000000      <1>
   564 00017BB4 0000C6C6C6C6C6C6C6- <1>     db  000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   564 00017BBD C6C67C00000000      <1>
   565 00017BC4 0000C3C3C3C3C3C3C3- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
   565 00017BCD 663C1800000000      <1>
   566 00017BD4 0000C3C3C3C3C3DBDB- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 000h
   566 00017BDD FF666600000000      <1>
   567 00017BE4 0000C3C3663C18183C- <1>     db  000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h
   567 00017BED 66C3C300000000      <1>
   568 00017BF4 0000C3C3C3663C1818- <1>     db  000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   568 00017BFD 18183C00000000      <1>
   569 00017C04 0000FFC3860C183060- <1>     db  000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h
   569 00017C0D C1C3FF00000000      <1>
   570 00017C14 00003C303030303030- <1>     db  000h, 000h, 03ch, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 030h, 03ch, 000h, 000h, 000h, 000h
   570 00017C1D 30303C00000000      <1>
   571 00017C24 00000080C0E070381C- <1>     db  000h, 000h, 000h, 080h, 0c0h, 0e0h, 070h, 038h, 01ch, 00eh, 006h, 002h, 000h, 000h, 000h, 000h
   571 00017C2D 0E060200000000      <1>
   572 00017C34 00003C0C0C0C0C0C0C- <1>     db  000h, 000h, 03ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 00ch, 03ch, 000h, 000h, 000h, 000h
   572 00017C3D 0C0C3C00000000      <1>
   573 00017C44 10386CC60000000000- <1>     db  010h, 038h, 06ch, 0c6h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   573 00017C4D 00000000000000      <1>
   574 00017C54 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h
   574 00017C5D 00000000FF0000      <1>
   575 00017C64 303018000000000000- <1>     db  030h, 030h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   575 00017C6D 00000000000000      <1>
   576 00017C74 0000000000780C7CCC- <1>     db  000h, 000h, 000h, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   576 00017C7D CCCC7600000000      <1>
   577 00017C84 0000E06060786C6666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 078h, 06ch, 066h, 066h, 066h, 066h, 07ch, 000h, 000h, 000h, 000h
   577 00017C8D 66667C00000000      <1>
   578 00017C94 00000000007CC6C0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c0h, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   578 00017C9D C0C67C00000000      <1>
   579 00017CA4 00001C0C0C3C6CCCCC- <1>     db  000h, 000h, 01ch, 00ch, 00ch, 03ch, 06ch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   579 00017CAD CCCC7600000000      <1>
   580 00017CB4 00000000007CC6FEC0- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   580 00017CBD C0C67C00000000      <1>
   581 00017CC4 0000386C6460F06060- <1>     db  000h, 000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   581 00017CCD 6060F000000000      <1>
   582 00017CD4 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 0cch, 078h, 000h
   582 00017CDD CCCC7C0CCC7800      <1>
   583 00017CE4 0000E060606C766666- <1>     db  000h, 000h, 0e0h, 060h, 060h, 06ch, 076h, 066h, 066h, 066h, 066h, 0e6h, 000h, 000h, 000h, 000h
   583 00017CED 6666E600000000      <1>
   584 00017CF4 000018180038181818- <1>     db  000h, 000h, 018h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   584 00017CFD 18183C00000000      <1>
   585 00017D04 00000606000E060606- <1>     db  000h, 000h, 006h, 006h, 000h, 00eh, 006h, 006h, 006h, 006h, 006h, 006h, 066h, 066h, 03ch, 000h
   585 00017D0D 06060666663C00      <1>
   586 00017D14 0000E06060666C7878- <1>     db  000h, 000h, 0e0h, 060h, 060h, 066h, 06ch, 078h, 078h, 06ch, 066h, 0e6h, 000h, 000h, 000h, 000h
   586 00017D1D 6C66E600000000      <1>
   587 00017D24 000038181818181818- <1>     db  000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   587 00017D2D 18183C00000000      <1>
   588 00017D34 0000000000E6FFDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h
   588 00017D3D DBDBDB00000000      <1>
   589 00017D44 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
   589 00017D4D 66666600000000      <1>
   590 00017D54 00000000007CC6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   590 00017D5D C6C67C00000000      <1>
   591 00017D64 0000000000DC666666- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0f0h, 000h
   591 00017D6D 66667C6060F000      <1>
   592 00017D74 000000000076CCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0cch, 0cch, 0cch, 0cch, 0cch, 07ch, 00ch, 00ch, 01eh, 000h
   592 00017D7D CCCC7C0C0C1E00      <1>
   593 00017D84 0000000000DC766660- <1>     db  000h, 000h, 000h, 000h, 000h, 0dch, 076h, 066h, 060h, 060h, 060h, 0f0h, 000h, 000h, 000h, 000h
   593 00017D8D 6060F000000000      <1>
   594 00017D94 00000000007CC66038- <1>     db  000h, 000h, 000h, 000h, 000h, 07ch, 0c6h, 060h, 038h, 00ch, 0c6h, 07ch, 000h, 000h, 000h, 000h
   594 00017D9D 0CC67C00000000      <1>
   595 00017DA4 0000103030FC303030- <1>     db  000h, 000h, 010h, 030h, 030h, 0fch, 030h, 030h, 030h, 030h, 036h, 01ch, 000h, 000h, 000h, 000h
   595 00017DAD 30361C00000000      <1>
   596 00017DB4 0000000000CCCCCCCC- <1>     db  000h, 000h, 000h, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   596 00017DBD CCCC7600000000      <1>
   597 00017DC4 0000000000C3C3C3C3- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h
   597 00017DCD 663C1800000000      <1>
   598 00017DD4 0000000000C3C3C3DB- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h
   598 00017DDD DBFF6600000000      <1>
   599 00017DE4 0000000000C3663C18- <1>     db  000h, 000h, 000h, 000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h
   599 00017DED 3C66C300000000      <1>
   600 00017DF4 0000000000C6C6C6C6- <1>     db  000h, 000h, 000h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 0f8h, 000h
   600 00017DFD C6C67E060CF800      <1>
   601 00017E04 0000000000FECC1830- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 0cch, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   601 00017E0D 60C6FE00000000      <1>
   602 00017E14 00000E181818701818- <1>     db  000h, 000h, 00eh, 018h, 018h, 018h, 070h, 018h, 018h, 018h, 018h, 00eh, 000h, 000h, 000h, 000h
   602 00017E1D 18180E00000000      <1>
   603 00017E24 000018181818001818- <1>     db  000h, 000h, 018h, 018h, 018h, 018h, 000h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   603 00017E2D 18181800000000      <1>
   604 00017E34 0000701818180E1818- <1>     db  000h, 000h, 070h, 018h, 018h, 018h, 00eh, 018h, 018h, 018h, 018h, 070h, 000h, 000h, 000h, 000h
   604 00017E3D 18187000000000      <1>
   605 00017E44 000076DC0000000000- <1>     db  000h, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   605 00017E4D 00000000000000      <1>
   606 00017E54 0000000010386CC6C6- <1>     db  000h, 000h, 000h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 0feh, 000h, 000h, 000h, 000h, 000h
   606 00017E5D C6FE0000000000      <1>
   607 00017E64 00003C66C2C0C0C0C2- <1>     db  000h, 000h, 03ch, 066h, 0c2h, 0c0h, 0c0h, 0c0h, 0c2h, 066h, 03ch, 00ch, 006h, 07ch, 000h, 000h
   607 00017E6D 663C0C067C0000      <1>
   608 00017E74 0000CC0000CCCCCCCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   608 00017E7D CCCC7600000000      <1>
   609 00017E84 000C1830007CC6FEC0- <1>     db  000h, 00ch, 018h, 030h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   609 00017E8D C0C67C00000000      <1>
   610 00017E94 0010386C00780C7CCC- <1>     db  000h, 010h, 038h, 06ch, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   610 00017E9D CCCC7600000000      <1>
   611 00017EA4 0000CC0000780C7CCC- <1>     db  000h, 000h, 0cch, 000h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   611 00017EAD CCCC7600000000      <1>
   612 00017EB4 0060301800780C7CCC- <1>     db  000h, 060h, 030h, 018h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   612 00017EBD CCCC7600000000      <1>
   613 00017EC4 00386C3800780C7CCC- <1>     db  000h, 038h, 06ch, 038h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   613 00017ECD CCCC7600000000      <1>
   614 00017ED4 000000003C66606066- <1>     db  000h, 000h, 000h, 000h, 03ch, 066h, 060h, 060h, 066h, 03ch, 00ch, 006h, 03ch, 000h, 000h, 000h
   614 00017EDD 3C0C063C000000      <1>
   615 00017EE4 0010386C007CC6FEC0- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   615 00017EED C0C67C00000000      <1>
   616 00017EF4 0000C600007CC6FEC0- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   616 00017EFD C0C67C00000000      <1>
   617 00017F04 00603018007CC6FEC0- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0feh, 0c0h, 0c0h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   617 00017F0D C0C67C00000000      <1>
   618 00017F14 000066000038181818- <1>     db  000h, 000h, 066h, 000h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   618 00017F1D 18183C00000000      <1>
   619 00017F24 00183C660038181818- <1>     db  000h, 018h, 03ch, 066h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   619 00017F2D 18183C00000000      <1>
   620 00017F34 006030180038181818- <1>     db  000h, 060h, 030h, 018h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   620 00017F3D 18183C00000000      <1>
   621 00017F44 00C60010386CC6C6FE- <1>     db  000h, 0c6h, 000h, 010h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   621 00017F4D C6C6C600000000      <1>
   622 00017F54 386C3800386CC6C6FE- <1>     db  038h, 06ch, 038h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   622 00017F5D C6C6C600000000      <1>
   623 00017F64 18306000FE66607C60- <1>     db  018h, 030h, 060h, 000h, 0feh, 066h, 060h, 07ch, 060h, 060h, 066h, 0feh, 000h, 000h, 000h, 000h
   623 00017F6D 6066FE00000000      <1>
   624 00017F74 00000000006E3B1B7E- <1>     db  000h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h
   624 00017F7D D8DC7700000000      <1>
   625 00017F84 00003E6CCCCCFECCCC- <1>     db  000h, 000h, 03eh, 06ch, 0cch, 0cch, 0feh, 0cch, 0cch, 0cch, 0cch, 0ceh, 000h, 000h, 000h, 000h
   625 00017F8D CCCCCE00000000      <1>
   626 00017F94 0010386C007CC6C6C6- <1>     db  000h, 010h, 038h, 06ch, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   626 00017F9D C6C67C00000000      <1>
   627 00017FA4 0000C600007CC6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   627 00017FAD C6C67C00000000      <1>
   628 00017FB4 00603018007CC6C6C6- <1>     db  000h, 060h, 030h, 018h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   628 00017FBD C6C67C00000000      <1>
   629 00017FC4 003078CC00CCCCCCCC- <1>     db  000h, 030h, 078h, 0cch, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   629 00017FCD CCCC7600000000      <1>
   630 00017FD4 0060301800CCCCCCCC- <1>     db  000h, 060h, 030h, 018h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   630 00017FDD CCCC7600000000      <1>
   631 00017FE4 0000C60000C6C6C6C6- <1>     db  000h, 000h, 0c6h, 000h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07eh, 006h, 00ch, 078h, 000h
   631 00017FED C6C67E060C7800      <1>
   632 00017FF4 00C6007CC6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   632 00017FFD C6C67C00000000      <1>
   633 00018004 00C600C6C6C6C6C6C6- <1>     db  000h, 0c6h, 000h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   633 0001800D C6C67C00000000      <1>
   634 00018014 0018187EC3C0C0C0C3- <1>     db  000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h
   634 0001801D 7E181800000000      <1>
   635 00018024 00386C6460F0606060- <1>     db  000h, 038h, 06ch, 064h, 060h, 0f0h, 060h, 060h, 060h, 060h, 0e6h, 0fch, 000h, 000h, 000h, 000h
   635 0001802D 60E6FC00000000      <1>
   636 00018034 0000C3663C18FF18FF- <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   636 0001803D 18181800000000      <1>
   637 00018044 00FC66667C62666F66- <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h, 000h
   637 0001804D 6666F300000000      <1>
   638 00018054 000E1B1818187E1818- <1>     db  000h, 00eh, 01bh, 018h, 018h, 018h, 07eh, 018h, 018h, 018h, 018h, 018h, 0d8h, 070h, 000h, 000h
   638 0001805D 181818D8700000      <1>
   639 00018064 0018306000780C7CCC- <1>     db  000h, 018h, 030h, 060h, 000h, 078h, 00ch, 07ch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   639 0001806D CCCC7600000000      <1>
   640 00018074 000C18300038181818- <1>     db  000h, 00ch, 018h, 030h, 000h, 038h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h
   640 0001807D 18183C00000000      <1>
   641 00018084 00183060007CC6C6C6- <1>     db  000h, 018h, 030h, 060h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   641 0001808D C6C67C00000000      <1>
   642 00018094 0018306000CCCCCCCC- <1>     db  000h, 018h, 030h, 060h, 000h, 0cch, 0cch, 0cch, 0cch, 0cch, 0cch, 076h, 000h, 000h, 000h, 000h
   642 0001809D CCCC7600000000      <1>
   643 000180A4 000076DC00DC666666- <1>     db  000h, 000h, 076h, 0dch, 000h, 0dch, 066h, 066h, 066h, 066h, 066h, 066h, 000h, 000h, 000h, 000h
   643 000180AD 66666600000000      <1>
   644 000180B4 76DC00C6E6F6FEDECE- <1>     db  076h, 0dch, 000h, 0c6h, 0e6h, 0f6h, 0feh, 0deh, 0ceh, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   644 000180BD C6C6C600000000      <1>
   645 000180C4 003C6C6C3E007E0000- <1>     db  000h, 03ch, 06ch, 06ch, 03eh, 000h, 07eh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   645 000180CD 00000000000000      <1>
   646 000180D4 00386C6C38007C0000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 07ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   646 000180DD 00000000000000      <1>
   647 000180E4 0000303000303060C0- <1>     db  000h, 000h, 030h, 030h, 000h, 030h, 030h, 060h, 0c0h, 0c6h, 0c6h, 07ch, 000h, 000h, 000h, 000h
   647 000180ED C6C67C00000000      <1>
   648 000180F4 000000000000FEC0C0- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h, 000h
   648 000180FD C0C00000000000      <1>
   649 00018104 000000000000FE0606- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 0feh, 006h, 006h, 006h, 006h, 000h, 000h, 000h, 000h, 000h
   649 0001810D 06060000000000      <1>
   650 00018114 00C0C0C2C6CC183060- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh, 000h, 000h
   650 0001811D CE9B060C1F0000      <1>
   651 00018124 00C0C0C2C6CC183066- <1>     db  000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h, 006h, 000h, 000h
   651 0001812D CE963E06060000      <1>
   652 00018134 00001818001818183C- <1>     db  000h, 000h, 018h, 018h, 000h, 018h, 018h, 018h, 03ch, 03ch, 03ch, 018h, 000h, 000h, 000h, 000h
   652 0001813D 3C3C1800000000      <1>
   653 00018144 0000000000366CD86C- <1>     db  000h, 000h, 000h, 000h, 000h, 036h, 06ch, 0d8h, 06ch, 036h, 000h, 000h, 000h, 000h, 000h, 000h
   653 0001814D 36000000000000      <1>
   654 00018154 0000000000D86C366C- <1>     db  000h, 000h, 000h, 000h, 000h, 0d8h, 06ch, 036h, 06ch, 0d8h, 000h, 000h, 000h, 000h, 000h, 000h
   654 0001815D D8000000000000      <1>
   655 00018164 114411441144114411- <1>     db  011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h, 011h, 044h
   655 0001816D 44114411441144      <1>
   656 00018174 55AA55AA55AA55AA55- <1>     db  055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah, 055h, 0aah
   656 0001817D AA55AA55AA55AA      <1>
   657 00018184 DD77DD77DD77DD77DD- <1>     db  0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h, 0ddh, 077h
   657 0001818D 77DD77DD77DD77      <1>
   658 00018194 181818181818181818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   658 0001819D 18181818181818      <1>
   659 000181A4 18181818181818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   659 000181AD 18181818181818      <1>
   660 000181B4 1818181818F818F818- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   660 000181BD 18181818181818      <1>
   661 000181C4 36363636363636F636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   661 000181CD 36363636363636      <1>
   662 000181D4 00000000000000FE36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0feh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   662 000181DD 36363636363636      <1>
   663 000181E4 0000000000F818F818- <1>     db  000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   663 000181ED 18181818181818      <1>
   664 000181F4 3636363636F606F636- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   664 000181FD 36363636363636      <1>
   665 00018204 363636363636363636- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   665 0001820D 36363636363636      <1>
   666 00018214 0000000000FE06F636- <1>     db  000h, 000h, 000h, 000h, 000h, 0feh, 006h, 0f6h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   666 0001821D 36363636363636      <1>
   667 00018224 3636363636F606FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f6h, 006h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   667 0001822D 00000000000000      <1>
   668 00018234 36363636363636FE00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0feh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   668 0001823D 00000000000000      <1>
   669 00018244 1818181818F818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 0f8h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   669 0001824D 00000000000000      <1>
   670 00018254 00000000000000F818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0f8h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   670 0001825D 18181818181818      <1>
   671 00018264 181818181818181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   671 0001826D 00000000000000      <1>
   672 00018274 18181818181818FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   672 0001827D 00000000000000      <1>
   673 00018284 00000000000000FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   673 0001828D 18181818181818      <1>
   674 00018294 181818181818181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   674 0001829D 18181818181818      <1>
   675 000182A4 00000000000000FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   675 000182AD 00000000000000      <1>
   676 000182B4 18181818181818FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   676 000182BD 18181818181818      <1>
   677 000182C4 18181818181F181F18- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   677 000182CD 18181818181818      <1>
   678 000182D4 363636363636363736- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   678 000182DD 36363636363636      <1>
   679 000182E4 363636363637303F00- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   679 000182ED 00000000000000      <1>
   680 000182F4 00000000003F303736- <1>     db  000h, 000h, 000h, 000h, 000h, 03fh, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   680 000182FD 36363636363636      <1>
   681 00018304 3636363636F700FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   681 0001830D 00000000000000      <1>
   682 00018314 0000000000FF00F736- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   682 0001831D 36363636363636      <1>
   683 00018324 363636363637303736- <1>     db  036h, 036h, 036h, 036h, 036h, 037h, 030h, 037h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   683 0001832D 36363636363636      <1>
   684 00018334 0000000000FF00FF00- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   684 0001833D 00000000000000      <1>
   685 00018344 3636363636F700F736- <1>     db  036h, 036h, 036h, 036h, 036h, 0f7h, 000h, 0f7h, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   685 0001834D 36363636363636      <1>
   686 00018354 1818181818FF00FF00- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   686 0001835D 00000000000000      <1>
   687 00018364 36363636363636FF00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   687 0001836D 00000000000000      <1>
   688 00018374 0000000000FF00FF18- <1>     db  000h, 000h, 000h, 000h, 000h, 0ffh, 000h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   688 0001837D 18181818181818      <1>
   689 00018384 00000000000000FF36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   689 0001838D 36363636363636      <1>
   690 00018394 363636363636363F00- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 03fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   690 0001839D 00000000000000      <1>
   691 000183A4 18181818181F181F00- <1>     db  018h, 018h, 018h, 018h, 018h, 01fh, 018h, 01fh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   691 000183AD 00000000000000      <1>
   692 000183B4 00000000001F181F18- <1>     db  000h, 000h, 000h, 000h, 000h, 01fh, 018h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   692 000183BD 18181818181818      <1>
   693 000183C4 000000000000003F36- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 03fh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   693 000183CD 36363636363636      <1>
   694 000183D4 36363636363636FF36- <1>     db  036h, 036h, 036h, 036h, 036h, 036h, 036h, 0ffh, 036h, 036h, 036h, 036h, 036h, 036h, 036h, 036h
   694 000183DD 36363636363636      <1>
   695 000183E4 1818181818FF18FF18- <1>     db  018h, 018h, 018h, 018h, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   695 000183ED 18181818181818      <1>
   696 000183F4 18181818181818F800- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   696 000183FD 00000000000000      <1>
   697 00018404 000000000000001F18- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 01fh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   697 0001840D 18181818181818      <1>
   698 00018414 FFFFFFFFFFFFFFFFFF- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   698 0001841D FFFFFFFFFFFFFF      <1>
   699 00018424 00000000000000FFFF- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh
   699 0001842D FFFFFFFFFFFFFF      <1>
   700 00018434 F0F0F0F0F0F0F0F0F0- <1>     db  0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h, 0f0h
   700 0001843D F0F0F0F0F0F0F0      <1>
   701 00018444 0F0F0F0F0F0F0F0F0F- <1>     db  00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh, 00fh
   701 0001844D 0F0F0F0F0F0F0F      <1>
   702 00018454 FFFFFFFFFFFFFF0000- <1>     db  0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   702 0001845D 00000000000000      <1>
   703 00018464 000000000076DCD8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 0d8h, 0d8h, 0d8h, 0dch, 076h, 000h, 000h, 000h, 000h
   703 0001846D D8DC7600000000      <1>
   704 00018474 000078CCCCCCD8CCC6- <1>     db  000h, 000h, 078h, 0cch, 0cch, 0cch, 0d8h, 0cch, 0c6h, 0c6h, 0c6h, 0cch, 000h, 000h, 000h, 000h
   704 0001847D C6C6CC00000000      <1>
   705 00018484 0000FEC6C6C0C0C0C0- <1>     db  000h, 000h, 0feh, 0c6h, 0c6h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 0c0h, 000h, 000h, 000h, 000h
   705 0001848D C0C0C000000000      <1>
   706 00018494 00000000FE6C6C6C6C- <1>     db  000h, 000h, 000h, 000h, 0feh, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h
   706 0001849D 6C6C6C00000000      <1>
   707 000184A4 000000FEC660301830- <1>     db  000h, 000h, 000h, 0feh, 0c6h, 060h, 030h, 018h, 030h, 060h, 0c6h, 0feh, 000h, 000h, 000h, 000h
   707 000184AD 60C6FE00000000      <1>
   708 000184B4 00000000007ED8D8D8- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0d8h, 0d8h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
   708 000184BD D8D87000000000      <1>
   709 000184C4 000000006666666666- <1>     db  000h, 000h, 000h, 000h, 066h, 066h, 066h, 066h, 066h, 07ch, 060h, 060h, 0c0h, 000h, 000h, 000h
   709 000184CD 7C6060C0000000      <1>
   710 000184D4 0000000076DC181818- <1>     db  000h, 000h, 000h, 000h, 076h, 0dch, 018h, 018h, 018h, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   710 000184DD 18181800000000      <1>
   711 000184E4 0000007E183C666666- <1>     db  000h, 000h, 000h, 07eh, 018h, 03ch, 066h, 066h, 066h, 03ch, 018h, 07eh, 000h, 000h, 000h, 000h
   711 000184ED 3C187E00000000      <1>
   712 000184F4 000000386CC6C6FEC6- <1>     db  000h, 000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0feh, 0c6h, 0c6h, 06ch, 038h, 000h, 000h, 000h, 000h
   712 000184FD C66C3800000000      <1>
   713 00018504 0000386CC6C6C66C6C- <1>     db  000h, 000h, 038h, 06ch, 0c6h, 0c6h, 0c6h, 06ch, 06ch, 06ch, 06ch, 0eeh, 000h, 000h, 000h, 000h
   713 0001850D 6C6CEE00000000      <1>
   714 00018514 00001E30180C3E6666- <1>     db  000h, 000h, 01eh, 030h, 018h, 00ch, 03eh, 066h, 066h, 066h, 066h, 03ch, 000h, 000h, 000h, 000h
   714 0001851D 66663C00000000      <1>
   715 00018524 00000000007EDBDBDB- <1>     db  000h, 000h, 000h, 000h, 000h, 07eh, 0dbh, 0dbh, 0dbh, 07eh, 000h, 000h, 000h, 000h, 000h, 000h
   715 0001852D 7E000000000000      <1>
   716 00018534 00000003067EDBDBF3- <1>     db  000h, 000h, 000h, 003h, 006h, 07eh, 0dbh, 0dbh, 0f3h, 07eh, 060h, 0c0h, 000h, 000h, 000h, 000h
   716 0001853D 7E60C000000000      <1>
   717 00018544 00001C3060607C6060- <1>     db  000h, 000h, 01ch, 030h, 060h, 060h, 07ch, 060h, 060h, 060h, 030h, 01ch, 000h, 000h, 000h, 000h
   717 0001854D 60301C00000000      <1>
   718 00018554 0000007CC6C6C6C6C6- <1>     db  000h, 000h, 000h, 07ch, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 0c6h, 000h, 000h, 000h, 000h
   718 0001855D C6C6C600000000      <1>
   719 00018564 00000000FE0000FE00- <1>     db  000h, 000h, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 0feh, 000h, 000h, 000h, 000h, 000h
   719 0001856D 00FE0000000000      <1>
   720 00018574 0000000018187E1818- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 07eh, 018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h
   720 0001857D 0000FF00000000      <1>
   721 00018584 00000030180C060C18- <1>     db  000h, 000h, 000h, 030h, 018h, 00ch, 006h, 00ch, 018h, 030h, 000h, 07eh, 000h, 000h, 000h, 000h
   721 0001858D 30007E00000000      <1>
   722 00018594 0000000C1830603018- <1>     db  000h, 000h, 000h, 00ch, 018h, 030h, 060h, 030h, 018h, 00ch, 000h, 07eh, 000h, 000h, 000h, 000h
   722 0001859D 0C007E00000000      <1>
   723 000185A4 00000E1B1B18181818- <1>     db  000h, 000h, 00eh, 01bh, 01bh, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h
   723 000185AD 18181818181818      <1>
   724 000185B4 1818181818181818D8- <1>     db  018h, 018h, 018h, 018h, 018h, 018h, 018h, 018h, 0d8h, 0d8h, 0d8h, 070h, 000h, 000h, 000h, 000h
   724 000185BD D8D87000000000      <1>
   725 000185C4 000000001818007E00- <1>     db  000h, 000h, 000h, 000h, 018h, 018h, 000h, 07eh, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h
   725 000185CD 18180000000000      <1>
   726 000185D4 000000000076DC0076- <1>     db  000h, 000h, 000h, 000h, 000h, 076h, 0dch, 000h, 076h, 0dch, 000h, 000h, 000h, 000h, 000h, 000h
   726 000185DD DC000000000000      <1>
   727 000185E4 00386C6C3800000000- <1>     db  000h, 038h, 06ch, 06ch, 038h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   727 000185ED 00000000000000      <1>
   728 000185F4 000000000000001818- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   728 000185FD 00000000000000      <1>
   729 00018604 000000000000000018- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 018h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   729 0001860D 00000000000000      <1>
   730 00018614 000F0C0C0C0C0CEC6C- <1>     db  000h, 00fh, 00ch, 00ch, 00ch, 00ch, 00ch, 0ech, 06ch, 06ch, 03ch, 01ch, 000h, 000h, 000h, 000h
   730 0001861D 6C3C1C00000000      <1>
   731 00018624 00D86C6C6C6C6C0000- <1>     db  000h, 0d8h, 06ch, 06ch, 06ch, 06ch, 06ch, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   731 0001862D 00000000000000      <1>
   732 00018634 0070D83060C8F80000- <1>     db  000h, 070h, 0d8h, 030h, 060h, 0c8h, 0f8h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   732 0001863D 00000000000000      <1>
   733 00018644 000000007C7C7C7C7C- <1>     db  000h, 000h, 000h, 000h, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 07ch, 000h, 000h, 000h, 000h, 000h
   733 0001864D 7C7C0000000000      <1>
   734 00018654 000000000000000000- <1>     db  000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h
   734 0001865D 00000000000000      <1>
   735                              <1> 
   736                              <1> ; 01/01/2021 (TRDOS 386 v2.0.3)
   737                              <1> 
   738                              <1> %if 0
   739                              <1> 
   740                              <1> vgafont14alt:
   741                              <1>     db  01dh, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h, 022h
   742                              <1>     db  000h, 063h, 063h, 063h, 022h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 02bh, 000h
   743                              <1>     db  000h, 000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h, 02dh, 000h, 000h
   744                              <1>     db  000h, 000h, 000h, 000h, 0ffh, 000h, 000h, 000h, 000h, 000h, 000h, 000h, 04dh, 000h, 000h, 0c3h
   745                              <1>     db  0e7h, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh
   746                              <1>     db  099h, 018h, 018h, 018h, 018h, 018h, 03ch, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h
   747                              <1>     db  0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h
   748                              <1>     db  0dbh, 0dbh, 0ffh, 066h, 066h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h
   749                              <1>     db  03ch, 066h, 0c3h, 0c3h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   750                              <1>     db  018h, 018h, 03ch, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h, 030h, 061h
   751                              <1>     db  0c3h, 0ffh, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h, 0ffh, 0dbh, 0dbh, 0dbh
   752                              <1>     db  0dbh, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   753                              <1>     db  000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h, 000h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h
   754                              <1>     db  000h, 000h, 091h, 000h, 000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h
   755                              <1>     db  000h, 09bh, 000h, 018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h
   756                              <1>     db  09dh, 000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 000h, 000h, 000h, 09eh
   757                              <1>     db  000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 0f3h, 000h, 000h, 000h, 0f1h, 000h
   758                              <1>     db  000h, 018h, 018h, 018h, 0ffh, 018h, 018h, 018h, 000h, 0ffh, 000h, 000h, 000h, 0f6h, 000h, 000h
   759                              <1>     db  018h, 018h, 000h, 000h, 0ffh, 000h, 000h, 018h, 018h, 000h, 000h, 000h, 000h
   760                              <1> vgafont16alt:
   761                              <1>     db  01dh, 000h, 000h, 000h, 000h, 000h, 024h, 066h, 0ffh, 066h, 024h, 000h, 000h, 000h, 000h, 000h
   762                              <1>     db  000h, 030h, 000h, 000h, 03ch, 066h, 0c3h, 0c3h, 0dbh, 0dbh, 0c3h, 0c3h, 066h, 03ch, 000h, 000h
   763                              <1>     db  000h, 000h, 04dh, 000h, 000h, 0c3h, 0e7h, 0ffh, 0ffh, 0dbh, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 000h
   764                              <1>     db  000h, 000h, 000h, 054h, 000h, 000h, 0ffh, 0dbh, 099h, 018h, 018h, 018h, 018h, 018h, 018h, 03ch
   765                              <1>     db  000h, 000h, 000h, 000h, 056h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch
   766                              <1>     db  018h, 000h, 000h, 000h, 000h, 057h, 000h, 000h, 0c3h, 0c3h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh
   767                              <1>     db  066h, 066h, 000h, 000h, 000h, 000h, 058h, 000h, 000h, 0c3h, 0c3h, 066h, 03ch, 018h, 018h, 03ch
   768                              <1>     db  066h, 0c3h, 0c3h, 000h, 000h, 000h, 000h, 059h, 000h, 000h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h
   769                              <1>     db  018h, 018h, 018h, 03ch, 000h, 000h, 000h, 000h, 05ah, 000h, 000h, 0ffh, 0c3h, 086h, 00ch, 018h
   770                              <1>     db  030h, 060h, 0c1h, 0c3h, 0ffh, 000h, 000h, 000h, 000h, 06dh, 000h, 000h, 000h, 000h, 000h, 0e6h
   771                              <1>     db  0ffh, 0dbh, 0dbh, 0dbh, 0dbh, 0dbh, 000h, 000h, 000h, 000h, 076h, 000h, 000h, 000h, 000h, 000h
   772                              <1>     db  0c3h, 0c3h, 0c3h, 0c3h, 066h, 03ch, 018h, 000h, 000h, 000h, 000h, 077h, 000h, 000h, 000h, 000h
   773                              <1>     db  000h, 0c3h, 0c3h, 0c3h, 0dbh, 0dbh, 0ffh, 066h, 000h, 000h, 000h, 000h, 078h, 000h, 000h, 000h
   774                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 03ch, 066h, 0c3h, 000h, 000h, 000h, 000h, 091h, 000h, 000h
   775                              <1>     db  000h, 000h, 000h, 06eh, 03bh, 01bh, 07eh, 0d8h, 0dch, 077h, 000h, 000h, 000h, 000h, 09bh, 000h
   776                              <1>     db  018h, 018h, 07eh, 0c3h, 0c0h, 0c0h, 0c0h, 0c3h, 07eh, 018h, 018h, 000h, 000h, 000h, 000h, 09dh
   777                              <1>     db  000h, 000h, 0c3h, 066h, 03ch, 018h, 0ffh, 018h, 0ffh, 018h, 018h, 018h, 000h, 000h, 000h, 000h
   778                              <1>     db  09eh, 000h, 0fch, 066h, 066h, 07ch, 062h, 066h, 06fh, 066h, 066h, 066h, 0f3h, 000h, 000h, 000h
   779                              <1>     db  000h, 0abh, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 060h, 0ceh, 09bh, 006h, 00ch, 01fh
   780                              <1>     db  000h, 000h, 0ach, 000h, 0c0h, 0c0h, 0c2h, 0c6h, 0cch, 018h, 030h, 066h, 0ceh, 096h, 03eh, 006h
   781                              <1>     db  006h, 000h, 000h, 000h
   782                              <1> 
   783                              <1> %endif
  3429                                  
  3430                                  ; 20/11/2020
  3431                                  vbe2_bochs_vbios:
  3432                                  ;	db "BOCHS/QEMU"
  3433 00018664 424F4348532F51454D-     	db "BOCHS/QEMU/VIRTUALBOX"  ; 26/11/2020
  3433 0001866D 552F5649525455414C-
  3433 00018676 424F58             
  3434                                  ;vbe_vnumber equ vbe2_bochs_vbios + 28 ; "3" or "2"
  3435                                  ; 26/11/2020
  3436                                  vbe_vnumber equ vbe2_bochs_vbios + 30 ; "3" or "2"
  3437                                  ; 15/11/2020
  3438                                  vesa_vbe3_bios_msg:
  3439                                  	;db " VESA VBE version 3 Video BIOS ..."
  3440 00018679 205645534120564245-     	db " VESA VBE3 Video BIOS ..." ; 26/11/2020
  3440 00018682 3320566964656F2042-
  3440 0001868B 494F53202E2E2E     
  3441 00018692 0D0A0D0A00              	db 0Dh, 0Ah, 0Dh, 0Ah, 0
  3442                                  
  3443 00018697 90                      align 2
  3444                                  
  3445                                  ; EPOCH Variables
  3446                                  ; 13/04/2015 - Retro UNIX 386 v1 Beginning
  3447                                  ; 09/04/2013 epoch variables
  3448                                  ; Retro UNIX 8086 v1 Prototype: UNIXCOPY.ASM, 10/03/2013
  3449                                  ;
  3450 00018698 B207                    year: 	dw 1970
  3451 0001869A 0100                    month: 	dw 1
  3452 0001869C 0100                    day: 	dw 1
  3453 0001869E 0000                    hour: 	dw 0
  3454 000186A0 0000                    minute: dw 0
  3455 000186A2 0000                    second: dw 0
  3456                                  
  3457                                  DMonth:
  3458 000186A4 0000                    	dw 0
  3459 000186A6 1F00                    	dw 31
  3460 000186A8 3B00                    	dw 59
  3461 000186AA 5A00                    	dw 90
  3462 000186AC 7800                    	dw 120
  3463 000186AE 9700                    	dw 151
  3464 000186B0 B500                    	dw 181
  3465 000186B2 D400                    	dw 212
  3466 000186B4 F300                    	dw 243
  3467 000186B6 1101                    	dw 273
  3468 000186B8 3001                    	dw 304
  3469 000186BA 4E01                    	dw 334
  3470                                  
  3471                                  ; 15/11/2020
  3472 000186BC 00                      db	0
  3473                                  kernel_version_msg: ; 20/11/2020
  3474 000186BD 5452444F5320283338-     db	"TRDOS (386) Kernel v2.0.3 by Erdogan Tan"
  3474 000186C6 3629204B65726E656C-
  3474 000186CF 2076322E302E332062-
  3474 000186D8 79204572646F67616E-
  3474 000186E1 2054616E           
  3475 000186E5 00                      db	0
  3476                                  
  3477                                  ; 20/02/2017
  3478                                  KERNELFSIZE  equ $  ; 04/07/2016
  3479                                  
  3480                                  bss_start:
  3481                                  
  3482                                  ABSOLUTE bss_start
  3483                                  
  3484 000186E6 <res 00000002>          alignb 8 ; 25/12/2016
  3485                                  
  3486                                  	; 15/04/2016
  3487                                  	; TRDOS 386 (TRDOS v2.0)
  3488                                  	; 	80 interrupts 	
  3489                                  	; 11/03/2015
  3490                                  	; Interrupt Descriptor Table (20/08/2014)
  3491                                  idt:
  3492                                  	;resb	64*8 ; INT 0 to INT 3Fh
  3493                                  	; 15/04/2016
  3494 000186E8 <res 00000280>          	resb	80*8 ; INT 0 to INT 4Fh
  3495                                  
  3496                                  idt_end:
  3497                                  
  3498                                  ;alignb 4
  3499                                  
  3500                                  task_state_segment:
  3501                                  	; 24/03/2015
  3502 00018968 <res 00000002>          tss.link:   resw 1
  3503 0001896A <res 00000002>          	    resw 1
  3504                                  ; tss offset 4	
  3505 0001896C <res 00000004>          tss.esp0:   resd 1
  3506 00018970 <res 00000002>          tss.ss0:    resw 1
  3507 00018972 <res 00000002>          	    resw 1	
  3508 00018974 <res 00000004>          tss.esp1:   resd 1
  3509 00018978 <res 00000002>          tss.ss1:    resw 1
  3510 0001897A <res 00000002>          	    resw 1 	
  3511 0001897C <res 00000004>          tss.esp2:   resd 1
  3512 00018980 <res 00000002>          tss.ss2:    resw 1
  3513 00018982 <res 00000002>          	    resw 1
  3514                                  ; tss offset 28
  3515 00018984 <res 00000004>          tss.CR3:    resd 1
  3516 00018988 <res 00000004>          tss.eip:    resd 1
  3517 0001898C <res 00000004>          tss.eflags: resd 1
  3518                                  ; tss offset 40
  3519 00018990 <res 00000004>          tss.eax:    resd 1		 		
  3520 00018994 <res 00000004>          tss.ecx:    resd 1
  3521 00018998 <res 00000004>          tss.edx:    resd 1
  3522 0001899C <res 00000004>          tss.ebx:    resd 1
  3523 000189A0 <res 00000004>          tss.esp:    resd 1
  3524 000189A4 <res 00000004>          tss.ebp:    resd 1
  3525 000189A8 <res 00000004>          tss.esi:    resd 1
  3526 000189AC <res 00000004>          tss.edi:    resd 1
  3527                                  ; tss offset 72
  3528 000189B0 <res 00000002>          tss.ES:     resw 1
  3529 000189B2 <res 00000002>          	    resw 1	
  3530 000189B4 <res 00000002>          tss.CS:	    resw 1
  3531 000189B6 <res 00000002>          	    resw 1
  3532 000189B8 <res 00000002>          tss.SS:	    resw 1
  3533 000189BA <res 00000002>          	    resw 1
  3534 000189BC <res 00000002>          tss.DS:	    resw 1
  3535 000189BE <res 00000002>          	    resw 1
  3536 000189C0 <res 00000002>          tss.FS:	    resw 1
  3537 000189C2 <res 00000002>          	    resw 1
  3538 000189C4 <res 00000002>          tss.GS:	    resw 1
  3539 000189C6 <res 00000002>          	    resw 1		
  3540 000189C8 <res 00000002>          tss.LDTR:   resw 1
  3541 000189CA <res 00000002>          	    resw 1
  3542                                  ; tss offset 100		
  3543 000189CC <res 00000002>          	    resw 1		
  3544 000189CE <res 00000002>          tss.IOPB:   resw 1
  3545                                  ; tss offset 104 
  3546                                  tss_end:
  3547                                  
  3548 000189D0 <res 00000004>          k_page_dir:  resd 1 ; Kernel's (System) Page Directory address
  3549                                  		    ; (Physical address = Virtual address)	 	
  3550 000189D4 <res 00000004>          memory_size: resd 1 ; memory size in pages
  3551 000189D8 <res 00000004>          free_pages:  resd 1 ; number of free pages		
  3552 000189DC <res 00000004>          next_page:   resd 1 ; offset value in M.A.T. for
  3553                                  		    ; first free page search
  3554 000189E0 <res 00000004>          last_page:   resd 1 ; offset value in M.A.T. which
  3555                                  		    ; next free page search will be
  3556                                  		    ; stopped after it. (end of M.A.T.)
  3557 000189E4 <res 00000004>          first_page:  resd 1 ; offset value in M.A.T. which
  3558                                  		    ; first free page search
  3559                                  		    ; will be started on it. (for user)
  3560 000189E8 <res 00000004>          mat_size:    resd 1 ; Memory Allocation Table size in pages
  3561                                  
  3562                                  ; 20/11/2020
  3563                                  ;vbe2bios:    resw 1 ; VBE2 video bios ID (bochs/qemu)
  3564                                  ;		    ; (0B0C4h or 0B0C5h for bochs/plex86 vgabios)				
  3565                                  
  3566                                  ; 02/09/2014 (Retro UNIX 386 v1)
  3567                                  ; 04/12/2013 (Retro UNIX 8086 v1)
  3568 000189EC <res 00000002>          CRT_START:   resw 1 	  ; starting address in regen buffer
  3569                                  			  ; NOTE: active page only	
  3570 000189EE <res 00000010>          CURSOR_POSN: resw 8 ; cursor positions for video pages
  3571                                  ACTIVE_PAGE: 
  3572 000189FE <res 00000001>          ptty: 	     resb 1 ; current tty
  3573                                  ; 01/07/2015 - 29/01/2016
  3574 000189FF <res 00000001>          ccolor:	     resb 1 ; current color attribute
  3575                                  ; 26/10/2015
  3576                                  ; 07/09/2014
  3577 00018A00 <res 00000014>          ttychr:      resw ntty+2 ; Character buffer (multiscreen)
  3578                                  
  3579                                  ; 18/05/2015 (03/06/2013 - Retro UNIX 8086 v1 feature only!)
  3580 00018A14 <res 00000004>          p_time:      resd 1     ; present time (for systime & sysmdate)
  3581                                  
  3582                                  ; 18/05/2015 (16/08/2013 - Retro UNIX 8086 v1 feature only !)
  3583                                  ; (open mode locks for pseudo TTYs)
  3584                                  ; [ major tty locks (return error in any conflicts) ]
  3585 00018A18 <res 00000014>          ttyl:        resw ntty+2 ; opening locks for TTYs.
  3586                                  
  3587                                  ; 15/04/2015 (Retro UNIX 386 v1)
  3588                                  ; 22/09/2013 (Retro UNIX 8086 v1)
  3589 00018A2C <res 0000000A>          wlist:       resb ntty+2 ; wait channel list (0 to 9 for TTYs)
  3590                                  ; 15/04/2015 (Retro UNIX 386 v1)
  3591                                  ;; 12/07/2014 -> sp_init set comm. parameters as 0E3h
  3592                                  ;; 0 means serial port is not available 
  3593                                  ;;comprm: ; 25/06/2014
  3594 00018A36 <res 00000001>          com1p:       resb 1  ;;0E3h
  3595 00018A37 <res 00000001>          com2p:       resb 1  ;;0E3h
  3596                                  
  3597                                  ; 17/11/2015
  3598                                  ; request for response (from the terminal)	
  3599 00018A38 <res 00000002>          req_resp:    resw 1 			
  3600                                  ; 07/11/2015
  3601 00018A3A <res 00000001>          ccomport:    resb 1 ; current COM (serial) port
  3602                                  		    ; (0= COM1, 1= COM2)
  3603                                  ; 09/11/2015
  3604 00018A3B <res 00000001>          comqr:	     resb 1 ; 'query or response' sign (u9.s, 'sndc')
  3605                                  ; 07/11/2015
  3606 00018A3C <res 00000002>          rchar:	     resw 1 ; last received char for COM 1 and COM 2		
  3607 00018A3E <res 00000002>          schar:	     resw 1 ; last sent char for COM 1 and COM 2
  3608                                  
  3609                                  ; 22/08/2014 (RTC)
  3610                                  ; (Packed BCD)
  3611 00018A40 <res 00000001>          time_seconds: resb 1
  3612 00018A41 <res 00000001>          time_minutes: resb 1
  3613 00018A42 <res 00000001>          time_hours:   resb 1
  3614 00018A43 <res 00000001>          date_wday:    resb 1
  3615 00018A44 <res 00000001>          date_day:     resb 1
  3616 00018A45 <res 00000001>          date_month:   resb 1			
  3617 00018A46 <res 00000001>          date_year:    resb 1
  3618 00018A47 <res 00000001>          date_century: resb 1
  3619                                  
  3620                                  ; 24/01/2016
  3621 00018A48 <res 00000004>          RTC_LH:	       resd 1
  3622 00018A4C <res 00000001>          RTC_WAIT_FLAG: resb 1
  3623 00018A4D <res 00000001>          USER_FLAG:     resb 1
  3624                                  ; 19/05/2016
  3625                                  ;RTC_second:
  3626 00018A4E <res 00000001>          RTC_2Hz:       resb 1 ;  from 2Hz interrupt to 1Hz timer event function	
  3627                                  
  3628                                  %include 'diskbss.s'	; UNINITIALIZED DISK (BIOS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel) - v2.0.0 - diskbss.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 24/01/2016
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Turkish Rational DOS
    11                              <1> ; Operating System Project v2.0 by ERDOGAN TAN (Beginning: 04/01/2016)
    12                              <1> ;
    13                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    14                              <1> ; diskbss.inc (10/07/2015)
    15                              <1> ;
    16                              <1> ; Derived from 'IBM PC-XT-286' BIOS source code (1986) 
    17                              <1> ; ****************************************************************************
    18                              <1> 
    19                              <1> ; Retro UNIX 386 v1 Kernel - DISKBSS.INC
    20                              <1> ; Last Modification: 10/07/2015
    21                              <1> ;	(Unnitialized Disk Parameters Data section for 'DISKIO.INC') 
    22                              <1> 
    23 00018A4F <res 00000001>      <1> alignb 2
    24                              <1> 
    25                              <1> ;----------------------------------------
    26                              <1> ;	TIMER DATA AREA 		:
    27                              <1> ;----------------------------------------
    28                              <1> 
    29                              <1> TIMER_LH:	; 16/02/205
    30 00018A50 <res 00000002>      <1> TIMER_LOW:      resw	1               ; LOW WORD OF TIMER COUNT
    31 00018A52 <res 00000002>      <1> TIMER_HIGH:     resw	1               ; HIGH WORD OF TIMER COUNT
    32 00018A54 <res 00000001>      <1> TIMER_OFL:      resb 	1               ; TIMER HAS ROLLED OVER SINCE LAST READ
    33                              <1> 
    34                              <1> ;----------------------------------------
    35                              <1> ;	DISKETTE DATA AREAS		:
    36                              <1> ;----------------------------------------
    37                              <1> 
    38 00018A55 <res 00000001>      <1> SEEK_STATUS:	resb	1
    39 00018A56 <res 00000001>      <1> MOTOR_STATUS:	resb	1
    40 00018A57 <res 00000001>      <1> MOTOR_COUNT:	resb	1
    41 00018A58 <res 00000001>      <1> DSKETTE_STATUS:	resb	1
    42 00018A59 <res 00000007>      <1> NEC_STATUS:	resb	7
    43                              <1> 
    44                              <1> ;----------------------------------------
    45                              <1> ;	ADDITIONAL MEDIA DATA		:
    46                              <1> ;----------------------------------------
    47                              <1> 
    48 00018A60 <res 00000001>      <1> LASTRATE:	resb 	1
    49 00018A61 <res 00000001>      <1> HF_STATUS:	resb 	1
    50 00018A62 <res 00000001>      <1> HF_ERROR:	resb 	1
    51 00018A63 <res 00000001>      <1> HF_INT_FLAG:	resb 	1
    52 00018A64 <res 00000001>      <1> HF_CNTRL:	resb 	1
    53 00018A65 <res 00000004>      <1> DSK_STATE:	resb 	4
    54 00018A69 <res 00000002>      <1> DSK_TRK:	resb 	2
    55                              <1> 
    56                              <1> ;----------------------------------------
    57                              <1> ;	FIXED DISK DATA AREAS		:
    58                              <1> ;----------------------------------------
    59                              <1> 
    60 00018A6B <res 00000001>      <1> DISK_STATUS1:	resb 	1		; FIXED DISK STATUS
    61 00018A6C <res 00000001>      <1> HF_NUM:		resb 	1		; COUNT OF FIXED DISK DRIVES
    62 00018A6D <res 00000001>      <1> CONTROL_BYTE:	resb 	1		; HEAD CONTROL BYTE
    63                              <1> ;@PORT_OFF	resb	1		; RESERVED (PORT OFFSET)
    64                              <1> ;port1_off	resb	1		; Hard disk controller 1 - port offset
    65                              <1> ;port2_off	resb	1		; Hard idsk controller 2 - port offset
    66                              <1> 
    67 00018A6E <res 00000002>      <1> alignb 4
    68                              <1> 
    69                              <1> ;HF_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
    70                              <1> ;HF1_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
    71                              <1> HF_TBL_VEC: ; 22/12/2014	
    72 00018A70 <res 00000004>      <1> HDPM_TBL_VEC:	resd	1 		; Primary master disk param. tbl. pointer
    73 00018A74 <res 00000004>      <1> HDPS_TBL_VEC:	resd	1		; Primary slave disk param. tbl. pointer
    74 00018A78 <res 00000004>      <1> HDSM_TBL_VEC:	resd	1 		; Secondary master disk param. tbl. pointer
    75 00018A7C <res 00000004>      <1> HDSS_TBL_VEC:	resd	1		; Secondary slave disk param. tbl. pointer
    76                              <1> 
    77                              <1> ; 03/01/2015
    78 00018A80 <res 00000001>      <1> LBAMode:     	resb	1
    79                              <1> 
    80                              <1> ; *****************************************************************************
  3629                                  
  3630                                  ;;; Real Mode Data (10/07/2015 - BSS)
  3631                                  
  3632                                  ;alignb 2
  3633                                  
  3634                                  ; 10/01/2016
  3635                                  %include 'trdoskx.s'	; UNINITIALIZED KERNEL (Logical Drive & FS) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.2) - UNINITIALIZED DATA : trdoskx.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 30/08/2020
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 04/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from TRDOS Operating System v1.0 (8086) source code by Erdogan Tan
    11                              <1> ; TRDOS2.ASM (09/11/2011)
    12                              <1> ; ****************************************************************************
    13                              <1> ; DRV_INIT.ASM [26/09/2009] Last Update: 07/08/2011
    14                              <1> ; MAINPROG.ASM [17/01/2004] Last Update: 09/11/2011
    15                              <1> ; DIR.ASM      [17/01/2004] Last Update: 09/10/2011
    16                              <1> ; CMD_INTR.ASM [29/01/2005] Last update: 09/11/2011
    17                              <1> ; DRV_FAT.ASM  [07/07/2009] Last update: 21/08/2011
    18                              <1> 
    19 00018A81 <res 00000003>      <1> alignb 4
    20                              <1> 
    21                              <1> ; MAINPROG.ASM
    22 00018A84 <res 00000004>      <1> MainProgCfg_FileSize:   resd 1 ; 14/04/2016
    23 00018A88 <res 00000004>      <1> MainProgCfg_LineOffset: resd 1 ; 14/04/2016
    24                              <1> 
    25 00018A8C <res 00000004>      <1> Current_VolSerial: resd 1
    26                              <1> 
    27 00018A90 <res 00000004>      <1> Current_Dir_FCluster: resd 1
    28                              <1> 
    29 00018A94 <res 00000001>      <1> Current_Dir_Level: resb 1
    30 00018A95 <res 00000001>      <1> Current_FATType: resb 1
    31 00018A96 <res 00000001>      <1> Current_Drv: resb 1
    32 00018A97 <res 00000001>      <1> Current_Dir_Drv:   resb 1 ; '?'
    33 00018A98 <res 00000001>      <1>                    resb 1 ; ':'
    34 00018A99 <res 00000001>      <1> Current_Dir_Root:  resb 1 ; '/' 
    35 00018A9A <res 0000005A>      <1> Current_Directory: resb 90
    36 00018AF4 <res 00000001>      <1> End_Of_Current_Dir_Str: resb 1
    37 00018AF5 <res 00000001>      <1> Current_Dir_StrLen: resb 1   
    38                              <1> 
    39 00018AF6 <res 00000001>      <1> CursorColumn: 	resb 1
    40 00018AF7 <res 00000001>      <1> CmdArgStart:    resb 1
    41                              <1> 
    42                              <1> ; 03/02/2016
    43 00018AF8 <res 0000004E>      <1> Remark:		resb 78
    44                              <1> 
    45 00018B46 <res 00000050>      <1> CommandBuffer: 	resb 80
    46                              <1> 
    47 00018B96 <res 00000100>      <1> TextBuffer:	resb 256
    48                              <1> 
    49                              <1> MasterBootBuff:
    50 00018C96 <res 000001BE>      <1> MasterBootCode: resb 1BEh
    51 00018E54 <res 00000040>      <1> PartitionTable: resb 64
    52 00018E94 <res 00000002>      <1> MBIDCode: resw 1
    53                              <1> 
    54                              <1> PTable_Buffer:
    55 00018E96 <res 00000040>      <1> PTable_hd0: resb 64
    56 00018ED6 <res 00000040>      <1> PTable_hd1: resb 64
    57 00018F16 <res 00000040>      <1> PTable_hd2: resb 64
    58 00018F56 <res 00000040>      <1> PTable_hd3: resb 64
    59                              <1> ; 15/07/2020
    60                              <1> ;PTable_ep0: resb 64
    61                              <1> ;PTable_ep1: resb 64
    62                              <1> ;PTable_ep2: resb 64
    63                              <1> ;PTable_ep3: resb 64
    64                              <1> 
    65                              <1> ; 13/08/2020
    66 00018F96 <res 00000001>      <1> scount: resb 1 ; 16/05/2016 (diskio.s, 'int33h:')
    67 00018F97 <res 00000001>      <1> 	resb 1
    68 00018F98 <res 00000001>      <1> 	resb 1
    69 00018F99 <res 00000001>      <1> 	resb 1
    70                              <1> 	
    71 00018F9A <res 00000001>      <1> HD_LBA_yes: resb 1
    72 00018F9B <res 00000001>      <1> PP_Counter: resb 1
    73 00018F9C <res 00000001>      <1> EP_Counter: resb 1
    74                              <1> ; 13/08/2020
    75 00018F9D <res 00000001>      <1> LD_Counter: resb 1
    76                              <1> 
    77                              <1> ; 30/08/2020
    78 00018F9E <res 00000004>      <1> MBR_EP_StartSector: resd 1 
    79                              <1> 		; Extd partition start sector as in MBR
    80 00018FA2 <res 00000004>      <1> EP_StartSector: resd 1 ; next extd partition start sector
    81                              <1> 	; 15/07/2020	
    82                              <1>                 ;resd 1
    83                              <1>                 ;resd 1
    84                              <1> 
    85                              <1> ; 20/07/2020
    86 00018FA6 <res 00000200>      <1> DOSBootSectorBuff: resb 512
    87                              <1> ; 15/07/2020
    88                              <1> ;DOSBootSectorBuff: resb 446 ; 1BEh
    89                              <1> ;MiniPartitionTable: resb 64 ;  40h
    90                              <1> ;MiniPartitionMagic: resw  1 ;  02h 		
    91                              <1> 
    92                              <1> FAT_BuffDescriptor:
    93 000191A6 <res 00000004>      <1> FAT_CurrentCluster: resd 1
    94 000191AA <res 00000001>      <1> FAT_BuffValidData: resb 1
    95 000191AB <res 00000001>      <1> FAT_BuffDrvName: resb 1
    96 000191AC <res 00000002>      <1> FAT_BuffOffset: resw 1
    97 000191AE <res 00000004>      <1> FAT_BuffSector: resd 1
    98                              <1> 
    99 000191B2 <res 00000004>      <1> FAT_ClusterCounter: resd 1
   100 000191B6 <res 00000004>      <1> LastCluster: resd 1
   101                              <1> 
   102                              <1> ; 16/05/2016
   103                              <1> ;; 18/03/2016 (TRDOS v2.0)
   104                              <1> ;ClusterBuffer_Valid: resb 1
   105                              <1> 
   106                              <1> Dir_BuffDescriptor:
   107 000191BA <res 00000001>      <1> DirBuff_DRV: resb 1
   108 000191BB <res 00000001>      <1> DirBuff_FATType: resb 1
   109 000191BC <res 00000001>      <1> DirBuff_ValidData: resb 1
   110 000191BD <res 00000002>      <1> DirBuff_CurrentEntry: resw 1
   111 000191BF <res 00000002>      <1> DirBuff_LastEntry: resw 1
   112 000191C1 <res 00000004>      <1> DirBuff_Cluster: resd 1 
   113 000191C5 <res 00000002>      <1> DirBuffer_Size: resw 1
   114                              <1> ;DirBuff_EntryCounter: resw 1
   115                              <1> 
   116                              <1> ; 01/02/2016
   117                              <1> ; these are on (real mode) segment 8000h and later
   118                              <1> ; FAT_Buffer:	resb 1536 ; 3 sectors
   119                              <1> ; Dir_Buffer:	resb 512*32
   120                              <1> ; Logical_DOSDisks:  resb 6656 ; 26 * 256 bytes
   121                              <1> 
   122                              <1> ; 18/01/2016
   123                              <1> 
   124 000191C7 <res 00000004>      <1> FreeClusterCount: resd 1
   125                              <1> 
   126 000191CB <res 00000004>      <1> VolSize_Unit1:   resd 1
   127 000191CF <res 00000004>      <1> VolSize_Unit2:   resd 1
   128                              <1> 
   129 000191D3 <res 00000004>      <1> Vol_Tot_Sec_Str_Start:	    resd 1
   130 000191D7 <res 0000000A>      <1> Vol_Tot_Sec_Str: 	    resb 10
   131 000191E1 <res 00000001>      <1> Vol_Tot_Sec_Str_End:	    resb 1
   132 000191E2 <res 00000001>      <1> resb 1
   133 000191E3 <res 00000004>      <1> Vol_Free_Sectors_Str_Start: resd 1
   134 000191E7 <res 0000000A>      <1> Vol_Free_Sectors_Str:	    resb 10				
   135 000191F1 <res 00000001>      <1> Vol_Free_Sectors_Str_End:   resb 1
   136                              <1> 
   137                              <1> ; 10/02/2016
   138 000191F2 <res 00000001>      <1> RUN_CDRV: resb 1 ; CMD_INTR.ASM  ; 09/11/2011
   139                              <1> 
   140                              <1> ; 24/01/2016
   141 000191F3 <res 00000080>      <1> PATH_Array:     resb 128 ; DIR.ASM ; 09/10/2011
   142                              <1> ; 06/02/2016
   143 00019273 <res 00000004>      <1> CCD_DriveDT:	resd 1 ; DIR.ASM ; (word)
   144 00019277 <res 00000001>      <1> CCD_Level:	resb 1 ; DIR.ASM
   145 00019278 <res 00000001>      <1> Last_Dir_Level:	resb 1 ; DIR.ASM
   146                              <1> ;
   147 00019279 <res 00000002>      <1> CDLF_AttributesMask: resw 1 ; DIR.ASM
   148 0001927B <res 00000004>      <1> CDLF_FNAddress:	resd 1 ; DIR.ASM (word)
   149 0001927F <res 00000002>      <1> CDLF_DEType:	resw 1 ; DIR.ASM
   150                              <1> ;
   151 00019281 <res 00000001>      <1> CD_COMMAND:	resb 1 ; DIR.ASM
   152                              <1> 
   153 00019282 <res 00000002>      <1> alignb 4
   154                              <1> 
   155                              <1> ; 29/01/2016
   156 00019284 <res 00000001>      <1> Program_Exit:	resb 1 ; CMD_INTR.ASM  ; 09/11/2011
   157                              <1> 
   158                              <1> ;alignb 4
   159                              <1> ; 23/02/2016
   160 00019285 <res 00000001>      <1> disk_rw_op:	resb 1 ;  0 = disk read, 1 = disk write
   161                              <1> ;disk_rw_spt:	resb 1 ; sectors per track (<= 63) /// (<256)
   162                              <1> ; 31/01/2016
   163 00019286 <res 00000001>      <1> retry_count: 	resb 1 ; DISK_IO.ASM ; 20/07/2011 (CHS_RetryCount)
   164 00019287 <res 00000001>      <1> disk_rw_err: 	resb 1 ; DISK_IO.ASM ; (Disk_IO_err_code)
   165 00019288 <res 00000004>      <1> sector_count:	resd 1 ; DISK_IO.ASM ; (Disk_RW_SectorCount)
   166                              <1> 
   167                              <1> ; 06/02/2016 (long name)
   168 0001928C <res 00000002>      <1> FDE_AttrMask:	   resw 1 ; DIR.ASM
   169 0001928E <res 00000002>      <1> AmbiguousFileName: resw 1 ; DIR.ASM
   170 00019290 <res 00000001>      <1> PreviousAttr:	   resb 1 ; DIR.ASM
   171                              <1> ;	
   172 00019291 <res 00000001>      <1> LongNameFound:   resb 1	  ; DIR.ASM
   173 00019292 <res 00000001>      <1> LFN_EntryLength: resb 1   ; DIR.ASM
   174 00019293 <res 00000001>      <1> LFN_CheckSum:    resb 1   ; DIR.ASM
   175 00019294 <res 00000084>      <1> LongFileName:    resb 132 ; DIR.ASM
   176                              <1> 
   177                              <1> ;PATH_Array_Ptr: resw 1 ; DIR.ASM
   178 00019318 <res 00000001>      <1> PATH_CDLevel:	 resb 1 ; DIR.ASM
   179 00019319 <res 00000001>      <1> PATH_Level:	 resb 1 ; DIR.ASM
   180                              <1> 
   181                              <1> ; 07/02/2016
   182 0001931A <res 0000000D>      <1> Dir_File_Name:	resb 13 ; DIR.ASM ; 09/10/2011
   183                              <1> 
   184                              <1> ; 10/02/2016
   185 00019327 <res 0000000D>      <1> Dir_Entry_Name:	resb 13 ; DIR.ASM
   186                              <1> 
   187                              <1> alignb 2
   188                              <1> 
   189 00019334 <res 00000002>      <1> AttributesMask: resw 1 ; CMD_INTR.ASM ; 09/11/2011
   190                              <1> 
   191                              <1> ; 10/02/2016 (128 bytes -> 126 bytes)
   192                              <1> ; 08/02/2016
   193                              <1> ;FFF Structure (128 bytes) ; DIR.ASM ; 09/10/2011
   194 00019336 <res 00000001>      <1> FindFile_Drv:		  resb 1
   195 00019337 <res 00000041>      <1> FindFile_Directory:	  resb 65
   196 00019378 <res 0000000D>      <1> FindFile_Name:		  resb 13
   197                              <1> FindFile_LongNameEntryLength:
   198 00019385 <res 00000001>      <1> FindFile_LongNameYes: 	  resb 1 ; Sign for longname procedures
   199                              <1> ;Above 80 bytes form
   200                              <1> ;TR-DOS Source/Destination File FullName Format/Structure
   201 00019386 <res 00000002>      <1> FindFile_AttributesMask:  resw 1
   202 00019388 <res 00000020>      <1> FindFile_DirEntry:	  resb 32
   203 000193A8 <res 00000004>      <1> FindFile_DirFirstCluster: resd 1
   204 000193AC <res 00000004>      <1> FindFile_DirCluster:	  resd 1
   205 000193B0 <res 00000002>      <1> FindFile_DirEntryNumber:  resw 1
   206 000193B2 <res 00000002>      <1> FindFile_MatchCounter:	  resw 1
   207 000193B4 <res 00000002>      <1> FindFile_Reserved:	  resw 1 ; 06/03/2016
   208                              <1> 
   209 000193B6 <res 00000004>      <1> First_Path_Pos: resd 1	; DIR.ASM ; 09/10/2011
   210 000193BA <res 00000004>      <1> Last_Slash_Pos: resd 1	; DIR.ASM 
   211                              <1> 
   212                              <1> ; 10/02/2016
   213 000193BE <res 00000002>      <1> File_Count:     resw 1 	; DIR.ASM ; 09/10/2011
   214 000193C0 <res 00000002>      <1> Dir_Count:      resw 1
   215 000193C2 <res 00000004>      <1> Total_FSize:    resd 1
   216 000193C6 <res 00000004>      <1> TFS_Dec_Begin:  resd 1
   217 000193CA <res 0000000A>      <1>                 resb 10
   218 000193D4 <res 00000001>      <1> TFS_Dec_End:    resb 1
   219                              <1> 
   220 000193D5 <res 00000001>      <1> PrintDir_RowCounter: resb 1
   221                              <1> 
   222 000193D6 <res 00000002>      <1> alignb 4
   223                              <1> ; 15/02/2015 ('show' command variables)
   224 000193D8 <res 00000004>      <1> Show_FDT:	resd 1
   225 000193DC <res 00000004>      <1> Show_LDDDT:	resd 1
   226 000193E0 <res 00000004>      <1> Show_Cluster:	resd 1
   227 000193E4 <res 00000004>      <1> Show_FileSize:	resd 1
   228 000193E8 <res 00000004>      <1> Show_FilePointer: resd 1
   229 000193EC <res 00000002>      <1> Show_ClusterPointer: resw 1
   230 000193EE <res 00000002>      <1> Show_ClusterSize: resw 1
   231 000193F0 <res 00000001>      <1> Show_RowCount:	resb 1
   232                              <1> 
   233 000193F1 <res 00000003>      <1> alignb 4
   234                              <1> ; 21/02/2016
   235 000193F4 <res 00000004>      <1> DelFile_FNPointer:	resd 1 ; ; CMD_INTR.ASM (word) ; 09/11/2011
   236                              <1> ; 27/02/2016
   237                              <1> ; DIR.ASM (09/10/2011)
   238 000193F8 <res 00000004>      <1> DelFile_FCluster:	resd 1
   239 000193FC <res 00000002>      <1> DelFile_EntryCounter:	resw 1
   240 000193FE <res 00000001>      <1> DelFile_LNEL:		resb 1
   241 000193FF <res 00000001>      <1> resb 1
   242                              <1> 
   243                              <1> ; DIR.ASM
   244 00019400 <res 00000004>      <1> mkdir_DirName_Offset: 	resd 1
   245 00019404 <res 00000004>      <1> mkdir_FFCluster:	resd 1
   246 00019408 <res 00000004>      <1> mkdir_LastDirCluster:	resd 1
   247 0001940C <res 00000004>      <1> mkdir_FreeSectors:	resd 1
   248 00019410 <res 00000002>      <1> mkdir_attrib:		resw 1 
   249 00019412 <res 00000001>      <1> mkdir_SecPerClust:	resb 1
   250 00019413 <res 00000001>      <1> mkdir_add_new_cluster:	resb 1
   251 00019414 <res 0000000D>      <1> mkdir_Name:		resb 13
   252 00019421 <res 00000002>      <1> resw 1 ; 01/03/2016
   253                              <1> ; 27/02/2016
   254 00019423 <res 00000001>      <1> RmDir_MultiClusters:	resb 1  
   255 00019424 <res 00000004>      <1> RmDir_DirEntryOffset:	resd 1 ; 01/03/2016 (word -> dword)
   256 00019428 <res 00000004>      <1> RmDir_ParentDirCluster: resd 1
   257 0001942C <res 00000004>      <1> RmDir_DirLastCluster:   resd 1
   258 00019430 <res 00000004>      <1> RmDir_PreviousCluster:  resd 1
   259                              <1> ; 22/02/2016
   260 00019434 <res 00000001>      <1> UPDLMDT_CDirLevel:	resb 1
   261 00019435 <res 00000004>      <1> UPDLMDT_CDirFCluster:	resd 1
   262                              <1> 	
   263 00019439 <res 00000003>      <1> alignb 4
   264                              <1> ; DRV_FAT.ASM ; 21/08/2011
   265 0001943C <res 00000004>      <1> gffc_next_free_cluster:  resd 1
   266 00019440 <res 00000004>      <1> gffc_first_free_cluster: resd 1
   267 00019444 <res 00000004>      <1> gffc_last_free_cluster:  resd 1
   268                              <1> 
   269                              <1> ;29/04/2016
   270                              <1> Cluster_Index: ; resd 1
   271                              <1> ; 22/02/2016
   272 00019448 <res 00000004>      <1> ClusterValue:	resd 1
   273                              <1> ; 04/03/2016
   274 0001944C <res 00000001>      <1> Attributes:	resb 1 
   275                              <1> ;;CFS_error:  resb 1 ;; 01/03/2016
   276 0001944D <res 00000001>      <1> resb 1
   277 0001944E <res 00000001>      <1> CFS_OPType: resb 1
   278 0001944F <res 00000001>      <1> CFS_Drv:    resb 1
   279 00019450 <res 00000004>      <1> CFS_CC:	    resd 1
   280 00019454 <res 00000004>      <1> CFS_FAT32FSINFOSEC: resd 1
   281 00019458 <res 00000004>      <1> CFS_FAT32FC: resd 1
   282                              <1> 
   283                              <1> ; 27/02/2016
   284                              <1> ;alignb 4
   285 0001945C <res 00000004>      <1> glc_prevcluster: resd 1 ; DRV_FAT.ASM (21/08/2011)
   286                              <1> ; 22/10/2016
   287 00019460 <res 00000004>      <1> glc_index:	 resd 1 ;  Last Cluster Index (22/10/2016)	
   288                              <1> 
   289                              <1> ; DIR.ASM
   290 00019464 <res 00000002>      <1> DLN_EntryNumber: resw 1
   291 00019466 <res 00000001>      <1> DLN_40h:	 resb 1
   292                              <1> ; 28/02/2016
   293 00019467 <res 00000001>      <1> TCC_FATErr:	 resb 1 ; DRV_FAT.ASM
   294                              <1> 
   295                              <1> alignb 4
   296                              <1> ; DIR.ASM (09/10/2011)
   297 00019468 <res 00000002>      <1> LCDE_EntryIndex: resw 1 ; LCDE_EntryOffset
   298 0001946A <res 00000002>      <1> LCDE_ClusterSN:  resw 1
   299 0001946C <res 00000004>      <1> LCDE_Cluster: 	 resd 1
   300 00019470 <res 00000004>      <1> LCDE_ByteOffset: resd 1
   301                              <1> 
   302                              <1> ;alignb4
   303                              <1> ; 06/03/2016 (word -> dword)
   304                              <1> ; CMD_INTR.ASM (01/08/2010)
   305 00019474 <res 00000004>      <1> SourceFilePath:	     resd 1
   306 00019478 <res 00000004>      <1> DestinationFilePath: resd 1
   307                              <1> 
   308                              <1> ;alignb 4
   309                              <1> ; 06/03/2016
   310                              <1> ; FILE.ASM (09/10/2011)
   311                              <1> ;Source File Structure (same with 'Find File' Structure)
   312 0001947C <res 00000001>      <1> SourceFile_Drv:			resb 1
   313 0001947D <res 00000041>      <1> SourceFile_Directory:		resb 65
   314 000194BE <res 0000000D>      <1> SourceFile_Name:		resb 13
   315                              <1> SourceFile_LongNameEntryLength: 
   316 000194CB <res 00000001>      <1> SourceFile_LongNameYes:		resb 1 ; Sign for longname procedures
   317                              <1> ;Above 80 bytes
   318                              <1> ;is TR-DOS Source File FullName Format/Structure
   319 000194CC <res 00000002>      <1> SourceFile_AttributesMask:	resw 1
   320 000194CE <res 00000020>      <1> SourceFile_DirEntry:		resb 32
   321 000194EE <res 00000004>      <1> SourceFile_DirFirstCluster:	resd 1
   322 000194F2 <res 00000004>      <1> SourceFile_DirCluster:		resd 1
   323 000194F6 <res 00000002>      <1> SourceFile_DirEntryNumber:	resw 1
   324 000194F8 <res 00000002>      <1> SourceFile_MatchCounter:	resw 1
   325                              <1> ; 16/03/2016
   326 000194FA <res 00000001>      <1> SourceFile_SecPerClust:		resb 1
   327 000194FB <res 00000001>      <1> SourceFile_Reserved:		resb 1
   328                              <1> ; Above is 128 bytes
   329                              <1> 
   330                              <1> ;Destination File Structure (same with 'Find File' Structure)
   331 000194FC <res 00000001>      <1> DestinationFile_Drv:		resb 1
   332 000194FD <res 00000041>      <1> DestinationFile_Directory: 	resb 65
   333 0001953E <res 0000000D>      <1> DestinationFile_Name:		resb 13
   334                              <1> DestinationFile_LongNameEntryLength:
   335 0001954B <res 00000001>      <1> DestinationFile_LongNameYes:	resb 1 ; Sign for longname procedures
   336                              <1> ;Above 80 bytes
   337                              <1> ;is TR-DOS Destination File FullName Format/Structure
   338 0001954C <res 00000002>      <1> DestinationFile_AttributesMask: resw 1
   339 0001954E <res 00000020>      <1> DestinationFile_DirEntry:	resb 32
   340 0001956E <res 00000004>      <1> DestinationFile_DirFirstCluster: resd 1
   341 00019572 <res 00000004>      <1> DestinationFile_DirCluster:	resd 1
   342 00019576 <res 00000002>      <1> DestinationFile_DirEntryNumber: resw 1
   343 00019578 <res 00000002>      <1> DestinationFile_MatchCounter:	resw 1
   344                              <1> ; 16/03/2016
   345 0001957A <res 00000001>      <1> DestinationFile_SecPerClust:	resb 1
   346 0001957B <res 00000001>      <1> DestinationFile_Reserved:	resb 1
   347                              <1> ; Above is 128 bytes
   348                              <1> 
   349                              <1> ; 24/04/2016
   350 0001957C <res 00000002>      <1> resw 1
   351                              <1> 
   352                              <1> ; 10/03/2016
   353                              <1> ; FILE.ASM
   354 0001957E <res 00000001>      <1> move_cmd_phase:	   resb 1
   355 0001957F <res 00000001>      <1> msftdf_sf_df_drv:  resb 1
   356 00019580 <res 00000004>      <1> msftdf_drv_offset: resd 1
   357                              <1> 
   358                              <1> ; 11/03/2016
   359                              <1> ; DRV_FAT.ASM (21/08/2011)
   360 00019584 <res 00000004>      <1> FAT_anc_LCluster:  resd 1
   361 00019588 <res 00000004>      <1> FAT_anc_FFCluster: resd 1
   362                              <1> 
   363                              <1> ;alignb 4
   364                              <1> 
   365                              <1> ; 14/03/2016
   366                              <1> ; TRDOS 386 = TRDOS v2.0 feature only !
   367                              <1> ; 'allocate_memory_block' in 'memory.s'
   368 0001958C <res 00000004>      <1> mem_ipg_count:	resd 1 ; page count (for contiguous allocation)
   369 00019590 <res 00000004>      <1> mem_pg_count:	resd 1 ; page count (for count down)
   370 00019594 <res 00000004>      <1> mem_aperture:	resd 1 ; contiguous free pages (current)
   371 00019598 <res 00000004>      <1> mem_max_aperture: resd 1 ; maximum value of contiguous free pages
   372 0001959C <res 00000004>      <1> mem_pg_pos:	resd 1 ; mem. position (page #) of current aperture
   373 000195A0 <res 00000004>      <1> mem_max_pg_pos: resd 1 ; mem. position (page #) of max. aperture
   374                              <1> 
   375                              <1> ; 15/03/2016
   376                              <1> ; FILE.ASM ('copy_source_file_to_destination_file')
   377 000195A4 <res 00000001>      <1> copy_cmd_phase:       resb 1
   378 000195A5 <res 00000001>      <1> csftdf_rw_err:	      resb 1
   379 000195A6 <res 00000001>      <1> DestinationFileFound: resb 1
   380 000195A7 <res 00000001>      <1> csftdf_cdrv: 	      resb 1
   381 000195A8 <res 00000004>      <1> csftdf_filesize:      resd 1
   382                              <1> ; TRDOS386 (TRDOS v2.0)
   383 000195AC <res 00000004>      <1> csftdf_sf_mem_addr:   resd 1
   384 000195B0 <res 00000004>      <1> csftdf_sf_mem_bsize:  resd 1
   385                              <1> ;
   386                              <1> 
   387 000195B4 <res 00000004>      <1> csftdf_sf_cluster:    resd 1 ; 16/03/2016
   388 000195B8 <res 00000004>      <1> csftdf_df_cluster:    resd 1
   389                              <1> ; 16/03/2016
   390 000195BC <res 00000004>      <1> csftdf_r_size:        resd 1
   391 000195C0 <res 00000004>      <1> csftdf_w_size:        resd 1
   392 000195C4 <res 00000004>      <1> csftdf_sf_rbytes:     resd 1
   393 000195C8 <res 00000004>      <1> csftdf_df_wbytes:     resd 1
   394 000195CC <res 00000001>      <1> csftdf_percentage:    resb 1
   395                              <1> ; 17/03/2016
   396 000195CD <res 00000001>      <1> csftdf_videopage:     resb 1
   397 000195CE <res 00000002>      <1> csftdf_cursorpos:     resw 1
   398 000195D0 <res 00000004>      <1> csftdf_sf_drv_dt:     resd 1
   399 000195D4 <res 00000004>      <1> csftdf_df_drv_dt:     resd 1
   400                              <1> 
   401                              <1> ; 21/03/2016
   402                              <1> ; 20/03/2016
   403                              <1> ; FILE.ASM
   404 000195D8 <res 00000004>      <1> createfile_Name_Offset:  resd 1
   405 000195DC <res 00000004>      <1> createfile_FreeSectors:  resd 1 
   406 000195E0 <res 00000004>      <1> createfile_size:         resd 1
   407 000195E4 <res 00000004>      <1> createfile_FFCluster:    resd 1 ; 11/03/2016
   408 000195E8 <res 00000004>      <1> createfile_LastDirCluster: resd 1
   409 000195EC <res 00000004>      <1> createfile_Cluster:      resd 1
   410 000195F0 <res 00000004>      <1> createfile_PCluster:     resd 1
   411 000195F4 <res 00000001>      <1> createfile_attrib:	 resb 1
   412 000195F5 <res 00000001>      <1> createfile_SecPerClust:  resb 1
   413 000195F6 <res 00000002>      <1> createfile_DirIndex:     resw 1
   414 000195F8 <res 00000004>      <1> createfile_CCount:	 resd 1
   415 000195FC <res 00000002>      <1> createfile_BytesPerSec:	 resw 1 ; 23/03/2016
   416 000195FE <res 00000001>      <1> createfile_wfc:	         resb 1
   417 000195FF <res 00000001>      <1> createfile_UpdatePDir:	 resb 1 ; 31/03/2016
   418                              <1> 
   419                              <1> ;alignb 4
   420                              <1> 
   421                              <1> ; 11/04/2016
   422 00019600 <res 00000002>      <1> env_var_length:	   resw 1
   423                              <1> 
   424 00019602 <res 00000002>      <1> alignb 4
   425                              <1> 
   426                              <1> ; 25/04/2016
   427 00019604 <res 00000001>      <1> readi.valid:	resb 1 ; valid data (>0 = valid for readi)
   428 00019605 <res 00000001>      <1> readi.drv:	resb 1 ; drive number (0, 1,2,3,4..)
   429 00019606 <res 00000001>      <1> readi.spc:	resb 1 ; sectors per cluster for 'readi' drive
   430 00019607 <res 00000001>      <1> readi.s_index:  resb 1 ; sector index in current cluster (buffer)
   431 00019608 <res 00000004>      <1> readi.sector:	resd 1 ; current disk sector
   432 0001960C <res 00000002>      <1> readi.bpc:	resw 1 ; bytes per cluster - 1
   433 0001960E <res 00000002>      <1> readi.offset:	resw 1 ; byte offset in cluster buffer
   434 00019610 <res 00000004>      <1> readi.cluster:  resd 1 ; current cluster number
   435 00019614 <res 00000004>      <1> readi.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
   436 00019618 <res 00000004>      <1> readi.fclust:	resd 1 ; first cluster of the current cluster
   437 0001961C <res 00000004>      <1> readi.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
   438                              <1> ;readi.buffer:	resd 1 ; readi sector buffer address
   439                              <1> 
   440                              <1> ;alignb 4
   441                              <1> 
   442 00019620 <res 00000001>      <1> writei.valid:	resb 1 ; valid data (>0 = valid for writei)
   443 00019621 <res 00000001>      <1> writei.drv:	resb 1 ; drive number (0, 1,2,3,4..)
   444 00019622 <res 00000001>      <1> writei.spc:	resb 1 ; sectors per cluster for 'writei' drive
   445 00019623 <res 00000001>      <1> writei.s_index: resb 1 ; sector index in current cluster (buffer)
   446 00019624 <res 00000004>      <1> writei.sector:	resd 1 ; current disk sector
   447 00019628 <res 00000002>      <1> writei.bpc:	resw 1 ; bytes per cluster - 1
   448 0001962A <res 00000002>      <1> writei.offset:	resw 1 ; byte offset in cluster buffer
   449 0001962C <res 00000004>      <1> writei.cluster: resd 1 ; current cluster number
   450 00019630 <res 00000004>      <1> writei.c_index:	resd 1 ; cluster index of the current cluster (0,1,2,3..)
   451 00019634 <res 00000004>      <1> writei.fclust:  resd 1 ; first cluster of the current cluster
   452 00019638 <res 00000004>      <1> writei.fs_index: resd 1 ; sector index in disk/file section (for Singlix FS)
   453                              <1> ;writei.buffer:	resd 1 ; writei sector buffer address
   454 0001963C <res 00000004>      <1> writei.lclust:	resd 1 ; writei last cluster (mget_w) ; 23/10/2016
   455 00019640 <res 00000004>      <1> writei.l_index:	resd 1 ; writei last cluster index (mget_w) ; 23/10/2016
   456 00019644 <res 00000001>      <1> writei.ofn:	resb 1 ; open file number (to be written) ; 23/10/2016
   457                              <1> 
   458 00019645 <res 00000003>      <1> alignb 4
   459                              <1> 
   460                              <1> ; 29/04/2016
   461 00019648 <res 00000004>      <1> Run_CDirFC:	resd 1
   462 0001964C <res 00000001>      <1> Run_Auto_Path:	resb 1
   463 0001964D <res 00000001>      <1> Run_Manual_Path: resb 1 ; 0 -> auto path sequence needed
   464 0001964E <res 00000001>      <1> EXE_ID:		resb 1	
   465 0001964F <res 00000001>      <1> EXE_dot:	resb 1
   466                              <1> 
   467                              <1> ; 06/05/2016
   468 00019650 <res 00000004>      <1> mainprog_return_addr: resd 1
   469 00019654 <res 00000004>      <1> last_error:	resd 1  ; this will be used to return error code to MainProg
   470                              <1> 			; 'lasterror' keyword will be used later to get the
   471                              <1> 			; last error code/number/status.
   472                              <1> ; 12/05/2016
   473 00019658 <res 00000004>      <1> video_eax:	resd 1  ; eax return value of video function
   474                              <1> 
   475                              <1> ; 01/06/2016
   476 0001965C <res 00000004>      <1> user_buffer:	resd 1  ; 'diskio.s' (INT 33h, Function 08h, floppy disk type)
   477                              <1> 
   478                              <1> ; 21/05/2016 - TRDOS 386 ('swap/switch', 'rswap', [u.pri])
   479 00019660 <res 00000001>      <1> priority:	resb 1  ; running priority level of process (0,1,2)
   480                              <1> 			; (run queue which is process comes from)
   481                              <1> ; 22/05/2016 - TRDOS 386 ('set_run_sequence', 'rtc_int', 'u_timer')
   482 00019661 <res 00000001>      <1> p_change:	resb 1  ; process change status (for timer events)
   483                              <1> ; 23/05/2016 - TRDOS 386 ('clock')
   484 00019662 <res 00000001>      <1> multi_tasking:	resb 1   ; Multi Tasking status (0 = disabled, >0 = enabled)
   485                              <1> 			; (EBX will return with user buffer addr or disk type)
   486                              <1> ; 07/06/2016
   487 00019663 <res 00000001>      <1> timer_events:	resb 1  ; number of (active) timer events, <= 16		
   488                              <1> 
   489                              <1> ; 24/06/2016
   490 00019664 <res 00000001>      <1> w_str_cmd:	resb 1	; WRITE_STRING command (0,1,2,3) ; video.s
   491 00019665 <res 00000001>      <1> p_crt_mode:	resb 1  ; previous video mode (=3 or 0), backup mark/sign
   492                              <1> ; 26/06/2016
   493 00019666 <res 00000001>      <1> p_crt_page:	resb 1  ; previous active page (for 'set_mode')
   494                              <1> ; 04/07/2016
   495 00019667 <res 00000001>      <1> noclearmem:	resb 1  ; if set, 'SET MODE' (INT 31h) function (AH = 4)
   496                              <1> 			; will not clear the video memory
   497                              <1> 			; (usable for graphics modes only)
   498                              <1> alignb 2
   499 00019668 <res 00000002>      <1> CRT_LEN:	resw 1  ; length of regen buffer in bytes
   500 0001966A <res 00000010>      <1> cursor_pposn:	resw 8  ; cursor positions backup
   501                              <1> 
   502                              <1> ; 10/07/2016 ('VGA_FONT_SETUP', INT 43H address for x86 real mode bios)
   503 0001967A <res 00000004>      <1> VGA_INT43H:	resd 1	; 0 = default (not configured by user)
   504                              <1> 			; 0FFFFFFFFh = user defined fonts
   505                              <1> 			; address:
   506                              <1> 			; 	vgafont8
   507                              <1> 			; 	vgafont16
   508                              <1> 			; 	vgafont14
   509                              <1> 
   510                              <1> ; 25/07/2016
   511 0001967E <res 00000001>      <1> VGA_MTYPE:	resb 1  ; 0=CTEXT,1=MTEXT,2=CGA,3=PLANAR1,4=PLANAR4,5=LINEAR 
   512                              <1> 
   513                              <1> ; 23/10/2016
   514 0001967F <res 00000001>      <1> setfmod		resb 1	; update last modification date&time sign (if >0)
   515                              <1> 			; (it is Open File Number + 1, if > 0)
   516                              <1> alignb 4
   517                              <1> 
   518                              <1> ; 16/10/2016
   519 00019680 <res 00000004>      <1> FFF_UBuffer:	resd 1  ; User's buffer address for FFF & FNF system calls 
   520                              <1> ; 15/10/2016
   521 00019684 <res 00000001>      <1> FFF_Valid:	resb 1  ; Find First File Structure validation byte
   522                              <1> 			; 0  = invalid (Find Next File can't use FFF struct)
   523                              <1> 			; >0 = valid, return type for FFF and Find Next File
   524                              <1> 			; 24 = basic parameters, 24 bytes
   525                              <1> 			; 128 = entire FFF structure/table, 128 bytes
   526                              <1> ; 16/10/2016 (FFF_Attrib: resw 1)
   527 00019685 <res 00000001>      <1> FFF_Attrib:	resb 1	; Find First File attributes for Find Next File (LB)
   528 00019686 <res 00000001>      <1> FFF_RType:	resb 1  ; FFF return type (0 = Basic, >0 = complete) (HB)
   529                              <1> ; 16/10/2016 - 05/10/2016 (Set Working Path)
   530 00019687 <res 00000001>      <1> SWP_inv_fname:	resb 1	; Set Working Path - Invalid File Name
   531 00019688 <res 00000002>      <1> SWP_Mode:	resw 1	; Set Working Path - Mode
   532 0001968A <res 00000001>      <1> SWP_DRV:	resb 1	; Set Working Path - Drive	
   533 0001968B <res 00000001>      <1> SWP_DRV_chg:	resb 1	; Set Working Path - Drive Change
   534                              <1> 
   535                              <1> ; 27/02/2017
   536 0001968C <res 00000001>      <1> fpready:	resb 1	; '80387 fpu is ready' flag	
   537                              <1> 
   538                              <1> ; 08/10/2016
   539 0001968D <res 00000009>      <1> device_name:    resb 9  ; capitalized (and zero padded) device canem 
   540                              <1> 			; (example: "TTY0",0,0,0,0,0")
   541                              <1> 
   542 00019696 <res 00000002>      <1> alignb 4
   543                              <1> 
   544                              <1> ; 08/10/2016
   545                              <1> ; 07/10/2016
   546                              <1> ; Table of kernel devices (which do not use installable device drivers)
   547                              <1> ; has been coded into KERNEL (trdosk9.s) 
   548                              <1> ; 07/10/2016
   549                              <1> ; 8 installable device drivers available to install (NUMIDEV)
   550 00019698 <res 00000020>      <1> IDEV_PGDIR: resd NUMIDEV
   551                              <1> 			; Page directories of installable device drivers
   552                              <1> 			;
   553                              <1> 			; Note: Virtual start address is always 400000h
   554                              <1> 			; (end of the 1st 4MB). [org 400000h]
   555                              <1> 			; Segments: KCODE, KDATA
   556                              <1> 			; Method: call 400000h (after changing page dir) 	
   557                              <1> 			; Query code located at the start (400000h).
   558                              <1> 			; Query code returns with
   559                              <1> 			;   eax = device type and driver version
   560                              <1> 			;         AL = Device Type minor
   561                              <1> 			;         AH = Device Type major
   562                              <1> 			;         Byte 16-23 : Version minor
   563                              <1> 			;	  Byte 24-31 : Version major - 1
   564                              <1> 			;		       (0:0 -> 1.0)
   565                              <1> 			;   ebx = initialization code address
   566                              <1> 			;   ecx = configuration table address
   567                              <1> 			;   edx = description table address
   568                              <1> 			;   esi = device (default) name address (ASCIIZ)
   569                              <1> 			;	 (name has "/DEV/" prefix)		
   570                              <1> 			;   edi = dispatch table address
   571                              <1> 			;        (for calling kernel-device functions)
   572                              <1> 			;   ebp = address table address
   573                              <1> 			; Initialization code returns with
   574                              <1> 			;   eax = open code address
   575                              <1> 			;   ecx = close code address 
   576                              <1> 			;   ebx = read code address
   577                              <1> 			;   edx = write code address 	
   578                              <1> 			;   esi = IOCTL code address
   579                              <1> 			;   edi = dispatch table address
   580                              <1> 			;   ebp = address table address
   581                              <1> 			; Address Table:
   582                              <1> 			;    Offset 0  : open code address
   583                              <1> 			;    Offset 4  : read code address
   584                              <1> 			;    Offset 8  : write code address
   585                              <1> 			;    Offset 12 : close code address
   586                              <1> 			;    Offset 16 : IOCTL code address
   587                              <1> 			;    Offset 20 : initialization code address
   588                              <1> 			;    Offset 24 : description table address
   589                              <1> 			;    Offset 28 : configuration table address
   590                              <1> 			;    Offset 32 : device name address
   591                              <1> 			;    Offset 36 : dispatch table address
   592                              <1> 			;          (for calling kernel-device functions)
   593                              <1> 
   594 000196B8 <res 00000040>      <1> IDEV_NAME:  resb 8*NUMIDEV 
   595                              <1> 			; 8 byte names of installable device drivers
   596                              <1> 
   597 000196F8 <res 00000008>      <1> IDEV_TYPE:  resb NUMIDEV ; Driver type of installable device drivers
   598 00019700 <res 00000008>      <1> IDEV_FLAGS: resb NUMIDEV ; Device access parameters for installable
   599                              <1>                          ; device drivers (These values are set while
   600                              <1> 			 ; the device driver is being loaded.)
   601 00019708 <res 00000020>      <1> IDEV_OADDR: resd NUMIDEV ; open function addr for installable dev driver
   602 00019728 <res 00000020>      <1> IDEV_CADDR: resd NUMIDEV ; close function addr for installable dev driver
   603 00019748 <res 00000020>      <1> IDEV_RADDR: resd NUMIDEV ; read function addr for installable dev driver
   604 00019768 <res 00000020>      <1> IDEV_WADDR: resd NUMIDEV ; write function addr for installable dev driver
   605                              <1> 	
   606                              <1> ; 08/10/2016	
   607                              <1> ; 07/10/2016
   608                              <1> ; Device Open and Access parameters
   609 00019788 <res 0000001E>      <1> DEV_ACCESS:	 resb NUMOFDEVICES   ; bit 0 = accessable by normal users
   610                              <1> 				     ; bit 1 = read access permission
   611                              <1> 				     ; bit 2 = write access permission
   612                              <1> 				     ; bit 3 = IOCTL permission to users
   613                              <1> 				     ; bit 4 = block device if it is set	
   614                              <1> 				     ; bit 5 = 16 bit or 1024 byte data
   615                              <1> 				     ; bit 6 = 32 bit or 2048 byte data
   616                              <1> 				     ; bit 7 = installable device driver
   617 000197A6 <res 0000001E>      <1> DEV_R_OWNER:	 resb NUMOFDEVICES   ; Reading owner no (u.uid) of devices		
   618 000197C4 <res 0000001E>      <1> DEV_R_OPENCOUNT: resb NUMOFDEVICES   ; Reading open count 
   619 000197E2 <res 0000001E>      <1> DEV_W_OWNER:	 resb NUMOFDEVICES   ; Writing owner no (u.uid) of devices		
   620 00019800 <res 0000001E>      <1> DEV_W_OPENCOUNT: resb NUMOFDEVICES   ; Writing open count
   621 0001981E <res 0000001E>      <1> DEV_DRIVER:	 resb NUMOFDEVICES   ; device driver number (1 to 7Fh)
   622                              <1> 				     ; *if bit 7 is set (80 to FFh)
   623                              <1> 				     ; *if it is installable device driver
   624                              <1> 				     ; *index (0 to 7Fh)
   625                              <1> 				     ; otherwise it is kernel device index
   626 0001983C <res 0000001E>      <1> DEV_OPENMODE:	 resb NUMOFDEVICES   ; 1 = read mode
   627                              <1> 				     ; 2 = write mode
   628                              <1> 				     ; 3 = read & write 	  
   629                              <1> 				     ; 0 = not open (free)		
   630 0001985A <res 00000078>      <1> DEV_NAME_PTR:    resd NUMOFDEVICES   ; pointers to name addresses of drivers
   631                              <1> 				     ; Address base: KDEV_NAME+		
   632                              <1> 				     ; or IDEV_NAME+
   633 000198D2 <res 00000078>      <1> DEV_R_POINTER:	 resd NUMOFDEVICES   ; reading pointer, writing pointer	
   634 0001994A <res 00000078>      <1> DEV_W_POINTER:	 resd NUMOFDEVICES   ; sector number if block device
   635                              <1> 				     ; character offset if char device
   636 000199C2 <res 00000002>      <1> alignb 4
   637                              <1> 
   638                              <1> ; 06/10/2016
   639                              <1> ; Open File Parameters
   640 000199C4 <res 00000028>      <1> OF_FCLUSTER:	resd OPENFILES  ; First clusters of open files
   641 000199EC <res 0000000A>      <1> OF_DRIVE:	resb OPENFILES  ; Logical DOS drive numbers of open files 
   642 000199F6 <res 0000000A>      <1> OF_MODE:	resb OPENFILES  ; Open mode (1 = read, 2 = write, 3 = r&w) 
   643 00019A00 <res 0000000A>      <1> OF_STATUS:	resb OPENFILES  ; (bit 0 = read, bit 1 = write)
   644 00019A0A <res 0000000A>      <1> OF_OPENCOUNT:	resb OPENFILES  ; Open counts of open files
   645 00019A14 <res 00000028>      <1> OF_POINTER:	resd OPENFILES	; File seek/read/write pointer
   646 00019A3C <res 00000028>      <1> OF_SIZE:	resd OPENFILES	; File sizes of open files (in bytes)
   647 00019A64 <res 00000028>      <1> OF_DIRFCLUSTER:	resd OPENFILES  ; Directory First Clusters of open files
   648 00019A8C <res 00000028>      <1> OF_DIRCLUSTER:	resd OPENFILES  ; Directory (Entry) Clusters of open files
   649 00019AB4 <res 00000028>      <1> OF_VOLUMEID:	resd OPENFILES  ; Vol ID for removable drives of open files
   650 00019ADC <res 00000028>      <1> OF_CCLUSTER:	resd OPENFILES  ; Current clusters of open files
   651 00019B04 <res 00000028>      <1> OF_CCINDEX:	resd OPENFILES  ; Cluster index numbers of current clusters
   652                              <1> ; 24/10/2016
   653 00019B2C <res 00000014>      <1> OF_DIRENTRY:	resw OPENFILES  ; Directory entry index no. in dir cluster 
   654                              <1> 				; Sector index = entry index / 16
   655                              <1> ;alignb 2
   656                              <1> 
   657 00019B40 <res 00000060>      <1> DTA:		resd 24		; Find First File data transfer area
   658                              <1> 
   659                              <1> ; 19/12/2016
   660 00019BA0 <res 00000001>      <1> tcallback:	resb 1		; Timer callback method flag for 'systimer'
   661 00019BA1 <res 00000001>      <1> trtc:		resb 1		; Timer interrupt type flag for 'systimer'
   662                              <1> ; 20/02/2017
   663 00019BA2 <res 00000001>      <1> no_page_swap:	resb 1		; Swap lock for Signal Response Byte pages 
   664                              <1> ;;15/01/2017
   665                              <1> ; 02/01/2017
   666                              <1> ;;intflg:	resb 1		; software interrupt in progress signal
   667                              <1> 				; (for timer interrupt)
   668                              <1> 
   669 00019BA3 <res 00000001>      <1> alignb 4
   670                              <1> ; 13/04/2017
   671 00019BA4 <res 0000001E>      <1> DEV_INTR:	resb NUMOFDEVICES ; Device Interrupt (IRQ) number + 1	
   672                              <1> 				; (0= not available, 1= IRQ 0, 16= IRQ 15)
   673 00019BC2 <res 00000040>      <1> DEV_INT_HNDLR:	resd 16		; Device Interrupt Handler addr, if > 0 	
   674                              <1> 
   675                              <1> 
   676                              <1> ;alignb 4
   677                              <1> 
   678                              <1> ; 26/02/2017 ; IRQ Callback parameters ('syscalbac')
   679                              <1> ;Index: ; 0 to 8
   680                              <1> ;	0 = IRQ3, 1 = IRQ4, 2 = IRQ5, 3 = IRQ7
   681                              <1> ;	4 = IRQ9, 5 = IRQ10, 6 = IRQ11, 7 = IRQ12, 8 = IRQ13  
   682 00019C02 <res 00000009>      <1> IRQ.owner:	resb 9		; owner, 0 = free, >0 = [u.uno]
   683 00019C0B <res 00000009>      <1> IRQ.dev:	resb 9		; 0 = default/kernel, >0 = device number
   684 00019C14 <res 00000009>      <1> IRQ.method:	resb 9 		; 0 = Signal Response Byte, 1 = Callback
   685 00019C1D <res 00000009>      <1> IRQ.srb:	resb 9 		; Signal Response/Return Byte value
   686 00019C26 <res 00000024>      <1> IRQ.addr:	resd 9		; Rignal Response Byte address (physical)
   687                              <1> 				; or Callback service address (virtual)
   688                              <1> ; 28/02/2017
   689 00019C4A <res 00000004>      <1> IRQ_cr3:	resd 1		; for saving cr3 register in IRQ handler
   690 00019C4E <res 00000001>      <1> IRQnum:		resb 1		; IRQ number for IRQ handler (trdosk8.s)
   691                              <1> 
   692                              <1> ; 10/04/2017
   693                              <1> ; 03/04/2017
   694                              <1> ; UNINITIALIZED AUDIO DATA
   695 00019C4F <res 00000001>      <1> alignb 4
   696 00019C50 <res 00000001>      <1> audio_pci:	resb 1
   697 00019C51 <res 00000001>      <1> audio_device:	resb 1
   698 00019C52 <res 00000001>      <1> audio_mode:	resb 1
   699 00019C53 <res 00000001>      <1> audio_intr:	resb 1
   700 00019C54 <res 00000001>      <1> audio_busy:	resb 1  ; Busy flag for audio irq ; 21/04/2017
   701 00019C55 <res 00000001>      <1> audio_reserved: resb 1
   702 00019C56 <res 00000002>      <1> audio_io_base:	resw 1 	; Base I/O address of audio device
   703 00019C58 <res 00000004>      <1> audio_dev_id:	resd 1	; BUS/DEV/FN ; 00000000BBBBBBBBDDDDDFFF00000000
   704 00019C5C <res 00000004>      <1> audio_vendor:	resd 1
   705 00019C60 <res 00000004>      <1> audio_stats_cmd: resd 1
   706                              <1> ;
   707 00019C64 <res 00000004>      <1> audio_buffer:	resd 1	; virtual address of user's audio buffer
   708 00019C68 <res 00000004>      <1> audio_p_buffer:	resd 1	; Physical address of user's audio buffer
   709 00019C6C <res 00000004>      <1> audio_buff_size: resd 1 ; user's audio buffer size (half buffer size) 
   710 00019C70 <res 00000004>      <1> audio_dma_buff: resd 1  ; dma buffer address
   711 00019C74 <res 00000004>      <1> audio_dmabuff_size: resd 1 ; dma buffer size (2 * half buffer size)
   712 00019C78 <res 00000001>      <1> audio_flag:	resb 1  ; dma buffer flag (1st half = 0, 2nd half = 1)
   713 00019C79 <res 00000001>      <1> audio_user:	resb 1	; user number of the owner
   714 00019C7A <res 00000001>      <1> audio_cb_mode:	resb 1	; 0 = signal response byte method
   715                              <1> 			; 1 = callback method
   716                              <1> 			; 2 = s.r.b. method with auto increment
   717 00019C7B <res 00000001>      <1> audio_srb:	resb 1	; signal response byte value
   718 00019C7C <res 00000004>      <1> audio_cb_addr:	resd 1  ; callback service address or s.r.b. address
   719                              <1> 			; (s.r.b. addr is physical, cbs addr is virtual)
   720                              <1> 
   721 00019C80 <res 00000001>      <1> audio_bps:	resb 1  ; selected mode: 8 bit, 16 bit
   722 00019C81 <res 00000001>      <1> audio_stmo:	resb 1	; selected mode: mono /stereo
   723 00019C82 <res 00000002>      <1> audio_freq: 	resw 1	; sampling rate
   724                              <1> 
   725                              <1> ; 21/04/2017
   726 00019C84 <res 00000001>      <1> audio_play_cmd: resb 1  ; Play/Stop command (1 = play, 0 = stop)
   727                              <1> audio_civ: ; 28/05/2017 ; Current Buffer Index (AC'97)
   728 00019C85 <res 00000001>      <1> audio_flag_eol:	resb 1  ; End of Link status (vt8233, EOL/FLAG)
   729                              <1> 
   730                              <1> audio_master_volume:
   731 00019C86 <res 00000001>      <1> audio_master_volume_l: resb 1 ; sound volume (lineout) left channel
   732 00019C87 <res 00000001>      <1> audio_master_volume_r: resb 1 ; sound volume (lineout) right channel
   733                              <1> 
   734                              <1> alignb 4
   735                              <1> ; 28/05/2017
   736                              <1> ; AC'97 Audio Controller Base Adress Registers
   737 00019C88 <res 00000002>      <1> NAMBAR:		resw 1	; Native Audio Mixer Base Address
   738 00019C8A <res 00000002>      <1> NABMBAR:	resw 1	; Native Audio Bus Mastering Base Address
   739                              <1> 	
   740                              <1> ;alignb 4
   741                              <1> ; 21/04/2017
   742 00019C8C <res 00000400>      <1> audio_bdl_buff:	resd 32*8  ; VT8233 (AC97) BDL Buffer Size
   743                              <1> ; 12/05/2017
   744 0001A08C <res 00000004>      <1> base_addr:	resd 1	; 'direct_memory_access' (memory.s)
   745                              <1> 
   746                              <1> ; 28/08/2017
   747                              <1> ; 20/08/2017
   748 0001A090 <res 00000001>      <1> 		resb 1  ;
   749 0001A091 <res 00000001>      <1> dma_user:	resb 1	; user number for sysdma
   750 0001A092 <res 00000001>      <1> dma_channel:	resb 1	; dma channel for sysdma
   751 0001A093 <res 00000001>      <1> dma_mode:	resb 1  ; dma mode for sysdma	
   752 0001A094 <res 00000004>      <1> dma_addr:	resd 1	; dma buffer physical addr for sysdma
   753 0001A098 <res 00000004>      <1> dma_size:	resd 1  ; dma buffer size (in bytes) for sysdma
   754 0001A09C <res 00000004>      <1> dma_start:	resd 1  ; dma start address for sysdma
   755 0001A0A0 <res 00000004>      <1> dma_count:	resd 1  ; dma count (in bytes) for sysdma 
   756                              <1> 
   757 0001A0A4 <res 00005F5C>      <1> alignb 65536
   758                              <1> ; 09/08/2017
   759                              <1> ; 12/05/2017
   760 00020000 <res 00010000>      <1> sb16_dma_buffer: resb 65536 ; DMA buffer for sb16 audio playing.
  3636                                  ; 24/01/2016
  3637                                  %include 'ubss.s'	; UNINITIALIZED KERNEL (USER) DATA
     1                              <1> ; ****************************************************************************
     2                              <1> ; TRDOS386.ASM (TRDOS 386 Kernel - v2.0.0) - UNINITIALIZED USER DATA : ubss.s
     3                              <1> ; ----------------------------------------------------------------------------
     4                              <1> ; Last Update: 28/02/2017
     5                              <1> ; ----------------------------------------------------------------------------
     6                              <1> ; Beginning: 24/01/2016
     7                              <1> ; ----------------------------------------------------------------------------
     8                              <1> ; Assembler: NASM version 2.11 (trdos386.s)
     9                              <1> ; ----------------------------------------------------------------------------
    10                              <1> ; Derived from 'Retro UNIX 386 Kernel - v0.2.1.0' source code by Erdogan Tan
    11                              <1> ; ux.s (04/12/2015)
    12                              <1> ; ****************************************************************************
    13                              <1> 
    14                              <1> ; Retro UNIX 386 v1 Kernel - ux.s
    15                              <1> ; Last Modification: 04/12/2015
    16                              <1> ;
    17                              <1> ; ///////// RETRO UNIX 386 V1 SYSTEM DEFINITIONS ///////////////
    18                              <1> ; (Modified from 
    19                              <1> ;	Retro UNIX 8086 v1 system definitions in 'UNIX.ASM', 01/09/2014)
    20                              <1> ; ((UNIX.ASM (RETRO UNIX 8086 V1 Kernel), 11/03/2013 - 01/09/2014))
    21                              <1> ; ----------------------------------------------------------------------------
    22                              <1> ; Derived from UNIX Operating System (v1.0 for PDP-11) 
    23                              <1> ; (Original) Source Code by Ken Thompson (1971-1972)
    24                              <1> ; <Bell Laboratories (17/3/1972)>
    25                              <1> ; <Preliminary Release of UNIX Implementation Document>
    26                              <1> ; (Section E10 (17/3/1972) - ux.s)
    27                              <1> ; ****************************************************************************
    28                              <1> 
    29                              <1> alignb 2
    30                              <1> 
    31                              <1> inode:
    32                              <1> 	; 11/03/2013. 
    33                              <1> 	;Derived from UNIX v1 source code 'inode' structure (ux).
    34                              <1> 	;i.
    35                              <1> 
    36 00030000 <res 00000002>      <1> 	i.flgs:	 resw 1
    37 00030002 <res 00000001>      <1> 	i.nlks:	 resb 1
    38 00030003 <res 00000001>      <1> 	i.uid:	 resb 1
    39                              <1>         ;i.size:  resw 1 ; size
    40 00030004 <res 00000002>      <1> 	resw 1 ; 29/04/2016
    41 00030006 <res 00000010>      <1> 	i.dskp:	 resw 8 ; 16 bytes
    42 00030016 <res 00000004>      <1> 	i.ctim:	 resd 1
    43 0003001A <res 00000004>      <1> 	i.mtim:	 resd 1
    44 0003001E <res 00000002>      <1> 	i.rsvd:  resw 1 ; Reserved (ZERO/Undefined word for UNIX v1.)
    45                              <1> 
    46                              <1> I_SIZE	equ $ - inode 
    47                              <1> 
    48                              <1> process:
    49                              <1> 	; 19/12/2016
    50                              <1> 	; 21/05/2016
    51                              <1> 	; 19/05/2016 - TRDOS 386 (TRDOS v2.0)
    52                              <1> 	; 06/05/2015 - Retro UNIX 386 v1
    53                              <1> 	; 11/03/2013 - 05/02/2014 (Retro UNIX 8086 v1)
    54                              <1> 	;Derived from UNIX v1 source code 'proc' structure (ux).
    55                              <1> 	;p.
    56                              <1> 	
    57 00030020 <res 00000020>      <1>         p.pid:   resw nproc
    58 00030040 <res 00000020>      <1>         p.ppid:  resw nproc
    59 00030060 <res 00000020>      <1>         p.break: resw nproc
    60 00030080 <res 00000010>      <1>         p.ttyc:  resb nproc ; console tty in Retro UNIX 8086 v1.
    61 00030090 <res 00000010>      <1> 	p.waitc: resb nproc ; waiting channel in Retro UNIX 8086 v1.
    62 000300A0 <res 00000010>      <1> 	p.link:	 resb nproc
    63 000300B0 <res 00000010>      <1> 	p.stat:	 resb nproc
    64                              <1> 
    65                              <1> 	; 06/05/2015 (Retro UNIX 386 v1 feature only !) 
    66 000300C0 <res 00000040>      <1> 	p.upage: resd nproc ; Physical address of the process's
    67                              <1> 			    ; 'user' structure
    68                              <1> 	; 21/05/2016	
    69                              <1> 	; 19/05/2016 (TRDOS 386 feature only!)
    70 00030100 <res 00000010>      <1> 	p.timer: resb nproc ; number of timer events of the processs
    71                              <1> 
    72                              <1> 	; 19/12/2016
    73 00030110 <res 00000040>      <1> 	p.tcb:	resd nproc ; timer callback service address (if > 0)
    74                              <1> 			  		 			 	  
    75                              <1> P_SIZE	equ $ - process
    76                              <1> 
    77                              <1> ; fsp table (original UNIX v1)
    78                              <1> ;
    79                              <1> ;Entry
    80                              <1> ;          15                                      0
    81                              <1> ;  1     |---|---------------------------------------|
    82                              <1> ;        |r/w|       i-number of open file           |
    83                              <1> ;        |---|---------------------------------------| 
    84                              <1> ;        |               device number               |
    85                              <1> ;        |-------------------------------------------|
    86                              <1> ;    (*) | offset pointer, i.e., r/w pointer to file |
    87                              <1> ;        |-------------------------------------------| 
    88                              <1> ;        |  flag that says    | number of processes  |
    89                              <1> ;        |   file deleted     | that have file open  |
    90                              <1> ;        |-------------------------------------------| 
    91                              <1> ;  2     |                                           |
    92                              <1> ;        |-------------------------------------------| 
    93                              <1> ;        |                                           |
    94                              <1> ;        |-------------------------------------------|
    95                              <1> ;        |                                           |
    96                              <1> ;        |-------------------------------------------|
    97                              <1> ;        |                                           |
    98                              <1> ;        |-------------------------------------------| 
    99                              <1> ;  3     |                                           | 
   100                              <1> ;        |                                           |  
   101                              <1> ;
   102                              <1> ; (*) Retro UNIX 386 v1 modification: 32 bit offset pointer 
   103                              <1> 
   104                              <1> 
   105                              <1> ; 15/04/2015
   106 00030150 <res 000001F4>      <1> fsp:	 resb nfiles * 10 ; 11/05/2015 (8 -> 10)
   107 00030344 <res 00000002>      <1> idev:	 resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
   108 00030346 <res 00000002>      <1> cdev:    resw 1 ; device number is 1 byte in Retro UNIX 8086 v1 !
   109                              <1> ; 18/05/2015
   110                              <1> ; 26/04/2013 device/drive parameters (Retro UNIX 8086 v1 feature only!)
   111                              <1> ; 'UNIX' device numbers (as in 'cdev' and 'u.cdrv')
   112                              <1> ;	0 -> root device (which has Retro UNIX 8086 v1 file system)
   113                              <1> ; 	1 -> mounted device (which has Retro UNIX 8086 v1 file system)
   114                              <1> ; 'Retro UNIX 8086 v1' device numbers: (for disk I/O procedures)
   115                              <1> ;	0 -> fd0 (physical drive, floppy disk 1), physical drive number = 0
   116                              <1> ;	1 -> fd1 (physical drive, floppy disk 2), physical drive number = 1
   117                              <1> ;	2 -> hd0 (physical drive, hard disk 1), physical drive number = 80h
   118                              <1> ;	3 -> hd1 (physical drive, hard disk 2), physical drive number = 81h
   119                              <1> ;	4 -> hd2 (physical drive, hard disk 3), physical drive number = 82h
   120                              <1> ;	5 -> hd3 (physical drive, hard disk 4), physical drive number = 83h
   121 00030348 <res 00000001>      <1> rdev:	 resb 1 ; root device number ; Retro UNIX 8086 v1 feature only!
   122                              <1> 	        ; as above, for physical drives numbers in following table
   123 00030349 <res 00000001>      <1> mdev:	 resb 1 ; mounted device number ; Retro UNIX 8086 v1 feature only!
   124                              <1> ; 15/04/2015
   125 0003034A <res 00000001>      <1> active:	 resb 1 
   126 0003034B <res 00000001>      <1> 	 resb 1 ; 09/06/2015
   127 0003034C <res 00000002>      <1> mnti:	 resw 1
   128 0003034E <res 00000002>      <1> mpid:	 resw 1
   129 00030350 <res 00000002>      <1> rootdir: resw 1
   130                              <1> 
   131                              <1> ; 21/05/2016 - TRDOS 386 (TRDOS v2.0) - priority levels, 3 run queues 
   132                              <1> runq:
   133 00030352 <res 00000002>      <1> runq_event:	 resw 1 ; high priority, 'run for event'            ; 2
   134 00030354 <res 00000002>      <1> runq_normal:	 resw 1 ; normal/regular priority, 'run as reqular' ; 1
   135 00030356 <res 00000002>      <1> runq_background: resw 1 ; low priority, 'run on background'         ; 0
   136                              <1> ;
   137 00030358 <res 00000001>      <1> imod:	 resb 1
   138 00030359 <res 00000001>      <1> smod:	 resb 1
   139 0003035A <res 00000001>      <1> mmod:	 resb 1
   140 0003035B <res 00000001>      <1> sysflg:	 resb 1
   141                              <1> 
   142                              <1> alignb 4
   143                              <1> 
   144                              <1> user:
   145                              <1> 	; 13/01/2017
   146                              <1> 	; 19/12/2016
   147                              <1> 	; 21/05/2016 - TRDOS 386 (TRDOS v2.0) 
   148                              <1> 	; 	       [u.pri] usage method modification
   149                              <1> 	; 04/12/2015 
   150                              <1> 	; 18/10/2015
   151                              <1> 	; 12/10/2015
   152                              <1> 	; 21/09/2015
   153                              <1> 	; 24/07/2015
   154                              <1> 	; 16/06/2015
   155                              <1> 	; 09/06/2015
   156                              <1> 	; 11/05/2015
   157                              <1> 	; 16/04/2015 (Retro UNIX 386 v1 - 32 bit modifications)
   158                              <1> 	; 10/10/2013
   159                              <1> 	; 11/03/2013. 
   160                              <1> 	;Derived from UNIX v1 source code 'user' structure (ux).
   161                              <1> 	;u.
   162                              <1> 
   163 0003035C <res 00000004>      <1> 	u.sp:	  resd 1 ; esp (kernel stack at the beginning of 'sysent')
   164 00030360 <res 00000004>      <1> 	u.usp:	  resd 1 ; esp (kernel stack points to user's registers)
   165 00030364 <res 00000004>      <1> 	u.r0:	  resd 1 ; eax
   166 00030368 <res 00000002>      <1> 	u.cdir:	  resw 1
   167 0003036A <res 0000000A>      <1> 	u.fp:	  resb 10
   168 00030374 <res 00000004>      <1> 	u.fofp:	  resd 1
   169 00030378 <res 00000004>      <1> 	u.dirp:	  resd 1
   170 0003037C <res 00000004>      <1> 	u.namep:  resd 1
   171 00030380 <res 00000004>      <1> 	u.off:	  resd 1
   172 00030384 <res 00000004>      <1> 	u.base:	  resd 1
   173 00030388 <res 00000004>      <1> 	u.count:  resd 1
   174 0003038C <res 00000004>      <1> 	u.nread:  resd 1
   175 00030390 <res 00000004>      <1> 	u.break:  resd 1 ; break
   176 00030394 <res 00000002>      <1> 	u.ttyp:	  resw 1 
   177                              <1> 	; 10/01/2017 (TRDOS 386, relocation and dword alignment)
   178                              <1> 	; tty number (rtty, rcvt, wtty)
   179 00030396 <res 00000001>      <1> 	u.ttyn:	  resb 1 ; 28/07/2013 - Retro Unix 8086 v1 feature only !
   180 00030397 <res 00000001>      <1> 	u.resb:   resb 1 ; 10/01/2017 (TRDOS 386, temporary)
   181 00030398 <res 00000010>      <1> 	u.dirbuf: resb 16 ; 04/12/2015 (10 -> 16) 
   182                              <1> 	;u.pri:	  resw 1 ; 14/02/2014
   183 000303A8 <res 00000001>      <1> 	u.quant:  resb 1 ; Retro UNIX 8086 v1 Feature only ! (uquant)
   184 000303A9 <res 00000001>      <1> 	u.pri:	  resb 1 ; Modification: 21/05/2016 (priority levels: 0, 1, 2)
   185 000303AA <res 00000002>      <1> 	u.intr:	  resw 1
   186 000303AC <res 00000002>      <1> 	u.quit:	  resw 1
   187                              <1> 	;u.emt:	  resw 1 ; 10/10/2013
   188                              <1> 	;u.ilgins: resw 1 ; 10/01/2017
   189 000303AE <res 00000002>      <1> 	u.cdrv:	  resw 1 ; cdev
   190 000303B0 <res 00000001>      <1> 	u.uid:	  resb 1 ; uid
   191 000303B1 <res 00000001>      <1> 	u.ruid:	  resb 1
   192 000303B2 <res 00000001>      <1> 	u.bsys:	  resb 1
   193 000303B3 <res 00000001>      <1> 	u.uno:	  resb 1
   194 000303B4 <res 00000004>      <1>         u.upage:  resd 1 ; 16/04/2015 - Retro Unix 386 v1 feature only !
   195 000303B8 <res 00000004>      <1> 	u.pgdir:  resd 1 ; 09/03/2015 (page dir addr of process)
   196 000303BC <res 00000004>      <1> 	u.ppgdir: resd 1 ; 06/05/2015 (page dir addr of the parent process)
   197 000303C0 <res 00000004>      <1> 	u.pbase:  resd 1 ; 20/05/2015 (physical base/transfer address)
   198 000303C4 <res 00000002>      <1> 	u.pcount: resw 1 ; 20/05/2015 (byte -transfer- count for page)
   199                              <1> 	;u.pncount: resw 1 
   200                              <1> 		; 16/06/2015 (byte -transfer- count for page, 'namei', 'mkdir')
   201                              <1> 	;u.pnbase:  resd 1 
   202                              <1> 		; 16/06/2015 (physical base/transfer address, 'namei', 'mkdir')
   203                              <1> 			 ; 09/06/2015
   204 000303C6 <res 00000001>      <1> 	u.kcall:  resb 1 ; The caller is 'namei' (dskr) or 'mkdir' (dskw) sign		
   205 000303C7 <res 00000001>      <1> 	u.brwdev: resb 1 ; Block device number for direct I/O (bread & bwrite)
   206                              <1> 			 ; 24/07/2015 - 24/06/2015
   207                              <1> 	;u.args:  resd 1 ; arguments list (line) offset from start of [u.upage]
   208                              <1> 			 ; (arg list/line is from offset [u.args] to 4096 in [u.upage])
   209                              <1> 			 ; ([u.args] points to argument count -argc- address offset)
   210                              <1>  			 ; 24/06/2015	  	
   211                              <1> 	;u.core:  resd 1 ; physical start address of user's memory space (for sys exec)
   212                              <1> 	;u.ecore: resd 1 ; physical end address of user's memory space (for sys exec)
   213                              <1> 	; last error number
   214 000303C8 <res 00000004>      <1> 	u.error:  resd 1 ; 28/07/2013 - 09/03/2015 
   215                              <1> 		        ; Retro UNIX 8086/386 v1 feature only!
   216                              <1> 			; 21/09/2015 (debugging - page fault analyze)
   217 000303CC <res 00000004>      <1> 	u.pfcount: resd 1 ; page fault count for (this) process (for sys geterr)
   218                              <1> 		; 19/12/2016 (TRDOS 386)	
   219 000303D0 <res 00000004>      <1> 	u.tcb:	  resd 1 ; Timer callback address/flag which will be used by timer int
   220                              <1> 		; 13/01/2017 (TRDOS 386)
   221 000303D4 <res 00000001>      <1> 	u.t_lock: resb 1 ; Timer interrupt (callback) lock (unlocked by 'sysrele')
   222 000303D5 <res 00000001>      <1> 	u.t_mode: resb 1 ; running mode during timer interrupt (0= system, 0FFh= user)
   223                              <1> 		; 26/02/2017 (TRDOS 386)
   224 000303D6 <res 00000001>      <1> 	u.irqc:	  resb 1  ; Count of IRQ callback services (IRQs in use)
   225                              <1> 		; 28/02/2017 (TRDOS 386) 
   226 000303D7 <res 00000001>      <1> 	u.irqwait: resb 1 ; IRQ waiting for callback service flag (IRQ number, If > 0)
   227 000303D8 <res 00000001>      <1> 	u.r_lock:  resb 1 ; 'IRQ callback service is in progress' flag (IRQ lock)
   228 000303D9 <res 00000001>      <1> 	u.r_mode:  resb 1 ; running mode during hadware interrupt	
   229                              <1> 		; 27/02/2017 (TRDOS 386) 
   230 000303DA <res 00000001>      <1> 	u.fpsave: resb 1  ; TRDOS 386, 'save/restore FPU registers' flag
   231 000303DB <res 00000001>      <1> alignb 4
   232 000303DC <res 0000005E>      <1> 	u.fpregs: resb 94 ; 94 byte area for saving and restoring FPU registers	
   233                              <1> 
   234 0003043A <res 00000002>      <1> alignb 4
   235                              <1> 
   236                              <1> U_SIZE	equ $ - user
   237                              <1> 
   238                              <1> ; 18/10/2015 - Retro UNIX 386 v1 (local variables for 'namei' and 'sysexec')
   239 0003043C <res 00000004>      <1> pcore:  resd 1  ; physical start address of user's memory space (for sys exec)
   240 00030440 <res 00000004>      <1> ecore:  resd 1  ; physical address of user's stack/last page (for sys exec)
   241 00030444 <res 00000004>      <1> nbase:	resd 1	; physical base address for 'namei' & 'sysexec'
   242 00030448 <res 00000002>      <1> ncount: resw 1	; remain byte count in page for 'namei' & 'sysexec'
   243 0003044A <res 00000002>      <1> argc:	resw 1	; argument count for 'sysexec'
   244 0003044C <res 00000004>      <1> argv:	resd 1	; argument list (recent) address for 'sysexec'
   245                              <1> 
   246                              <1> ; 03/06/2015 - Retro UNIX 386 v1 Beginning
   247                              <1> ; 07/04/2013 - 31/07/2013 - Retro UNIX 8086 v1
   248 00030450 <res 00000001>      <1> rw: 	 resb 1 ;; Read/Write sign (iget)
   249                              <1> 
   250                              <1> ;alignb 4
   251                              <1> 
   252                              <1> ; 24/04/2016
   253 00030451 <res 00000004>      <1> ii:		resd 1 ; first cluster of the program file
   254 00030455 <res 00000004>      <1> i.size:		resd 1 ; size of the program file
  3638                                  
  3639 00030459 <res 00000003>          alignb 4
  3640                                  
  3641                                  ; 23/05/2016 (TRDOS 386)
  3642                                  ; 14/10/2015 (Retro UNIX 386 v1, 'unix386.s')
  3643 0003045C <res 00000004>          cr3reg:	 resd 1  ; cr3 register content at the beginning of the timer
  3644                                  		 ; (or RTC) interrupt handler.
  3645                                  
  3646                                  ; 10/12/2016 (callback)
  3647                                  ; 10/06/2016
  3648                                  ; 19/05/2016
  3649                                  ; 18/05/2016 - TRDOS 386 feature only !
  3650 00030460 <res 00000100>          timer_set: resd 16*4   ; 256 bytes memory space for 16 timer events
  3651                                  	; Timer Event Structure: (max. 16 timer events, 16*16 bytes)
  3652                                  	;       Owner:	        resb 1 ; 0 = free
  3653                                  	;		  	       ;>0 = process number (u.uno)
  3654                                  	;	Callback:	resb 1 ; 0 = response byte address (phy)
  3655                                  	;				 1 = callback address (virtual)				
  3656                                  	;	Interrupt:      resb 1 ; 0 = Timer interrupt (or none)
  3657                                  	;		   	       ; 1 = Real Time Clock interrupt 
  3658                                  	;	Response:       resb 1 ; 0 to 255, signal return value
  3659                                  	;	Count Limit:	resd 1 ; count of ticks (total/set)
  3660                                  	;	Current Count: 	resd 1 ; count of ticks (current)
  3661                                  	;	Response Addr:  resd 1 ; response byte (pointer) address
  3662                                  	;			       ; (or callback -user service- address)	
  3663                                  
  3664                                  ;; Memory (swap) Data (11/03/2015)
  3665                                  ; 09/03/2015
  3666 00030560 <res 00000002>          swpq_count: resw 1 ; count of pages on the swap queue
  3667 00030562 <res 00000004>          swp_drv:    resd 1 ; logical drive description table address of the swap drive/disk
  3668 00030566 <res 00000004>          swpd_size:  resd 1 ; size of swap drive/disk (volume) in sectors (512 bytes). 		  				
  3669 0003056A <res 00000004>          swpd_free:  resd 1 ; free page blocks (4096 bytes) on swap disk/drive (logical)
  3670 0003056E <res 00000004>          swpd_next:  resd 1 ; next free page block
  3671 00030572 <res 00000004>          swpd_last:  resd 1 ; last swap page block	
  3672                                  
  3673 00030576 <res 00000002>          alignb 4
  3674                                  
  3675                                  ; 10/07/2015
  3676                                  ; 28/08/2014
  3677 00030578 <res 00000004>          error_code:	resd 1
  3678                                  ; 29/08/2014
  3679 0003057C <res 00000004>          FaultOffset: 	resd 1
  3680                                  ; 21/09/2015
  3681 00030580 <res 00000004>          PF_Count:	resd 1	; total page fault count
  3682                                  		       	; (for debugging - page fault analyze)
  3683                                  		 	; 'page_fault_handler' (memory.inc)
  3684                                  			; 'sysgeterr' (u9.s)
  3685                                  
  3686                                  ; 29/04/2016 (TRDOS 386 = TRDOS v2.0)
  3687                                  ; 22/08/2015 (Retro UNIX 386 v1)
  3688                                  buffer: 
  3689 00030584 <res 00000008>          	resb	8 
  3690                                  readi_buffer:
  3691 0003058C <res 00000200>          	resb 	512
  3692 0003078C <res 00000008>          	resb	8
  3693                                  writei_buffer:
  3694 00030794 <res 00000200>          	resb	512	
  3695                                  ; 24/10/2016
  3696 00030994 <res 00000008>          	resb	8 
  3697                                  rw_buffer:
  3698 0003099C <res 00000800>          	resb 	2048  ; general purposed, r/w sector buffer
  3699                                  
  3700                                  %if 1
  3701                                  ; 17/01/2021
  3702 0003119C <res 00000080>          edid_info:	resb 128 ; VESA EDID (monitor capabilities) info	
  3703                                  ; 28/11/2020
  3704 0003121C <res 00000001>          pmi32:		resb 1	; (>0) use VESA VBE3 protected mode calls 
  3705 0003121D <res 00000001>          vbe_mode_x:	resb 1  ; VESA VBE3 video bios mode set options
  3706 0003121E <res 00000002>          video_mode:	resw 1	; VESA VBE3 video mode (with option flags)
  3707                                  ; 30/11/2020
  3708 00031220 <res 00000004>          vbe3bios_addr:	resd 1	; new (writable mem) address of VBE3 bios
  3709                                  ; 02/12/2020
  3710 00031224 <res 00000004>          pmid_addr:	resd 1	; PMInfoBlock ('PMID') linear address
  3711                                  ; 14/01/2021
  3712                                  ; 06/12/2020		; VESA VBE 3 video state
  3713                                  ;vbe3stbufsize: resw 1	; video regs/dac/bios state buffer size
  3714                                  ;			; block size in bytes
  3715                                  ; 16/01/2021
  3716 00031228 <res 00000002>          vbe3stbsflags: resw 1	; video regs/dac/bios state buffer size
  3717                                  ;			; pointer flags for buffer state options
  3718                                  %endif
  3719                                  
  3720                                  %if 1
  3721                                  ; 10/12/2020
  3722                                  LFB_Info:
  3723 0003122A <res 00000010>          		resb 16	; Linear Frame Buffer info block
  3724                                  
  3725                                  ;24/11/2020 - TRDOS 386 v2.0.3
  3726                                  ; BOCHS/PLEX86 VESA VBE3 MODE INFO extension to TRDOS 386 v2 kernel	
  3727                                  MODE_INFO_LIST:
  3728 0003123A <res 00000044>          		resb 68	; mode + 66 byte VESA vbe3 mode info (4F01h) 
  3729                                  %endif
  3730                                  
  3731                                  ; 05/01/2021
  3732 0003127E <res 00000001>          ufont:		resb 1	; (VGA graphics) user font flags
  3733                                  			; bit 7 - permission flag for int 31h
  3734                                  			; bit 4 - 8x16 user font ready/loaded flag  
  3735                                  			; bit 3 - 8x8 user font ready/loaded flag
  3736                                  			; bit 1 - select 8x16 user font (sysvideo)
  3737                                  			; bit 0 - select 8x8 user font (sysvideo)
  3738 0003127F <res 00000001>          		resb 1	; 19/01/2021
  3739                                  ; 17/01/2021
  3740 00031280 <res 00000001>          srvsf:		resb 1	; 'save restore video state' permission flag
  3741                                  ; 18/01/2021
  3742 00031281 <res 00000001>          srvso:		resb 1	; video state buffer save/restore option
  3743 00031282 <res 00000004>          VideoStateID:	resd 1	; used to verify state saved by same prog
  3744                                  ; 29/01/2021
  3745 00031286 <res 00000002>          v_width:	resw 1	; screen (display page) width
  3746 00031288 <res 00000001>          v_ops:		resb 1	; 'sysvideo' graphics data transfer option	
  3747 00031289 <res 00000001>          v_bpp:		resb 1	; bits per pixels ('sysvideo')
  3748 0003128A <res 00000004>          v_mem:		resd 1	; video memory ('sysvideo')	
  3749 0003128E <res 00000004>          v_siz:		resd 1	; video page size ('sysvideo')
  3750 00031292 <res 00000004>          v_str:		resd 1	; window start adress ('sysvideo')
  3751 00031296 <res 00000004>          v_end:		resd 1	; window end (end+1) adress ('sysvideo')
  3752                                  ; 31/01/2021
  3753                                  ; 01/01/2021
  3754                                  ;maskbuff:     ;resd 1	; user's bitmask buffer addr ('sysvideo')
  3755 0003129A <res 00000004>          maskcolor:	resd 1	; VGA/SVGA pixel mask color ('sysvideo')
  3756                                  ; 27/02/2021
  3757 0003129E <res 00000004>          pixcount:	resd 1	; pixel count ('sysvideo' window ops) 
  3758                                  ; 02/02/2021
  3759 000312A2 <res 00000008>          buffer8:	resd 2	; 8 bytes small buffer for 'sysvideo'  
  3760                                  
  3761                                  bss_end:
  3762                                  
  3763                                  ; 27/12/2013
  3764                                  _end:  ; end of kernel code
